akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        b: [usize; n-1],
    }

    let mut ans = vec![0; n];
    ans[0] = b[0];
    ans[n - 1] = b[n - 2];

    for i in 0..n - 2 {
        ans[i + 1] = min(b[i], b[i + 1]);
    }

    println!("{}", ans.iter().sum::<usize>());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
bool ok[3][3][7001];
string S[3];
int ans = 1e9;

int main() {
    for(int i = 0; i < 3; i++) cin >> S[i];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k <= 7000; k++) {
                ok[i][j][k] = true;
                for(int l = k; l < S[i].size(); l++) {
                    int m = l - k;
                    if(m >= S[j].size()) continue;
                    if(S[i][l] != '?' and S[j][m] != '?' and S[i][l] != S[j][m]) ok[i][j][k] = false;
                    //if(i == 0 and j == 2 and k == 3) cerr << m << " " << ok[i][j][k] << endl;
                }
            }
        }
    }
    vector<int> v;
    for(int i = 0; i < 3; i++) {
        v.push_back(i);
    }
    /*
    for(int i = 0; i <= 10; i++) {
        cerr << ok[0][2][i] << " ";
    }
    cerr << endl;
    */
    do {
        for(int i = 0; i <= 4001; i++) {
            for(int j = i; j <= 4001; j++) {
                if(ok[v[0]][v[1]][i] and ok[v[0]][v[2]][j] and ok[v[1]][v[2]][j-i]) {
                    int now = S[v[0]].size();
                    chmax(now, i + (int)S[v[1]].size());
                    chmax(now, j + (int)S[v[2]].size());
                    if(chmin(ans, now)) {
                    //cerr << v[0] << " " << v[1] << " " << v[2] << " " << i << " " << j << " " << now << endl;
                    }
                }
            }
        }
    } while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace _0015
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                char[] c1 = Console.ReadLine().ToCharArray();
                Array.Reverse(c1);
                string s1 = new string(c1);
                char[] c2 = Console.ReadLine().ToCharArray();
                Array.Reverse(c2);
                string s2 = new string(c2);
                if (s1.Length > s2.Length)
                {
                    string s = s1;
                    s1 = s2;
                    s2 = s;
                }
                string ret = "";
                int kuriagari = 0;
                int j;
                for (j = 0; j < s1.Length; j++)
                {
                    ret += (int.Parse(s1[j].ToString()) + int.Parse(s2[j].ToString()) + kuriagari) % 10;
                    kuriagari = int.Parse(s1[j].ToString()) + int.Parse(s2[j].ToString()) + kuriagari >= 10 ? 1 : 0;
                }
                for (; j < s2.Length; j++)
                {
                    ret += (int.Parse(s2[j].ToString()) + kuriagari) % 10;
                    kuriagari = int.Parse(s2[j].ToString()) + kuriagari >= 10 ? 1 : 0;
                }
                if (kuriagari == 1) ret += "1";
                char[] c3 = ret.ToCharArray();
                Array.Reverse(c3);
                string s3 = new string(c3);
                Console.WriteLine(s3.Length > 80 ? "overflow" : s3);
            }
        }
    }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int N, C;
  cin >> N >> C;

  int D[C][C];
  rep (i, C) rep (j, C) cin >> D[i][j];

  int c[N][N];
  rep (i, N) rep (j, N) cin >> c[i][j];

  int sum[3][C];
  memset(sum, 0, sizeof(sum));
  rep (i, N) rep (j, N) rep (k, C) {
    int idx = (i + 1 + j + 1) % 3;
    sum[idx][k] += D[c[i][j] - 1][k];
  }

  int ans = INF;
  REP (i, 0, C) REP (j, i + 1, C) REP (k, j + 1, C) {
    rep (p, 3) rep (q, 3) rep (r, 3) if (p != q && q != r && r != p) {
      ans = min(ans, sum[p][i] + sum[q][j] + sum[r][k]);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj,n,m;
ll a,b,c,d,e,g,h,r,num,sum,ans;
ll x[500005],y[500005],z[500005];
bool dame;

int main(){
    cin >> n >> m;
    for(i=0;i<n;i++){
        cin >> x[i];
    }
    for(i=1;i<n;i++){
        a = x[i] - x[i-1];
        if(a < 0)a += m;
        sum += a;
        G[x[i]].pb(a - 1);
        b = x[i] - (a - 2);
        if(b <= 0)b += m;
        y[b]++;
    }
    //1番のをお気に入りにした時のを求める
    num = 0;
    for(i=1;i<n;i++){
        a = x[i] - x[i-1];
        if(a < 0)a += m;
        b = x[i];
        if(b < 0)b += m;
        num += min(a,b);
        if(b < a)c++;
    }
    z[1] = num;
    a = c;
    for(i=2;i<=m;i++){
        num = z[i-1];
        for(k=0;k<G[i-1].size();k++){
            num += G[i-1][k];
            a--;
        }
        //assert(a >= 0);
        a += y[i];
        z[i] = num - a;
    }
    ans = INF;
    for(i=1;i<=m;i++){
        ans = min(ans,z[i]);
       // pe(i);p(y[i]);
    }
    p(ans);
    
    return 0;
}



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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define req(i,f,N) for(int i = f; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

template<class T, class Q> inline bool chmin(T& a, Q b) {
    if (a > b) { 
        a = b;
        return true; 
    }
    return false;
}

template<class T, class Q> inline bool chmax(T& a, Q b) {
    if (a < b) { 
        a = b; 
        return true; 
    }
    return false;
}

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W * H / 2;
    bool flag = false;

    if ((x && y) && (x != W && y != H)) {
        if (H / W == y / x) flag = true;
        if (H - H * x / W == y) flag = true;
    }
    
    cout << " " << (flag ? 1 : 0) << endl;

}

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

int main() {
string hitachi;
cin >> hitachi;

bool ans = true;
for (int i = 0; i < hitachi.size();i++) {
  if (i % 2 == 0 && hitachi.at(i) !='h' || i % 2 == 1 && hitachi.at(i) != 'i') {
  ans = false;
    break;
  } 
  
}

if (hitachi.at(hitachi.size() -1) == 'h') {
    ans = false;
} 

if (ans == 1)  {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
}


Measured memory_bytes: 256
class common_function():
    """
        1. よく使いそうで予め用意してあるものをまとめた
        2. よく使いそうな関数群をまとめた
    """
    def make_divisors(self, n:int):
        """
            試し割り法による約数の列挙を行うメソッド
            ある値 n の約数の列挙を行うのに O(n^(1/2)) かかる.
            e.g.
                input: 96
                output: [1, 96, 2, 48, 3, 32, 4, 24, 6, 16, 8, 12]
        """
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        return divisors

def main():
    common = common_function()
    N = int(input())
    m = common.make_divisors(N)
    ans = 0
    for i in m:
        if i == 1:
            continue
        ans += (N%(i-1) == N//(i-1)) * (i-1)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9356
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll N; cin>>N;
    ll array[2*N];
    for(int i=0; i<2*N; ++i) cin>>array[i];
    sort(array, array+2*N);
    ll sum = 0;
    for(int i=0; i<2*N; i+=2) sum = sum + array[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <climits>
#include<vector>
#include<cstring>
#define mod 1000000007
using namespace std;

long long int Paths(char arr[][1001], int r, int c){
	long long int dp[r+1][c+1];
	for(int i = 0; i <= r; i++){
		for(int j = 0; j <= c; j++){
			if(i == 0 || j == 0 || arr[i][j] == '#'){
				dp[i][j] = 0;
			}else if(i == 1 && j == 1){
				dp[i][j] = 1;
			}else{
				dp[i][j] = ((dp[i-1][j] % mod) + (dp[i][j-1]%mod) )% mod;
			}
		}
	}

	return dp[r][c];
}



int main(){

	int r, c;
	cin>>r>>c;
	char arr[1001][1001];
	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			cin>>arr[i][j];
		}
	}
	
	cout<<Paths(arr, r, c);

}

Measured memory_bytes: 11864
#include <stdio.h>
int main()
{
int a, b, c;
while (1)
{
scanf("%d", &a);
scanf("%d", &b);
if (a == 0&&b == 0)
break;
else if (a > b){
c = a;
a = b;
b = c;
}
printf("%d %d\n", a, b);
}
return 0;
}

Measured memory_bytes: 2696
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

template <class Weight>
struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

template <class Weight>
bool operator<(const Edge<Weight> &e, const Edge<Weight> &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? (e.src < f.src) : (e.dst < f.dst);
    }
};

template <class Weight>
using Edges=vector<Edge<Weight>>;
template <class Weight>
using Vertex=vector<Edge<Weight>>;
template <class Weight>
using Graph=vector<Vertex<Weight>>;

template <class Weight>
void join(Graph<Weight> &g, size_t s, size_t d, Weight w=1) {
    g[s].push_back(Edge<Weight>(s, d, w));
    g[d].push_back(Edge<Weight>(d, s, w));
}

template <class Weight>
void connect(Graph<Weight> &g, size_t s, size_t d, Weight w=1) {
    g[s].push_back(Edge<Weight>(s, d, w));
}

template <class Weight>
vector<Weight> shortest_distance(const Graph<Weight> &g, size_t s) {
    /* Dijkstra */
    size_t V=g.size();
    vector<Weight> d(V, INF); d[s]=0;

    lp_queue<pair<Weight, size_t>> q; q.push(make_pair(0, s));
    while (!q.empty()) {
        pair<Weight, size_t> p=q.top(); q.pop();
        size_t v=p.second;
        if (d[v] < p.first) continue;

        for (const Edge<Weight> &e: g[v])
            if (d[e.dst] > d[v] + e.weight) {
                d[e.dst] = d[v] + e.weight;
                q.push(make_pair(d[e.dst], e.dst));
            }
    }
    return d;
}


int main() {
    size_t V, E, r;
    scanf("%zu %zu %zu", &V, &E, &r);

    Graph<Weight> g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight d;
        scanf("%zu %zu %lld", &s, &t, &d);

        connect(g, s, t, d);
    }

    vector<Weight> d=shortest_distance(g, r);
    for (size_t i=0; i<V; ++i)
        if (d[i] < INF) {
            printf("%lld\n", d[i]);
        } else {
            printf("INF\n");
        }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF 1000000000
#define int ll
#define PI (acos(-1))
//const ll mod = 1000000007;

int n, m, p;
int a, b, c;

struct edge {
    int from, to, cost;
};

vector<edge> edges; // 辺
vector<int> d(2510);  // 最短距離[頂点の最大数]
int V, E;       // V:頂点数，E:辺数

void shortest_path(int start) {
    // 初期化
    fill(d.begin(), d.end(), INF);
    d[start] = 0;

    int count_updates = 0;

    // BellmanFord
    for (int i = 0; i < V - 1; i++) {
        for (auto &e:edges) {
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) d[e.to] = d[e.from] + e.cost;
        }
    }

    // 負の経路の発見
    for (auto &e:edges) {
        if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) d[e.to] = -INF;
    }

    // 負の経路の伝搬
    for (int i = 0; i < V - 1; i++) {
        for (auto &e:edges) {
            if (d[e.from] == -INF) d[e.to] = -INF;
        }
    }
}

