akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
vector<ll> Prime;
vector<ll> ans;
void get_prime(){
    bool isPrime[60606];
    isPrime[0]=isPrime[1]=false;
    REP(i, 2, 60606) isPrime[i]=true;

    for(int i=2; i*i<=55555; i++){
        for(int j=i*2; j<=55555; j+=i){
            isPrime[j]=false;
        }
    }
    REP(i, 0, 55555){
        if(isPrime[i]) Prime.push_back(i);
    }
}
int main() {
    cin>>n;

    get_prime();

    for(auto itr:Prime){
        if(itr%10==1) ans.push_back(itr);
    }

    REP(i, 0 , n-1){
        cout<<ans[i]<<" ";
    }
    cout<<ans[n]<<endl;
    return 0;
}

Measured memory_bytes: 384
import sys
# sys.stdin = open('input.txt')

def fillMatrix():
    for i in range(n):
        u, k, *v = map(int, input().split())
        for j in v:
            matrix[i][j-1] = 1

def dfs(u):
    global time
    status[u] = VISITING
    time += 1
    discoverTime[u] = time
    for v in range(n):
        if matrix[u][v] and status[v] == NOT_VISITED:
            dfs(v)
    status[u] = VISITED
    time += 1
    finishTime[u] = time


n = int(input())
matrix = [[0]*n for i in range(n)]
time = 0
discoverTime = [0] * n
finishTime = [0] * n

NOT_VISITED = 0 # WHITE
VISITING = 1 # GRAY
VISITED = 2 # BLACK
status = [NOT_VISITED] * n

fillMatrix()
# Calling dfs(0) alone cannot reach nodes not connected from 0
for i in range(n):
    if status[i] != VISITED:
        dfs(i)

for i in range(n):
    ans = []
    ans.append(i+1)
    ans.append(discoverTime[i])
    ans.append(finishTime[i])
    ans = map(str, ans)
    print(' '.join(ans))


Measured memory_bytes: 5748
n = int( input() )
a = list( map( int, input().split() ) )

step = 0
max_a = a[ 0 ]

for i in range( n ):
    if a[ i ] > max_a:
        max_a = a[ i ]
    else:
        step += ( max_a - a[ i ] )

print( step )

Measured memory_bytes: 32176
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }
    
    int size(int x){
        return sizeuf[root(x)];
    }
};

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

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/

