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

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++){
		bool a = false;
		int x = i;
		if (x % 3 == 0)
			a = true;
		while (x != 0){
		if (x % 10 == 3)
			a = true;
		x /= 10;
		}
		if (a) 
			cout << " " << i;
	}
	cout << endl;
	return 0;
}


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

UL N,M; ULL K;
ULL A[200001];
ULL B[200001];

int main() {
 scanf("%u%u%llu",&N,&M,&K);
 A[0]=B[0]=0;
 rep(i,N) {scanf("%llu",&A[i+1]);A[i+1]+=A[i];}
 rep(i,M) {scanf("%llu",&B[i+1]);B[i+1]+=B[i];}
 UL q=M;
 UL ans=0;
 rep(p,N+1){
  if(A[p]>K) break;
  while(A[p]+B[q]>K) q--;
  ans=max(ans,p+q);
 }
 printf("%u\n",ans);
 return 0;
}


Measured memory_bytes: 6948
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define MAXN 100000
vector<int>G[MAXN+5];
int n,ans=1;
int dfs(int u,int pre)
{
	int c=0,ret=0;
	for(int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if(v!=pre)
		{
			int m=dfs(v,u);
			if(m==0) c++;
			else ret+=m;
		}
	}
	if(c>1)
		ret+=c-1;
	return ret;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=0;i<n;i++)
		if(G[i].size()>2)
		{
			ans=dfs(i,-1);
			break;
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >>n;
    vector<int> b(n);
    vector<int> a(n);
    rep(i,n-1) cin >>b.at(i);
    a[0]=b[0];
    for (int i=1;i<n-1;i++){
        a[i]=min(b[i],b[i-1]);
    }
    a[n-1]=b[n-2];
    //rep(i,n) cout <<a.at(i);
    int sum = accumulate(a.begin(),a.end(),0);
    cout << sum << endl;
}

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

int main() {
  int A1, A2, A3;
  string op;
  cin >> A1 >> A2 >> A3;

  if (A1+A2+A3>=22) {
    cout<<"bust"<<endl;
  }

  else {
    cout<<"win"<<endl;
  }
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    if((x-r>=0)and(y-r>=0)and(x+r<=w)and(y+r<=h))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3200
#include <stdio.h>
    int main(void){     
    int i,x;
    

    for (i=1;  i <=100000; i++){
     scanf("%d", &x);
    if ( x == 0 ) 
    
    break;
    
    printf("Case %d: %d\n",i,x);
    
    }
    
    return 0;
    
}



Measured memory_bytes: 2044
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
        //int input=int.Parse(Console.ReadLine());
        //string a = Console.ReadLine();
        Console.WriteLine((input[0]*input[1])%2==0 ?"Even":"Odd");
        Console.ReadLine();
    }
}


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

using namespace std;

typedef long long ll;

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

	int n = 3;
	int a[n];
	rep(i, n) cin >> a[i];

	sort(a, a + n);
	cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 256
# ABC113C - ID
import sys
input = sys.stdin.readline

def main():
    N, M = tuple(map(int, input().split()))
    P = [[] for _ in range(N + 1)]  # prefectures
    for num in range(M):  # classify cities by prefectures
        pref, year = tuple(map(int, input().split()))
        P[pref] += [(year, num)]
    ans = [""] * M
    P = tuple(sorted(p) for p in P)  # sort by year
    for pref_idx, pref in enumerate(P):
        for city_idx, (_, num) in enumerate(pref, 1):
            x = "{:06}{:06}".format(pref_idx, city_idx)
            ans[num] = x
    print(*ans, sep="\n")

if __name__ == "__main__":
    main()

Measured memory_bytes: 40564
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }
struct Permutation { n: usize, idx: usize }
impl Permutation {
    fn new(n: usize) -> Permutation {
        Permutation { n: n, idx: 0 }
    }
}
impl Iterator for Permutation {
    type Item = Vec<usize>;
    fn next(&mut self) -> Option<Vec<usize>> {
        let mut r = vec![0; self.n];
        let mut idx = self.idx;
        for k in 1..self.n {
            r[k] = idx % (k + 1);
            idx /= k + 1;
        }
        if idx > 0 { return None }
        r.reverse();
        let mut b = vec![true; self.n];
        b[r[0]] = false;
        for k in 1..self.n {
            let mut count = 0;
            for j in 0..self.n {
                if b[j] {
                    if count == r[k] {
                        r[k] = j;
                        b[j] = false;
                        break;
                    }
                    count += 1;
                }
            }
        }
        self.idx += 1;
        return Some(r)
    }
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();

    let mut table = vec![vec![false; n]; n];