signed main() {
    cin >> n >> m >> p;
    for (int i = 0; i < m; i++) {
        cin >> a >> b >> c;
        edges.emplace_back(edge{a, b, p - c});
    }

    V = n;
    E = m;
    shortest_path(1);

    if (d[n] == -INF) cout << -1 << endl;
    else cout << max(-d[n], 0LL) << endl;

}
// グラフ
// コスト最大化(ベルマンフォード)

Measured memory_bytes: 576
import numpy as np
n = int(input())
a = list(map(int, input().split()))
n = len(a)
Mean1 = np.floor(sum(a) / n)
Mean2 = np.ceil(sum(a) / n)
sum1 = sum([(x-Mean1)**2 for x in a])
sum2 = sum([(x-Mean2)**2 for x in a])
print(int(min(sum1, sum2)))


Measured memory_bytes: 12436
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long f = 0;
		//
		if ( n % 2 == 1 ) {
			System.out.println(0);
		} else {
			for ( long m = 10; m <= n; m = m * 5 ) {
				f = f + ( n / m ) ;
			}
			System.out.println(f);
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
using namespace std;
const int INF=LLONG_MAX-1e10;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;
deque<int> have;
main()
{
    IOS
    cin>>n>>m;
    int mm=m;
    fun(i){
        cin>>a[i];
    }
    int now=a[1],num=0;
    have.pb(1);
    b[1]=1;
    while(m--)
    {
        if(b[now])break;
        b[now]++;
        have.pb(now);
        now=a[now];
    }

    if(m==-1) {
        out(have.back())
        return 0;
    }
    while(!have.empty())
        if(have.front()==now){
            break;
        }else{
            num++;
            have.ppf();
        }
    int len=have.size();
    mm-=num;
    out(have[mm%len])
    return 0;
}

Measured memory_bytes: 7688
# include <bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,n;
	cin>>a>>b>>n;
	for (int i=1;i<=n;++i)
	  {
	  	if (i%2!=0)
	  	  {
	  	    if (a%2==0)
			  {
			    a=a/2;
			   	b=b+a;
			  }	
			else
			  {
			  	a=(a-1)/2;
			  	b=b+a;
			  }
		  }
		else
		 {
		 	if (b%2==0)
		 	  {
		 	    b=b/2;
				a=a+b;	
			  }
			else
			  {
			  	b=(b-1)/2;
			  	a=a+b;
			  }
		 }
	  }
	printf ("%d %d\n",a,b);
	return 0;
}