signed main(){
    int n;
    cin>>n;
    bool ans=false;
    for(int i=1;i<=9;i++){
        if(n%i==0&&1<=n/i&&n/i<=9){
            ans=true;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

#define i64 long long int

i64 n, a, b;

int main() {
	cin>>n>>a>>b;
	
	i64 rep = n/(a+b);
	i64 ans = rep * a;
	ans += min(a, n%(a+b));
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define f(i,a,n)        for(ll i=a;i<n;i++)
#define ve              vector
#define ss              second 
#define ff              first
#define pf              pop_front
#define pob             pop_back
#define psf             push_front
#define res(x)          cout<<x<<'\n'
#define read(t)         ll t;cin>>t

#define pii             pair<ll,ll>
#define vii             vector<ll,ll>
#define INFI            1000000000000000000;


int main(){
   ll x,k,d;
   cin>>x>>k>>d;
   x=abs(x);
  ll temp=x/d;
  ll ans=0;
  ll rem=x%d;
  if(temp>k) {
       ans=min(x,abs(x-k*d));
  }
  else if(temp==k){
      ans=rem;
  }
  else{
      ll temp2=k-temp;
      if(temp2%2==0){
          ans=rem;
      }
      else{
          ans=abs(d-rem);
      }
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 3564
import math
n, p = map(int, input().split())
a = []
if n == 1:
  print(p)
  exit()
for i in range(2, math.ceil(p**0.5)+1):
  cnt = 0
  while p % i == 0:
    cnt += 1
    p //= i
  a.append(cnt)
gcd = 1
for i in range(len(a)):
  if a[i] >= n:
    gcd *= (i+2) ** (a[i] // n)
print(gcd)

Measured memory_bytes: 10904
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	c := make([]int, n-1)
	s := make([]int, n-1)
	f := make([]int, n-1)
	for i := 0; i < n-1; i++ {
		fmt.Scan(&c[i], &s[i], &f[i])
	}
	for i := 0; i < n-1; i++ {
		curr := s[i]
		for j := i; j < n-1; j++ {
			curr += c[j]
			point := s[j] + c[j]
			if curr > point {
				for curr > point {
					point += f[j]
				}
			}
			curr = point
		}
		fmt.Println(curr)
	}
	fmt.Println(0)
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) { cin >> s[i]; }
    ll black_num = 0;
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                black_num++;
            }
        }
    }
    ll white_num = h * w - black_num;

    queue<pair<pair<ll, ll>, ll>> q;
    q.push(make_pair(make_pair(0, 0), 1));
    ll move_x[4] = {0, -1, 1, 0}, move_y[4] = {1, 0, 0, -1};
    ll flag[h][w] = {};
    ll num = -1;
    while (!q.empty()) {
        auto top = q.front();
        q.pop();
        ll x = top.first.first;
        ll y = top.first.second;
        if (x < 0 || w <= x || y < 0 || h <= y) {
            continue;
        }
        ll count = top.second;
        if (s[y][x] == '#') {
            continue;
        }
        if (flag[y][x]) {
            continue;
        }
        flag[y][x] = true;
        if (x == w - 1 && y == h - 1) {
            num = count;
            break;
        }
        rep(i, 4) {
            ll next_x = x + move_x[i], next_y = y + move_y[i];
            q.push(make_pair(make_pair(next_x, next_y), count + 1));
        }
    }
    if (num == -1) {
        cout << -1 << endl;
    } else {
        cout << white_num - num << endl;
    }
    return 0;
}



Measured memory_bytes: 256
H = []
W = []
i = 0
while True:
  h, w = map(int, input().split())
  H.append(h)
  W.append(w)
  if H[i] == 0 and W[i] == 0:
    break
  i += 1

i = 0
while True:
  if H[i] == 0 and W[i] == 0:
    break
  for j in range(H[i]):
    for k in range(W[i]):
      print("#", end="")
    print()
  print()
  i += 1

Measured memory_bytes: 8980
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

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

		int N = Integer.parseInt(br.readLine());
		String[] ss0 = br.readLine().trim().split(" ", 0);
		Integer[] ii0 = new Integer[N];
		for(int i = 0; i < N; i++){
			ii0[i] = Integer.parseInt(ss0[i]);
		}
		
		int[] color = new int[9];
		for(int i: ii0) {
			if((1<=i)&&(i<=399)){
				color[0] += 1;
			}else if((400<=i)&&(i<=799)){
				color[1] += 1;
			}else if((800<=i)&&(i<=1199)){
				color[2] += 1;
			}else if((1200<=i)&&(i<=1599)){
				color[3] += 1;
			}else if((1600<=i)&&(i<=1999)){
				color[4] += 1;
			}else if((2000<=i)&&(i<=2399)){
				color[5] += 1;
			}else if((2400<=i)&&(i<=2799)){
				color[6] += 1;
			}else if((2800<=i)&&(i<=3199)){
				color[7] += 1;
			}else{
				color[8] += 1;
			}
		}
		
		int min=0;
		int max=0;
		for(int i=0; i < 8; i++) {
			if(color[i]>0){ min += 1; }
		}
		max = min + color[8];
		if (min < 1) { min =1; }

		System.out.println(min + " " + max);

	return;
	}



}


Measured memory_bytes: 21076
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf(“%lld”, &(n))
#define scd(n) scanf(“%Ld”, &(n))
typedef long long LL;

int main(void)
{
	LL a, b;
	cin >> a >> b;
	cout << (a + b) % 24;
	return 0;
}

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

