akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    
    HashSet<Integer> rightAnswer = new HashSet<Integer>();
    List<Integer> wrongAnswers = new ArrayList<Integer>();
    for (int i=0; i<n; i++) {
      wrongAnswers.add(0);
    }
    int right = 0;

    int wrongs = 0;
    
    for (int i=0; i<m; i++) {
      int p = sc.nextInt();
      String answer = sc.next();
     
      if (rightAnswer.contains(p)) {
        continue;
      }
      if (answer.equals("WA")) {
        int wrongNum = wrongAnswers.get(p-1);
        wrongNum++;
        wrongAnswers.set(p-1, wrongNum);
      }
      else {
        rightAnswer.add(p);
      }
    }
    
    for (int answer: rightAnswer) {
      wrongs += wrongAnswers.get(answer-1);
    }

    System.out.println(rightAnswer.size() + " " + String.valueOf(wrongs));
  }
}

Measured memory_bytes: 68020
#include<iostream>
#include <math.h>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	
	if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
		cout << A * B;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  vector<int> vec(3);
  for(auto &e: vec)cin>>e;
  sort(vec.begin(), vec.end());
  if((vec[0]==5 && vec[1]==5)&&vec[2]==7)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  if (N < 1000) cout << "ABC"  << endl;
  else cout << "ABD" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

void sieve(vector<int>& prime, int n){
  bool is_prime[n];
  memset(is_prime, 1, sizeof(is_prime));
  for (int i = 2; i <= n; i++) {
    if(is_prime[i] == false)continue;
    prime.push_back(i);
    for(int j = 2*i; j <= n; j += i)is_prime[j] = false;
  }
}