Measured memory_bytes: 256
import sys
 
mod=10**9+7
N=input()
X=map(int, sys.stdin.readline().split())
L=map(lambda x: pow(x,mod-2,mod), range(1,N))
 
L_RUISEKI=[]
 
for i,x in enumerate(L):
    if i==0: L_RUISEKI.append(x)
    else: L_RUISEKI.append(L_RUISEKI[-1]+x)
 
ans=0
for i in range(N-1):
    value=X[i+1]-X[i]
    ans+=value*L_RUISEKI[i]
 
 
fact=[1]
fact_tmp = 1
for i in range(1, N+1):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)
 
print ans*fact[N-1]%mod

Measured memory_bytes: 53212
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

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

  VL hs = VL(N);

  REP(i, 0, N){
    cin >> hs[i];
  }

  ll ub = LIM_INF, lb = 0;
  while(ub - lb > 1){
    VL cs = VL(hs);
    ll mid = (ub + lb) / 2;

    ll rem = 0;
    REP(i, 0, N){
      cs[i] -= mid * B;
      if(cs[i] > 0){
        rem += ceil((double)cs[i] / (A - B));
      }
    }
    if(rem <= mid){
      ub = mid;
    } else {
      lb = mid;
    }
  }

  cout << ub << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%lf",&n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%lf ",n)
