akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii; 
typedef vector<string> vs;
typedef vector<vi> vvi;
int f(int x){
	if(x%2==0)return x/2;
	else return 3*x+1;
}
int s;
map<int,bool> mp;
int a;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>s;
	int lst=s;
	mp[s]++;
	for(int i=1;;i++){
		a=f(lst);
		if(mp[a]){
			cout<<i+1<<endl;
			return 0;
		}
		mp[a]++;
		lst=a;
	}
    return 0;
}

Measured memory_bytes: 256
/*
    WRITER:kakitamasziru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<long,long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    //n!はi = 1;i<=nでする
    for (long long i = n-r+1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    int N,M;cin >> N >> M;
    vector<int> like(M,0);
    for(int i = 0;i<N;i++){
        int a;cin >> a;
        for(int j = 0;j<a;j++){
            int food;cin >> food;
            like.at(food-1)++;
        }
    }
    int ans = 0;
    for(int i = 0;i<M;i++){
        if(like.at(i) == N) ans++;
    }
    cout << ans << endl;
    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

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

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

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> C(N);
  REP(i, N) {
    int A, B;
    cin >> A >> B;
    C[i] = make_pair(A, B);
  }
  sort(ALL(C));

  int pos = 0;
  int ret = 0;
  priority_queue<int> que;
  for(int i = M - 1; i >= 0; --i) {
    while((pos < N) && (C[pos].first + i <= M)) {
      que.push(C[pos].second);
      pos++;
    }
    if (!que.empty()) {
      int q = que.top(); que.pop();
      ret += q;
    }
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];
  vector<vector<int>> ans(H,vector<int>(W));
  int color = 1;
  int colorp = 0;
  for(int h=0;h<H;h++){
    if(h%2==0){
      for(int w=0;w<W;w++){
        ans[h][w] = color;
        A[colorp]--;
        if(A[colorp]==0){
          color++;
          colorp++;
        }
      }
    }
    else{
      for(int w=W-1;w>=0;w--){
        ans[h][w] = color;
        A[colorp]--;
        if(A[colorp]==0){
          color++;
          colorp++;
        }
      }
    }
  }
  rep(i,H){
    rep(j,W){
      if(j!=0) cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np


def solve(S):
    dp = np.zeros(2019, np.int64)
    pow10 = 1
    answer = 0
    for x in S[::-1]:
        dp[0] += 1
        x = x * pow10 % 2019
        newdp = np.zeros_like(dp)
        newdp[x:] += dp[:-x]
        newdp[:x] += dp[-x:]
        answer += newdp[0]
        pow10 *= 10
        pow10 %= 2019
        dp = newdp
    return answer


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4[:],)')(solve)
    cc.compile()


try:
    from my_module import solve
except:
    cc_export()
    exit()

S = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')
print(solve(S))


Measured memory_bytes: 29016
#include<bits/stdc++.h>
#define N 100005
#define Mod 1000000007
#define db(x) cout<<#x<<"="<<x<<endl;
using namespace std;
struct edge {
	int to,nxt;
} e[N<<1];
int n,k,head[N],cnt[N];
bool mark[N];
long long ans=1;
void link(int s,int t,int n) {
	e[n]=(edge)<%t,head[s]%>;
	head[s]=n;
	cnt[s]++;
}
void dfs(int x,int f,int t) {
	if(f!=1&&f)t++;
	ans=ans*(k-t)%Mod;
	int now=0;
	for(int i=head[x]; i; i=e[i].nxt) {
		int to=e[i].to;
		if(to!=f)dfs(to,x,++now);
	}
}
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1; i<n; i++) {
		int s,t;
		scanf("%d%d",&s,&t);
		link(s,t,(i<<1)-1);
		link(t,s,i<<1);
	}
	dfs(1,0,0);
	printf("%lld\n",ans);
	return 0;
}


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

const ll mod = 1000000007;

struct mint{
  ll v;
  mint(ll a=0):v((a%mod+mod)%mod){}
  mint operator-() const {
    return mint(-v);
  }
  mint& operator+=(const mint a){
    if ((v += a.v) >= mod) v -= mod;
    return *this;
  }
  mint& operator-=(const mint a){
    if ((v += mod - a.v) >= mod) v -= mod;
    return *this;
  }
  mint& operator*=(const mint a){
    (v *= a.v) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  // v^t
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }

  // for prime mod
  // Fermat's little theorem : a^(p-1) = 1 (mod p) when p is prime and a = 1 (mod p)
  mint inv() const {
    return pow(mod - 2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }

  // k < 10^6, n < 10^9
  static mint comb(ll n, int k){
    mint num(1), den(1);
    for(int i=0; i<k; i++){
      num *= mint(n-i);
      den *= mint(i+1);
    }
    return num / den;
  }
};

// for cout << 
ostream& operator<<(ostream& stream, const mint a){
  stream << a.v;
  return stream;
}
// include mint

struct combination{
  vector<mint> fact, ifact;
  combination(int n): fact(n+1), ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i=1; i<=n; i++){
      fact[i] = fact[i-1] * i;
    }
    ifact[n] = fact[n].inv();
    for(int i=n; i >=1; i--){
      ifact[i-1] = ifact[i] * i;
    }
  }
  mint operator()(int n, int k){
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

// example
int ABC156_E(){
  ll n, k;
  cin >> n >> k;

  combination c(n);
  mint ans(0);
  for(int i=0; i<=min(n, k); i++){
    ans += c(n, i) * c(n-1, i);
  }
  cout << ans << endl;

  return 0;
}

int main(){
  ABC156_E();

  return 0;
}

Measured memory_bytes: 3328
n = "0"+input()
a = [0, 0]
flag = True

for i in reversed(n):
    b = int(i)
    c=[0,0]
    if flag:
        flag = False
        c[0] = b
        c[1] = 10 - b
    else:
        c[0] = min(a[0] + b, a[1] + b + 1)
        c[1] = min(a[0] + 10 - b, a[1] + 10 - b - 1)
    a=c[:]
print(min(a))

Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define SZ(x) ((int)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const double pi=acos(-1);


int main() {
    int N;
    cin >> N;
  vector<string> pre(N);
  
  rep (i, N) {
  cin >> pre.at(i);
  }
  
  sort(all(pre));
  
  int ans=1;
  
  for (int i = 1; i < N; i++) {
  if (pre.at(i)!=pre.at(i-1)) ans++;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 9596
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  string s;
  cin >> s;
  int ans = 0;
  for(int i=0; i<s.size(); ++i){
    if(s[i] == '1') ans++;
  }

  cout << ans << endl;

}


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


int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n)   cin >> a[i];

    ll p = 0;
    rep(i, n){
        p += a[i] / 2;
        a[i] %= 2;
        if(a[i] == 1 && i+1 < n && 0 < a[i+1]){
            p++;
            a[i+1]--;
        }
    }

    cout << p << endl;


    return 0;
}


Measured memory_bytes: 1024
package main
 
import (
	"bufio"
	"os"
	"strings"
)
 
const scBufSize = 1 * 1024 * 1024 // 1MB

var sc = func() *bufio.Scanner {
  sc := bufio.NewScanner(os.Stdin)
  sc.Buffer(make([]byte, scBufSize), scBufSize)
  sc.Split(bufio.ScanWords)
  return sc
}()
var w = []string{"dream", "dreamer", "erase", "eraser"}
 
func main() {
	s := scans()
 
	if check(s) {
		os.Stdout.WriteString("YES")
		return
	}
	os.Stdout.WriteString("NO")
}
 
func scans() string {
	sc.Scan()
	return sc.Text()
}
 
func check(s string) bool {
	var b bool
	for _, v := range w {
		if v == s {
			return true
		}
		if strings.HasPrefix(s, v) {
			b = b || check(s[len(v):])
		}
	}
	return b
}

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


int main() {
	
	int a, b;
	scanf("%d%d", &a, &b);

	if (b >= a)printf("%d", a);
	else(printf("%d",a - 1));


}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    int a, b;
    cin >> a >> b;

    for (int i = 1; i <= 3; i++) {
        if (i != a && i != b) {
            cout << i << '\n';
        }
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }
int N,M;
int S,T;
vector<pair<int,int> > G[100000+30][3];
int visited[100000+10][3];

int solve(void) {
    for(int i = 0;i < 3;i++) {
        for(int j = 0;j < 100000+10;j++) {
            visited[j][i] = -1;
        }
    }

    queue<pair<pair<int,int>,int> > Q;

    Q.push(make_pair(make_pair(S,0),0));
    while(!Q.empty() ) {
        auto n = Q.front();Q.pop();
        //cout<<n.first.first<<" "<<n.first.second<<endl;
        if(visited[n.first.first][n.first.second] != -1)
            continue;
        visited[n.first.first][n.first.second] = n.second;

        for(auto e : G[n.first.first][n.first.second]) {
            Q.push(make_pair(e,n.second+1));
        }
    }
    
    return (visited[T][0] != -1 ? visited[T][0] / 3 : -1);
}

int main(void) {
    cin>>N>>M;

    for(int i = 0;i < M;i++) {
        int u,v;
        cin>>u>>v;
        G[u][0].push_back(make_pair(v,1));
        G[u][1].push_back(make_pair(v,2));
        G[u][2].push_back(make_pair(v,0));
    }

    cin>>S>>T;

    cout<<solve()<<endl;

    return 0;
}


Measured memory_bytes: 17792
#include <iostream>
#include <string>

using namespace std;
string s;
long long a[500010];
int main(){
	int i,j,n;
	cin >> s;
	n = s.size() + 1;
	for(i=0;i<n;i++){
		a[i] = -1;
	}
	if(s[0]=='<') a[0] = 0;
	if(s[n - 2]=='>') a[n - 1] = 0;
	for(i=1;i<n - 1;i++){
		if(s[i - 1]=='>' && s[i]=='<'){
			a[i] = 0;
		}
	}
	for(i=0;i<n;i++){
		if(a[i]==0){
			for(j=i + 1;j<n;j++){
				if(s[j - 1]=='<'){
					a[j] = max(a[j],a[j - 1] + 1);
				}else{
					break;
				}
			}
			for(j=i - 1;j>=0;j--){
				if(s[j]=='>'){
					a[j] = max(a[j],a[j + 1] + 1);
				}else{
					break;
				}
			}
		}
	}
	long long sum = 0;
	for(i=0;i<n;i++){
		sum += a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 4740
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

bool check(int i, vector<int> v){
  bool flag = true;
  for (auto e: v){
    if (e%i != 0){
      flag = false;
      break;
    }
  }
  return flag;
}

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

  int N, X; cin >> N >> X;
  vector<int> x(N);
  for (int i=0; i<N; i++){
    int xtemp; cin >> xtemp;
    x[i] = abs(xtemp-X);
  }
  int xmin = x[min_element(x.begin(), x.end()) - x.begin()];
  int D = 1;
  for (int i=1; i*i<=xmin; i++){
    if (xmin%i == 0){
      if (check(i, x))
        D = max(D, i);
      if (check(xmin/i, x))
        D = max(D, xmin/i);
    }
  }
  cout << D << endl;
  return 0;
}

Measured memory_bytes: 1024
//https://jeffbradberry.com/posts/2015/09/intro-to-monte-carlo-tree-search/
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <ctime>
#include <random>
#include <set>
#include <chrono>
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define C 1.4

using namespace std;
using namespace std::chrono;
 
int gcd(int a,int b){
  if(b==0)return a;
  else return gcd(b,a%b);
}
 
int main() {
  int n,a[114514],l[114514],r[114514];
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  l[0]=0;
  r[0]=0;
  for(int i=0;i<=n-1;i++){
    l[i+1]=gcd(l[i],a[i]);
    r[i+1]=gcd(r[i],a[n-1-i]);
  }
  int res=0;
  for(int i=0;i<=n-1;i++){
    if(res<gcd(l[i],r[n-1-i]))res=gcd(l[i],r[n-1-i]);
  }
  cout << res << endl;
}

Measured memory_bytes: 1408
import java.util.*;
import java.text.DecimalFormat;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(); double t=1;
		int m = 1000000007;
		for (double i=1; i<=n; i++) t=(t*i)%m;
		System.out.println(new DecimalFormat("#").format(t));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 36012
import java.util.Scanner;

class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner( System.in );
    int A = sc.nextInt();
    int B = sc.nextInt();
    int quot = (B-A)/(A-1);
    int mod = (B-A)%(A-1);
    
    if (mod > 0) {
      quot ++;
    }
    
    System.out.println(quot+1);
    
  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

bool check(int f, int s, int v, int x){
    if(f==v && s==x) return true;
    if(f==x && s==v) return true;
    return false;
}

int main(){
    int n,m;
    cin >> n >> m;
    VVI G(n+1);
    vector<P> list(m);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
        list.push_back(P(a,b));
    }

    int ans = 0;

    for(auto p : list){
        int f = p.first;
        int s = p.second;
        set<int> seen;
        VI todo = {};
        seen.insert(1);
        for(auto x : G[1]){
            if(check(f,s,1,x)) continue;
            seen.insert(x);
            todo.push_back(x);
        }
        while(!todo.empty()){
            int v = todo.back();
            todo.pop_back();
            for(auto x : G[v]){
                if(seen.count(x)) continue;
                if(check(f,s,v,x)) continue;
                seen.insert(x);
                todo.push_back(x);
            }
        }
        if(seen.size() != n){
            ans++;
            // cout << f << " " << s << endl;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*- 
def cost(h,N,K):
    dp=[0]*N
    dp[1]=abs(h[0]-h[1])
    for i in range(2,N):
        tmp=[abs(h[i]-h[j])+dp[j] for j in range(max(0,i-K),i)]
        dp[i]=min(tmp)
    return dp[-1]

N,K=map(int,input().split())
h=[int(num) for num in input().split()]

print(cost(h,N,K))


Measured memory_bytes: 13980
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

const int MAXN = 500;
int n, x[MAXN+1];
int a[MAXN*MAXN+1];

vector<pair<int,int>> q;

void fk(){
	puts("No");
	exit(0);
}

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++){
		scanf("%d", &x[i]);
		a[x[i]]=i;
		q.push_back(make_pair(x[i], i));
	}

	sort(q.begin(), q.end());
	int index=1;
	for(auto &p:q){
		int place=p.first, num=p.second;
		for(int i=1; i<num; i++){
			while(index<n*n && a[index]) index++;
			if(a[index] || index > place) fk(); ///
			a[index]=num; index++;
		}
	}

	for(int i=1; i<=n; i++){
        for(int j=1, k=x[i]; j<=n-i; j++){
			while(k<n*n && a[k]) k++;
			if(a[k]) fk(); ///
			a[k]=i;
        }
	}

	puts("Yes");
	for(int i=1; i<=n*n; i++)
		printf("%d ", a[i]);
	return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<unordered_map>

#define REP(i,n) for(int i=0;i<n;i++)
#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int main() {
  int n;
  cin >> n;
  if(n < 105) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 1;
  for(int i = 107; i <= n; i += 2) {
    int tmp = 0;
    for(int j = 1; j <= i; j++) {
      if(i%j == 0) tmp++;
    }
    if(tmp == 8){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	string O, E; cin >> O >> E;
	string P; 
	rep(i, 0, E.length()) {
		P.push_back(O[i]);
		P.push_back(E[i]);
	}
	if (O.length() > E.length())P.push_back(O[O.length() - 1]);

	cout << P << endl;

	return 0;
}

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

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int k = sc.nextInt();
            String s = sc.next();
            
            if (s.length()<=k){
                System.out.println(s);
            } else{
            System.out.println(s.substring(0,k)+"...");

            }
            
        }
    }

Measured memory_bytes: 38588
n,m=map(int,input().split())
s=[input() for i in range(n)]
t=[input() for i in range(m)]

z=0
c=0

for i in range(n-m+1):
    for j in range(n-m+1): 
        
        for x in range(m):
            for y in range(m):
                if s[i+x][j+y]==t[x][y]:
                    z+=1
        if z==m**2:
            c+=1
        else:
            z=0
if c>0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;

    for(int i=0; i<dy; i++){
        cout << 'U';
    }
    for(int i=0; i<dx; i++){
        cout << 'R';
    }
    for(int i=0; i<dy; i++){
        cout << 'D';
    }
    for(int i=0; i<dx; i++){
        cout << 'L';
    }
    cout << "LU";
    for(int i=0; i<dy; i++){
        cout << 'U';
    }
    for(int i=0; i<dx; i++){
        cout << 'R';
    }
    cout << "RDRD";
    for(int i=0; i<dy; i++){
        cout << 'D';
    }
    for(int i=0; i<dx; i++){
        cout << 'L';
    }
    cout << "LU";

    return 0;
}

Measured memory_bytes: 256
n=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
B1=[A1[0]]
B2=[A2[-1]]
for i in range(1,n):
    B1.append(B1[i-1]+A1[i])
    B2.append(B2[i-1]+A2[n-i-1])
ans=0
for i in range(n):
    ans=max(ans,B1[i]+B2[n-i-1])
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#define min(a,b)((a)>(b))?(b):(a)
typedef long long ll;

using namespace std;

ll f(ll r,ll a,ll b){
	return a*r/b;
}

int main(){
	ll a,b,n,ans;
	cin >> a >> b >> n;
	ans = f(min(b-1,n),a,b);
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


int main(void){

	vector< int > v( 5, 0 );

	for( int i = 0; i < 5; i++ )
		cin >> v[i];

	sort( v.begin(), v.end() );
	
	cout << v[4];
	for( int i = 3; i >= 0; i-- )
		cout << " " << v[i];

	cout << endl;

    return 0;
}

Measured memory_bytes: 1208
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.Functor

main :: IO()
main = do
  n <- readLn :: IO Int
  cs <- replicateM n $ B.words <$> B.getLine :: IO [[B.ByteString]]
  solveBs cs EmptyTree

solveBs :: [[B.ByteString]] -> Tree Int -> IO()
solveBs [] _ = return ()
solveBs (c:cs) t
  | B.unpack command == "insert" = solveBs cs $! insertTree v t
  | B.unpack command == "print" = do
      printTree t
      solveBs cs t
    where
      command = head c
      v = fst . fromJust . B.readInt $ c !! 1 :: Int

data Tree a = EmptyTree | Node !a !(Tree a) !(Tree a) deriving (Show)

insertTree :: (Ord a) => a -> Tree a -> Tree a
insertTree c EmptyTree = Node c EmptyTree EmptyTree
insertTree c !(Node v !left !right)
  | c >= v = let !inserted = insertTree c right
             in Node v left inserted
  | c < v = let !inserted = (insertTree c left)
            in Node v inserted right

inorder :: Tree a -> [a]
inorder EmptyTree = []
inorder (Node v left right) = (inorder left) ++ [v] ++ (inorder right)

preorder :: Tree a -> [a]
preorder EmptyTree = []
preorder (Node v left right) = v:(preorder left) ++ (preorder right)

printTree :: Tree Int -> IO ()
printTree t = do
    putStr " "
    putStrLn . unwords . map show $ inorder t
    putStr " "
    putStrLn . unwords . map show $ preorder t



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

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

  int cnt = 0;

  for (int i = 100; i > 0; i--) {
    if (A % i == 0 && B % i == 0) cnt++;
    if (cnt == K) {
      cout << i << "\n";
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vd(T) vector<vector<T>>
#define v(T) vector<T>
#define mod (ll)(1e9+7)
#define pp(T) pair<T,T>
#define pb push_back
#define mp make_pair
#define NN 100005
#define IO ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG cout<<"***********DEBUGGING***********"<<endl
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 
ll power(ll a,ll b){ if(b==0) return 1; ll s=power(a,b/2); s*=s;if(b&1) return s*a; return s;}
ll powermod(ll a,ll b,ll m){ if(b==0) return 1; ll s=power(a,b/2);s*=s; s%=m; if(b&1) return (s*a)%m; return s;}
inline int add(ll a,ll b,ll m=0){
    if(m==0) return a+b;
    return (a%m+b%m)%m;
}

inline int sub(ll a,ll b ,ll m=0){
    if(m==0) return a-b;
    return ((a%m-b%m)%m+m)%m;
}

inline int mul(ll a,ll b,ll m=0){
    if(m==0)return (a*b);
    return ((a%m)*(b%m))%m;
}

inline int div(ll a,ll b,ll m=0){
    if(m==0) return a/b;
    return ((a%m)*(powermod(a,b,m-2)%m))%m;
}

bool isopen(char c){
    return ((c=='(')||(c=='{')||(c=='['));
}

ll longest_balanced_parenthesis(string a,ll n){
    stack<char> s;
    ll start=0;
    ll ans=0,m=0;
    for(ll i=0;i<n;i++){
        if(isopen(a[i])){
            s.push(a[i]);
        }
        else{
            if(isopen(a[i])|| s.empty()){
                m=max(m,ans);
                continue;
            }
            else{
                s.pop();
                ans+=2;
                m=max(ans,m);
            }
        }
    }

    return m;

}

ll setup_k(ll *a,ll k){
  ordered_set x;
  // Now , insert and then check number of integers less than k by just using x.order_of_key(k+1)
}

bool isupperCase(char c){
    return (c>=65 && c<=90);
}

int main() {

    IO; 

    string s;
    string ans;
    ans.clear();
    cin>>s;
    while(s!="Contest"){
        ans.push_back(s[0]);
        cin>>s;
    }
    ans.push_back('C');

    cout<<ans<<endl;
    

}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

string s;
int n;

const int MAX = 2e5+10;

int memo[MAX][2][2];

int solve(int i, bool p = false, bool d = false){
	if (i == n) return 0;
	int &ans = memo[i][p][d];
	if (ans != -1) return ans;
	ans = 0;
	if (s[i] == '?'){
		ans = max(
			1 + p + solve(i+1, false, true),
			solve(i+1, true, false)
		);
	}
	else if (s[i] == 'D')
		ans = 1 + p + solve(i+1, false, true);
	else if (s[i] == 'P')
		ans = solve(i+1, true, false);
	return ans;
}

int main(){ _
	cin >> s;
	n = s.size();
	memset(memo, -1, sizeof memo);
	solve(0);
	int i = 0;
	bool p = false, d = false;
	while (i < n){
		if (s[i] == '?'){
			if (1 + p + solve(i+1, false, true) > solve(i+1, true, false))
				s[i] = 'D';
			else
				s[i] = 'P';
		}

		if (s[i] == 'D'){
			i++;
			p = false;
			d = true;
		}
		else if (s[i] == 'P'){
			i++;
			p = true;
			d = false;
		}
	}
	cout << s << endl;

	exit(0);
}


Measured memory_bytes: 16272
# dp[i]:  minimum possible total cost to reach Stone i.
# dp[1] = 0
# dp[2] = |h[2]-h[1]|
# dp[i+2] = min{ dp[i] + |h[i]-h[i+2]|,  dp[i+1] + |h[i+1]-h[i+2]| }
# dp[0] = INF, h[0] = INF

INF = 10**9

N, K = map(int, input().split())
h = [INF] + list(map(int, input().split()))

dp = [INF]*(N+1)
dp[1] = 0

for i in range(1, N+1):
    for j in range(1, K+1):
        if i+j > N:
            break

        tmp = dp[i] + abs(h[i] - h[i+j])

        if tmp < dp[i+j]:
            dp[i+j] = tmp

print(dp[N])


Measured memory_bytes: 52512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

//priority_queue<ll, vector<ll>, greater<ll>> gpq;

ll nck(ll n, ll k){
    ll ans = 1;
    FOR(i, 1, k+1){
        ans *= n--;
        ans /= i;
    }
    return ans;
}

int main(){
    ll N, A, B; cin >> N >> A >> B;
    vl v(N); REP(i, N) cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());
    
    double ans_avg = 0.0; ll ans_sum = 0;
    ll ans_cnt = 0;
    FOR(i, A, B+1){
        ll sum = 0;
        REP(j, i) sum += v[j];
        double avg = (1.0 * sum) / i;
        if(i == A){
            ans_avg = avg; ans_sum = sum;
        }
        else if( i*ans_sum > A*sum){
            break;
        }
        
        // cnt
        ll mx = v[0], mn = v[i-1];
        if(mx == mn){
            ll cnt = 0;
            REP(k, N) if(v[k] == mx) cnt++;
            ans_cnt += nck(cnt, i);
        }
        else{
            ll cnt = 0; ll idx = LINF;
            REP(k, N){
                if(v[k] == mn){
                    cnt++; idx = min(idx, k);
                }
            }
            ans_cnt += nck(cnt, i-1-idx+1);
        }
    }
    cout << fixed << setprecision(20) << ans_avg << endl;
    cout << ans_cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500000
int A[MAX];
int B[MAX]; 
int n;
void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
 
  if(l<=n && A[l] > A[i])largest = l;
  else largest = i;
  if(r<=n && A[r]>A[largest])largest = r;

  if(largest != i){
    B[i]=A[i];
    A[i]=A[largest];
    A[largest]=B[i];
    
    maxHeapify(largest);
  }}

int main(){
  int i;
  scanf("%d", &n);
  
  for(i=1;i<n+1;i++){scanf("%d", &A[i]);}
  for(i=n/2;i>=1;i--){maxHeapify(i);}

  for(i=1;i<n+1;i++){if(i!=n)printf(" %d", A[i]);
    else printf(" %d\n", A[i]);}
  
  return 0;
}



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

const long int mod=1e9+7;
long modpow(long x, long n){
    long res=1;
    for(; n>0; n>>=1) {
        if (n&1) res=res*x%mod;
        x=x*x%mod;
    }
    return res;
}
long nCr(long n, long r){
    long res=1;
    for(long int i=0; i<r; ++i) res=res*(n-i)%mod;
    for(long int i=1; i<=r; ++i) res=res*modpow(i, mod-2)%mod;
    return res;
}
int main(){
    long int X,Y;
    cin >> X >> Y;
    if((X+Y)%3!=0)cout << 0 << endl;
    else{
        long int dev = 3;
        long int num = (X+Y)/dev;
        long int x = X-num;
        long int y = Y-num;
        if(x<0 || y<0)cout << 0 << endl;
        else{cout << nCr(num,x)<<endl;}
    }
}

Measured memory_bytes: 256
/* kadai3_2
   Saikyo_Kazune
*/
#include <stdio.h>
#include <string.h>