int main(void){
  string s,t;
  cin >> s >> t;
  int count = 0;
  if(s[0] == t[0]){
    count++;
  }
  if(s[1] == t[1]){
    count++;
  }
  if(s[2] == t[2]) {
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long // for codeforces

int main(){
  char a,b;
  scanf("%c %c", &a, &b);
  bool ba = a=='H',bb = b=='H';
  if(ba^bb) cout<<"D"<<endl;
  else cout<<"H"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  ll ans=0;
  ll kn=1;
  while(n>0){
    ans+=kn;
    kn*=2;
    n/=2;
  }cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		Console.WriteLine("{0}",Levenshtein(sc.S,sc.S));
	}
	static int Levenshtein(string a,string b){
		a="-"+a;b="-"+b;
		int[,] dp=new int[a.Length+1,b.Length+1];
		for(int i=1;i<a.Length;i++){dp[i,0]=i;}
		for(int i=1;i<b.Length;i++){dp[0,i]=i;}
		for(int i=1;i<a.Length;i++){
			for(int j=1;j<b.Length;j++){
				dp[i,j]=Min(dp[i-1,j]+1,dp[i,j-1]+1);
				dp[i,j]=Min(dp[i,j],dp[i-1,j-1]+(a[i]==b[j]?0:1));
			}
		}
		return dp[a.Length-1,b.Length-1];
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}



Measured memory_bytes: 21288
#include<stdio.h>

int main(){

    int N;
    scanf("%d", &N);

    int x[N], y[N];
    for (int i = 0; i < N; i++){
        scanf("%d %d", &x[i], &y[i]);
    }

    int p, q;
    int cost0_times = 0;
    int cost0_max = 0;

    for (int i = 0;i < N-1; i++){
        for (int j = i + 1; j < N; j++){

            cost0_times = 0;

            p = x[i] - x[j];
            q = y[i] - y[j];

            for (int a = 0;a < N-1; a++){
                for (int b = a + 1; b < N; b++){

                    if(((x[a] - x[b] == p) && (y[a] - y[b] == q)) || ((x[a] - x[b] == -p) && (y[a] - y[b] == -q))){
                        cost0_times += 1;
                    }
                }
            }

            if(cost0_max < cost0_times){
                cost0_max = cost0_times;
            }
        }
    }

    printf("%d", N - cost0_max);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int a,b=0;
  int y1,y2;
  double y3;

  scanf("%d%d",&a,&b);
  y1=a/b;
  y2=a%b;
  y3=(double)a/b;

  printf("%d %d %f\n",y1,y2,y3);
  return 0;
}

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


int main(){
   long long  N,M;
   cin >> N >> M;
   if(N == 1 && M == 1){
       cout <<1<< endl;
   }if(N == 1 && M != 1){
       cout << M - 2 << endl;
   }if(N!=1&&M ==1){
       cout << N-2<<endl;
   }if(N!=1&&M!=1){
       cout << (N-2)*(M-2) << endl;
   }
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

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

  int n; cin >> n;
  string s; cin >> s;

  int r = 0, b = 0;

  for (int i = 0; i < n; ++i){
    r += (s[i] == 'R');
    b += (s[i] == 'B');
  }

  if (r > b) print("Yes");
  else print("No");


  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=1e6+5;
queue<int>q;
int head[N],nxt[N],go[N],val[N],k;
int dis[N],vis[N],tot;
inline void add(int x,int y,int z)
{
	go[++tot]=y;
	nxt[tot]=head[x];
	val[tot]=z;
	head[x]=tot;
}
inline void spfa(int s)
{
	q.push(s),dis[s]=0;
	vis[s]=1;
	while (!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=head[x];i;i=nxt[i])
		{
			int v=go[i];
			if (dis[v]>dis[x]+val[i])
			{
				dis[v]=dis[x]+val[i];
				if (!vis[v])
				{
					vis[v]=1;
					q.push(v);
				}
			}
		}
		vis[x]=0;
	}
}
int main()
{
	scanf("%d",&k);
	fo(i,0,k-1)
	{
		add(i,(i+1)%k,1);
		add(i,i*10%k,0);
	}
	memset(dis,127/3,sizeof(dis));
	spfa(1);
	printf("%d\n",dis[0]+1);
} 

Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;



int32_t main(){

int n;cin>>n;
string s;cin>>s;
int cnt=0;
for(int i=0;i<n-2;i++){
   if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')cnt+=1;
}
cout<<cnt<<endl;

}

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

using namespace std;

int64_t p[20];
int digcnt[10];

int main() {
    int64_t D;
    cin >> D;

    p[0] = 1;
    for (int i = 1; i < 19; i++)
        p[i] = 10 * p[i - 1];

    for (int k = 0; k < 10; k++)
        for (int i1 = 0; i1 < 10; i1++)
            for (int i2 = 0; i2 < 10; i2++)
                if (i1 - i2 == k)
                    digcnt[k]++;

    int64_t total = 0;
    for (int d = 2; d < 19; d++) {
        int e = (d + 1) / 2, sgn[19], dig[19];
        for (int i = 0; i < (1 << e); i++)  {
            int64_t td = D;
            for (int j = 0; j < e; j++)
                sgn[j] = (i & (1 << j)) ? 1 : -1;
            for (int j = 0; j < e; j++) {
                int curdig = (td / p[j] % 10 + 10) % 10;
                if (sgn[j] == 1)
                    dig[j] = (10 - curdig) % 10;
                else
                    dig[j] = -curdig;

                dig[d - j - 1] = -dig[j];
                if (2 * j - 1 == d)
                    td += p[j] * dig[j];
                else
                    td += p[j] * dig[j] + p[d - j - 1] * dig[d - j - 1];
            }
            if (td == 0)  {
                /*
                cout << d << " " << i << " dig:";
                for (int j = 0; j < e; j++)
                    cout << " " << dig[j];
                cout << endl;
                */
                bool repeat = false;
                for (int j = 0; j < e; j++)
                    if (dig[j] == 0 && sgn[j] == -1) {
                        repeat = true;
                        break;
                    }
                if (repeat)
                    continue;
                int64_t cnt = 0;
                for (int i1 = 0; i1 < 10; i1++)
                    for (int i2 = 1; i2 < 10; i2++)
                        if (i1 - i2 == dig[0])
                            cnt++;
                for (int j = 1; j < e; j++)
                    cnt *= digcnt[abs(dig[j])];
                total += cnt;
            }
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N, AC = 0, WA = 0, TLE = 0, RE = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++ ) {
		char s[6];
	    scanf("%s", &s);
	    if (s[0] == 'A') {
	    	AC++;
		}
		if (s[0] == 'W') {
			WA++;
		}
		if (s[0] == 'T') {
			TLE++;
     	}
		if (s[0] == 'R') {
			RE++;
	    }
    }
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE);
	return 0;
}

Measured memory_bytes: 1732
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            Console.WriteLine((1000 - N % 1000) % 1000);
        }
    }
}


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