#define dprin(n) printf("%lf\n",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

ll bs(ll a[],ll b[],ll i,ll n)
{
      ll low=i+1,high=n-1;
      
}

int main()
{
     int l,r,d;
     scf(l);scf(r);scf(d);
     int ans=0;
     rep(i,l,r+1)
     if(i%d==0&&i>=d)
     ans++;
     cout<<ans;
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    double ans = 0;
    REP (i, 0, N) {
        double C;
        string str;
        cin >> C >> str;
        if (str == "JPY") {
            ans += C;
        } else {
            ans += C * 380000;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int n, a;
int x[51];

int main() {
    scanf("%d %d", &n, &a);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", x + i);
    }

    int X = a;
    for (int i = 1; i <= n; ++i) {
        if (X < x[i]) X = x[i];
    }

    long long int dp[51][5000];//dp[j][t]はx1からxjから0枚以上選んで合計をt-NXにする選び方の総数
    int y[51];
    for (int i = 1; i <= n; ++i) {
        y[i] = x[i] - a;
    }

    for (int j = 0; j <= n; ++j) {
        for (int t = 0; t <= 2 * n * X; ++t) {
            if (j == 0 && t == n * X) {
                dp[j][t] = 1;
            } else if (j >= 1 && (2 * n * X < t - y[j] || t - y[j] < 0)) {
                dp[j][t] = dp[j - 1][t];
            } else if (j >= 1 && 0 <= t - y[j] && t - y[j] <= 2 * n * X) {
                dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y[j]];
            } else {
                dp[j][t] = 0;
            }
        }
    }

    printf("%lld\n", dp[n][n * X] - 1);

    return 0;
}


Measured memory_bytes: 2176
def resolve():
    N = int(input())
    H = list(map(int,input().split()))
    temp = 0
    ans = 0
    for i in range(N-1):
        if H[i] - H[i+1] >= 0:
            temp += 1
        else:
            if ans < temp:
                ans = temp
            temp = 0
        if i == N-2:
            if ans < temp:
                ans = temp
    print(ans)
resolve()

Measured memory_bytes: 63856
#include <bits/stdc++.h>
#if defined(__GNUC__)
#pragma GCC optimize ("Ofast")
#endif
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 924844033;
const int MAXN = 2010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, ans;
int matching[MAXN][MAXN];
int dp[MAXN*2][MAXN];
int F[MAXN];
int A[MAXN*2];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	matching[0][0]=matching[1][0]=1;
	for (int i=2; i<MAXN; i++){
		matching[i][0]=1;
		for (int j=1; j<MAXN; j++) matching[i][j]=(matching[i-1][j]+matching[i-2][j-1])%mod;
	}
	
	F[0]=1;
	for (int i=1; i<MAXN; i++) F[i]=1ll*F[i-1]*i%mod;
	cin>>n>>k;
	for (int i=0; i<k; i++){
		A[2*i+1]=A[2*i+2]=(n-i+k-1)/k;
	}
	dp[0][0]=1;
	for (int j=0; j<=n; j++){
		for (int i=1; i<=2*k; i++){
			for (int k=0; k<=min(j, A[i]); k++) dp[i][j]=(dp[i][j] + 1ll*dp[i-1][j-k] * matching[A[i]][k])%mod;
		}
	}
	
	for (int i=0; i<=n; i++){
		if (i&1) ans=(ans-1ll*dp[2*k][i]*F[n-i])%mod;
		else ans=(ans+1ll*dp[2*k][i]*F[n-i])%mod;
	}
	cout<<(ans+mod)%mod<<'\n';
	
	return 0;
}