int main(void){
   //int型　Nを宣言
   int N;
   scanf("%d",&N);
   //1の位の数で場合分け
   switch(N%10){
       case 2:case 4:case 5:case 7: case 9:printf("hon\n");break;
       case 0:case 1:case 6:case 8:printf("pon\n");break;
       case 3:printf("bon\n");break;
   }
    return 0;
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define OK -1
#define NO -2
#define USED -3
 
 
 
int main () {
 
	lli n,m,k=0;
	lli *d,*t;
 
	cin >> n;
	d = new lli[n];
	for(lli i=0;i<n;i++){
		cin >> d[i];
	}
 
	sort(d, d+n);
 
	cin >> m;
	t = new lli[m];
	for(lli i=0;i<m;i++){
		cin >> t[i];
	}
	sort(t, t+m);
 
 
	for(lli i=0;i<m;i++){
		for(lli j=k;j<n;j++){
			if(t[i]==d[j]){
				t[i] = OK;
				d[j] = USED;
				k=j+1;
				break;
			}else if(t[i]<d[j]){
				break;
			}
		}
		if(t[i]!=OK){
			cout << "NO" << endl;
			return 0;
		}
	}
 
	cout << "YES" << endl;
 
	
 
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i)
void fastscan(int &x)
 {
        bool neg=false;
        register int c;
        x =0;
        c=getchar();
        if(c=='-')
        {
            neg = true;
            c=getchar();
        }
        for(;(c>47 && c<58);c=getchar())
            x = (x<<1) + (x<<3) +c -48;
        if(neg)
            x *=-1;
    } 
string alpha = "abcdefghijklmnopqrstuvwxyz";
const int mod = 1e9+7;
const int inf = 2e18+5;
const int nax = 100010;
const int mod1 = 998244353;
   

signed main()
 {

   int h,w;
   cin>>h>>w;
   char a[h][w];
   int dp[h+1][w+1];
   loop(i,0,h+1)
    dp[i][0] = -1;
   loop(i,0,w+1)
    dp[0][i] = -1; 
   loop(i,0,h)
    {
      loop(j,0,w)
        {
          dp[i+1][j+1] = 0;
          cin>>a[i][j];
          if(a[i][j] == '#')
             dp[i+1][j+1] = -1;
        } 
    }
    dp[1][1] = 1;
    loop(i,1,h+1)
     {
      loop(j,1,w+1)
       {
        if(i==1 && j==1)
           continue;
        if(dp[i][j]>-1)
           {
             if(dp[i-1][j] >0 && dp[i][j-1]>0)
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod ;
             else 
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]); 
           }
       }
     }
     loop(i,1,h+1)
     {
      loop(j,1,w+1)
       cerr<<dp[i][j]<<" ";
      cerr<<END; 
     }
    if(dp[h][w] == -1)
       cout<<0<<END;
     else
      cout<<(dp[h][w])%mod;
