akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC123C
    {
        static public void Main(string[] args)
        {
            var N = NextLong;
            var param = NextLongArray(5);
            var mini = param.Min();

            Console.WriteLine(N / mini - (N % mini == 0 ? 1 : 0) + 5);
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static int[] NextIntArray(int N)
        {
            var ret = new int[N];
            for (int i = 0; i < N; ++i) ret[i] = NextInt;
            return ret;
        }
        static long NextLong => long.Parse(Console_.NextString());
        static long[] NextLongArray(int N)
        {
            var ret = new long[N];
            for (int i = 0; i < N; ++i) ret[i] = NextLong;
            return ret;
        }
        static string NextString => Console_.NextString();
        static void Rep(int count, Action<int> func)
        {
            for (int i = 0; i < count; ++i) func(i);
        }
        static void Rep(int count, Action func)
        {
            for (int i = 0; i < count; ++i) func();
        }
        static void Foreach<T>(IEnumerable<T> list, Action<T> func)
        {
            foreach (var item in list) func(item);
        }
        static void Foreach<T>(IEnumerable<T> list, Action<T, int> func)
        {
            int idx = -1;
            foreach (var item in list) func(item, ++idx);
        }
        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int a[3],t,u;
    cin>>a[0]>>a[1]>>a[2];
    int r=a[0]+a[1];
    int d=a[0]+a[2];
    int e=a[2]+a[1];
   t= min (r,d);
    u= min (t,e);

    cout<<u<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int GCD(int a,int b){
	while(a!=b){
	if(a>b){
		a=a-b;
	}else if(a<b){
		b=b-a;
	}
	}
	return a;
}

int main(){
	int x,y,gcd;
	cin>>x>>y;
	gcd=GCD(x,y);
	cout<<gcd<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include<vector>
#include<algorithm>
#define lli long long int
// #include <bits/stdc++.h>
using namespace std;
lli fun(lli n,lli c){
	if (n==1){
		return c;
	}
	else{
		c=c+1;
		return fun(n/2,c);
	}
}
int main() {
	// your code goes here
	lli i,n,k,temp,s,c;
	// i=1;
	cin>>n;
	c=1;
	s=0;
	temp = fun(n,c);
	for(lli i =0;i<temp;i++){
		s=s+ (1ll<<i);
		// cout<<(1<<i)<<endl;
	}
	
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x int64
	fmt.Scanf("%d", &x)
	fx := digit_sum(x)

	if x%fx == 0 {
		fmt.Printf("Yes")
	} else {
		fmt.Printf("No")
	}

}

func digit_sum(n int64) int64 {
	if n < 10 {
		return n
	}
	return digit_sum(n/10) + n%10
}


Measured memory_bytes: 1836
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();
        System.out.println(solve(X));
    }

    private static String solve(long X) {
        for (long i=0; i<=1000; i++) {
            for (long j=-2000; j<=2000; j++) {
                long tmp = (long)Math.pow(i, 5) - (long)Math.pow(j, 5);

                if (tmp == X) {
                    return i + " " + j;
                }
            }

        }

        return null;
    }
}

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

using namespace std;

int main() {
	int N,M;
	double A[110] = {},sum = 0;

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

	sort(A, A + N, greater<>());

	if (A[M - 1] >= sum / (4 * M)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

#define ll long long
#define mod 1000000007

using namespace std;



int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    ll n,s=1000,x=0;
    cin>>n;
    ll l1[n+1];
    for(int i=1;i<=n;i++)cin>>l1[i];
    for(int i=1;i<n;i++){
        if(l1[i]<l1[i+1])s=((s/l1[i])*l1[i+1])+(s%l1[i]);
    }
    cout<<s;
}


Measured memory_bytes: 3636
import math

a,b,x = map(int, input().split())
c = a * b
if c / 2 >= x / a:
  ans = math.degrees(math.atan((a*b**2)/(2*x)))
else:
  ans = math.degrees(math.atan((a*b-x/a)*(2/a**2)))
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
using namespace std;

typedef long long Int;

int main(){
	const int MAX_N = 100;
	int N;
	int a[MAX_N];
	Int dp[MAX_N + 1][21];
	
	for(int i = 0; i <= MAX_N; i++){
		for(int j = 0; j <= 20; j++){
			dp[i][j] = 0;
		}
	}
	
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", a + i);
	}
	
	dp[0][0] = 1;
	for(int i = 1; i < N; i++){
		for(int j = 0; j <= 20; j++){
			if(j - a[i - 1] >= 0) dp[i][j] += dp[i - 1][j - a[i - 1]];
			if(j + a[i - 1] <= 20) dp[i][j] += dp[i - 1][j + a[i - 1]];
			if(i == 1 && a[i - 1] == 0) dp[i][j] /= 2;
		}
	}
	
	printf("%lld\n", dp[N - 1][a[N - 1]]);
	
	return 0;
}

Measured memory_bytes: 1044
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#define ll long long
using namespace std;

ll x,t,m=100;

int main()
{
    cin>>x;
    while(m<x)
    {
        m=m*1.01;
        t++;
    }
    cout<<t<<endl;
}

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

void solve(long long N, std::string S)
{
    ll R = 0, G = 0, B = 0;
    for (auto ch : S) {
        if (ch == 'R') {
            R++;
        }
        if (ch == 'G') {
            G++;
        }
        if (ch == 'B') {
            B++;
        }
    }
    ll Rl = 0, Gl = 0, Bl = 0;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        auto ch = S[i];
        if (ch == 'R') {
            ans += Gl * B + Bl * G;
            Rl++;
            R--;
        }
        if (ch == 'G') {
            ans += Rl * B + Bl * R;
            Gl++;
            G--;
        }
        if (ch == 'B') {
            ans += Rl * G + Gl * R;
            Bl++;
            B--;
        }
        for (ll j = 1; 0 <= i - j && i + j < N; j++) {
            if (ch != S[i - j] && ch != S[i + j] && S[i - j] != S[i + j]) {
                ans--;
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  string ans = "Christmas";
  if(n==22){
    ans+=" Eve Eve Eve";
  }else if(n==23) {
    ans+=" Eve Eve";
  }else if(n==24) {
    ans+=" Eve";
  }
  cout <<ans;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int T = 0;
	int A, B, K, i;
	scanf("%d", &K);
	getchar();
	scanf("%d %d", &A, &B);
	for(i = A; i <= B; i++)
	{
		if (i%K == 0)
		{
		T++;
		}
	}
		if (T > 0){printf("OK\n");
		}
		else{printf("NG\n");
		}
  	return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

vector<vector<int> > D;
vector<map<int, int> > M;

llong calculate_iwakan(int c1, int c2, int c3) {
    llong res = 0;
    stl_rep(itr, M[0]) res += D[itr->first - 1][c1] * itr->second;
    stl_rep(itr, M[1]) res += D[itr->first - 1][c2] * itr->second;
    stl_rep(itr, M[2]) res += D[itr->first - 1][c3] * itr->second;

    return res;
}

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, c;
    cin >> n >> c;
    D.resize(c);
    rep(i, c) {
        rep(_, c) {
            int d;
            cin >> d;
            D[i].push_back(d);
        }
    }

    M.resize(3);
    rep(i, n) {
        rep(j, n) {
            int c;
            cin >> c;
            ++M[(i + 1 + j + 1) % 3][c];
        }
    }

    llong ans = INF;
    rep(i, c) {
        rep(j, c) {
            rep(k, c) {
                if (i == j || j == k || i == k) continue;
                ans = min(ans, calculate_iwakan(i, j, k));
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    ll n; cin >> n;
    if (n == 1) {cout << 0 << endl; return 0;}
    int m = sqrt(n)+1;
    int ans = 0;
    repp(i,m,2){
        int a = 0;
        while (n % i == 0){
            a++;
            n /= i;
        }
        if (a == 0) continue;
        int c = 0;
        while (a >= c+1){
            a -= c+1;
            c++;
        }
        ans += c;
    }
    if (n != 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
#ifdef FIO
const int S = 1 << 21;
char p0[S],*p1,*p2;
#ifndef ZXY
#define getchar() (p2 == p1 && (p2 = (p1 = p0) + fread(p0,1,S,stdin)) == p1 ? EOF : *p1++)
#endif
inline int read() {
	static int x,c;x = 0;
	do{c = getchar();}while(!isdigit(c));
	do{x = (x << 3) + (x << 1) + (c & 15);c = getchar();}while(isdigit(c));
	return x;
}
#endif
const int N = 205;
long long x,n,a[N],now = 0x7fffffff;
int vis[N];
int main() {
	cin >> x >> n;
	for(int i = 1;i <= n;++i)
		cin >> a[i],vis[a[i]] = 1;
	int len = 0;
	while(vis[x-len] && vis[x+len]) ++len;
	if(!vis[x-len]) cout << x-len << endl;
	else cout << x+len << endl;
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;
long long int mode=0;
string s,t;

long long int h,w,d,a[310][310],q,L[120000],R[120000],mp_consumption[100000];
pair<long long int,long long int>ij[300005];

int main() {
	cout << fixed << setprecision(18);
    cin>>h>>w>>d;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
            ij[a[i][j]]={i,j};
        }
    }
    cin>>q;
    for(int i=1;i<=d;i++){
        mp_consumption[i]=0;
        long long int now=i+d;
        while(now<=h*w){
            mp_consumption[now]=mp_consumption[now-d]+abs(ij[now].first-ij[now-d].first)+abs(ij[now].second-ij[now-d].second);
            now+=d;
        }
    }
    for(int i=0;i<q;i++){
        cin>>L[i]>>R[i];
        cout<<mp_consumption[R[i]]-mp_consumption[L[i]]<<endl;
    }
} 


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N, a, b, c ;
   cin >> N ;
   a=N/100 ;
   b=N/10-a*10 ;
   c=N-(100*a+10*b) ;
   if(a==7 ||b==7 ||c==7){
     cout<<"Yes"<<endl;
   }
  else{
    cout<<"No"<<endl;
  }
}


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

N, K = map(int, readline().split())
A = np.array(readline().split(), dtype=np.int64)
A = np.array([(1+a)/2 for a in A])

Acum = np.zeros(N+1, np.float64)
Acum[1:] = A.cumsum()

x = Acum[K:] - Acum[:-K]
print(x.max())


Measured memory_bytes: 24312
N, x = map(int, input().split())
ai = list(map(int, input().split()))
gokei = 0
if ai[0] > x:
    gokei += ai[0] - x
    ai[0] = ai[0] - (ai[0] - x)

for i in range(N - 1):
    taberu = ai[i] + ai[i+1] - x
    if taberu > 0:
        gokei += taberu
        ai[i+1] = ai[i+1] - taberu 
print(gokei)
       

Measured memory_bytes: 63984
#include<iostream>
#include<string>
#include<functional>
#include<math.h>
#include<stdio.h>
using namespace std;

typedef struct{
    double x,y;
} koch;

koch tens(koch p1, koch p2){
    koch s;
    s.x=(2*p1.x + p2.x)/3;
    s.y=(2*p1.y + p2.y)/3;
    return s;
}
koch tent(koch p1, koch p2){
    koch t;
    t.x=(p1.x + 2*p2.x)/3;
    t.y=(p1.y + 2*p2.y)/3;
    return t;
}
koch tenu(koch s, koch t){
    koch u;
    u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
    u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;
    return u;
}
void Koch(int n, koch p1, koch p2){
    if(n==0){
        return;
    }
    koch s;
    koch t;
    koch u;
    s=tens(p1,p2);
    t=tent(p1,p2);
    u=tenu(s,t);
    Koch(n-1,p1,s);
    cout<<s.x<<" "<<s.y<<endl;
    Koch(n-1,s,u);
    cout<<u.x<<" "<<u.y<<endl;
    Koch(n-1,u,t);
    cout<<t.x<<" "<<t.y<<endl;
    Koch(n-1,t,p2);
    
    
}
int main(){
    int n;
    cin>>n;
    koch p1;
    koch p2;
    p1.x=0;
    p1.y=0;
    p2.x=100;
    p2.y=0;
    cout<<"0.00000000 0.00000000"<<endl;
    
    Koch(n,p1,p2);
    
    cout<<"100.00000000 0.00000000"<<endl;
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;

    int ans = 0;
    for(int i = a; i <= b; i++){
        string tmp_t = to_string(i);
        bool is_ro = true;
        rep(j,tmp_t.size()/2){
            if(tmp_t[j] != tmp_t[tmp_t.size()-1-j]){
                is_ro = false;
            }
        }
        if(is_ro){
            ans++;
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
  int A, B, C;

  if (scanf("%d %d %d", &A, &B, &C) == 1)
    ;

  if ((A == B && A != C) ||
      (A == C && A != B) ||
      (B == C && B != A))
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return (0);
}


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

using ll=long long; 

void solve(){
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1; i<x+k; i++){
		cout<<i;
		if(i!=x+k-1)cout<<" ";
	}	
	cout<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}

#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}

fn main() {
    let (n, k): (usize, usize) = (read(), read());
    let mut kids: Vec<bool> = (0..n).into_iter().map(|_| false).collect();
    for _ in 0..k {
        let d: usize = read();
        for _ in 0..d {
            let index: usize = read();
            kids[index - 1] = true;
        }
    }
    println!("{}", kids.iter().filter(|&&x| x == false).count());
}


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

map<int, int> cnt;
priority_queue<int> pq;

int main()
{
    ll n,ans=0;
    cin>>n;
    REP(i,n) cnt[input<int>()]++;
    REPITR(itr,cnt) {
        pq.push(itr->e2);
    }
    while (pq.top() > 1) {
        auto p = pq.top();
        pq.pop();
        if (p > 2) {
            pq.push(p-2);
        } else {
            auto q = pq.top();
            pq.pop();
            pq.push(p-1);
            if (q > 1) {
                pq.push(q-1);
            }
        }
    }

    while (!pq.empty()) {
        ans++;
        pq.pop();
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 8612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {
	
	int h, w, m;
	cin >> h >> w >> m;
	set<P> se;

	V<P> bh(h), bw(w);
	rep(i, h)bh[i].second = i;
	rep(i, w)bw[i].second = i;

	rep(i, m) {
		int y, x;
		cin >> y >> x;
		y--, x--;
		bh[y].first++;
		bw[x].first++;
		se.insert(P(y, x));
	}

	sort(all(bh), greater<P>());
	sort(all(bw), greater<P>());

	int wwo = bh[0].first + bw[0].first;
	if (se.find(P(bh[0].second, bw[0].second)) == se.end()) {
		cerr << "pt1" << endl;
		cout << wwo << endl;
		return 0;
	}

	rep(i, h)rep(j, w) {
		int b = bh[i].first + bw[j].first;
		if (b < wwo)break;
		if (se.find(P(bh[i].second, bw[j].second)) == se.end()) {
			cerr << "pt2" << endl;
			cout << wwo << endl;
			return 0;
		}
	}

	cerr << "pt3" << endl;
	cout << wwo-1 << endl;

}

Measured memory_bytes: 31480
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#include <climits>
#include <deque>
#include <random>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int i=0;i < (int)(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int c[10][10];
int a[300][300];
int num[10];
int main(){
    int h,w;
    cin >> h >> w;
    rep(i,10){
        rep(j,10){
            cin >> c[i][j];
        }
    }
    rep(k,10){
        rep(i,10){
            rep(j,10){
                c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
            if(a[i][j] >= 0)num[a[i][j]]++;
        }
    }
    int ans = 0;
    rep(i,10){
        if(i == 1)continue;
        ans += num[i] * c[i][1];
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 512
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
int ac[3];

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  rep(i, s.size()){
    ac[s[i] - 'a']++;
  }
  if(max(ac[0], max(ac[1], ac[2])) - min(ac[0], min(ac[1], ac[2])) > 1)cout << "NO" << endl;
  else cout << "YES" << endl;
	return 0;
}


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

int main() 
{
    int n, x,a,b,c,i,j,k;
    while (true){
        a = 0;
        cin >> n >> x;
        if (n == 0) break;
        
        for (i = 1; i <= n; i ++){
            for (j = 1; j < i; j++){
                k = x - i - j;
                if (k >= 1 && k <= n && k < j && i != j){
                a += 1;
                }
            }
        }
        cout << a << endl;

    }

}




Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    vb dp(k+1, false);
    rep(i, k+1) rep(j, n) if (i-a[j] >= 0) dp[i] = dp[i] || !dp[i-a[j]];
    cout << (dp[k] ? "First" : "Second") << endl;
}

Measured memory_bytes: 256
import math
arr=[]
for _ in range(5):
    arr.append(int(input()))

targetnum=999
minnum=10
for num,i in enumerate(arr):
    if int(str(i)[-1])<minnum and int(str(i)[-1])>0:
        minnum=int(str(i)[-1])
        targetnum=num

result=0
for num,i in enumerate(arr):
    if num==targetnum:
        result+=i
        #print("aa")
    else:
        result+=math.ceil(i/10)*10


print(result)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
    ll x,y,z;
    cin>>x>>y>>z;
x=x-z;
cout<<x/(y+z)<<endl;
}












Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int a,b,c,d,e,k,m;
  cin>>a>>b>>c>>d>>e>>k;
  m=b-a;
  m=max(m,c-b);
  m=max(m,c-a);
  m=max(m,d-c);
  m=max(m,d-b);
  m=max(m,d-a);
  m=max(m,e-d);
  m=max(m,e-c);
  m=max(m,e-b);
  m=max(m,e-a);
  if(m<=k) cout<<"Yay!";
  else cout<<":(";
  return 0;
}

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

int main()
{
  string s,t;
  cin>>s>>t; 
  set<char> st_s,st_t;
  for(auto &e: s) {
    st_s.insert(e);
  }
  for(auto &e: t) {
    st_t.insert(e);
  }
  for(auto &e: st_s) {
    
  }

  std::vector<int> num_s;
  std::vector<int> num_t;
  for(auto &e: st_s) {
    int cnt=0;
    for(auto &f: s) {
      if(e==f) cnt++; 
    }
    num_s.emplace_back(cnt);
  }
  for(auto &e: st_t) {
    int cnt=0;
    for(auto &f: t) {
      if(e==f) cnt++; 
    }
    num_t.emplace_back(cnt);
  }
  sort(num_t.begin(), num_t.end());
  sort(num_s.begin(), num_s.end());
  if(num_s==num_t){
    cout<<"Yes";
  }
  else cout<<"No";
}

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

class B
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(Enumerable.Range(1, h[0]).Select(i => (i, s: $"{i}".Sum(c => c - '0'))).Where(x => h[1] <= x.s && x.s <= h[2]).Sum(x => x.i));
	}
}


Measured memory_bytes: 28956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc156_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if (a < 10)
            {
                Console.WriteLine(b+((10-a)*100));
            }
            else
            {
                Console.WriteLine(b);
            }
        }
    }
}


Measured memory_bytes: 13140
N, M = map(int, input().split())
items = []
for i in range(N):
    items.append(tuple(map(int, input().split())))

items = sorted(items, key=lambda x: x[0])
cnt = 0
ans = 0
for item in items:
    a, b = item
    if cnt + b > M:
        tmp = M - cnt
        ans += a * tmp
        print(ans)
        exit()
    else:
        ans += a * b
        cnt += b
    if cnt >= M:
        print(ans)
        exit()


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

struct A {
	string name;
	int point;
	int index;
};

int main() {
	int N;
	cin >> N;
	vector<A> SP(N);
	for (int i = 0; i < N; ++i) {
		cin >> SP[i].name >> SP[i].point;
		SP[i].index = i + 1;
	}
	sort(SP.begin(), SP.end(), [](A a, A b)->bool {
		if (a.name < b.name) return true;
		else if (a.name > b.name) return false;
		else {
			if (a.point < b.point) return false;
			else return true;
		}
	});
	for (int i = 0; i < N; ++i) cout << SP[i].index << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 int N, A[3][3], b[10];
 bool appear[3][3];
 int main() {
 for(int i = 0; i < 3; i++) {
 for(int j = 0; j < 3; j++) cin >> A[i][j];
 }
 cin >> N;
 for(int i = 0; i < N; i++) cin >> b[i];
 for(int i = 0; i < N; i++) {
 for(int j = 0; j < N; j++) {
 	//appear[i][j] = false;
 for(int k = 0; k < N; k++) {
 if(A[i][j] == b[k]) appear[i][j] = true;
 }
 }
 }
 string ANS = "No";
 for(int i = 0; i < 3; i++) {
 if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
 }
 for(int i = 0; i < 3; i++) {
 if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
 }
 if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
 if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
 cout << ANS << endl;
 return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int K; int S;
    cin >> K >> S;
    int total = 0;
    int count = 0;
    for(int i = 0; i <= K; i++) {
        for(int j = 0; j <= K; j++) {
            total = S - i - j;
            if(0 <= total && total <= K) {
                count++;
            }
        }
    }
    cout << count << endl;
}

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

using namespace std;

int main(void){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    ans += min(A, K);
    K -= A + B;
    if(K > 0){
        ans -= K;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
from itertools import product
n= int(input())

ls6 = []
ls9 = [1]
for i in range(1,8):
    ls6.append(6**i)
    ls9.append(9**i)
ls9.sort(reverse=True)
l= len(ls6)
ans = 10**9
for s in product([0,1,2,3,4,5],repeat=l):
    cnt = 0
    t=n
    for i,c in enumerate(s):
        t-= ls6[i]*c
        cnt+=c
    if t<0:continue
    for num in ls9:
        q,t = divmod(t,num)
        cnt+=q
    if t==0:ans=min(ans,cnt)
print(ans)


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

using namespace std;

int main()
{
    int a[4];
    cin >> a[1] >> a[2] >> a[3];
    sort(a + 1 , a + 4);
    if(a[1] == a[2] && a[2] != a[3]) {
        cout << "Yes";
        return 0;
    }
    if(a[1] != a[2] && a[2] == a[3]) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	auto cnt = [0, 0, 0];
	foreach (c; S)
	{
		auto i = c - 'a';
		++cnt[i];
	}
	cnt.sort();
	auto ans = cnt[2] - cnt[0] <= 1;
	if (cnt[0] == 0 || cnt[1] == 0 || cnt[2] == 0)
		ans = false;

	if (S.length == 1)
		writeln("YES");
	else if (S.length == 2)
		writeln(S[0] != S[1] ? "YES" : "NO");
	else
		writeln(ans ? "YES" : "NO");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 508
import java.util.Scanner;

public class Main {

	/**
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();

		scan.close();
		int r = B/A;
		if(C<r) {
			System.out.println(C);
		} else {
			System.out.println(r);
			
		}
	}

}

Measured memory_bytes: 22996
//    https://youtu.be/8SbUC-UaAxE

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,temp,flag,ans=0;
    cin>>n;
    ll a[n+1],b[n];
    for(i=0;i<n+1;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        cin>>b[i];
        if(!i){
            ans+=min(a[i],b[i]);
            b[i]-=min(a[i],b[i]);
        }else{
            ans+=min(a[i],b[i-1]);
            a[i]-=min(a[i],b[i-1]);
            ans+=min(a[i],b[i]);
            b[i]-=min(a[i],b[i]);
        }
    }
    ans+=min(a[i],b[i-1]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
#079C Train Ticket
import sys
S = list(map(int, sys.stdin.readline().strip()))
L=[]
def saiki(i, score, ans):
    if i+1==4:
        if score ==7:
            ans+='=7'
            L.append(ans)
    else:
        saiki(i+1, score+S[i+1], ans+'+'+str(S[i+1]))
        saiki(i+1, score-S[i+1], ans+'-'+str(S[i+1]))


saiki(0, S[0], str(S[0]))
    
print(L[0])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(void) {
	int N, M;
	int ans = 0;
	std::cin >> N >> M;
	ans = 1900 * M + (N - M) * 100;
	ans *= std::pow(2, M);
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
n = int(input())
tlst = list(map(int, input().split()))
alst = list(map(int, input().split()))
cand_t = [[1, 1] for _ in range(n)]
cand_t[0] = [tlst[0], tlst[0]]
for i in range(1, n):
    if tlst[i] == tlst[i - 1]:
        cand_t[i][1] = tlst[i]
    else:
        cand_t[i] = [tlst[i], tlst[i]]
cand_a = [[1, 1] for _ in range(n)]
cand_a[-1] = [alst[-1], alst[-1]]
for i in range(n - 2, -1, -1):
    if alst[i] == alst[i + 1]:
        cand_a[i][1] = alst[i]
    else:
        cand_a[i] = [alst[i], alst[i]]
ans = 1
for (t_r, t_h), (a_r, a_h) in zip(cand_t, cand_a):
    r = max(t_r, a_r)
    h = min(t_h, a_h)
    if r > h:
        print(0)
        break
    ans *= (h - r + 1)
    ans %= MOD
else:
    print(ans)

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

using namespace std;

#define MOD 1000000007
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626

typedef long long ll;

void solve()
{
    cout<<"\n";
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;

    int cnt = 0;
    int ans = 0;

    for(int i=0; i<3; i++)
    {
        if(s[i]=='R')cnt++;
        else cnt=0;

        ans = max(ans,cnt);
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
int l,n,m;
cin >> l >> n >> m;
if(n == m && n == l){
  cout << "No" << '\n';
	}
else if(n == m || n == l || l == m){
  cout << "Yes" << '\n';
	}
else{
  cout << "No" << '\n';
	}
return 0;
}

Measured memory_bytes: 3552
PROGRAM ATCODER

implicit none
character(len=10**5) :: s
integer :: check,len

read(*,*) s

do
  len = len_trim(s)
  if ( trim(s) == '' ) then
    write(*,'(a)') 'YES'
    stop
  end if
  check = 0
  if ( s(len-4:len) == 'dream' .or. s(len-4:len) == 'erase' ) then
    s(len-4:len) = ''
    check = 1
  else if ( s(len-6:len) == 'dreamer' ) then
    s(len-6:len) = ''
    check = 1
  else if ( s(len-5:len) == 'eraser' ) then
    s(len-5:len) = ''
    check = 1
  end if
  if ( check == 0 ) then
    write(*,'(a)') 'NO'
    stop
  end if
end do

contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER

Measured memory_bytes: 700
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
//#define int ll
#pragma region
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#pragma endregion

int n;
vector<int> g[111'111'1];
int deg[111'111'1];
int dp[111'111'1];
void solve()
{
    cin>>n;
    auto idx = [&](int i, int j)
    {
        if (i > j) swap(i, j);
        return i*n + j;
    };
    forn(i, n)
    {
        int pv = -1;
        forn(j, n-1)
        {
            int p; cin>>p;
            --p;
            if (pv != -1)
            {
                int t1 = idx(i, pv);
                int t2 = idx(i, p);
                g[t1].pb(t2);
                deg[t2]++;
            }
            pv = p;
        }
    }
    queue<int> q;
    forn(i, n*n)
    {
        if (deg[i] == 0) q.push(i);
    }

    while(sz(q))
    {
        int now = q.front(); q.pop();
        for (int nxt: g[now])
        {
            dp[nxt] = max(dp[nxt], dp[now] + 1);
            deg[nxt]--;
            if (deg[nxt] < 0)
            {
                cout << "-1\n";
                return;
            }
            else if(deg[nxt] == 0) q.push(nxt);
        }
    }
    int ans = 0;
    forn(i, n*n)
    {
        if (deg[i])
        {
            cout << "-1\n";
            return;
        }
        ans = max(ans, dp[i]);
    }
    cout << ans+1 << '\n';
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << fixed << setprecision(22);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << '\n';
        solve();
    }
    return 0;
}

Measured memory_bytes: 54768
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
set<string>s;
string a[1000009];
int main()
{
    int n;
    string z;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        z=a[i];
        s.insert(z);
    }
      cout<<s.size();



    return 0;
}


Measured memory_bytes: 50428
x, n = gets.split.map(&:to_i)
ps = gets.split.map(&:to_i).sort!

if n == 0
  puts x
  exit 0
end

ans = diff = x

(ps.last + 10 ** 5).downto(-ps.last - 10 ** 5) do |i|
  next if ps.include?(i)

  abs = (x - i).abs
  if abs <= diff
    ans = i
    diff = abs
  end
end

puts ans


Measured memory_bytes: 14396
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x)
#define debug(x)
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)


void mainmain(){
    ll H, W;
    cin >> H >> W;

    if (min(H, W) == 1) {
        cout << 1 << endl;
        return;
    }

    if (H * W % 2 == 0) {
        cout << H * W / 2 << endl;
    }
    else {
        cout << H * W / 2 + 1 << endl;
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;
  int ans;
  if(s[0]=='R'){
    if(s[1]=='R'){
      if(s[2] == 'R') ans = 3;
      else ans = 2;
    }
    else ans = 1;
  }
  else{
    if(s[1]=='R'){
      if(s[2]=='R') ans = 2;
      else ans = 1;
    }
    else{
      if(s[2]=='R') ans = 1;
      else ans = 0;
    }
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620