Measured memory_bytes: 50780
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b;
    cin >> a >> b;
    cout << a - b + 1;
}

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

int main() {
	int s, a, b;
	int cntb=0, cntl=0;
	string part;
	cin >> s >> a >> b >> part;
	for (int i = 0; i < s; i++) {
		if (part[i] == 'a') {
			if (cntl < a + b) {
				cntl++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
		else if (part[i] == 'b') {
			if (cntl < a + b && cntb < b) {
				cntl++;
				cntb++;
				cout << "Yes" << endl;
			}
			else cout << "No" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

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

const int D = 86400;
const int M = 10800;

int main() {
        int n;
        scanf("%d", &n);
        int now = 0;
        vector<int> imos(200000);
        for (int i = 0; i < n; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                now += a;
                now %= D;
                imos[now] ++;
                now += b;
        }
        for (int i = 0; i < D; i ++) imos[i + D] = imos[i];
        for (int i = 1; i < 200000; i ++) imos[i] += imos[i - 1];
        int ans = 0;
        for (int i = 0; i < D; i ++) ans = max(ans, imos[i + M + 1] - imos[i]);
        printf("%d\n", ans);
}


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

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define all(x) x.begin(),x.end()

const int INF=INT_MAX;
const ld PI=3.1415926535897932384626433;
const ld E=2.71828183;
const int MOD=1e9+7;

vi bfs(vector<vi>adj,int src){
    //adjacency list, not-weighted, possibly directed ,src is 1-indexed, adj[0].size()=0!!!
    //for n vertices, adj.size()=n+1. (constructed via push_back() ).

    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return dst;
}
vi bfsParents(vector<vi>adj,int src){
    vi parents=vi(adj.size(),INF);
    parents[src]=-1;
    queue<int>q;
    q.push(src);
    vi dst(adj.size(),INF);
    dst[src]=0;
    while(!q.empty()){
        int c=q.front();
        q.pop();
        for(int nbr:adj[c]){
            if(dst[nbr]==INF){
                parents[nbr]=c;
                dst[nbr]=dst[c]+1;
                q.push(nbr);
            }
        }
    }
    return parents;
}
vi shortestPath(vector<vi>adj,int src,int dst){
    vi bfsParetns=bfsParents(adj,src);
    vi ans;
    while(src!=dst){
        if(bfsParetns[src]==INF)
            return {};
        ans.push_back(src);
        src=bfsParetns[src];
    }
    return ans;
}
int powMod(int base,int exp,int mod){
    //(base^exp) %mod
    int ans=1;
    for(int i=0; i<exp; i++)
        ans=((ans%mod)*(base%mod))%mod;
    return ans;
}
vi divisorsOf(int n){
    //vector of divisors of n (inc. 1 , excl.n)
    vi ans;
    for(int i=1; i*i<=n; i++){
        if(n%i==0)
            ans.push_back(i);
        if(i*i!=n && i!=1)
            ans.push_back(n/i);
    }
    return ans;
}
int gcd(int a,int b){
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}

ld log (ld a,ld b){return log(b)/log(a);}
void solve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
  //  cin >> t;
  //  while(t--)
        solve();
    return 0;
}

void solve(){
    int a,b,c;
    cin >> a >>b >> c;
    vi v={a,b,c};
    sort(all(v));
    if((v[0]!=v[2]) && (v[0]==v[1] || v[1]==v[2]))
        cout << "Yes\n";
    else
        cout << "No\n";
}





Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    for (int i = 0; i < K; i++)
    {
        if (i % 2 == 0)
        {
            if (A % 2 == 1)
            {
                A--;
                B += A / 2;
                A /= 2;
            }
            else
            {
                B += A / 2;
                A /= 2;
            }
        }
        else
        {
            if (B % 2 == 1)
            {
                B--;
                A += B / 2;
                B /= 2;
            }
            else
            {
                A += B / 2;
                B /= 2;
            }
        }
    }
    cout << A << " " << B << endl;
    return 0;
}

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

const int maxn=1e5+10;

int s[maxn]={0};
string ss;
bool found;

inline void solve(int left,int right)
{
     int mid=(left+right)/2;
     cout<<mid<<endl;
     cin>>ss;
     if(ss[0]=='V'){
          found=1;
          return;
     }
     s[mid]=(ss[0]=='F')?0:1;//printf("%d:%d\n",mid,s[mid]);

     if(((!((mid-left)%2))&&s[mid]!=s[left])||((mid-left)%2&&s[mid]==s[left])){
          solve(left,mid);
     }
     else{
          solve(mid,right);
     }
}

int main()
{
     int n;
     found=0;
     cin>>n;

     cout<<0<<endl;
     cin>>ss;
     if(ss[0]=='V') return 0;
     s[0]=ss[0]=='F'?0:1;
     cout<<n-1<<endl;
     cin>>ss;
     if(ss[n-1]=='V') return 0;
     s[n-1]=ss[0]=='F'?0:1;
     solve(0,n-1);

     return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    ll H, N; cin >> H >> N;
    vll A(N), B(N); REP(i, N) cin >> A[i] >> B[i];
    vll dp(10001, INF);
    dp[0] = 0;

    REP1(i, 10000)
    {
        REP(j, N)
        {
            if(A[j] >= i)
            {
                dp[i] = min(dp[i], B[j]);
            }
            else if(i >= A[j])
            {
                dp[i] = min(dp[i], dp[i-A[j]] + B[j]);
            }
        } 
    }
    cout << dp[H] << endl;
}
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;


ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

int main() {
    ll X; cin >> X;
    // ll deg = 360;
    // while (deg % X != 0) {
    //     cout << deg << endl;
    //     deg *= 2;
    // }
    // cout << deg << endl;
    // cout << deg / X << endl;
    cout << lcm(X, 360LL) / X << endl;
    return 0;
}

Measured memory_bytes: 3632
s = input().rstrip()
n = len(s)

removed = 0
cnt_s = 0

for i in range(n):
    if s[i] == 'S':
        cnt_s += 1
    elif cnt_s:
        cnt_s -= 1
        removed += 1
#     print(cnt_s,cnt_t)
print(n - removed*2)

Measured memory_bytes: 65868
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 100005;
int a[N];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int n, t;
    cin >> n >> t;
    FOR(i,1,n){
        cin >> a[i];
    }
    int mn = MOD;
    int d = 0, c = 0;
    FOR(i,1,n){
        mn = min(mn, a[i]);
        if(a[i] - mn > d){
            d = a[i] - mn;
            c = 1;
        }
        else if(a[i] - mn == d){
            c++;
        }
    }
    cout << c;

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a , b;
    cin >> a >> b;
    if(a <=5){
        cout << "0"<<endl;
    }
    else if(5<a &&a<13){
        cout<< b/2 <<endl;
    }
    else if(12<a){
        cout <<b << endl;
    }
}

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

using namespace std;

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

    long long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    //2 * C = A + B

    //cout << 2 * c * max(x, y) << '\n' << x * a + b * y << ' ' << 2 * c * x + (y - x) * b << '\n' << 2 * c * y + (x - y) * a << '\n';
    long long answer = 2 * c * max(x, y);

    answer = min(answer, x * a + b * y);

    x <= y? answer = min(answer, 2 * c * x + (y - x) * b) : answer = min(answer, 2 * c * y + (x - y) * a);

    cout << answer << '\n';
}


Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, A, B;
  
  ll gou = A + B;


  return N / gou * A + min(N % gou, (ll)A);
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}




Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