int main()
{
    ll n,k,h,i,x=0;
    scanf("%lld %lld",&n,&k);

    while(n--)
    {
        cin>>h;
        if(h>=k)
            x++;
    }

    printf("%lld\n",x);

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define int long long int
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,a,b) for(i=a;i<b;i++)
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
void solve()
{
    int n,i,j;
    cin>>n;
    int a, ans=0;
    map<int,int> m;
    rep(i,0,n)
    {
      cin>>a;
      m[a]++;
    }
    for(auto it=m.begin();it!=m.end();it++)
    {
        if(it->sc> it->fs)
          ans+= it->sc-it->fs;
        else if(it->sc< it->fs)
          ans+=it->sc;
    }
    cout<<ans;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 9500
import sys
input = sys.stdin.readline

a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            cnt = (500*i) + (100*j) + (50*k)
            if x == cnt:
                ans += 1
                break
print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())
d = {1:-1, 2:-1, 3:-1}

for _ in range(M):
    s, c = map(int, input().split())
    if d[s]!=-1 and d[s]!=c:
        print(-1)
        break
    d[s] = c
else:
    for i in list(range(10**(N-1)-(N==1), 10**N)):
        n = i
        for j in range(1, N+1)[::-1]:
            if not (d[j] == -1 or d[j] == i%10):
                break
            i//=10
        else:
            print(n)
            break
    else:
        print(-1)


Measured memory_bytes: 3064
H, W = map(int, input().split())
c = []
for _ in range(H):
    *w, = map(int, input().split())
    c.append(w)

# 上方向に連続するタイルの数を記録する
t = []
for _ in range(H+2):
    t.append([0]*(W+2))

for w in range(1, W+1):
    for h in range(1, H+1):
        if c[h-1][w-1] == 1:
            t[h][w] = 0
        else:
            t[h][w] = t[h-1][w]+1

ans = 0
for h in range(1, H+1):
    s = []
    for w in range(1, W+2):
        if len(s) == 0 or s[-1][0] < t[h][w]:
            s.append([t[h][w], w])
        elif s[-1][0] > t[h][w]:
            li = w
            while len(s) > 0 and s[-1][0] >= t[h][w]:
                r = s.pop(-1)
                tmp = (w-r[1])*r[0]
                if tmp > ans:
                    ans = tmp
                li = r[1]
            s.append([t[h][w], li])
print(ans)



Measured memory_bytes: 63428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N,i,j,x,ans = 0;scanf("%lld",&N);
  bool a[N+1][20];
  for(i=0;i<N;i++){
    scanf("%lld",&x);
    for(j=0;j<20;j++){
      a[i][j] = x%2;
      x >>= 1;
    }
  }
  ll l = 0,r = 0,sum[20] = {};
  bool ok;
  while(r <= N){
    ok = true;
    for(i=0;i<20;i++) ok &= sum[i] <= 1;
    if(ok){
      ans += r-l;
      for(i=0;i<20;i++) sum[i] += a[r][i];
      r++;
    } else {
      for(i=0;i<20;i++) sum[i] -= a[l][i];
      l++;
    }
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 7736
#include <cstdio>

int n,k,ans,tmp;
int a[100000];

int main(){
	while(scanf("%d%d", &n, &k)){
		if(n == 0 && k == 0) break;
		ans = 0;
		for(int i = 0; i < n; i++) scanf("%d", &a[i]);
		for(int i = 0; i < k; i++) ans += a[i];
		tmp = ans;
		for(int i = 0; i < n-k; i++){
			tmp += a[k+i]-a[i];
			if(ans < tmp) ans = tmp;
		}
		printf("%d\n", ans);
	}
}

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

int main(){
int n,t,a; cin>>n>>t>>a;
int hh;
int mina=1000000;
int mini;
for(int i=0; i<n; i++){
cin>>hh;
if(mina>abs(a*1000-t*1000+hh*6)){
mini=i+1;
mina=abs(a*1000-t*1000+hh*6);
}
}
cout<<mini<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        String H = sc.next();
        String T = sc.next();
        
        System.out.println(T+H);
        		
    }
}