return 0;
}

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

int main()
{cin.tie(0);
cin.sync_with_stdio(0);
int a,b,c,d;
cin>>a>>b>>c>>d;
while (true){
    c-=b;
if(c<=0){
    cout<<"Yes";
    return 0;}
    a-=d;
    if(a<=0){
    cout<<"No";
    return 0;}}}


Measured memory_bytes: 3608
#include<iostream>

using namespace std;
int main()
{
     int a,b;
     while(cin>>a>>b)
     {
         if(a==0 && b==0)
            break;
         else if(a>b)
            cout<<b<<" "<<a<<endl;
         else
            cout<<a<<" "<<b<<endl;
     }
     return 0;
}


Measured memory_bytes: 3072
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;
ll mn[maxn];
ll arr[maxn];
vector<ll>v;
int main(){
	migmig;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	int cnt=0;
	int ans=-1;
	v.pb(0);
	for(int i = 1; i <= n ; i ++	){
		if(i==n){
		ans=max(ans,cnt);
		}else{
		if(arr[v.back()] < arr[i]){
    	ans=max(ans,cnt);
	  	cnt=0;
	  }else{
	  	cnt++;
	  }	
		}
    v.push_back(i);
  }
  cout<<ans;
	return 0;
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
struct dice {
    int v[6];
    void mov(const char c) {
        int buf;
        switch (c) {
            case 'N':
                buf = v[0];
                v[0] = v[1];
                v[1] = v[5];
                v[5] = v[4];
                v[4] = buf;
                break;
            case 'E': {
                buf = v[0];
                v[0] = v[3];
                v[3] = v[5];
                v[5] = v[2];
                v[2] = buf;
                break;
            }
            case 'W': {
                buf = v[0];
                v[0] = v[2];
                v[2] = v[5];
                v[5] = v[3];
                v[3] = buf;
                break;
            }
            case 'S': {
                buf = v[0];
                v[0] = v[4];
                v[4] = v[5];
                v[5] = v[1];
                v[1] = buf;
                break;
            }
            case 'R': {
                buf = v[1];
                v[1] = v[2];
                v[2] = v[4];
                v[4] = v[3];
                v[3] = buf;
            }
        }
    }
    int top() { return v[0]; }
    int right() { return v[2]; }
    int left() { return v[3]; }
    int front() { return v[1]; }
    bool compare(dice a) {
        for (int i = 0; i < 6; i++) {
            if (v[i] != a.v[i]) {
                return false;
            }
        }
        return true;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    dice d1, d2;
    for (int i = 0; i < 6; i++) {
        cin >> d1.v[i];
    }
    for (int i = 0; i < 6; i++) {
        cin >> d2.v[i];
    }
    for (int i = 0; i < 4; i++) {
        d1.mov('E');
        for (int j = 0; j < 4; j++) {
            d1.mov('N');
            if (d1.compare(d2)) {
                puts("Yes");
                return 0;
            }
        }
    }
    d1.mov('R');
    for (int i = 0; i < 4; i++) {
        d1.mov('E');
        for (int j = 0; j < 4; j++) {
            d1.mov('N');
            if (d1.compare(d2)) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 3092
using System;

class Program
{
    static void Main(string[] args)
    {
        char[] s = Console.ReadLine().ToCharArray();
        int count = 0;
        int max = 0;
        for(int i = 0; i < s.Length ; i++)
        {
            if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
                count++;
            else
            {
                if (count > max)
                    max = count;
                count = 0;
            }
        }

        if (count > max)
            max = count;
        Console.WriteLine(max);

    }


}

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

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  
  vector<long long> b2(m);
  b2[0] = b[0];
  for(int i = 1; i < m; ++i) 
    b2[i] = b2[i - 1] + b[i];
  
  int sum = 0, ans = 0;
  for(int i = 0; i <= n; ++i) {
    if (k - sum < 0) break;
    int count = upper_bound(
      b2.begin(),
      b2.end(),
      int(k - sum)
    ) - b2.begin();
    ans = max(ans, i + count);
    
    if (i < n)
      sum += a[i];
  }
  cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
    cout << 3 << endl;
  } else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
    cout << 2 << endl;
  } else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3620
class in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const my_iterator& begin(){return i;}const my_iterator& end(){return n;}};

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

using i64 = long long;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n, a, b; string s;
    cin >> n >> a >> b >> s;
    int nai = 0, gai = 0;
    for(char c : s) {
        if(c == 'a') {
            if(nai + gai < a + b) {
                cout << "Yes" << '\n';
                ++nai;
            }
            else
              cout << "No" << '\n';
        }
        else if(c == 'b') {
            if(nai + gai < a + b && gai < b) {
              cout << "Yes" << '\n';
                ++gai;
            }
            else
              cout << "No" << '\n';
        }
        else
          cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 976
A,B,C,X,Y = map(int,input().split())
if(A+B<2*C):
    print(A*X+B*Y)
else:
    X,Y,temp = X - min(X,Y),Y - min(X,Y),(C*2)*min(X,Y)
    if(C*2 <= A and C*2 <= B):
        print(temp+2*C*X+2*C*Y)
    elif(C*2 <= A and C*2 > B):
        if(Y == 0):
            print(temp+C*2*X)
        else:
            print(temp+B*Y)
    elif(C*2 > A and C*2 <= B):
        if(Y == 0):
            print(temp+A*X)
        else:
            print(temp+C*2*Y)
    else:
        print(temp+A*X+Y*B)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string N;
    cin >> N;
    if(N[0]=='9'||N[1]=='9')prt("Yes")
    else prt("No")
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int MAXN = 100000;

struct edge{
	int to; bool tag;
	edge *nxt, *rev;
}edges[2*MAXN + 5], *adj[MAXN + 5], *ecnt = edges;
void addedge(int u, int v) {
	edge *p = (++ecnt), *q = (++ecnt);
	p->to = v, p->nxt = adj[u], adj[u] = p;
	q->to = u, q->nxt = adj[v], adj[v] = q;
	p->rev = q, q->rev = p;
}

int arr[MAXN + 5], cnt;
void dfs(int x) {
	for(;adj[x];) {
		edge *p = adj[x]; adj[x] = adj[x]->nxt;
		if( p->tag ) continue;
		p->rev->tag = true, dfs(p->to);
	}
	arr[++cnt] = x;
}

int nxt[MAXN + 5];

int deg[MAXN + 5];

int main() {
	int N, M; scanf("%d%d", &N, &M);
	for(int i=1;i<=M;i++) {
		int a, b; scanf("%d%d", &a, &b);
		addedge(a, b), deg[a]++, deg[b]++;
	}
	
	for(int i=1;i<=N;i++)
		if( deg[i] & 1 ) {
			puts("No");
			return 0;
		}
	for(int i=1;i<=N;i++)
		if( deg[i] >= 6 ) {
			puts("Yes");
			return 0;
		}
		
	dfs(1);
//	for(int i=1;i<=cnt;i++) printf("%d ", arr[i]);
	int mx = 1, mn = cnt;
	for(int i=cnt;i>=1;i--) {
		if( deg[arr[i]] == 4 ) {
			if( nxt[arr[i]] ) mx = max(mx, i);
			else mn = min(mn, nxt[arr[i]] = i);
		}
	}
	
	if( mn < mx ) puts("Yes");
	else {
		int p = 1;
		for(int i=1;i<=cnt;i++)
			if( nxt[arr[i]] && nxt[arr[i]] != i ) {
				if( nxt[arr[i]] < p ) {
					puts("Yes");
					return 0;
				}
				else p = nxt[arr[i]];
			}
		puts("No");
	}
}

Measured memory_bytes: 9600
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int A, B;

  std::cin >> A >> B;

  for (int i = 0; i < 11111; i ++) {
    int a = i * 0.08, b = i * 0.1;

    if (a == A && b == B) {
      std::cout << i << std::endl;

      return 0;
    }
  }

  std::cout << -1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n,k,a=1;
 cin>>n >>k;
 for(int i=1;i<=n;i++){
 
 		 if(a+k<a*2) a+=k;
		  else a =a*2;	
}
	
cout<< a<<endl;	
	
	
	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;
int _w;

int dat[N] , n , cur;
map<int,int> f[2];

void upd( map<int,int> & mp , int x , int y ) {
  if( mp.count( y ) ) mp[y] = min( mp[y] , x );
  else mp[y] = x;
}

int main( void ) {
  _w = scanf("%d",&n);
  for( int i = 1 ; i <= n ; ++i ) _w = scanf("%d",dat+i);
  f[0][0] = dat[1] , f[0][1] = 0 , cur = 0;
  for( int i = 2 ; i <= n ; ++i ) {
    f[cur ^= 1].clear();
    int a = 0 , b = dat[i] - dat[i - 1];
    if( a > b ) swap( a , b );
    for( auto v : f[cur ^ 1] ) 
      if( v.first < (*f[cur ^ 1].begin()).first + 2 ) {
        if( v.second + a > 0 ) upd( f[cur] , 0 , v.first + 2 );
        if( v.second + a <= dat[i] ) upd( f[cur] , max( 0 , v.second + a ) , v.first + 1 );
        if( v.second + b <= dat[i] ) upd( f[cur] , v.second + b , v.first );
      }
  }
  int ans = n;
  for( auto v : f[cur] )
    ans = min( ans , v.first + ( v.second > 0 ) );
  cout << ans;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define N_MAX 100

typedef struct _v {
    int k;
    int *v;
    int f;
    int l;
} Vertex;
Vertex Adj[N_MAX];

int t = 0;

void depth_search(int i) {
//    printf(" i %d\n", t);
    if (Adj[i].f == 0) {
        Adj[i].f = t;
//        printf("  Adj[%d] : k = %d f = %d\n", i, Adj[i].k, t);
    }
    else {
        t--;
        return;
    }

    for (int j = 0; j < Adj[i].k; j++) {
        t++;
//        printf("t:%d\n", t);
        depth_search(Adj[i].v[j]);
    }
    t++;
//    printf("t:%d\n", t);
    Adj[i].l = t;
//    printf(" Adj[%d].l = %d\n", i, Adj[i].l);
    return;
}

int main() {
    int n;

    cin >> n;

    for (int i = 0; i < n; i++) {
        int k;
        cin >> k >> k;
        Adj[i].k = k;
        Adj[i].v = new int[k];
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            Adj[i].v[j] = v - 1;
        }
        Adj[i].f = 0;
        Adj[i].l = 0;
    }

    for (int i = 0; i < n; i++) {
        t++;
        depth_search(i);
        cout << i + 1 << " " << Adj[i].f << " " << Adj[i].l << endl;
    }

    return 0;
}



Measured memory_bytes: 3108
n,m = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(m)]
ab = sorted(ab, key=lambda x:x[1])

min_island = -float('inf')
ans = 0
for i in ab:
    if min_island <= i[0]:
        ans += 1
        min_island = i[1]
print(ans)

Measured memory_bytes: 29848