class Main {
    public static void main(String args[]) {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	try {
	    String s[] = new String[2];
	    while ((s[0] = br.readLine())!=null) {
		s[1] = br.readLine();
		StringTokenizer st[] = new StringTokenizer[2];
		st[0] = new StringTokenizer(s[0]);
		st[1] = new StringTokenizer(s[1]);
		int a[] = new int[4];
		int b[] = new int[4];
		for (int i=0;i<4;i++) {
		    a[i] = Integer.parseInt(st[0].nextToken());
		    b[i] = Integer.parseInt(st[1].nextToken());
		}

		int hit = 0;
	        int blow = 0;
		for (int i=0;i<4;i++) {
		    for (int j=0;j<4;j++) {
			if (a[i]==b[j]) {
			    if (i==j) hit++;
			    else blow++;
			}
		    }
		}
		System.out.println(hit+" "+blow);
	    }
	} catch (Exception e) {
	    e.printStackTrace();
	}
    } 
}

Measured memory_bytes: 16872
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    string S;
    cin >> S;
    regex re("^(dream|dreamer|erase|eraser)+");
    if(regex_match(S, re)){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 39888
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, pair<ll, ll> > p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);

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

    ll x = *max_element(A.begin(), A.end());

    ll front = 1LL;
    ll back = x;

    ll mid = (front + back) / 2LL;

    ll ans = x;

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

    while(front < back) {
        ll count = 0LL;
        for(int i = 0; i < N; i++) {
            if(A[i] <= mid) continue;
            ll t = A[i] / mid;
            if(t * mid < A[i]) {
                t++;
            }
            count += t - 1LL;
        }

        if(count <= K) {
            ans = mid;
            back = mid;
        } else {
            front = mid + 1LL;
        }
        mid = (front + back) / 2LL;
    }

    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

