akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	int b = a.at(0);
	int cnt = 0;
	for(int i = 1; i < n; i++){
		if(a.at(i) == b){
			cnt += 1;
		}
		else{
			b = a.at(i);
		}
	}
	// cout << "b : " << b << endl;
	// cout << "cnt : " << cnt << endl;
	if(cnt % 2 == 0){
		cout << n - cnt << endl;
	}
	else{
		cout << n - cnt - 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    m,k = map(int, input().split())
    if m == 0:
        if k == 0:
            print(0, 0)
        else:
            print(-1)
    elif m == 1:
        if k == 0:
            print(0,0,1,1)
        else:
            print(-1)
    else:
        if k >= 2**m:
            print(-1)
        else:
            res = []
            for i in range(2**m):
                if i != 0 and i != k:
                    res.append(i)
            if k == 0:
                res = res + [0] + res[::-1] + [0]
            else:
                res = res + [0, k] + res[::-1] + [k, 0]
            print(*res)

if __name__ == '__main__':
    main()

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

// 割り算（小数点以下切り上げ）
int	roundup(int a, int b){
    return (a + (b - 1)) / b;
}

int main(){
    int H, W, N;
    cin >> H >> W >> N;

    int num = max(H, W);
    
    cout << roundup(N, num) << endl;

}

Measured memory_bytes: 256
#n , m , l = map(int , input().split())

# list_n = list(map(int , inpuut().split()))<Paste>

#n = input()
# list = [input() for i in range(N)

#list = [[i for i in range(N)] for _ in range(M)]


K, N = map(int, input().split())
List_A = list(map(int, input().split()))
List_AA = List_A[1:]+List_A[:1]
List_d = List_AA

for i in range(N):
    d = abs(List_AA[i]-List_A[i])
    List_d[i] = min(d, K-d)
ans = K - max(List_d)
print(ans)


Measured memory_bytes: 32300
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    for i in d.keys():
        if d[i] != 2:
            print("No")
            quit()
    print("Yes")
    return

#B
def B():
    n = I()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        k = p[i-1:i+2]
        k.sort()
        if k[1] == p[i]:
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    d = LI()
    d.sort()
    print(d[n//2]-d[n//2-1])
    return

#D
def D():
    n,k = LI()
    fact = [1]*100001
    for i in range(1,100001):
        fact[i] = fact[i-1]*i%mod
    inv = [1]*100001
    inv[-1] = pow(fact[-1],mod-2,mod)
    for i in range(1,100001)[::-1]:
        inv[i-1] = inv[i]*i%mod

    for i in range(1,k+1):
        if n-k+1 < i:
            print(0)
        else:
            ans = fact[n-k+1]*inv[i]*inv[n-k+1-i]%mod
            ans *= fact[k-1]*inv[k-i]*inv[i-1]%mod
            ans %= mod
            print(ans)
    return

#E
def E():
    ma = 100000000
    def dijkstra(s):
        d = defaultdict(lambda : ma)
        q = [(0,s,0)]
        d[(s,0)] = 0
        while q:
            dx,x,t = heappop(q)
            t = (t+1)%3
            k = t == 1
            for y in v[x]:
                if dx+k < d[(y,t)]:
                    d[(y,t)] = dx+k
                    heappush(q,(d[(y,t)],y,t))
        res = d[(g,0)]
        if res == ma:
            res = -1
        return res

    n,m = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
    s,g = LI()
    s -= 1
    g -= 1
    print(dijkstra(s))
    return

#F
def F():
    n,k = LI()
    if n == 1:
        print(1)
        quit()
    f = [0,n]
    i = 1
    while f[i] >= i:
        i += 1
        f.append(n//i)
    s = [0]*len(f)
    for i in range(1,len(f)):
        s[i] = 1
    for i in range(2,len(f))[::-1]:
        if f[i] <= i:
            s[-1] = f[i-1]-f[i]
        else:
            s.append(f[i-1]-f[i])
    MA = len(s)
    dp = [[0]*MA for i in range(k)]
    dp[0] = [s[i] for i in range(MA)]
    for i in range(MA-1):
        dp[0][i+1] += dp[0][i]
        dp[0][i+1] %= mod
    for l in range(k-1):
        for i in range(1,MA):
            j = MA-i
            dp[l+1][i] += dp[l][j]*s[i]
            dp[l+1][i] %= mod
            dp[l+1][i] += dp[l+1][i-1]
            dp[l+1][i] %= mod
    print(dp[-1][-1])
    return


#Solve
if __name__ == "__main__":
    F()


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

int main()
{
    string al;
    cin >> al ;
    if(al == "a" || al == "e" ||
    al == "i"|| al == "o" ||al == "u")
    {
        cout <<"vowel" << endl;
    }else{
        cout <<"consonant";
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();
        P p[] = new P[n];
        for (int i = 0; i < p.length; i++) {
			p[i] = new P(sc.nextInt(), sc.nextInt());
		}
        
        sort(p);
        long ans=0;
        PriorityQueue<Integer> q=new PriorityQueue<Integer>();
        for (int t=0,c=1; c <= m; c++) {
        	while(t<p.length && p[t].a<=c) {
//               	db(c,p[t].a,p[t].b);
               	q.add(-p[t].b);
        		t++;
        	}
        	if(!q.isEmpty())ans+=-q.poll();
		}
       
        out.println(ans);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
    	if(a==p.a) return b-p.b;
        return -p.a+a;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 46248
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[100000];
  int n,k,ans=1000000005;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n-k+1;i++){
    ans=min(ans,a[i+k-1]-a[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
s=input()
S=[a for a in s]
N=len(S)
number=0
for a in range(N//2):
    if S[a]==S[N-a-1]:
        number+=1
if number!=N//2:
    print('No')
else:
    n=N//2
    answer=0
    for b in range(n//2):
        if S[b]==S[n-1-b]:
            answer+=1
    if answer!=n//2:
        print('No')
    else:
        moji=S[n+1:]
        suuji=0
        for a in range(n//2):
            if moji[a]==moji[n-a-1]:
                suuji+=1
        if suuji==n//2:
            print('Yes')
        else:
            print('No')
            

Measured memory_bytes: 38384
//In the name of GOD
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define pb push_back
#define Mp make_pair
#define pll pair<ll, ll>
#define F first
#define S second

ll n, m, ans;

int main(){
	fast_io;
	
	ans = inf;
	cin >> n >> m;
	if(n >= 3) ans = min(ans, ((n + 2) / 3 - n / 3) * m);
	for(ll i = 1; i < n; i++){
		ans = min(ans, max(m * i, (n - i) * max(m / 2, (m + 1) / 2)) - min(m * i, (n - i) * min(m / 2, (m + 1) / 2)));
	}
	swap(n, m);
	if(n >= 3) ans = min(ans, ((n + 2) / 3 - n / 3) * m);
	for(ll i = 1; i < n; i++){
		ans = min(ans, max(m * i, (n - i) * max(m / 2, (m + 1) / 2)) - min(m * i, (n - i) * min(m / 2, (m + 1) / 2)));
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{
  int n, g;
  cin >> n >> g;
  int mini = g;
  for(int i = 0 ; i < n ; ++i){
    int mi;
    cin >> mi;
    g -= mi;
    if(mi < mini){
      mini = mi;
    }
  }
  int cnt = n;
  cnt += g / mini;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=2010;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int siz[N],son[N],fa[N],top[N];
int v[N],dep[N],cur[N],D[N];
VI ans;
bool in[N];bool o[N];
inline void change(int k) {
	ans.pb(k-1);
	int t,p;
	for (int x=k;x;x=fa[x])
		p=v[x],v[x]=t,t=p;
	v[k]=t;
}
int main()
{
	int n=gi(),i,k,all,t,s;
	for (i=2;i<=n;i++) D[i]=D[fa[i]=gi()+1]+1,dep[i]=1;
	for (i=n;i;i--)
		if (siz[fa[i]]+=++siz[i],siz[i]>siz[son[fa[i]]])
			son[fa[i]]=i,dep[fa[i]]=dep[i]+1;
	for (i=1;i<=n;i++)
		top[i]=son[fa[i]]==i?top[fa[i]]:i,v[i]=gi()+1;
	while (1) {
		for (i=n;i;i--)
			if (v[i]!=i)
				in[top[i]]=true;
		for (i=n,all=0;i;i--)
			if (in[i])
				for (k=fa[i],all+=dep[i];k;k=fa[k])
					in[k]=false;
		if (!all)
			break;
		while (all)
			if (in[k=top[v[1]]]) {
				for (t=k;son[t];t=son[t]);
				for (s=0;s<cur[k]&&v[1]<v[t];s++,t=fa[t]);
				o[v[1]]=true;
				change(t);
				if (++cur[k]==dep[k])
					in[k]=false;
				all--;
			} else {
				for (i=1,t=0;i<=n;i++)
					if (in[top[v[i]]]&&!o[v[i]])
						if (!t||D[i]>D[t])
							t=i;
				change(t);
			}
	}
	cout<<ans.size()<<endl;
	for (int t:ans)
		printf("%d\n",t);
	return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	set<string> tes;
	int N;
	cin>>N;
	vector<string> S;
	for(int i=0;i<N;i++){
		string T;
		cin>>T;
		S.pb(T);
	}
	tes.insert(S[0]);
	for(int i=1;i<N;i++){
		string prev=S[i-1],now=S[i];
		if(now[0]!=prev.back() || tes.count(now)){
			cout<<"No"<<endl;
			return 0;
		}
		tes.insert(now);
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap, VecDeque};

static dx: [i32; 4] = [0, 1, 0, -1];
static dy: [i32; 4] = [-1, 0, 1, 0];
static INF: i32 = 1<<30;

fn is_inside(y: i32, x: i32, h: usize, w: usize) -> bool{
    // println!("y = {}, x = {}", y, x);
    if y < 0 || h as i32 <= y || x < 0|| w as i32 <= x{
        false
    }else{
        true
    }
}

fn main() {
    input! {
        h: usize,
        w: usize,
        ch: Usize1,
        cw: Usize1,
        dh: Usize1,
        dw: Usize1,
        mut s: [Chars; h],
    }
    let mut c = vec![vec![INF; w]; h];
    c[ch][cw] = 0;
    let mut q= VecDeque::new();
    q.push_back((ch, cw));
    while !q.is_empty(){
        let (y, x) = *q.front().unwrap();
        q.pop_front();
        s[y][x] = '#';
        for i in 0..4{
            let ny = y as i32 + dy[i];
            let nx = x as i32 + dx[i];
            if !is_inside(ny, nx , h , w){
                continue;
            }
            let ny = ny as usize;
            let nx = nx as usize;
            if s[ny][nx] != '#' && c[ny][nx] > c[y][x]{
                c[ny][nx] = c[y][x];
                q.push_front((ny, nx));
            }
        }
        for i in -2..=2{
            for j in -2..=2{
                let ny = y as i32 + i;
                let nx = x as i32 + j;
                if !is_inside(ny, nx , h , w){
                    continue;
                }
                let ny = ny as usize;
                let nx = nx as usize;
                if s[ny][nx] != '#' && c[ny][nx] > c[y][x] + 1{
                    c[ny][nx] = c[y][x] + 1;
                    q.push_back((ny, nx));
                }
            }
        }

    }
    let ans = if c[dh][dw] != INF {c[dh][dw]} else {-1};
    println!("{}", ans);
}


Measured memory_bytes: 11228
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int64_t dfs(const vector<vector<int64_t>>& links, vector<int64_t>& distance, int64_t node) {
    auto d = distance[node];

    int64_t mn = node;
    int64_t m = d;
    for (auto a : links[node]) {
        if (distance[a] != numeric_limits<int64_t>::max()) {
            continue;
        }

        distance[a] = d + 1;
        auto nn = dfs(links, distance, a);
        if (distance[nn] > m) {
            mn = nn;
            m = distance[nn];
        }
    }

    return mn;
}

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

    vector<vector<int64_t>> links(n);
    for (auto _ : irange(0L, n - 1)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        links[a].push_back(b);
        links[b].push_back(a);
    }

    vector<int64_t> distance(n, numeric_limits<int64_t>::max());
    distance[0] = 0;
    int64_t u = dfs(links, distance, 0);

    cerr << "u=" << u << endl;

    distance.assign(n, numeric_limits<int64_t>::max());
    distance[u] = 0;
    int64_t v = dfs(links, distance, u);

    cerr << "v=" << v << endl;

    auto d = distance[v];

    cerr << "d=" << d << endl;

    if (d % 3 == 1) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }

    return 0;
}


Measured memory_bytes: 28416
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


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


void solve(){
	int n;
	cin >> n;
	int a[n];
	ll ans =0;
	map<int,int> cnt;
	forn(i,0,n){ 
		cin >> a[i];
		ans+=a[i];
		cnt[a[i]]++;
	}
	int q;
	cin >> q;
	while(q--){
		int b,c;
		cin >> b >> c;
		int tmp = cnt[b];
		cnt[b]=0;
		cnt[c]+=tmp;
		ans+=(c*tmp-b*tmp);
		cout << ans << endl;
	}	
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


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

signed main() {
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  map<int,int> mf,mp;
  int nx[n];
  fill(nx,nx+n,-1);
  for(int i=0;i<n;i++){
    if(mf.find(a[i])==mf.end()){
      mf[a[i]]=i;
      mp[a[i]]=i;
    }else{
      nx[mp[a[i]]]=i;
      mp[a[i]]=i;
    }
  }
 // for(int i=0;i<n;i++)cerr<<nx[i]<<' ';
  int c[n]={};
  int j=1,p=0;
  while(c[p]==0){
    c[p]=j;
    if(nx[p]==-1){
      j++;
      p=(mf[a[p]]+1);
      if(p>=n){
        p-=n;
        j++;
      }
    }else{
      p=nx[p]+1;
      if(p>=n){
        p-=n;
        j++;
      }
    }
  }
  int q=c[p]+(k-c[p])%(j-c[p]),m=n-1;
 // cerr<<q;
  while(c[m]!=q)m--;
 // cerr<<m;
  while(m<n){
   // cerr<<m<<nx[m]<<endl;
    if(nx[m]==-1){
      cout<<a[m]<<' ';
      m++;
    }else{
      m=nx[m]+1;
    }
  }
  return 0;
}


Measured memory_bytes: 31232
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define N 1000
#define md 1000000007
int n,m,k,dp[2000010],sta,id,o,p,q,go[2000010][23],put[2000010],need1[30],need2[30],i,ans;
void add(int &x,int y){x+=y;if (x>md) x-=md;}
int main()
{
	scanf("%d %d %d",&n,&m,&k);n--;
	for (i=1;i<=k;i++)
	{
		scanf("%d %d %d",&o,&p,&q);o--;p--;
		need1[o]|=(1<<p);
		need2[o]|=(1<<p)*q;
	}
	memset(go,-1,sizeof(go));
	for (sta=0;sta<(1<<n);sta++)
	{
		id=0;
		for (i=0;i<n;i++)
			if (sta&(1<<i))
			{
				if (i>0&&!(sta&(1<<(i-1)))) go[sta][id]=sta^(1<<i)^(1<<(i-1));
				id++;
			}
	}
	memset(put,-1,sizeof(put));
	for (sta=0;sta<(1<<n);sta++)
		for (i=n-1;i>=0;i--)
			if ((sta&(1<<i))==0){put[sta]=sta^(1<<i);break;}
	dp[0]=1;
	for (i=0;i<m;i++)
	{
		for (sta=0;sta<(1<<n)-1;sta++)  add(dp[put[sta]],dp[sta]);
		for (int id=0;id<n;id++)
			for (int sta=(1<<n)-1;sta>=0;sta--)
			if (go[sta][id]!=-1) add(dp[go[sta][id]],dp[sta]);
		for (sta=0;sta<(1<<n);sta++) if ((sta&need1[i])!=need2[i]) dp[sta]=0;
	}
	for (sta=0;sta<(1<<n);sta++) add(ans,dp[sta]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 193536
import math
a,b,c,d=map(int, input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
	
e = (c * d // gcd(c, d))
 
 
f=(a+c-1)//c
g=b//c
h=(a+d-1)//d
k=b//d
l=(a+e-1)//e
m=b//e
x=b-a+1
y=g-f+1
z=k-h+1
w=m-l+1
print(x-y-z+w)


Measured memory_bytes: 38384
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
# print(n, a)

dp = [[0] * n for _ in range(2)]
dp[0][0] = a[0][0]
dp[1][0] = dp[0][0] + a[1][0]
# print(dp)

for i in range(2):
    for j in range(1, n):
        if i == 0:
            dp[i][j] = dp[i][j - 1] + a[i][j]
        else:
            dp[i][j] = max(dp[i][j - 1] + a[i][j], dp[i - 1][j] + a[i][j])

ans = 0
for i in range(2):
    for j in range(n):
        ans = max(ans, dp[i][j])

# print(dp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )

using namespace std;

typedef long double ld;
typedef long long ll;

int N;
ld A[1005];

int main(void) {

	scanf("%d", &N);

	REP(i, 0, N) scanf("%Lf", &A[i]);

	ld sum = 0;
	REP(i, 0, N) {
		sum += 1 / A[i];
	}

	ld ans = 1 / sum;


	printf("%0.15Lf\n", ans);


	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	int cnt = 0;
	String T = "CODEFESTIVAL2016";
	for ( int i = 0; i < S.length(); i++ ) {
	    if ( S.charAt(i) != T.charAt(i) ) cnt++;
	}
	System.out.println(cnt);
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll b[4010][4010], a[2][1010][1010];
ll n, k, x, y, ans = 0;
char c;

int main() {
	cin >> n >> k;
	for (int i = 0;i < n;i++) {
		cin >> x >> y >> c;
		if (c == 'B')y += k;
		x %= 2 * k, y %= 2 * k;
		b[x][y]++;
		b[x + k][y + k]++;
		b[x + k][y]--;
		b[x][y + k]--;
	}
	for (int i = 0;i < 3 * k;i++) {
		for (int j = 0;j < 3 * k;j++) {
			b[i][j + 1] += b[i][j];
		}
	}
	for (int i = 0;i < 3 * k;i++) {
		for (int j = 0;j < 3 * k;j++) {
			b[i + 1][j] += b[i][j];
		}
	}
	for (int i = 0;i < 3 * k;i++) {
		for (int j = 0;j < 3 * k;j++) {
			a[(i / k + j / k) % 2][i%k][j%k] += b[i][j];
		}
	}
	for (int i = 0;i < 2;i++) {
		for (int j = 0;j < k;j++) {
			for (int l = 0;l < k;l++) {
				ans = max(ans, a[i][j][l]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 110848
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  char s[3];
  cin  >>s ;
  int ans =0;
  REP(i,3) {
    if(s[0]=='R') {
      if(s[1]=='R') {
        if(s[2]=='R') {
          ans=3;
        } else {
          ans=2;
        }
      } else {
        ans=1;
      }
    } else {
      if(s[1]=='R') {
        if(s[2]=='R') {
          ans=2;
        } else {
          ans=1;
        }
      } else {
        if(s[2]=='R') {
          ans=1;
        } else {
          ans=0;
        }
      }
    }
  }
  cout << ans << endl;        
  return 0;
}


Measured memory_bytes: 3624
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int ans = 0;
        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                if (0 <= S - x - y && S - x - y <= K) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<vector<int> > v(n + 1, vector<int>(n + 1, 0));
  for(int i = 0; i < n; i++){
    int u, k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int x; cin >> x;
      v[u][x] = 1;
    }
  }
  vector<int> d(n + 1), f(n + 1), c(n + 1, 0);
  stack<int> s;
  int t = 0;
  for(int j = 1; j <= n; j++){
    if(c[j] == 0){
      s.push(j);
      d[j] = ++t;
      c[j] = 1;
      while(s.size() != 0){
        t++;
        int x = s.top();
        int i;
        for(i = 1; i <= n; i++){
          if(v[x][i] == 1 && c[i] == 0){
            d[i] = t;
            c[i] = 1;
            s.push(i);
            break;
          }
        }
        if(i == n + 1){
          f[x] = t;
          s.pop();
        }
      }
    }
  }
  for(int i = 1; i <= n; i++){
    cout << i << " " << d[i] << " " << f[i] << endl;
  }
  return;
}

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



Measured memory_bytes: 3180
import sys
sys.setrecursionlimit(10000000)
MOD = 998244353
INF = 10 ** 9

def main():
    A,B,C,D = map(int,input().split())
    dp = [[0]*(1+D) for _ in range(C + 1)]

    dp[A][B] = 1
    for i in range(A - 1,C):
        for j in range(B - 1,D):
            if i == A - 1 and j == B - 1:
                continue
            dp[i + 1][j + 1] = (i + 1)*dp[i + 1][j] + (j + 1)*dp[i][j + 1] - dp[i][j] * i*j
            dp[i + 1][j + 1] %= MOD
    print(dp[C][D])
if __name__ == '__main__':
    main()

Measured memory_bytes: 138844
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n;
    int hoge=0;
    while(cin>>n,n){
        if(hoge++)cout<<endl;
        vector<pii>v;
        vector<string>amausa;
        rep(i,n){
            int gotiusa=0;
            string rabit; cin>>rabit;
            amausa.push_back(rabit);
            int kokoa,rize,tino; cin>>kokoa>>rize>>tino;
            gotiusa+=kokoa*3+tino;
            v.push_back(pii(gotiusa,-i));
        }
        sort(all(v),greater<pii>());
        rep(i,n)cout<<amausa[-1*v[i].second]<<","<<v[i].first<<endl;
    }
}

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

using namespace std;

constexpr int INF = 1e9 + 7;

int gcd(int a, int b)
{
	return b ? gcd(b, a % b) : a;
}


void solve()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	vector<vector<int>> row(h), column(w);
	for (auto&& i : row)
	{
		i.push_back(-1);
		i.push_back(w);
	}
	for (auto&& i : column)
	{
		i.push_back(-1);
		i.push_back(h);
	}
	for(int i = 0; i < h; i++)
	{
		cin >> s[i];
		for(int j = 0; j < w; j++)
		{
			if(s[i][j] == '#')
			{
				row[i].push_back(j);
				column[j].push_back(i);
			}
		}
	}

	for(auto&& i : row)
	{
		sort(begin(i), end(i));
	}
	for (auto&& i : column)
	{
		sort(begin(i), end(i));
	}
	int ans = 0;
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
		{
			if(s[i][j] == '.')
			{
				ans = max<int>(*upper_bound(begin(row[i]), end(row[i]), j)
					- *(lower_bound(begin(row[i]), end(row[i]), j) - 1)
					+ *upper_bound(begin(column[j]), end(column[j]), i)
					- *(lower_bound(begin(column[j]), end(column[j]), i) - 1)
					- 3
					, ans);
			}
		}
	}
	cout << ans << "\n";
}

int main()
{
	solve();
}

Measured memory_bytes: 40320
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int b[4005]={};
    vector<int> r, g;
    int cntb = 0;
    rep(i, n){
        if (s[i] == 'R') r.push_back(i+1);
        if (s[i] == 'G') g.push_back(i+1);
        if (s[i] == 'B'){
            b[i+1]++;
            cntb++;
        }
    }

    ll ans = 0;
    rep(i, r.size()){
        rep(j, g.size()){
            int tmp = cntb;
            int X = min(r[i], g[j]);
            int Y = max(r[i], g[j]);
            if ((Y - X) % 2 == 0 && b[(Y + X) / 2] == 1) tmp--;
            if (2 * Y - X <= n && b[2 * Y - X] == 1) tmp--;
            if (2 * X - Y >= 1 && b[2 * X - Y] == 1) tmp--;
            ans += tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define PI 3.14159265

int main () {
    int a[6];
    int flag = 0;
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5];
    
    if (a[4] - a[0] > a[5]) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
module Main where

-- import Utils
import Control.Applicative

getInt :: IO Int
getInt = head <$> getInts

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  { [a,b] <- getInts
  ;putStrLn (unwords(map show [a * b, 2 * (a + b)]))
  }





Measured memory_bytes: 3576
from itertools import combinations_with_replacement

n,m,q = map(int,input().split())
qlist = []
for i in range(q):
	a = map(int,input().split())
	qlist.append(list(a))

best = 0
seqlist = combinations_with_replacement(range(1,m+1),n)
for seq in seqlist:
	score = 0
	for x in qlist:
		if seq[x[1]-1] - seq[x[0]-1] == x[2]:
			score += x[3]
	if score > best:
		best = score
	
print(best)

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

using namespace std;
#define ll long long
#define mod 1000000007

int n1, n2;
string s1, s2;
ll dp[3000][3000];

ll f(ll i, ll j) {
    if (i == n1 || j == n2) {
        return 0;
    }

    if (dp[i][j] != -1) return dp[i][j];

    ll ans;
    if (s1[i] == s2[j]) {
        ans = 1 + f(i + 1, j + 1);
    } else {
        ans = max(f(i + 1, j), f(i, j + 1));
    }

    dp[i][j] = ans;
    return ans;
}

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

    memset(dp, -1, sizeof(dp));

    cin >> s1 >> s2;
    n1 = s1.length(), n2 = s2.length();

    int i = 0, j = 0;
    while (i < n1 && j < n2) {
        if (s1[i] == s2[j]) {
            cout << s1[i];
            i++, j++;
        } else if (f(i + 1, j) > f(i, j + 1)) {
            i++;
        } else {
            j++;
        }
    }
}


Measured memory_bytes: 74220
#include<bits/stdc++.h>
#define inf ((1<<30)-1)
#define linf ((1<<62)ll-1)
#define LL long long
#define F(i,a,b,c) for(register int i=(a);(b);i=(c))
#define Fu(i,a,b) for(register int i=(a);i<=(b);++i)
#define Fd(i,a,b) for(register int i=(a);i>=(b);--i)
#define Fn(i,a) for(register int i=las[(a)];i;i=nex[i])
#define COND(c) (isprint(c))
int Fl,Pn,SI=100;char mch=' ',ch,Bf[21];
void chin(char&c){while(!COND(c=getchar()));}
template<typename t>void in(t&a){a=0;ch=getchar();Fl=1;while(((ch<'0')||(ch>'9'))&&ch!=EOF)Fl=(ch=='-')?-Fl:Fl,ch=getchar();while((ch>='0')&&(ch<='9'))a=a*10+ch-'0',ch=getchar();a*=Fl;}template<typename t>void out(t a){if(a<0)putchar('-'),a=-a;if(a==0)putchar('0');while(a)Bf[++Pn]=a%10+'0',a/=10;while(Pn)putchar(Bf[Pn]),--Pn;putchar(mch);}
template<typename t,typename ...ARGS>void in(t&a,ARGS&...args){in(a);in(args...);}
template<typename t,typename ...ARGS>void out(t a,ARGS... args){out(a);out(args...);}
using namespace std;
int a[10001],b,n;LL s1,s2;
int main()
{
	in(n);
	Fu(i,1,n)in(a[i]);
	Fu(i,1,n)
	{
		in(b);
		if(a[i]>b)s1+=(a[i]-b);
		else s2+=(b-a[i])/2; 
	}
	if(s1<=s2)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}
//BY Segment_Tree_Juruo (2020严誉沣)


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

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

	int p[n];
	for(int i=0;i<n;i++) cin>>p[i];

	sort(p,p+(sizeof(p)/sizeof(p[0])));

	int ans=0;
	for(int i=0;i<k;i++){
		ans+=p[i];
	}
	cout<<ans<<endl;
	return 0;
}
	

Measured memory_bytes: 3604
import java.util.*;
public class Main {
public static void main(String args[])
{
  Scanner sp=new Scanner(System.in);
    int n=sp.nextInt();
    int sc=0;
    int l=(int) (Math.log10(n) + 1);
 
    if(l%2==0)
    
     {
     for(int i=n;i>0;i--)
     {
        int sn=(int) (Math.log10(i) + 1);
        if(!(sn%2==0))
         {
          sc++;  
         }
     }
      System.out.println(sc);
    }
    else
    {
     for(int i=n;i>0;i--)
     {
        int sn=(int) (Math.log10(i) + 1);
        if(!(sn%2==0))
         {
          sc++;  
         }
     }
      System.out.println(sc);
    }
}
}
	
	
	


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	vll A(N); cin >> A;
	vector<Pl> ans;
	sort(rbegin(A), rend(A));

	int plus = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] > 0) plus++;
	}
	
	if (plus == 0) plus++;
	
	ll val = A[N-1];
	int num = min(N-2, plus-1);
	for (int i = 0; i < num; i++) {
		ans.emplace_back(val, A[i]);
		val = val - A[i];
	}
	ans.emplace_back(A[num], val);
	val = A[num] - val;
	for (int i = num+1; i < N-1; i++) {
		ans.emplace_back(val, A[i]);
		val = val - A[i];
	}
	cout << val << endl;
	for (auto &an : ans) {
		cout << an.first << " " << an.second << el;
	}
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

#define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  // int N;
  // int M;
  // array<int, 100000> A;
  // string S;
  // string T;

  int X, Y;

  cin >> X;
  cin >> Y;

  cout << X + Y / 2 << endl;


  return 0;
}


Measured memory_bytes: 256
from collections import deque

def main():
    K = int(input())
    num_list = list(range(0, 10))
    def bfs():
        q = deque(list(map(str, num_list)))
        
        while len(num_list) < 2 * 10**6:
            now_str = q.popleft()
            now = int(now_str[0])
            for j in [now-1, now, now+1]:
                if j not in [-1, 10]:
                    new = str(j) + now_str
                    q.append(new)
                    if j != 0:
                        num_list.append(int(new))
    
    bfs()
    print(sorted(set(num_list))[K])
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 293476
n = list(input())

if n[0]=="A":
    if n[1]=="B":
        print("Yes")
    else:
        if n[2]=="B":
            print("Yes")
        else:
            print("No")
else:
    if n[1]=="A":
        print("Yes")
    else:
        if n[2]=="A":
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
typedef pair<ll, ll> Pair;
template <class T> T input() {T t; cin>>t; return t;}
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define FIND(x,key) x.find(key) != x.end()
#define IN_RANGE_V2(v,k,x,y) (0<=x+dx[k]&&x+dx[k]<v[y].size()&&0<=y+dy[k]&&y+dy[k]<v.size())
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define PRINT_ARRAY_H(a) REPALL(__i,a) {cout<<a[__i]<<(__i != a.size()-1 ? " " : "");} newline;
#define PRINT_ARRAY_V(a) REPALL(__i,a) {cout<<a[__i]<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
#define cspace ' '
#define sspace " "
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};
//const VI dx = {1, 1, 0, -1, -1, -1, 0, 1};
//const VI dy = {0, 1, 1, 1, 0, -1, -1, -1};

void solve()
{
    ll a, b, c, d, n, m, l, r, k, x, y, z, ans = 0ll;
    string s, t;
    cin>>s;
    if (s.find("RRR") == 0)
        cout<<3<<endl;
    else if (s.find("RR") < 2)
        cout<<2<<endl;
    else if (s.find("R") < 3)
        cout<<1<<endl;
    else
        cout<<0<<endl;
}

int main()
{
    cout<<fixed<<setprecision(20);
    int __t = 1;
    //cin>>__t;
    REP(i,__t) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#define sevfiv(a) 

int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if( (a == 5 || a == 7) && (b == 5 || b == 7) && (c == 5 || c == 7) && a+b+c == 17) printf("YES");
  else printf("NO");
}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

void solve(){
    int N;
    cin >> N;
    vector<int> hat (N);
    for(int i = 0;i < N;i++){
        cin >> hat[i];
    }
    vector<int> count (3,0);
    LL ans = 1;
    for(int i = 0;i < N;i++){
        int times_count = 0;
        bool changed = false;
        for(int j = 0;j < 3;j++){
            if(count[j] == hat[i]){
                times_count++;
                if(changed == false){
                    count[j]++;
                    changed = true;
                }
            }
        }
        ans *= times_count;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#define INF 100000
//#include <chrono>
using namespace std;

int main()
{
  int  a, b, k;
  int count = 0;
  cin >> a >> b >> k;
  for(int i = min(a,b); i >= 1; i--){
    if(a % i == 0 && b % i == 0)
      count++;
    if(count == k){
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

int main() {
	int N;
	std::cin >> N;
	int * A= new int[N];
	int max, min;
	for (int i=0; i < N; ++i) {
		std::cin >> A[i];
		if(i==0)max = A[i], min = A[i];
		if (A[i] > max)max = A[i];
		if (A[i] < min)min = A[i];
	}
	int ans = max - min;
	std::cout << ans;
	delete A;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
  ll n;
  cin>>n;
  ll x=n%10;
  if(x==2 or x== 4 or x==5 or x==7 or x==9)
    cout<<"hon"<<"\n";
  else if(x==3) cout<<"bon"<<"\n";
  else
    cout<<"pon"<<"\n";
}

int main()       
{
  fastio
  ll tt=1;
  while(tt--)
    solve();
  return 0;
}

Measured memory_bytes: 3652
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var a = input[0];
		var b = input[1];
		var c = input[2];

		if (a < b && b < c)
		{
			System.Console.WriteLine("Yes");
		}
		else
		{
			System.Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 18344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> P;



int main(){ 
  int N, M; cin >> N >> M;
  vector<vector<bool>> like(N, vector<bool>(M,false));
  
  rep(i,N) {
    int K; cin >> K;
    rep(j,K) {
      int A; cin >> A;
      A--;
      like[i][A] = true;
    }
  }
  
  vector<bool> liked(M, true);
  rep(j,M) {
    rep(i,N) {
      if(!like[i][j]) liked[j] = false;
    }
  }
  
  int cnt = 0;
  rep(i,M) {
    if(liked[i]) cnt++;
  }
  cout << cnt << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
string s;
char c;
int main(){
    cin>>s;
    for(register int i=1;cin>>c;i+=2) s.insert(i,&c);
    cout<<s<<"\n";
    exit(0);
}

Measured memory_bytes: 256