int main(int argc, char *argv[]){
  vector<int> prime;
  sieve(prime, (1<<15) + 1);
  int n;
  while(std::cin >> n, n){
    int ans = 0;
    for (int i = 0; i < prime.size() && prime[i] < n; i++) {
      for (int j = i; j < prime.size(); j++) {
        if(prime[i] + prime[j] > n)break;
        if(prime[i] + prime[j] == n){
         ans++; 
        }
      }
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1280
const fs = require('fs');

// parameter "input" gets all data
function Main(input) {
    const r = parseInt(input);
    // const c = 2 * Math.PI * r;
    const c = 6283 * r;

    //output
    console.log(c / 1000);
}

// Don't edit this line!
Main(fs.readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,K;
  cin>>N>>K;
  vector<ll>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=K;i<N;i++){
    if(A[i-K]>=A[i])cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define INF 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a[3],n,m;
int type[10009];
vector<int> G[10005];
int dist[4][10005];
int id[4][10005];

int main(void){
	scanf("%d%d%d%d",&n,&a[0],&a[1],&a[2]);
	memset(type,-1,sizeof(type));
	for(int i=0;i<3;i++){
		for(int j=0;j<a[i];j++){
			int b;
			scanf("%d",&b);
			b--;
			type[b]=i;
		}
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--;
		v--;
		if(type[u]>=0){
			u=n+type[u];
		}
		if(type[v]>=0){
			v=n+type[v];
		}
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=0;i<3;i++){
		type[n+i]=i;
	}
	for(int i=0;i<3;i++){
		queue<int> que;
		for(int j=0;j<n+3;j++){
			dist[i][j]=INF;
			id[i][j]=j;
			if(type[j]==i){
				dist[i][j]=0;
				que.push(j);
			}
		}
		while(que.size()){
			int v=que.front();
			que.pop();
			for(int k=0;k<G[v].size();k++){
				int nv=G[v][k];
				if(dist[i][nv]==INF){
					dist[i][nv]=dist[i][v]+1;
					id[i][nv]=min(id[i][nv],id[i][v]);
					que.push(nv);
				}else if(dist[i][nv]==(dist[i][v]+1)){
					id[i][nv]=min(id[i][nv],id[i][v]);
				}
			}
		}
	}
	int ans=INF;
	for(int i=0;i<n+3;i++){
		int aa=dist[0][i]+dist[1][i]+dist[2][i];
		ans=min(aa,ans);
	}
	int bes=114514;
	for(int i=0;i<n+3;i++){
		if(type[i]>=0){
			bes=min(bes,i);
		}
		int aa=dist[0][i]+dist[1][i]+dist[2][i];
		if(aa==ans){
			for(int j=0;j<3;j++){
				bes=min(bes,id[j][i]);
			}
		}
	}
	printf("%d %d\n",ans,bes+1);
	return 0;
}


Measured memory_bytes: 9168
#include<stdio.h>

int main()
{
	int N;
	int D, X;
	int a[100];
	int sum = 0;
	int i;
	
	scanf("%d",&N);
	scanf("%d %d",&D,&X);
	for(i=0; i<N; i++){
		scanf("%d",&a[i]);
	}
	
	for(i=0; i<N; i++){
		sum += (D-1)/a[i] + 1;
	}
	
	sum += X;
	
	printf("%d",sum);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    VI v(N);
    bool judge=true;
    rep(i,N){
        cin >> v[i];
    }
    rep(i,N-1){
        if(v[i]!=v[i+1]){
            judge=false;
        }
    }
    if(judge){
        cout << N/2 << endl;
        return 0;
    }
    VI f;
    VI s;
    rep(i,N){
        if(i%2==0){
            f.PB(v[i]);
        }
        else{
            s.PB(v[i]);
        }
    }
    map<int, int> f_count;
    map<int, int> s_count;
    rep(i,f.size()){
        f_count[f[i]]++;
    }
    rep(i,s.size()){
        s_count[s[i]]++;
    }
    VP A,B;
    stl_rep(i,f_count){
        A.PB(pair<ll,ll>(i->S,i->F));
    }
    stl_rep(i,s_count){
        B.PB(pair<ll,ll>(i->S,i->F));
    }
    sort(all(A));
    sort(all(B));
    reverse(all(A));
    reverse(all(B));
    ll A_1=A[0].F, A_2=A[1].F;
    ll B_1=B[0].F, B_2=B[1].F;
    //cout << A_1 << " " << A_2 << " " << B_1 << " " << B_2 << endl;
    unsigned long long ans=INF;
    if(A[0].S!=B[0].S){
        cout << f.size()-A_1+s.size()-B_1 << endl;
    }
    else{
        ans=min(ans,((f.size()-A_1)+(s.size()-B_2)));
        ans=min(ans,((f.size()-A_2)+(s.size()-B_1)));
        cout << ans << endl;
    }
    /*
    ans=min(ans,((f.size()-A_1)+(s.size()-B_1)));
    ans=min(ans,((f.size()-A_1)+(s.size()-B_2)));
    ans=min(ans,((f.size()-A_2)+(s.size()-B_1)));
    ans=min(ans,((f.size()-A_2)+(s.size()-B_2)));
    */
}


Measured memory_bytes: 8052
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename F, typename... R>void input(F& f, R&... r) { cin >> f; input(r...); }
template<typename F, typename... R>void input(vector<F>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

// LCS 最長共通部分列
template<typename T>
ll LCS(const vector<T> &A, const vector<T> &B) {
    int n = A.size(), m = B.size();
    vector<vector<ll>> lcs(n + 1, vector <ll> (m + 1));
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            if (i == 0 || j == 0) {
                lcs[i][j] = 1;
            }
            else if (A[i - 1] == B[j - 1]) {
                lcs[i][j] = (lcs[i][j - 1] + lcs[i-1][j]) % MOD;
            }
            else {
                lcs[i][j] = (lcs[i][j - 1] + lcs[i - 1][j] + MOD - lcs[i-1][j-1]) % MOD;
            }
        }
    }
    return lcs[n][m];
}

int main() {
    int N, M; cin >> N >> M;
    vector<ll> S(N);
    vector<ll> T(M);
    input(S, T);
    cout << LCS(S, T) << endl;;
    getchar(); getchar();
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define M0D 998244353;

int main(){
  int N;
  cin >> N;
  if(N%10==3){
    cout << "bon" <<  endl;
  }else if(N%10==0 ||N%10==1 ||N%10==6 ||N%10==8){
    cout << "pon" <<  endl;
  }else{
    cout << "hon" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
	int N, L[10];
	int Max = 0;
	int sum = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &L[i]);

		if (i == 0) {
			Max = L[0];
		}


		else if (L[i] > Max) {
			sum = sum + Max;
			Max = L[i];
		}
		else //if (L[i] <= L[i - 1]) {
			sum = sum + L[i];
		//}
	}

	if (Max < sum) {
		printf("Yes");
	}
	else
		printf("No");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

bool isInc = false;
vector<int> a;

void check2(int i) {
	for (int k = i; k < a.size() - 1; k++) {
		if (a[k] != a[k + 1]) {
			if (a[k] < a[k + 1]) {
				isInc = true;
			}
			else {
				isInc = false;
			}
			break;
		}
	}
}
signed main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	rep(i, n) {
		int num;
		cin >> num;
		a.pb(num);
	}
	int ans = 0;
	check2(0);
	for (int i = 1; i < a.size(); i++) {
		if (isInc) {
			if (a[i - 1] > a[i]) {
				ans++;
				check2(i);
			}
		}
		else {
			if (a[i - 1] < a[i]) {
				ans++;
				check2(i);
			}
		}
	}
	cout << ans + 1 << endl;
	return 0;
}



Measured memory_bytes: 1400
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n,m;
	cin>>n>>m;
	vi v(m);
	string s[m];
	rep(i,m){
		cin>>v[i]>>s[i];
		// cout<<ans;
	}
	bool vis[n+1];
	bool check[n+1];
	rep(i,n+1){
		vis[i] = false;
		check[i] = false;
	}
	int c1=0;
	int c2 = 0;
	rep(i,m){
		if(s[i] == "AC"){
			check[v[i]] = true;
		}
	}
	rep(i,m){
		if(!vis[v[i]]){
			if(s[i] == "WA"){
				// cout<<i<<"\n";
				if(check[v[i]])c2++;
			}
			else{
				vis[v[i]] = true;
				c1++;
			}
		}
	}
	// rep(i,n+1){
	// 	cout<<vis[i]<<"\n";
	// }
	cout<<c1<<" "<<c2;
	// cout<<m*n - sum;
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int sum=0;
  for(int i=1;i<=n;i++){
    for(int k=1;k<=n;k++){
      for(int j=1;j<=n;j++){
        sum +=gcd(i,gcd(k,j));
      }
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <malloc.h>

int n;
char *b[300];

int main()
{
  int i,x,y,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    b[i] = (char*)malloc(310);
    scanf("%s",b[i]);
  }
  if( n==1 ){
    printf("1\n");
    exit(0);
  }
  for(i=0;i<n;i++){
    int no = 0;
    for(x=1;x<n;x++){
      for(y=0;y<x;y++){
        if( b[(x+i)%n][y] != b[(y+i)%n][x] ){
          no = 1;
          break;
        }
      }
      if( no==1 ) break;
    }
    if( no != 1 ) cnt += n;
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,int> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

int main(){
  ll x,y;
  cin>>x>>y;
  int tmp=0;
  while(x<=y){
    x*=2;
    tmp++;
  }
  cout<<tmp<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int x,y,mx,my,n,s,t,max,l;
  scanf("%d",&n);
  while(n--){
    max=x=y=0;
    while(scanf("%d %d",&s,&t),s||t){
      x+=s;
      y+=t;
      l=x*x+y*y;
      if((max==l&&mx<x)||max<l){
	max=l;
	mx=x;
	my=y;
      }
    }
    printf("%d %d\n",mx,my);
  }
  return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            
            int[] HMHMK = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int H1 = HMHMK[0], M1 = HMHMK[1], H2 = HMHMK[2], M2 = HMHMK[3], K = HMHMK[4];

            int HM1 = 60 * H1 + M1;
            int HM2 = 60 * H2 + M2;
            int total_time = HM2 - HM1;

            if (total_time > K)
            {
                Console.WriteLine(total_time - K);
            }
            else
            {
                Console.WriteLine(0);
            }

            Console.Out.Flush();
        }

    }
}


Measured memory_bytes: 28284
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        var line = Console.ReadLine().Split(' ');
        int A = int.Parse(line[0]);
        int B = int.Parse(line[1]);
        int C = int.Parse(line[2]);
        
        int ans = 0;
        if(A-B<C){
            ans = C-(A-B);
        }
        
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

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

  int n = s.size();
  vector<int> cnt(3, 0); // 0: a, 1: b, 2: c
  for (int i = 0; i < n; i ++) {
    cnt[s[i] - 'a'] ++;
  }

  string ans = "NO";
  if ((abs(cnt[0] - cnt[1]) <= 1) && (abs(cnt[1] - cnt[2]) <= 1) && (abs(cnt[2] - cnt[0]) <= 1)) ans = "YES";
  cout << ans << endl;
}

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

int func(string s,string t){
  int ans=0;
  for (char c = 'a'; c <= 'z'; c++) {
    bool founds=false,foundt=false;
    for (int i = 0; i < s.length(); i++) {
      if(s[i]==c){
        founds=true;
      }
    }
    for (int i = 0; i < t.length(); i++) {
      if(t[i]==c){
        foundt=true;
      }
    }
    if(founds&&foundt) ans++;
  }
  return ans;
}

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans=0;
  for (int i = 0; i <= N; i++) {
    int temp=func(S.substr(0,i),S.substr(i));
    ans=max(ans,temp);
  }
  cout << ans << endl;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

int n;

int main()
{
    vec<int> v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>n;
    n--;
    cout<< v[n];
    return 0;

}




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

bool dp[100009];

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    rep(i,n) cin>>a[i];
    for(int i=0;i<=k;i++){
        for(int j=0;j<n;j++){
           if(i>=a[j])dp[i] |= !dp[i-a[j]];
        }
    }
    cout<<(dp[k] ? "First" : "Second")<<endl;

}

Measured memory_bytes: 3720
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline
    s = input().rstrip()

    has_c = False

    for i, c in enumerate(s):
        if i == 0:
            if c != "A":
                print("WA")
                return
            continue
        if i in list(range(2, len(s) - 1)) and c == "C":
            if has_c:
                print("WA")
                return
            has_c = True
        else:
            if not c.islower():
                print("WA")
                return

    if not has_c:
        print("WA")
        return
    print("AC")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61440
n, k = map(int, input().split())
ans = 0
def func(l, r):
    return (l+r) * (r - l + 1) // 2
for i in range(k, n+2):
    ans += (func(n-i+1, n) - func(0, i-1) + 1) % (10**9 + 7)
print(ans % (10**9 + 7))

Measured memory_bytes: 9148
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll n;cin>>n;
	for(ll i=1;i<10;i++)for(ll j=1;j<10;j++)
	{
		if(i*j==n)
		{
			cout<<"Yes";
			return 0;
		}
	 } 
	 cout<<"No";
	 return 0;
	 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int l, r;
  cin >> l >> r;
  int c = r - l + 1;
  vector<int> num(c);
  for (int i = 0; i < c; i++){
    num[i] = l + i;
  }
  vector<int> cnt(c, 0);
  for (int i = 2; i * i <= r; i++){
    for (int j = (l + i - 1) / i * i; j <= r; j += i){
      while (num[j - l] % i == 0){
        num[j - l] /= i;
        cnt[j - l]++;
      }
    }
  }
  for (int i = 0; i < c; i++){
    if (num[i] > 1){
      cnt[i]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < c; i++){
    bool prime = true;
    if (cnt[i] == 0 || cnt[i] == 1){
      prime = false;
    }
    for (int j = 2; j * j <= cnt[i]; j++){
      if (cnt[i] % j == 0){
        prime = false;
      }
    }
    if (prime){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 10764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  map<char,int> m,a;
  string s;
  cin>>n>>s;
  for(int i=0;i<s.length();++i)a[s[i]]++;
  for(int i=1;i<n;++i){
    cin>>s;
    m.clear();
    for(int j=0;j<s.length();++j)m[s[j]]++;
    for(auto itr=a.begin();itr!=a.end();++itr){
      if(itr->second==0)continue;
      itr->second=min(itr->second,m[itr->first]);
    }
  }
  for(char i='a';i<='z';++i)for(int j=0;j<a[i];++j)cout<<i;
  cout<<"\n";
  return 0;
}

Measured memory_bytes: 256
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <list>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<ll> pqil;
typedef priority_queue<iil> pqiil;
typedef vector<iil> viil;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, ii> iii;
typedef pair<iil, ll> iiil;
typedef vector<pair<pair<int,int>,int> > viii;
typedef vector<pair<pair<ll,ll>,ll> > viiil;
typedef vector<vl> vvl;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 2000000000

ll MOD = 1000000007;

void solve() {
    
    int x;
    cin >> x;
    
    cout << 1 - x << endl;
    
}

void querySolve() {
    int t;
    cin >> t;
    for (int i = 0 ; i < t ; i++) {
        solve();
    }
}

int main() {
    solve();
    //querySolve();
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rdv(type, v, n) vector<type> v(n); rep(__ii, 0, n) cin >> v[__ii]
#define rdm(type, v, h, w) vector<vector<type>>(h, vector<type>(w)) v; rep(__ii, 0, h) rep(__jj, 0, w) cin >> v[__ii][__jj]
#define min_value(type) numeric_limits<type>::min()
#define max_value(type) numeric_limits<type>::max()
typedef long long ll;
void solve();
signed main() {ios::sync_with_stdio(false); cin.tie(0);
  cout << fixed; cout.precision(12); solve(); return 0;}
template<typename T> void prv(vector<T> v) {rep(__ii, 0, sz(v)) {if (__ii) cout << ' '; cout << v[__ii];} cout << '\n';} 
template<typename T> void prm(vector<vector<T>> v) {rep(__ii, 0, sz(v)) {rep(__jj, 0, v[__ii].size()) {if (__jj) cout << ' '; cout << v[__ii][__jj];} cout << '\n';}}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void pr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void pr(const Head& head, const Tail&... tail) {cout << head << ' '; pr(tail...);}
template<typename... T> void err(const T&... cod) {pr(cod...); exit(0);}

void solve() {
  rd(int, n);
  rdv(int, a, n);
  for (int &x : a) x--;
  int d = 0;
  rep(i, 0, n) d += (a[i] != i);
  pr(d <= 2 ? "YES" : "NO");
}

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

int main(){
  string N;
  cin >> N;
  
  if(((N[0]==N[1])&&(N[1]==N[2]))||((N[1]==N[2])&&(N[2]==N[3]))){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	long N = rel();
	long A = rel();
	long B = rel();
	long ans = N / (A+B) * A;
	ans += min(N % (A+B),A);
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
N,A,B = map(int,input().split())
h = [int(input()) for i in range(N)]

l = 0
r = 10**9

while r-l>1:
    tmp = (l+r)//2

    count = 0#Aの処理(A-B)を余ったところに適用していく
    for i in range(N):
        count += max(0,h[i]-B*tmp)//(A-B)
        if max(0,h[i]-B*tmp)%(A-B) != 0:
            count+=1
    
    if tmp >= count:
        r = tmp
    else:
        l=tmp

print(r)

Measured memory_bytes: 80772
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define P2(A)   ((A)*(A))
using namespace std;
typedef long long ll;

int main(){
    int n;
    for(;;){
        scanf("%d\n",&n);
        if(n==0) break;
        vector<double> xs(n),ys(n);
        for(int i=0;i<n;i++){
            scanf("%lf,%lf\n",&xs[i],&ys[i]);
        }
        if(n==1){
            printf("1\n");
            continue;
        }
        int ma=1;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                double mx=(xs[i]+xs[j])/2,my=(ys[i]+ys[j])/2,vlen=sqrt(P2(xs[i]-xs[j])+P2(ys[i]-ys[j])),llen=sqrt(1-(P2(xs[i]-mx)+P2(ys[i]-my)));
                double p1x=mx+(ys[i]-ys[j])*(llen/vlen),p1y=my-(xs[i]-xs[j])*(llen/vlen);
                double p2x=mx-(ys[i]-ys[j])*(llen/vlen),p2y=my+(xs[i]-xs[j])*(llen/vlen);
                int now1=0,now2=0;
                for(int k=0;k<n;k++){
                    if(P2(xs[k]-p1x)+P2(ys[k]-p1y)<=1.00005) now1++;
                    if(P2(xs[k]-p2x)+P2(ys[k]-p2y)<=1.00005) now2++;
                }
                ma=max(now1,ma);
                ma=max(now2,ma);
            }
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 980
X = int(input())
pt1000 = 0
pt5 = 0

if X >= 500:
    while X >= 500:
        X = X - 500
        pt1000 += 1
    while X >= 5:
        X = X-5
        pt5 += 1
else:
    while X >= 5:
        X = X-5
        pt5 += 1

print(pt1000*1000 + pt5*5)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int w,h,c;
	int max;
	int[][] panel;
	void run() {
		while (true) {
			h = sc.nextInt();
			w = sc.nextInt();
			c = sc.nextInt();
			if (w == 0 && h == 0 && c == 0) break;
			panel = new int[h+2][w+2];
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) panel[i][j] = sc.nextInt();
			max = 0;
			BFS( 0 );
			System.out.println(max);
		}
		
	}
	
	int dx[] = {-1,0,1,0};
	int dy[] = {0,-1,0,1};
	
	int cntColor( int color, int chclr, int x, int y ) {
//		for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
//			System.out.print(panel[i][j] + " ");
//			if (j==w)System.out.println();
//		}
//		System.out.println();
		
		int cnt=1;
		if( panel[y][x] != color )return 0;
		panel[y][x] = chclr;
		for(int i=0;i<4;i++) {
			if( panel[y+dy[i]][x+dx[i]] == color ) 
				cnt += cntColor( color, chclr, x+dx[i], y+dy[i]);
		}
		return cnt;
	}
	
	void BFS( int cnt ) {
		if( cnt == 5 ) {
//			System.out.println(panel[1][1] + " " + c);
			if( panel[1][1] == c ) {
//				printMap();
//				System.out.println();
				max = Math.max(max, cntColor(c,0,1,1));
			}
			return;
		}
		int[][] tmp = new int[h+2][w+2];
		for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){
			tmp[i][j] = panel[i][j];
//			System.out.print(tmp[i][j] + " ");
//			if (j==w)System.out.println();
		}
		
		for(int i=1;i<=6;i++) {
			if(panel[1][1] != i)
				cntColor( panel[1][1], i, 1, 1 );
			BFS( cnt+1 );
			for(int j=1;j<=h;j++) for(int k=1;k<=w;k++)
				panel[j][k] = tmp[j][k];
		}
	}
	
	public void printMap(){
		for(int i=1;i<=h;i++) {
			for (int j=1;j<=w;j++) System.out.print(panel[i][j] +" ");
			System.out.println();
		}
	}
	
	public static void main( String[] args ) {
		new Main().run();
	}
}

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

int main(){
    using namespace std;
    size_t N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<unsigned long>> train(N, vector<unsigned long>(N));
    for(size_t i = 0, L, R; i < M; ++i){
        cin >> L >> R;
        ++train[--L][--R];
    }
    for(auto& i : train)partial_sum(i.begin(), i.end(), i.begin());
    for(size_t i = N - 1; i--; )for(size_t j = 0; j < N; ++j)train[i][j] += train[i + 1][j];
    for(size_t i = 0, p, q; i < Q; ++i){
        cin >> p >> q;
        cout << train[--p][--q] << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


int func(int x)
{
	int tmp = 0;
	while (x)
	{
		tmp += x%10;
		x /= 10;
	}

	return tmp;
}

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

	ll ans = BIGLL;
	for (int a=1;a<=N-1;a++)
	{
		int b = N - a;

		ll tmp = func(a) + func(b);

		amin(ans, tmp);


	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  int N, K, A;
  cin >> N >> K;
  A = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x <= (K - x)) {
      A += (x * 2);
    }
    else {
      A += ((K - x) * 2);
    }
  }
  cout << A << endl;
}


Measured memory_bytes: 3612
import java.util.Scanner;
import java.util.ArrayList;

class Main {
   public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int i;
        ArrayList<Character> al = new ArrayList<Character>();
        ArrayList<Character> il = new ArrayList<Character>();
        char c;

        for (char cc : s.toCharArray())
            al.add(cc);
        for (i = 0; i < al.size(); i++) {
            c = al.get(i);
            switch(c) {
                case '0':
                case '1':
                    il.add(c); break;
                default:
                    if ((il.size() > 0))
                        il.remove(il.size()-1);
                    break;
            }
        }
        for (i = 0; i < il.size(); i++)
            System.out.printf("%c", il.get(i));
        System.out.printf("\n");
    }
}


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

int main(){
    int a[15];
    for(int i=0;i<10;++i){
        cin>>a[i];
    }
    sort(a,a+10);
    for(int i=9;i>6;--i){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	if (N==7 || N==5 || N==3){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323
#define nu          pair<ll,pll>



void solve()
{
       ll n,a,b;
       cin>>n>>a>>b;
       ll ans=min(n*a,b);
       cout<<ans<<endl;
}



int main() {
	ll T = 1;
	//speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}
ll dp[100010][13] = {0};
void solve(std::string S)
{
    for (int i = 0; i < S.size(); i++)
    {
        if (i != 0)
        {
            if (S[i] == '?')
            {
                for (int k = 0; k < 10; k++)
                {
                    for (int j = 0; j < 13; j++)
                    {
                        dp[i][(j * 10 + k) % 13] += dp[i - 1][j] % MOD;
                        dp[i][(j * 10 + k) % 13] %= MOD;
                    }
                }
            }
            else
            {
                int number = S[i] - '0';
                for (int j = 0; j < 13; j++)
                {
                    dp[i][(j * 10 + number) % 13] += dp[i - 1][j];
                    dp[i][(j * 10 + number) % 13] %= MOD;
                }
            }
        }
        else
        {
            if (S[i] == '?')
            {
                for (int j = 0; j < 10; j++)
                {
                    dp[i][j] = 1;
                }
            }
            else
            {
                dp[i][S[i] - '0'] = 1;
            }
        }
    }

    cout << dp[S.size() - 1][5] << endl;
}

int main()
{
    std::string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 10624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int n;
  string s;
  int cnt = 0;
  cin >> n >> s;
  rep(i, 10) rep(j, 10) rep(k, 10) {
    int now = 1;
    for(char x : s) {
      int xint = x - '0';
      if (now == 1 && i == xint) now = 2;
      else if (now == 2 && j == xint) now = 3;
      else if (now == 3 && k == xint) {
        cnt++;
        break;
      }
    }
  };
  cout << cnt << endl;
}


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

using namespace std;

int main(){
	int q;
	double xn1,xn;

	while(cin>>q){
		if(q==-1)break;
		xn = q/2.0;
		while(true){
			xn1 = xn - ( (xn*xn*xn - q)/(double)(3*xn*xn) );
			if(fabs(xn1*xn1*xn1 - q)<=0.00001*q){
				break;
			}
			xn = xn1;
		}
		printf("%.6f\n",xn1);
	}
	return 0;
}

/*
Sample Input
15
15
-1
Output for the Sample Input
2.466212
2.466212
*/

Measured memory_bytes: 1192
import java.util.Scanner;
     
    class Main{
     
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            String S = sc.nextLine();
            String T = "";
            String[] str = {"dream","dreamer","erase","eraser"};
     
            
            S = S.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "");
     
            if( S.equals("")){
                System.out.println("YES"); 
            }else{
                System.out.println("NO");
            }
            
        }
    }

Measured memory_bytes: 30396
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
sel = [0 for i in range(365)]

day = [[0 for i in range(26)] for j in range(365)]
ans = 0
for i in range(d):
	s.append(l())
	ss = [[s[-1][i],i+1] for i in range(26)]

	ak = 0

	for j in range(26):
		if i != 0:
			ak -= c[j] * (i-day[i-1][j]+1)
		else:
			ak -= c[j]

	ma = [-1,-1]
	for j in range(26):
		if i != 0:
			if ma[0] <= c[j] * (i-day[i-1][j]+1) + s[-1][j]:
				ma[0] = c[j] + (i-day[i-1][j]+1) + s[-1][j]
				ma[1] = j
		else:
			if ma[0] <= c[j] + s[-1][j]:
				ma[0] = c[j] + s[-1][j]
				ma[1] = j
	ans += ma[0] + ak
	sel[i] = ma[1]



for _ in range(140000):
	ima = random.randrange(365)
	po = [[s[ima][i]-c[i],i+1] for i in range(26)]
	po.sort(reverse = True)
	while True:
		data = random.randrange(10)
		if sel[ima] != data+1:
			break
	data = po[data][1]-1
	ppp = 0
	for i in range(26):
		if ima == day[ima][i]:
			now = i
			break
	else:
		while True:
			now = random.randrange(26)
			if now != data:
				break 
	for i in range(ima+1,365):
		if day[i][data] == i:
			ppp += (i - ima) * c[data]
			break
	else:
		ppp += (364-ima) * c[data]

	for i in range(ima+1,365):
		if day[i][now] == i:
			ppp -= (i - ima) * c[now]
			break
	else:
		ppp -= (364-ima) * c[now]
	if ppp > 0:
		for i in range(ima,365):
			if day[i][data] != i:
				day[i][data] = ima
			else:
				break
		po = ima - 1 if ima != 0 else 0
		for i in range(ima,365):
			if day[i][now] != i:
				day[i][now] = po
			else:
				break
		sel[ima] = data+1
		ans += ppp

for i in sel:
	print(i)


Measured memory_bytes: 84720
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
const int maxn = 1e5+5;
char a[maxn], b[maxn];

int main(){
	int n; cin >> n;
	scanf("%s",a);
	int len = strlen(a), cnt = 0;
	b[++cnt] = a[0];
	for(int i = 1; i < n; i++){
		if(a[i] != b[cnt]) b[++cnt] = a[i];
	}
	cout << cnt;
}

Measured memory_bytes: 384
N = int(raw_input())
U = [raw_input() for _ in range(N)]

M = int(raw_input())
T = [raw_input() for _ in range(M)]

msg = ["Opened by {}", "Closed by {}", "Unknown {}"]
cnt = 0
for t in T:
    if t in U:
        print msg[cnt%2].format(t)
        cnt += 1
    else:
        print msg[2].format(t)


Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

int main(){
    int n; cin>>n;
    vector<int> d(n);
    rep(i,n) cin>>d[i];
    ll ans=0;
    rep(i,n){
        rep(j,n){
            if(i<j) ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

typedef long long number;
typedef vector<number> vec;
typedef vector<vec> matrix;

const int MOD = 1e9+9;

// O( n )
matrix Identity(int n) {
    matrix A(n, vec(n));
    for (int i = 0; i < n; ++i) A[i][i] = 1;
    return A;
}
// O( n^3 )
matrix mul(const matrix &A, const matrix &B) {
    matrix C(A.size(), vec(B[0].size()));
    for (int i = 0; i < (int)C.size(); ++i)
        for (int j = 0; j < (int)C[i].size(); ++j)
            for (int k = 0; k < (int)A[i].size(); ++k) {
                C[i][j] += A[i][k] * B[k][j];
                C[i][j] %= MOD;
            }
    return C;
}
// O( n^3 log e )
matrix pow(const matrix &A, ll e) {
    if (e == 0) return Identity(A.size());
    if (e == 1) return A;
    if (e % 2 == 0) {
        matrix tmp = pow(A, e/2);
        return mul(tmp, tmp);
    } else {
        matrix tmp = pow(A, e-1);
        return mul(A, tmp);
    }
}
// O(n)
number tr(const matrix &A) {
    number ans = 0;
    for (int i = 0; i < (int)A.size(); ++i)
        ans += A[i][i];
    return ans;
}
// O( n )
number inner_product(const vec &a, const vec &b) {
    number ans = 0;
    for (int i = 0; i < (int)a.size(); ++i)
        ans += a[i] * b[i];
    return ans;
}
// O( n^2 )
vec mul(const matrix &A, const vec &x) {
    vec y(A.size());
    for (int i = 0; i < (int)A.size(); ++i)
        for (int j = 0; j < (int)A[0].size(); ++j)
            (y[i] += (A[i][j] * x[j] % MOD)) %= MOD;
    return y;
}


const int MAXN = 33;
int W, N;
ll H;

ll solve() {
	vector<pair<ll, int> > P(N);
	for (int i = 0; i < N; i++) {
		cin >> P[i].second >> P[i].first;
		P[i].first--; P[i].second--;
	}
	sort(P.begin(), P.end());
	vec v(W);
	v[0] = 1;
	ll now = 0;
	for (int i = 0; i < N; ) {
		matrix mat(W, vec(W));
		for (int j = 0; j < W; j++) {
			if (j-1 >= 0) mat[j][j-1] = 1;
			mat[j][j] = 1;
			if (j+1 < W) mat[j][j+1] = 1;
		}
		v = mul(pow(mat, P[i].first-now), v);
		now = P[i].first;
		int ni = i;
		while (ni < N && P[i].first == P[ni].first)
			ni++;
		for (int j = i; j < ni; j++)
			v[P[j].second] = 0;
		i = ni;
	}
	matrix mat(W, vec(W));
	for (int i = 0; i < W; i++) {
		if (i-1 >= 0) mat[i][i-1] = 1;
		mat[i][i] = 1;
		if (i+1 < W) mat[i][i+1] = 1;
	}
	v = mul(pow(mat, H-1-now), v);
	return v[W-1];
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int t = 1; ; t++) {
		cin >> W >> H >> N;
		if (W == 0) break;
		cout << "Case " << t << ": " << solve() << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
n=int(input())
a = list(map(int,input().split()))
b=0 in a
c=1
d=0
for i in range(n):
    c=c*a[i]
    if c>1000000000000000000:
        d=1
        break
    
if c<=1000000000000000000:
    print(c)
if d==1:
    if b==True:
        print("0")
    else:
        print("-1")

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

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans;
  REP(x, K+1) {
    int tmp = S - x;
    if ( tmp < 0 ) {
      break;
    } else if ( tmp > K * 2 ) {
      continue;
    } else {
      ans += tmp + 1 - 2 * max(tmp - K, 0);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    string s,t; cin >> s >> t;
    ll res = 100000000;
    rep(i,s.size() - t.size()+1){
        ll sum = 0;
        for(ll j = 0;j < t.size();j++){
            if(s[i+j] != t[j])sum++;
        }
        res = min(res,sum);
    }
    cout << res << endl;
}

Measured memory_bytes: 3648