LL a[100000],b[100000],c[100000];
int x[100000],y[100000];
int m,na,nb;

int main(){
  cin>>na>>nb>>m;
  REP(i,na)cin>>a[i];
  REP(i,nb)cin>>b[i];
  REP(i,m)cin>>x[i]>>y[i]>>c[i];
  LL mina = 100001,minb=100001;
  REP(i,na)mina=min(mina,a[i]);
  REP(i,nb)minb=min(minb,b[i]);
  LL ret = mina+minb;
  REP(i,m)ret = min(ret,a[x[i]-1]+b[y[i]-1]-c[i]);
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main()
{
long int a,b,i,ans=0;
cin>>a>>b;
for(i=a;i<=b;i++)
if((i%10==i/10000)&&
((i%100-i%10)/10==(i%10000-i%1000)/1000))
ans++;
cout<<ans;
return 0;
}

Measured memory_bytes: 256
/*input
2 5
4 9
2 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<pll> v;
int main()
{
	IOS;
	ll n,m;
	cin>>n>>m;
	REP(i,n){
		ll x,d;
		cin>>x>>d;
		v.pb(MP(x,d));
	}
	sort(ALL(v));
	ll ans=0;
	for(auto i:v){
		ll tmp=min(m,i.S);
		ans+=tmp*i.F;
		m-=tmp;
		if(m==0) break;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,j,n,taro_p=0,hana_p=0;
    char taro[101], hana[101];
    
    scanf("%d", &n);
    
    for(i=0;i<n;i++){
        scanf("%s %s", taro, hana);
        
        for(j=0;;j++){
            if(taro[j] > hana[j]){
                taro_p += 3;
                break;
            }else if(taro[j] < hana[j]){
                hana_p += 3;
                break;
            }else if(taro[j] + hana[j] == 0){
                hana_p++;
                taro_p++;
                break;
            }
        }
    }
    
    printf("%d %d\n", taro_p , hana_p);
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > A(N+1);
  long long Asum=0;
  for (int i=0; i<N+1; i++){
    scanf("%d", &A[i]);
    Asum+=A[i];
  }
  std::vector<long long > V(N+4);
  V[0]=1;
  long long multiple=Asum-1;
  for (int i=1; i<=N; i++){
    long long src=V[i-1]-A[i-1];
    if (src<0){
      printf("-1\n");
      return 0;
    }
    if (multiple>=src){
      V[i]=src*2;
      multiple-=src;
    } else {
      V[i]=multiple*2 + (src-multiple);
      multiple=0;
    }
  }
  if (V[N]!=A[N]){
    printf("-1\n");
    return 0;    
  }
  long long ans = 0;
  for (int i=0; i<=N; i++){
    ans += V[i];
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3940