    let m: usize = sc.cin();
    for _ in 0..m {
        let u: usize = sc.cin();
        let v: usize = sc.cin();
        table[u - 1][v - 1] = true;
        table[v - 1][u - 1] = true;
    }

    let mut ans = 0;
    for a in Permutation::new(n - 1) {
        if !table[0][a[0] + 1] { continue; }
        let mut ok = true;
        for i in 0..(a.len() - 1) {
            if !table[a[i] + 1][a[i + 1] + 1] {
                ok = false;
                break;
            }
        }
        if ok {
            ans += 1;
        }
    }

    println!("{}", ans);

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int a,b,c,k;
int main()
{
	scanf("%d%d%d%d", &a, &b, &c, &k);
	int ans=0;
	ans+=min(k,a);
	k-=ans;
	if(k>0)
	{
		k-=min(b,k);
	}
	if(k>0)
	{
		ans-=min(k,c);
		
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(ll i = (ll)a; i <= (ll)b; i++)
#define DEC(i, a, b) for(ll i = (ll)a; i >= (ll)b; i--)
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll INF = 1e15;
ll n, m, s, u, v, a, b, dist[55][2505];
vector<pii> adj[55];
priority_queue<pii, vector<pii>, greater<pii> > pq;

int main() {
	fastio; cin >> n >> m >> s;
	s = min(s, 50 * (n-1));
	FOR(i, 1, m) {
		cin >> u >> v >> a >> b;
		adj[u].pb(pii(b, pi(-a, v)));
		adj[v].pb(pii(b, pi(-a, u)));
	}
	FOR(i, 1, n) {
		cin >> a >> b;
		adj[i].pb(pii(b, pi(a, i)));
	}
	memset(dist, -1, sizeof dist);
	pq.push(pii(0, pi(s, 1)));
	dist[1][s] = 0;
	while (!pq.empty()) {
		pii cur = pq.top(); pq.pop();
		for (auto it:adj[cur.s.s]) {
			ll to = it.s.s, nc = cur.s.f + it.s.f, nt = cur.f + it.f;
			nc = min(nc, 50 * (n-1));
			if (nc < 0) continue;
			if (dist[to][nc] == -1 or dist[to][nc] > nt) {
				dist[to][nc] = nt;
				pq.push(pii(nt, pi(nc, to)));
			}
		}
	}
	FOR(i, 2, n) {
		ll ans = INF;
		FOR(j, 0, 50*(n-1)) if (dist[i][j] != -1) ans = min(ans, dist[i][j]);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 7336
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char *week[]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    char d[3]="";
    int i=0;
    scanf(" %s",&d);
    for(i=0;i<7;i++){
        if(strcmp(week[i],d)==0){
            break;
        }
    }
        printf("%d",7-i);

}


Measured memory_bytes: 128
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 40

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

int dp[4][MAXN+1];
int p[MAXN+1];
int t[MAXN+1];

int main(void) {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            cin >> p[i] >> t[i];
        }
        if (p[0] > t[0]) {
            printf("NG 1\n");
            continue;
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < n; j++) {
                dp[i][j] = INF;
            }
        }
        dp[1][0] = p[0];
        bool ok = true;
        for (int cur = 0; cur < n - 1; cur++) {
            bool flag = false;
            for (int i = 1; i < 4; i++) {
                if (dp[i][cur] >= INF) continue;
                int time = t[cur+1] - t[cur];
                // 戻る
                if (time >= p[cur] * (i+1) + p[cur+1]) {
                    flag = true;
                    dp[1][cur+1] = min(dp[1][cur+1], dp[i][cur] + p[cur] + p[cur+1]);
                }
                // 直接向かう
                if (i < 3 && time >= abs(p[cur] - p[cur+1]) * (i+1)) {
                    flag = true;
                    dp[i+1][cur+1] = min(dp[i+1][cur+1], dp[i][cur] +abs(p[cur] - p[cur+1]));
                }
            }
            if (!flag) {
                ok = false;
                printf("NG %d\n", cur+2);
            }
            if (!ok) break;
        }
        if (!ok) continue;
        int ans = INF;
        for (int i = 1; i < 4; i++) ans = min(dp[i][n-1], ans);
        printf("OK %d\n", ans+p[n-1]);
    }
    return 0;
}

Measured memory_bytes: 1148
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n= int(sys.stdin.readline())
    d= list(map(int, sys.stdin.readline().split()))
    d.sort()
    h=int(n/2)
    dz=d[:h]
    dk=d[h:]
    dz_max=max(dz)
    dk_min=min(dk)
    c=0
    print(dk_min-dz_max)

Measured memory_bytes: 77012
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000



int main(){
	
	int N;
	cin>>N;
	
	for(int i=0;i<=100000;i++){
		int k = i*108;
		k /= 100;
		if(k==N){
			cout<<i<<endl;
			return 0;
		}
	}
	
	cout<<":("<<endl;
	
	return 0;
}

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

using namespace std;
using ll = long long;

bool rf = false;
vector<vector<int>> hen;
vector<int> col;

void dfs0(int v) {
    for(auto i : hen[v]) {
        if(col[i] == col[v])rf = true;
        if(col[i] != -1)continue;
        col[i] =  !col[v];
        dfs0(i);
    }
}


int main()
{
    int n; cin >> n;
    hen.resize(n), col.resize(n, -1);
    for(int i = 0; i < n; i++) {
        string s; cin >> s;
        for(int j = 0; j < n; j++) {
            if(s[j] == '1') hen[i].push_back(j);
        }
    }
    col[0] = 0;
    dfs0(0); //二部グラフ判定

    if(rf) {
        cout << -1 << endl;
        return 0;
    }


    int nax = 2;
    for(int i = 0; i < n; i++) {
        vector<int> curc(n, -1);
        curc[i] = 1;
        queue<int> que;
        que.push(i);
        while(que.size()) {
            auto cur = que.front();
            que.pop();
            for(auto i : hen[cur]) {
                if(curc[i] != -1)continue;
                curc[i] = curc[cur] + 1;
                que.push(i);
            }
        }
        nax = max(nax, *max_element(curc.begin(), curc.end()));
    }
    cout << nax << endl;

}

Measured memory_bytes: 512
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def f(A, B, x):
    return math.floor(A * x / B) - A * math.floor(x / B)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, Q = il()
    abcd = [il() for _ in range(Q)]