Measured memory_bytes: 19924
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solveA(args);
//		solveB(args);
//		solveC(args);
//		solveD(args);
//		solveE(args);
//		solveF(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		int a = nextInt();
		pw.println(a+a*a+a*a*a);
	}
	public static void solveB(String[] args) throws Exception{

	}
	public static void solveC(String[] args) throws Exception{

	}
	public static void solveD(String[] args) throws Exception{

	}
	public static void solveE(String[] args) throws Exception{

	}

	public static void solveF(String[] args) throws Exception{

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25420
import Control.Monad
main = do
  n <- read <$> getLine
  xy <- forM [1..n] $ \i -> do
    a <- read <$> getLine
    forM [1..a] $ \j -> do
      [x,y] <- map read . words <$> getLine
      return (x,y)
  print $ maximum $ length <$> filter (ok xy) (powerset [1..n])
powerset = filterM (const [True,False])
ok xys kinds = and [(y == 0) /= (x `elem` kinds) | i <- kinds,(x,y) <- xys !! (i-1)]

Measured memory_bytes: 6936
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back 
#define mp make_pair
typedef long long ll;

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

int main(){
	int n,m; cin>>n>>m;
	ll A[n];
	bool comp=true;
	
	for(int i=0;i<n;i++){
		cin>>A[i];
		A[i]/=2;
	}
	
	ll g=A[0];
	ll lcd=A[0];
	
	for(int i=1;i<n;i++){
		g=gcd(lcd,A[i]);
		if(lcd/g<=m/A[i]) lcd=lcd*A[i]/g;	
		else{
			comp=false;
			break;
		}
	}
		
	if(!comp){
		cout<<0;
		return 0;
	}
	
	for(int i=0;i<n;i++){
		ll temp=lcd/A[i];
		if(temp%2==0) comp=false;
	}
	
	if(!comp){
		cout<<0;
		return 0;
	}
	
	cout<<(m/lcd+1)/2;
	return 0;
}


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

int main()
{
    int n,i,x,d;
    cin>>n>>x;
    int v[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    d=0;
    for(i=1;i<=n;i++)
    {
        d=__gcd(d,abs(x-v[i]));
    }
    cout<<d;
    return 0;
}


Measured memory_bytes: 640
n = int(input())
factors = []
import math
sqrt = math.floor(n ** 0.5)
z = n
for i in range(2, sqrt + 1):
    if not z % i:
        while z % i == 0:
            factors.append(i)
            z //= i
if z > 1:
    factors.append(z)
print('{}:'.format(n), *factors)


Measured memory_bytes: 5696
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
#define MAX9 1000000000
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

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

	if (a > b)cout << a - 1 <<endl;
	else cout << a << endl;

	return 0;
}


Measured memory_bytes: 384
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e18) + 1;
const int mod = 479001599;
const int maxn = 5e5 + 111;
        
using namespace std;          

int n;
string s, t;

void solve(){
	int a, b;

	cin >> a >> b;

	cout << a * b / __gcd(a, b);
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

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

    ll ans = k;
    REP(i, n-1) {
        ans *= k-1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
class Dice
  attr_accessor :faces

  # |T F L|
  # |B U R|
  def initialize(faces)
    top, front, right, left, back, bottom = faces
    @faces = [[top, bottom], [front, back], [left, right]]
  end

  def move(commands)
    commands.split('').each do |com|
      case com.upcase.to_sym
      when :E
        faces[0], faces[2] = faces[2], faces[0].reverse
      when :W
        faces[0], faces[2] = faces[2].reverse, faces[0]
      when :N
        faces[0], faces[1] = faces[1], faces[0].reverse
      when :S
        faces[0], faces[1] = faces[1].reverse, faces[0]
      end
    end
  end

  def method_missing(face)
    if %i(top bottom front back left right).include? face
      {
        top:    faces[0][0],
        bottom: faces[0][1],
        front:  faces[1][0],
        back:   faces[1][1],
        left:   faces[2][0],
        right:  faces[2][1]
      }[face]
    else
      super
    end
  end

  def ==(other)
    commands = (["N"]*3 + ["E"]*3)
    0.upto(commands.size) do |r|
      commands.permutation(r).each do |c|
        move(c.join)
        return true if faces == other.faces
      end
    end
    false
  end

  def clone
    self.class.new([top, front, right, left, back, bottom])
  end

  def info
    p({ T: top, F: front, R: right, L: left, U: back, B: bottom })
  end

end

$stdin = DATA if $<.eof?

dice_a = Dice.new(gets.split)
dice_b = Dice.new(gets.split)

puts(dice_a == dice_b ? "Yes" : "No")

__END__
10 20 20 40 50 50
20 10 40 50 50 20

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

//define ll long long;
//define ar array;


map<string, int> m;

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

    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        string k;
        cin >> k;
        m[k]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;


    return 0;
}



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


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    

    vector<vector<int>> temp(M+1);
    for (int i=0; i<N; ++i){
        if (A[i]<=M) // filter the impossible work
            temp[A[i]].push_back(B[i]);
    }

    priority_queue<long long> pq;
    long long result= 0LL;
    for (int j = 1; j<=M; ++j){
        for (auto k : temp[j]){
            pq.push(k);
        }

        if (!pq.empty()){
            result += pq.top();
            pq.pop();
        }
    }
    printf("%lld", result);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 7168
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    vector<int> n;
    n.push_back(A);
    n.push_back(B);
    n.push_back(C);
    int counter = 0;
    while (true) {
        if (n[0] == n[1] && n[1] == n[2]) break;
        sort(n.begin(), n.end());
        if (n[2] - n[0] >= 2) {
            n[0] += 2;
        }
        else {
            ++n[0];
            ++n[1];
        }
        ++counter;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 888
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
data SegmentTree m = Leaf m  | Node m (SegmentTree m) (SegmentTree m) Int
    deriving (Eq, Show)

val :: SegmentTree m -> m
val (Leaf v)     = v
val (Node v _ _ _) = v

update :: (Monoid m) => SegmentTree m  -> Int -> m -> SegmentTree m
update (Leaf v) _ x = Leaf x
update (Node v l r size)  i x
    | i < n'   =   Node (val left `mappend` val r) left r size
    | otherwise =   Node (val l `mappend` val right) l right size
    where n' = size `div` 2
          left = update l  i x
          right = update r (i-n') x


query :: (Monoid m) => SegmentTree m -> Int -> Int -> m

query (Leaf v) 0 1 = v
query (Node v l r size) a b
    | a >= b    = mempty
    | a == 0 && b == size   = v
    | b <= n'             = query l  a b
    | a >= n'                = query r  (a-n') (b-n')
    | otherwise             = query l  a n' `mappend` query r 0 (b-n')
    where n' = size `div` 2

resize :: Int -> Int -> Int
resize n m
    | m < n = resize n (2*m)
    | otherwise  = m


fromList :: Monoid m => [m] -> SegmentTree m
fromList xs =
    let n = length xs
        m = resize n 1
        plus = replicate (m-n) mempty
        xs' = xs ++ plus
    in fromList' xs' m

fromList' ::Monoid m => [m] -> Int ->SegmentTree m
fromList' _ 0 = Leaf mempty
fromList' [x] 1 = Leaf x
fromList' xs n = Node (val left `mappend` val right) left right n
    where n' = n `div` 2
          (xs1,xs2) = splitAt n' xs
          left = fromList'  xs1 n'
          right = fromList' xs2 (n-n')

get :: Monoid m => SegmentTree m -> Int -> m
get tree i= query tree i (i+1)

newtype Gcd = Gcd Int deriving (Eq,Ord,Read)

instance Show Gcd where
  show (Gcd x) = show x
instance Semigroup Gcd where
  Gcd x <> Gcd y = Gcd (gcd x y)

instance Monoid Gcd where
  mempty = Gcd 0
  
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- read <$> getLine
  a <- map Gcd <$> getIntList
  let seg = fromList a
  print $ maximum $ [query seg 0 i <> query seg (i+1) n | i <- [0..n]]

Measured memory_bytes: 35992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, int> P3;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, m, cnt[MAX_N]{};
    cin >> n >> m;
    REP(i,m){
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]--;
    }
    bool ok = true;
    REP(i,n){
        cnt[i+1] += cnt[i];
        ok &= cnt[i+1]%2==0;
    }
    cout << (ok?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,popcnt")
#include<bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define IL inline
#define ss system
using namespace std;

template <class T> void read(T &x){
	char ch=x=0;
	bool fl=false;
	while(!isdigit(ch))
		fl|=ch=='-',ch=getchar();
	while(isdigit(ch))
		x=x*10+ch-'0',ch=getchar();
	x=fl?-x:x;
}
int main(){
	int a,b;
	read(a),read(b);
	if(b%a==0)
		printf("%d\n",a+b);
	else
		printf("%d\n",b-a); 
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	
	int k;
	cin>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	bool dp[k+1];
	memset(dp,false,sizeof(dp));
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			   if(i-arr[j]>=0&&dp[i-arr[j]]==false)
               {
		    	
		    	   dp[i]=true;
		    	   break;
		    	
		    }
			
		}	
	}