    ret = 0
    for i in itertools.combinations_with_replacement(range(1, M + 1), N):
        tmp = 0
        for a, b, c, d in abcd:
            if i[b - 1] - i[a - 1] == c: tmp += d

        ret = max(ret, tmp)

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9520
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int Num1;
  cin >> Num1;
  vector<int> Vari(Num1,0);
  vector<int> Costi(Num1,0);
  for (size_t i = 0; i < Num1; i++) {
    std::cin >> Vari[i];
  }
  for (size_t i = 0; i < Num1; i++) {
    std::cin >> Costi[i];
  }
  /*for (size_t i = 0; i < Num1; i++) {
    std::cout << Vari[i] << ' ';
  }*/
  //std::cout <<'\n';
  /*for (size_t i = 0; i < Num1; i++) {
    std::cout << Costi[i] << ' ';
  }*/
  //std::cout <<'\n';
  int answer=0;
  for (size_t i = 0; i < Num1; i++) {
    if (Vari[i]-Costi[i]>0) {
      answer=answer+(Vari[i]-Costi[i]);
    }
  }
  std::cout << answer << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <cstdlib>
#include <queue>

#define MAX  100005

using namespace std;

struct Ques{ 
    char name[100];
    int time; 
};

Ques Q[MAX];


// ??¬???

int main(){

    int n, q, i, k, timer, head, tail;

    scanf("%d %d", &n, &q);

    head = 0;
    tail = n;

    Ques buffer;
 
    int last_time = 0 ;

    for( i = 0; i < n ; i++ ){

        scanf("%s", buffer.name);

        scanf("%d", &buffer.time);

        Q[i] = buffer;

    }

    while( head != tail ){

        timer = min( q, Q[head].time );
        last_time += timer;

        Q[head].time -= timer;

        if(Q[head].time > 0){

            Q[tail] = Q[head];

            tail++;
            if( tail > MAX ) tail = 0;
            head++;
            if( head > MAX ) head = 0;

        } else {

            printf("%s %d\n", Q[head].name, last_time);

            head++;
            if( head > MAX ) head = 0;

        }

    }

    return 0;

}

Measured memory_bytes: 12744
import sys
import copy

input = sys.stdin.readline

N, M = list(map(int,input().split()))
st = [list(map(int,input().split())) for i in range(M)]

neighbor = [[] for i in range(N)]
for s,t in st:
	neighbor[s-1].append(t-1)

INF = 100100100
ev = [INF]*N
ev[N-1] = 0
for i in range(N-2,-1,-1):
	dsum = 0
	dcount = 0
	for j in neighbor[i]:
		dsum += ev[j]
		dcount += 1
	ev[i] = dsum/dcount + 1

prb = [0]*N
prb[0] = 1
for i in range(N-1):
	for j in neighbor[i]:
		prb[j] += prb[i]/len(neighbor[i])

ans = ev[0]
for s, t in st:
	ss, tt = s-1, t-1
	pnum = len(neighbor[ss])
	if pnum==1: continue
	evdif = (ev[ss]-(ev[ss]*pnum-(ev[tt]+1))/(pnum-1))*prb[ss]
	ans = min(ans,ev[0]-evdif)

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define PI acos(-1.0)
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define MOD 1000000007
#define MOD1 998244353
#define ep 0.000000001
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, 1};
int dy4[] = {1, -1, 1, -1};
//#define fio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    #endif
    int d, t, s, x;
    cin>>d>>t>>s;
    x=(s*t);
    if(x>=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
//https://thebestoffersintheweb.com/redirect/57a764d042bf8/


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

int main() {
  ll n,k; cin >> n >> k;
  vector<ll>v(n);
  for(ll i = 0; i<n; i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  ll sum = 0;
  for(ll i = 0; i<k; i++){
    sum+=v[i];
  }
  cout << sum << endl;
    
  return 0;
}






Measured memory_bytes: 3604
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function bsearch(a::Array{Int,1},x::Int)
	l,r = 0, length(a)+1
	while r-l>1
		m = (r+l)>>1
		if a[m]<x
			l = m
		else
			r = m
		end
	end
	r
end
are(a::Array{Int,1},x::Int)=Int[i%x for i in a]

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = readline() |> split |> parseMap
	r = 29
	ans = 0
	for i in 1:r
		t = 2^(i-1)
		c = are(b,2t)
		c = sort(c)
		s = 0
		for j in 1:n
			x = a[j]%(2*t)
			s += bsearch(c,2t-x)-bsearch(c,t-x)+bsearch(c,4t-x)-bsearch(c,3t-x)

		end
		ans += (s%2)*t
	end
	println(ans)
end

main()

Measured memory_bytes: 172932
// AOJ 1366 Min-Max Distance Game
// 2018.2.8 bal4u

#include <stdio.h>

#define INF 0x30303030

int x[100002], n, m;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int check(int t)
{
	int i, j, f = 1;
	for (j = 0, i = 0; i < n; i++) if (x[i]-x[j] > t) f++, j = i;
	return f > m;
}

int main()
{
	int alice, i, ans;
	int lo, hi, mi;

	n = in(), m = (n+1) >> 1;
	alice = (getchar_unlocked() == 'A');
	while (getchar_unlocked() > ' ');
	for (i = 0; i < n; i++) x[i] = in();

	ans = INF;
	if ((n & 1) == alice) {
		for (i = 0; i+m < n; i++) if (x[i+m]-x[i] < ans) ans = x[i+m]-x[i];
	} else {
		lo = 0, hi = x[n-1];
		while (hi-lo > 1) {
			mi = (lo+hi) >> 1;
			if (check(mi)) lo = mi; else hi = mi;
		}
		ans = hi;
	}
	printf("%d\n", ans);
	return 0;
}


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

const int INF=0x3f3f3f3f;
const int MH=10;
const int MW=1005;

char g[MH][MW];
int n,m,k;

int id[MH];

int sum[MH];
int pre[MH];

int check(int st)
{
	int ans=0;
	for(int i=1;i<n;i++)
	{
		if(st&(1<<(i-1)))
		{	
			id[i]=id[i-1]+1;
			ans++;
		}
		else id[i]=id[i-1];
	}
	int nn=id[n-1];
	//cout<<nn<<endl;
	memset(pre,0,sizeof(pre));
	for(int i=0;i<m;i++)
	{
		memset(sum,0,sizeof(sum));
		for(int j=0;j<n;j++)
			sum[id[j]]+=g[j][i]-'0';
		int f=1;
		for(int j=0;j<=nn;j++)
		{
			//cout<<sum[j]<<" ";
			if(sum[j]>k) return INF;
			if(sum[j]+pre[j]>k)
			{
				f=0;
				break;
			}
			pre[j]+=sum[j];
		}
		//cout<<endl;
		if(!f)
		{
			for(int j=0;j<=nn;j++)
				pre[j]=sum[j];
			ans++;
		}
	}
	//cout<<st<<" "<<ans<<endl;
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++)
		scanf("%s",g[i]);
	int mask=1<<(n-1);
	int ans=INF;
	// enumerate all horizontal cut combinations
	for(int i=0;i<mask;i++)
		ans=min(ans,check(i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.IArrayI32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI32(), i|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.IArrayI64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI64(), i|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.IArrayF32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF32(), i|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public this.IArrayF64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF64(), i|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let s = scanner.Next().ToCharArray() |> Array.rev |> Array.toList
    let rec find =
        function
        | [] -> true
        | 'm':: 'a':: 'e':: 'r':: 'd' :: tail -> find tail
        | 'r':: 'e':: 'm':: 'a':: 'e':: 'r':: 'd' :: tail -> find tail
        | 'e':: 's':: 'a':: 'r':: 'e' :: tail -> find tail
        | 'r':: 'e':: 's':: 'a':: 'r':: 'e' :: tail -> find tail
        | _ -> false

    if find s then "YES" else "NO"
    |> printfn "%s"
    0


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

int main() {
    string S, T, U;
    int A, B;
    map<string, int> mp;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    mp[S] = A;
    mp[T] = B;
    mp[U]--;
    cout << mp[S] << " " << mp[T];
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX_DATA_NUM 10001	// Contain last zero

int main()
{
	int dataNum = 0, inValue[MAX_DATA_NUM] = {0}, i = 0;
	
	for(i = 0; i < MAX_DATA_NUM; i++)
	{
		cin  >> inValue[i];
		
		if(0 == inValue[i]){
			break;
		}
	}
	
	dataNum = i;
	
	for(i = 0; i < dataNum; i++)
	{
		cout << "Case " << i + 1 << ": " << inValue[i] << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3144
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,ans;
char a[100005];
stack <int> s;

int main()
{
    scanf("%s",a+1);
    n = strlen(a+1);
    for(int i = 1;i <= n;i++)
    {
        if(s.empty())
        {
            s.push(a[i]-'0');
            continue;
        }
        if(s.top()+a[i]-'0' == 1)
        {
            s.pop();
            ans += 2;
        }
        else s.push(a[i]-'0');
    }
    printf("%d",ans);
}

#endif // 1++

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;

map<int, int>mp;
const int MAX_INT = 1000000;
int is_prime[MAX_INT + 1];
vector<int>P;
void calc(int N) {
	while (-1 != is_prime[N]) {
		int p = is_prime[N];
		while (0 == N % p) {
			N /= p;
		}
		mp[p]++;
	}
	if (1 != N) {
		mp[N]++;

	}
	return;
}
//エラトステネスの篩(素数の数を返している)
void sieve(int  n) {
	is_prime[0] = -1;
	is_prime[1] = -1;
	for (int m = 2; m <= n; ++m) {//初期化
		is_prime[m] = -1;
	}
	for (int m = 2; m <= n; ++m) {
		if (-1 == is_prime[m]) {
			P.push_back(m);
			for (int l = 2 * m; l <= n; l += m) {
				is_prime[l] = m;
			}
		}
	}
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	vector<int>A(N);
	int maxA = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		maxA = max(maxA, A[i]);
	}
	sieve(maxA);
	for (int i = 0; i < N; ++i) {
		calc(A[i]);
	}

	bool b1 = true;
	bool b2 = false;
	for (auto p : mp) {
		if (1 != p.second) {
			b1 = false;
		}
		if (N == p.second) {
			b2 = true;
		}
	}
	if (b1) {
		cout << "pairwise coprime" << endl;
	}
	else if (!b2) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
	return 0;
}

Measured memory_bytes: 14916
function main(){
  var i = 0;
  while(true){
    var fieldInfo = input[i].split(' ');
    var width = fieldInfo[0] - 0;//toInt
    var height = fieldInfo[1] - 0;//toInt
   
    // 0 0が入力された
    if(!width && !height){
      break;
    }
   
    var start;
    var goal;
    var elem = [[],[],[],[],[]];
    for(var ei = 0;ei < 5; ei++){
      elem[ei].length = 0;
    }
       
    for(var y = 0; y < height; y++){
      i++;//1行進める
      for(var x = 0; x < width; x++){
        var c = input[i][x];
   
        switch(c){
        case 'S':
          start = pos(x, y);
          break;
        case 'G':
          goal = pos(x, y);
          break;
        case '.':
          break;
        default : // 入力値が正しいので、絶対に属性
          elem[c - 1][elem[c - 1].length] = pos(x, y);
          break;
        }
      }
    }
   
       
    var bestElement = -1;
    var distance = Infinity;
       
    // 属性ごとにループ
    for (var startElem = 0; startElem < 5; startElem++) {
      // DPの初期化 DP[属性][同じ属性内の連番]
      var dp = [[],[],[],[],[]];
      for(var h = 0; h < 5; h++){
        var hLength = elem[h].length;
        dp[h].length = hLength;
        for(var hidx = 0; hidx < hLength; hidx++){
          dp[h][hidx] = Infinity;
        }
      }
         
      // 最初に選んだパチモンから次に捕まえられる属性番号
      var first = (startElem + 1) % 5;
   
      var firstLength = elem[first].length;
      for (var j = 0; j < firstLength; j++) {
        // s→e1を計算
        dp[first][j] = dist(start, elem[first][j]);
      }
         
      // s->1->2->3->4->g
      // なので、ループは間の-> * 3分まわす
      for (var e = 0; e < 3; e++) {
        // ex->e(x+1)
        var now = (first + e) % 5;
        var next = (now + 1) % 5;
        var nowLength = elem[now].length;
        var nextLength = elem[next].length;
        for (var j = 0; j < nowLength; j++) {
          for (var k = 0; k < nextLength; k++) {
            dp[next][k] = fmin(
              dp[next][k],
              dp[now][j] + 
                  dist(elem[now][j], elem[next][k]));
          }
        }
      }
         
      var last = (first + 3) % 5;
      var lastLength = elem[last].length;
      for (var j = 0; j < lastLength; j++) {
        // e4->g
        var d = dp[last][j] + 
                    dist(elem[last][j], goal);
           
        if (d < distance) {
          distance = d;
          bestElement = startElem + 1;
        }
           
      }
         
    }
       
    if (distance == Infinity) {
      console.log("NA");
    } else {
      console.log(bestElement + " " + distance);
    }
   
    i++;
  }
     
   
}
   
function dist(from, to){
  return fabs((from >> 11) - (to >> 11)) + fabs((from & 2047) - (to & 2047));
}
   
function fmin(a, b){
 return b + ((a-b) & ((a-b) >> 31));
}
   
function pos(a, b){
  // 2^10 = 1024なので、下位10ビットでy座標を、上位ビットでx座標を表す
  return (a << 11) + b;
}
  
function fabs(a){
 var mask = a >> 31;
 return (a ^ mask) - mask;
}
   
var
input = '';
   
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 63688
import fractions
# input
left, right, fizz, buzz = map(int, input().split())

# define
nums = right - left + 1
fizzbuzz = fizz * buzz // fractions.gcd(fizz, buzz)

# main
if left % fizz == 0:
  fizz_nums = right // fizz - left // fizz + 1
else:
  fizz_nums = right // fizz - (left // fizz + 1) + 1

if left % buzz == 0:
  buzz_nums = right // buzz - left // buzz + 1
else:
  buzz_nums = right // buzz - (left // buzz + 1) + 1
  
if left % fizzbuzz == 0:
  fizzbuzz_nums = right // fizzbuzz - left // fizzbuzz + 1
else:
  fizzbuzz_nums = right // fizzbuzz - (left // fizzbuzz + 1) + 1
  
# output 
print(nums - (fizz_nums + buzz_nums - fizzbuzz_nums))
  
# debug
"""
debug = int(input())
if debug == (nums - (fizz_nums + buzz_nums - fizzbuzz_nums)):
  print("AC")
else:
  print("WA")
"""

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

const int N = (3e3) + 3;
deque<char> rec;
ll Prev[N][N];
int memo[N][N];
string s1, s2;
int n, m;

void LCS(int n, int m) {
	for (int i = 0; i <= n; ++i) {
		memo[i][0] = 0;
	}
	for (int i = 0; i <= m; ++i) {
		memo[0][i] = 0;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s1[i - 1] == s2[j - 1]) {
				memo[i][j] = 1 + memo[i - 1][j - 1];
				Prev[i][j] = 1;
			} else {
				memo[i][j] = max(memo[i - 1][j], memo[i][j - 1]);
				Prev[i][j] = (memo[i][j] == memo[i - 1][j]? 2 : 3);
			}
		}
	}
}

void LCSrec(int n, int m) {
	rec.clear();
	while	(n != 0 and m != 0) {
		if (Prev[n][m] == 1) {
			rec.push_front(s1[n - 1]);
			--n; --m;
		} else if (Prev[n][m] == 2) {
			--n; m;
		} else {
			n; --m;
		}
	}
}

int main() {
	getline(cin, s1);
	getline(cin, s2);
	int n = s1.size();
	int m = s2.size();
	LCS(n, m);
	LCSrec(n, m);
	for (int i = 0; i < rec.size(); ++i) {
		printf("%c", rec[i]);
	} printf("\n");
	return 0;
}

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


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for(int ii=0; ii<M*2; ii++){
    int a;
    cin >> a;
    A[a-1]++;
  }
  for(auto& a : A){
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
void printDivisors(ll n, ve<ll> &v1)
{
    // Note that this loop runs till square root
    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            // If divisors are equal, print only one
            if (n / i == i)
            {
                v1.pb(i);
            }

            else // Otherwise print both
            {
                v1.pb(i);
                v1.pb(n / i);
            }
        }
    }
}
int main()
{
    FAST
        // freopen("input1.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
        ll n;
    cin >> n;
    ve<ll> v1;
    printDivisors(n, v1);
    ve<ll> v2;
    printDivisors(n - 1, v2);
    ll ans = v2.size();
    ans--;
    ll noo = n;
    for (auto x : v1)
    {
        // cout<<"x.. "<<x<<"\n";
        if (x != 1)
        {
            n = noo;
            while (n % x == 0)
            {
                n /= x;
            }
            if (n%x==1)
            {
                ans++;
            }
        }
    }
    cout<<ans<<"\n";
}


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

int main()
{
    while (true)
    {
        ll h, w;
        cin >> h >> w;
        if (h == 0 && w == 0)
        {
            break;
        }

        for (size_t i = 0; i < h; i++)
        {
            if (i == 0 || i == h - 1)
            {
                for (size_t j = 0; j < w; j++)
                {
                    cout << "#";
                }
            }
            else
            {
                for (size_t j = 0; j < w; j++)
                {
                    if (j == 0 || j == w - 1)
                    {
                        cout << "#";
                    }
                    else
                    {
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3088
s  = list(str(input()))
t  = list(str(input()))

sd = {}
td = {}

for k in range(ord('a'),ord('z')+1):   
    sd[chr(k)] = 0
    td[chr(k)] = 0

for i in range(len(s)) :
    if s[i] in sd :
        sd[s[i]] = sd[s[i]] + 1

    if t[i] in td :
        td[t[i]] = td[t[i]] + 1
""" 
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in sd :
        print(str(sd[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print()
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in td :
        print(str(td[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print() """

ta = []
sa = []
for k in range(ord('a'),ord('z')+1):
    if td[chr(k)] != sd[chr(k)] : 
        if td[chr(k)] > 0 :
            ta.append(td[chr(k)])
        if sd[chr(k)] > 0 :    
            sa.append(sd[chr(k)])
#print(ta)
#print(sa)

ta.sort()
sa.sort()

if ta == sa :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 6704
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;

  int diff = 0;
  rep(i, n - 1) if(s[i] != s[i + 1]) diff++;
  cout << n - 1 - max(diff - 2 * k, 0) << endl;
}

Measured memory_bytes: 3756
n = gets.chop.to_i
a = gets.chop.split(' ').map { |e| e.to_i }

if (a[0] != 0)
    puts 0
    exit
end    
 
max = 0
m = {}
 
a.each do |num|
    max = [max, num].max
    if m[num]
        m[num] += 1
    else
        m[num] = 1
    end
end
 
if (m[0] != 1)
    puts 0
    exit
end    
 
prevCount = 1
ans = 1
 
(1..max).each do |i|
    unless m[i]
        puts 0
        exit
    end
 
    m[i].times do
        ans = (ans * prevCount) % 998244353
    end
 
    prevCount = m[i]
end
 
puts ans

Measured memory_bytes: 17676
import collections
import copy
N=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

table=collections.defaultdict(int)
for i in range(1,N+1):
  tmp=factorization(i)
  for a,b in tmp:
    table[a]+=b

divisors=[[5,5,3],[15,5],[25,3],[75]]
ans=0
for x in divisors:
  tmp=[set() for i in range(len(x))]
  for i,y in enumerate(x):
    for z in table:
      if table[z]>=y-1:
        tmp[i].add(z)
    if len(tmp[i])==0:
      break
  for y in tmp[0]:
    if len(x)>1:
      for z in tmp[1]:
        if y==z:
          continue
        if len(x)>2:
          if y>z:
            continue
          for w in tmp[2]:
            if z==w or w==y:
              continue
            else:
              ans+=1
        else:
              ans+=1
    else:
      ans+=1
print(ans)
  

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1][3];
	bool b[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i][1]>>a[i][2];
		if(a[i][1]==a[i][2])
			b[i]=1;
		else
			b[i]=0;
	}
	int temp=0;
	for(int i=1;i<=n;i++)
	{
		if(b[i])
			temp++;
		else
			temp=0;
		if(temp>=3)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main(){
	int n,k;
	cin>>n>>k;
	int tmp;
	tmp = n/2;
	if(n%2==1)tmp++;
	if(tmp>=k){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int h = in.nextInt();
		int w = in.nextInt();
		for (int i=0; i<h; i++) {
			String s = in.next();
			out.println(s);
			out.println(s);
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
}



Measured memory_bytes: 3648
g=proc{gets.split.map &:to_i}
n, m = g.call
z = n + 1
states = []
z.times { states << [] }
w = []
m.times do
  p, y = g.call
  states[p] << y
  w << [p, y]
end
hash = {}
z.times do |i|
  states[i].sort.each_with_index do |y, i|
    hash[y] = i + 1
  end
end
w.each do |v|
  p, y = v
  puts format('%06d%06d', p, hash[y])
end

Measured memory_bytes: 34920
// #pragma GCC optimize("Ofast,unroll-all-loops")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define all(v) v.begin(), v.end()
#define len(v) ((int)(v).size())
#define pb push_back
#define kek pop_back
#define pii pair<int, int>
#define mp make_pair
#define int ll

#define debug(x) cout << #x << " = " << x << endl;

const int INF = (is_same<int, ll>::value ? 1e18 + 666 : 1e9 + 666);

// const int MEM_SIZE = 1e8;
// char mem[MEM_SIZE];
// int cur_mem_ptr = 0;

// void* operator new(size_t n) {
//     cur_mem_ptr += n;
//     return mem + cur_mem_ptr - n;
// }

// void operator delete(void*) noexcept {}
// void operator delete(void*, size_t) noexcept {}

template<class t1, class t2>
bool cmin(t1 &a, const t2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class t1, class t2>
bool cmax(t1 &a, const t2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifndef LOCAL
void UseFiles(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
#else
void UseFiles(const string&) {}
#endif

void run();

signed main() {
    // UseFiles("squads");
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
}

void run() {
    // floor(ax / b) - a * floor(x / b) = ax - (ax % b) - a * (x - x % b)  = a * (x % b) - (ax % b) -> max
    // ax % b < a
    // a * (x % b) - (a * x % b) -> max
    // a * x % b < a
    int a, b, n;
    cin >> a >> b >> n;
    int x = 0;
    int ans = 0;
    while (x <= min(n, b)) {
        cmax(ans, a * (x % b) - ((a * x) % b));
        x += (b + a - 1) / a;
        if ((a * x) % b >= a) --x;
    }
    cout << ans / b << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int r, g, b;
    cin >> r >> g >> b;
    (((r * 100 + g * 10 + b) % 4 == 0) ? (cout << "YES" << endl) : (cout << "NO" << endl));
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Vector;

public class Main {
	static class FastScanner{//用于快速读入大量数据
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in),16384);
			eat("");
		}
		public void eat(String s) {
			st = new StringTokenizer(s);
		}
		public String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				return null;
			}
		}
		public boolean hasNext() {
			while(!st.hasMoreTokens()) {
				String s = nextLine();
				if(s==null) return false;
				eat(s);
			}
			return true;
		}
		public String next() {
			hasNext();
			return st.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}

	static FastScanner cin = new FastScanner(System.in);//快读
	static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));//快速输出
	
	   public static void main(String args[]) {
		 int t;
		 t=cin.nextInt();
		 HashMap<String,Integer>mp=new HashMap<>();
         while(t-->0) {
		     String str;
		     str=cin.next();
		     if(mp.containsKey(str)) {
		     mp.put(str,mp.get(str)+1);
		     }
		     else {
		    	 mp.put(str, 1);
		     }
        	 
		 }
         if(mp.containsKey("AC")) {
         out.println("AC x "+mp.get("AC"));
         }
         else {
        	 out.println("AC x 0");
         }
         if(mp.containsKey("WA")) {
             out.println("WA x "+mp.get("WA"));
             }
             else {
            	 out.println("WA x 0");
            }
         if(mp.containsKey("TLE")) {
             out.println("TLE x "+mp.get("TLE"));
             }
             else {
            	 out.println("TLE x 0");
             }if(mp.containsKey("RE")) {
                 out.println("RE x "+mp.get("RE"));
             }
             else {
            	 out.println("RE x 0");
             }
         
         
         out.flush();
	   }
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a,b;
    string s,t,u;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if (u==s)
        cout<<a-1<<" "<<b;
    else
        cout<<a<<" "<<b-1;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  5 12:20:16 2018
ABC44C
@author: maezawa
"""

def f(i, j):
    global xa
    global dp
    if i==0:
        cnt = 0
        if j==0:
            cnt += 1
        if j==xa[0]:
            cnt += 1
        return cnt
    if (i, j) in dp:
        return dp[(i,j)]
    else:
        dp[(i,j)] = f(i-1,j-xa[i]) + f(i-1,j)
        #print(i,j, dp[(i,j)])
        return dp[(i,j)]


n, a = list(map(int, input().split()))
x = list(map(int, input().split()))

xa = [x[i]-a for i in range(n)]
dp = dict([])

print(f(n-1, 0)-1)





Measured memory_bytes: 5236