// 	for(int i=0;i<=k;i++)
// 	cout<<dp[i]<<" ";
	if(dp[k]==true)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
	return 0;
}


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


int main() {
  string s;
  cin >> s;
  int n=s.size();
  int ch=0; 
  bool ex=true;
  while(ch+6<n){
  
    if(s.at(ch)=='d'&&s.at(ch+1)=='r'&&s.at(ch+2)=='e'&&s.at(ch+3)=='a'&&s.at(ch+4)=='m'){
      if(s.at(ch+5)=='e'&&s.at(ch+6)=='r'){
        if(ch+7<n&&s.at(ch+7)=='a'){
          ch+=5;
        }
        else{
          ch+=7;
        }
      }
      else{
        ch+=5;
      }
    }
    else if(s.at(ch)=='e'&&s.at(ch+1)=='r'&&s.at(ch+2)=='a'&&s.at(ch+3)=='s'&&s.at(ch+4)=='e'){
      if(s.at(ch+5)=='r'){        
        ch+=6;
      }
      else{
        ch+=5;
      }
    }
    else{
      ex=false;
      break;
    }
  
  }
  if(ex){
    if(n-ch==5){
      
        if((s.at(n-5)=='d'&&s.at(n-4)=='r'&&s.at(n-3)=='e'&&s.at(n-2)=='a'&&s.at(n-1)=='m')||(s.at(n-5)=='e'&&s.at(n-4)=='r'&&s.at(n-3)=='a'&&s.at(n-2)=='s'&&s.at(n-1)=='e')){
          ex=true;
        }
        
        else{
          ex=false;
        }
      
    }
    else if(n-ch==6){
      
        if(s.at(n-6)=='e'&&s.at(n-5)=='r'&&s.at(n-4)=='a'&&s.at(n-3)=='s'&&s.at(n-2)=='e'&&s.at(n-1)=='r'){
          ex=true;
        }
        else{
          ex=false;
        }
      
    }
    else if(n-ch==0){
      ex=true;
    }
    else{
      ex=false;
    }
  }
                   
  if(ex){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  
}




Measured memory_bytes: 512
#168 - F
import sys
import numpy as np
#from numba import njit


def main():
    N, M = map(int, sys.stdin.buffer.readline().split())
    LineData = np.int64(sys.stdin.buffer.read().split())

    INF = 10**9 + 1

    LineData = LineData.reshape(-1, 3)
    A, B, C = LineData[:N].T
    D, E, F = LineData[N:].T
    #X = np.unique(np.concatenate([D, [-INF, 0, INF]]))
    #Y = np.unique(np.concatenate([C, [-INF, 0, INF]]))
    X = np.unique(np.concatenate([D, [-INF, INF]]))
    Y = np.unique(np.concatenate([C, [-INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B, 'right') - 1
    C = np.searchsorted(Y, C)
    D = np.searchsorted(X, D)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F, 'right') - 1

    area = cal_area(A, B, C, D, E, F, X, Y)

    if area == 0:
        print("INF")
    else:
        print(area)


#@njit
def cal_area(A, B, C, D, E, F, X, Y):
    x = np.searchsorted(X, 0, 'right') - 1
    y = np.searchsorted(Y, 0, 'right') - 1

    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    A = A.tolist()
    B = B.tolist()
    C = C.tolist()
    D = D.tolist()
    E = E.tolist()
    F = F.tolist()
    X = X.tolist()
    Y = Y.tolist()
    DX = DX.tolist()
    DY = DY.tolist()

    LenX = len(X)
    LenY = len(Y)

    visit = [[False] * LenY for _ in range(LenX)]
    visit[x][y] = True
    area = 0
    queue = [(x, y)]

    LineX = [[False] * LenY for _ in range(LenX)]
    LineY = [[False] * LenY for _ in range(LenX)]

    #for x1, x2, y in zip(A, B, C):
    #    for x in range(x1, x2):
    #        LineY[x][y] = True
    for i in range(len(A)):
        y = C[i]
        for x in range(A[i], B[i]):
            LineY[x][y] = True

    #for x, y1, y2 in zip(D, E, F):
    #    for y in range(y1, y2):
    #        LineX[x][y] = True
    for i in range(len(D)):
        x = D[i]
        for y in range(E[i], F[i]):
            LineX[x][y] = True

    LenX -= 1
    LenY -= 1
    
    while queue:
        x, y = queue.pop()
        if x == 0 or x == LenX or y == 0 or y == LenY:
            area = 0
            break
        area += DX[x] * DY[y]
        if not LineX[x][y] and not visit[x - 1][y]:
            visit[x - 1][y] = True
            queue.append((x - 1, y))
        if not LineY[x][y] and not visit[x][y - 1]:
            visit[x][y - 1] = True
            queue.append((x, y - 1))
        if not LineX[x + 1][y] and not visit[x + 1][y]:
            visit[x + 1][y] = True
            queue.append((x + 1, y))
        if not LineY[x][y + 1] and not visit[x][y + 1]:
            visit[x][y + 1] = True
            queue.append((x, y + 1))

    return area


if __name__ == '__main__':
	main()

sys.exit()


Measured memory_bytes: 66100
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<char> S;
	char s;
	cin >> s;
	S.push_back(s);

	for (int i = 0; i < N - 1; ++i) {
		cin >> s;
		if (S[S.size() - 1] != s) {
			S.push_back(s);
		}
	}
	cout << S.size() << endl;

	return 0;
}

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

int main(){
 
  string S;
  cin >> S;
  
  int price = 700;
  
  if(S.at(0) == 'o'){
   price += 100; 
  }
  
  if(S.at(1) == 'o'){
   price += 100; 
  }
  
  if(S.at(2) == 'o'){
   price += 100; 
  }
  
  cout << price << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: i32
    }

    let n_100 = n / 100;
    let n_10 = n / 10 % 10;
    let n_1 = n % 10;

    if n_100 == 7 || n_10 == 7 || n_1 == 7 {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2144
#include <stdio.h>

int main(void){
	while(1){
		int h, w, i, j, x=0, y=0, flag=0;
		char f[101][101];
		int c[101][101] = {0};
		
		scanf("%d %d", &h, &w);
		if(h==0 && w==0) break;
		
		for(i=0; i<h; i++){
			for(j=0; j<w; j++){
				scanf(" %c", &f[i][j]);
			}
		}
		
		while(1){
			//printf("now(x,y)=(%d,%d)\n",x,y);
		
			if(f[x][y] == '.') break; 
			if(c[x][y] == 1) {
				flag=1;
				break;
			}
			c[x][y]=1;
			if(f[x][y] == '>') y++;
			else if(f[x][y] == '<') y--;
			else if(f[x][y] == '^') x--;
			else if(f[x][y] == 'v') x++;
			
		}
		
		if(flag==0) printf("%d %d\n", y, x);
		else printf("LOOP\n");
		
	}
	
	return 0;	
}

Measured memory_bytes: 668
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

class union_find {
private:
	vector<int> uf;

public:
	union_find(int n):uf(n, -1) {}

	inline int find(int x) {
		return uf[x] < 0 ? x : uf[x] = find(uf[x]);
	}

	inline void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y)
			return;

		if(uf[x] > uf[y])
			swap(x, y);

		else if(uf[x] == uf[y])
			--uf[x];

		uf[y] = x;
	}

	inline bool same(int x, int y) {
		return find(x) == find(y);
	}

	inline int number_of_sets() {
		return count_if(uf.begin(), uf.end(), [](int &x){return x < 0;});
	}
};

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

	const int N = 1001;

	static int fibonaccies[N];
	fibonaccies[0] = 1;
	fibonaccies[1] = 2;

	for(int i = 2; i < N; ++i) {
		fibonaccies[i] = (fibonaccies[i - 1] + fibonaccies[i - 2]) % N;
	}

	int v, d;
	while(cin >> v >> d) {
		union_find uf(v + 1);
		for(int i = 1; i <= v; ++i) {
			for(int j = i + 1; j <= v; ++j) {
				if(abs(fibonaccies[i] - fibonaccies[j]) < d)
					uf.unite(i, j);
			}
		}

		cout << uf.number_of_sets() - 1 << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1208