akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,n) for(int j=0;j<n;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef vector< vector < int> > vee;
typedef vector<pair<ll,ll> > vepa;
typedef set<int>se;
typedef map<int,int> mpp;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N];
bool visited[N]={};
ll cnt[N],freq[N];
bool f,ff;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);

  ll n,k;
  cin>>n>>k;
  ll ans=n%k;
  ll sol=abs(ans-k);
  cout<<min(ans,sol);
go;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
long long f[100007]={2,1};
int main()
{
	cin>>n;
	for(int i=2;i<=n;++i)
		f[i]=f[i-1]+f[i-2];
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c,d,h,i,j,k,l,m,n,o,p,q,r,s;
int joho[4][3][10];
for(i=0;i<4;i++){
for(s=0;s<3;s++){
for(m=0;m<10;m++){
joho[i][s][m]=0;
}
}
}
scanf("%d",&n);
for(h=0;h<n;h++){
scanf("%d %d %d %d",&a,&b,&c,&d);
joho[a-1][b-1][c-1]+=d;
}
for(i=0;i<4;i++){
for(s=0;s<3;s++){
for(m=0;m<10;m++){
printf(" %d",joho[i][s][m]);
}
printf("\n");
}
if(i!=3)
printf("####################\n");
}
return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <limits.h>

int ChainOrder(int []);

int n, p[100];

int main(){
  int i, val;

  scanf("%d", &n);

  for(i = 0; i < n; i++) scanf("%d%d", &p[i], &p[i+1]);

  val = ChainOrder(p);

  printf("%d\n", val);
  
  return 0;
}

int ChainOrder(int p[]){
  int i, l, j, k, q, m[100][100];

  for(i = 1; i <= n; i++) m[i][i] = 0;

  for(l = 2; l <= n; l++){
    for(i = 1; i <= n-l+1; i++){
      j = i+l-1;
      m[i][j] = INT_MAX;
      for(k = i; k <= j-1; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	m[i][j] = (m[i][j] < q ? m[i][j] : q);
      }
    }
  }
  return m[1][n];
}

Measured memory_bytes: 632
a, b = map(int, input().split())
s = input()

no = 0
for i in range(len(s)) :
    if i == a :
        if s[i] != "-" :
            no = 1
    else :
        if s[i] == "-" :
            no = 1

if no == 1 :
    print("No")
else :
    print("Yes")


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    while(true){
        int x, y, s;
        cin >> x >> y >> s;
 
        if(x==0 && y==0 && s==0)
            break;
 
        int tmax = -1;
 
        for(int a=1; a<=s-1; a++){
            int ax = a*(100+x)/100;
            int ay = a*(100+y)/100;
 
            for(int b=1; b<=s-1; b++){
                int bx = b*(100+x)/100;
                int by = b*(100+y)/100;
 
                if(ax+bx==s){
                    tmax = max(tmax, ay+by);
                }
                else if(ax+bx>s){
                    break;
                }
            }
        }
 
        cout << tmax << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
const int INF = 1001001001;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define re0 return 0

int npr(int n , int r){//nPr
    r = n - r;
    int sum = 1;
    int i;
    for (i=n;i>=r+1;i--)sum*=i;
    return sum;
}
int gcd(int a, int b) {//最大公約数
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
    return a * b / gcd(a, b);
}
int digsum(int n) {//桁和
    int res = 0;
    while(n > 0) {
        //res += n%10;
        //　↑をres++;にすれば桁数
         res++;
        n /= 10;
    }
    return res;
}
bool isPrime(int x){//素数
    if(x==1)return 0;
    if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i++)if(x%i==0)return 0;
    return 1;
}
/*bit全探索
for (int bit = 0; bit < (1<<N); ++bit) {
}
if (bit & (1 << i)) {
}
*/


signed main(){ 
    ll a,b;
    cin >> a >> b;
    if(a>0 && b>=a){
        cout << "Positive" <<endl;
    }else if(a<=b && b<0){
        if((abs(a)-abs(b)+1)%2!=0){
            cout << "Negative" <<endl;    
        }else{
            cout << "Positive" <<endl;
        }
    }else if(a<=0 && 0<=b){
        cout << "Zero" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 文字列の入力
    s <- filter (`elem` ['0'..'9']) <$> getLine
    let ps = subsequences [1..(length s - 1)]
    -- 出力
    putStrLn . show $ solve s ps

solve :: String -> [[Int]] -> Integer
solve s = sum . map (sum . map read . mulSplit s)

mulSplit :: String -> [Int] -> [String]
mulSplit s [] = [s]
mulSplit s (i:ix) = (take i s) : (mulSplit (drop i s) (map (subtract i) ix))


Measured memory_bytes: 892
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N,K;
int A[200001];

int main() {
  INCANT;
  cin >> N >> K;
  rep(i, N) cin >> A[i];
  rep(i, N-K) {
    if (A[i] < A[i+K]) {
      cout << "Yes";
    } else cout << "No";
    cout << endl;
  }
  return 0;
}

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

string S;
int c = 0;

void solve(){
    for(int i = 0; i<S.length();i++){
        if(S[i] == '+'){
            c++;
        }
        else{
            c--;
        }
    }
    cout << c << endl;
}

int main(){
    cin >> S;
    solve();
}

Measured memory_bytes: 256
//Trick or Treat

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int N,K;cin>> N>>K;
    vector<vector<int>> A(K);
    rep(i,0,K){
        int d;cin>>d;
        rep(j,0,d){
            int c;cin>>c;
            A[i].push_back(c);
        }
    }
    map<int,int> m{};
    rep(i,0,K){
        rep(j,0,A[i].size()){
            int c = A[i][j]-1;
            m[c]++;
        }
    }
    int ans = 0;
    rep(i,0,N)if(m[i]==0)ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = S()
    r = 0
    for c in n:
        if c == '2':
            r += 1

    return r


print(main())


Measured memory_bytes: 5456
#include <stdio.h>

int main()
{
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if((a + b + c == a * 2) || (a + b + c == b * 2) || (a + b + c == c * 2))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
struct edge {
  ll to, cost;
};

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }

  sort(begin(ret), end(ret));
  return (ret);
}

// Sieve of Eratosthenes
// (*this)[i] = (divisor of i, greater than 1)
// Example: [0, 1, 2, 3, 2, 5, 3, 7, 2, 3, 2, 11, ...]
// Complexity: Space O(MAXN), Time (construction) O(MAXNloglogMAXN)
struct SieveOfEratosthenes : std::vector<int> {
  std::vector<int> primes;
  SieveOfEratosthenes(int MAXN) : std::vector<int>(MAXN + 1) {
    std::iota(begin(), end(), 0);
    for (int i = 2; i <= MAXN; i++) {
      if ((*this)[i] == i) {
        primes.push_back(i);
        for (int j = i; j <= MAXN; j += i) (*this)[j] = i;
      }
    }
  }
  using T = long long int;
  // Prime factorization for x <= MAXN^2
  // Complexity: O(log x)          (x <= MAXN)
  //             O(MAXN / logMAXN) (MAXN < x <= MAXN^2)
  std::map<T, int> Factorize(T x) {
    assert(x <= 1LL * (int(size()) - 1) * (int(size()) - 1));
    std::map<T, int> ret;
    if (x < int(size())) {
      while (x > 1) {
        ret[(*this)[x]]++;
        x /= (*this)[x];
      }
    }
    else {
      for (auto p : primes) {
        while (!(x % p)) x /= p, ret[p]++;
        if (x == 1) break;
      }
      if (x > 1) ret[x]++;
    }
    return ret;
  }
  std::vector<T> Divisors(T x) {
    std::vector<T> ret{1};
    for (auto p : Factorize(x)) {
      int n = ret.size();
      for (int i = 0; i < n; i++) {
        for (T a = 1, d = 1; d <= p.second; d++) {
          a *= p.first;
          ret.push_back(ret[i] * a);
        }
      }
    }
    return ret; // Not sorted
  }
  // Moebius function Table
  // return: [0=>0, 1=>1, 2=>-1, 3=>-1, 4=>0, 5=>-1, 6=>1, 7=>-1, 8=>0, ...]
  std::vector<int> GenerateMoebiusFunctionTable() {
    std::vector<int> ret(size());
    for (int i = 1; i < int(size()); i++) {
      if (i == 1) ret[i] = 1;
      else if ((i / (*this)[i]) % (*this)[i] == 0) ret[i] = 0;
      else ret[i] = -ret[i / (*this)[i]];
    }
    return ret;
  }
};
SieveOfEratosthenes sieve(1000000);

int main() {
  int N; cin >> N;
  ll ans = 0;
  for(int i = 1; i < N; ++i) {
    int tmp = N - i;
    auto x = sieve.Divisors(tmp);
    ans += x.size();
  }
  cout << ans << endl;
}

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

int main() 
{
    int N;
    cin >> N;
  
    for(int i = 0; i < N; i++){
      int a;
      cin >> a;
      if(0 == (a & 1) && (0 != (a % 3) && 0 != (a % 5))){
        cout << "DENIED" << endl;
        return 0;
      }
    }
    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c = map(int, input().split())
k = int(input())

while k:
    if a>=b:
        b *= 2
        k -= 1
    elif b>=c:
        c *= 2
        k -= 1
    else:
        break

if a<b and b<c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S; cin >> S;
  int N = S.size();
  int res = 0;
  REP(i, N){
    res += S[i]-'0';
  }
  if(res%9 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3736
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e12

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    ll A[N],B[N],C[N];
    ll dp[N][3];
    
    for(ll i=0;i<N;++i)
    {   
        cin>>A[i]>>B[i]>>C[i];
        
        dp[i][0] = A[i] + ((i > 0) ? max(dp[i - 1][1],dp[i - 1][2]) : 0);
        dp[i][1] = B[i] + ((i > 0) ? max(dp[i - 1][0],dp[i - 1][2]) : 0);
        dp[i][2] = C[i] + ((i > 0) ? max(dp[i - 1][0],dp[i - 1][1]) : 0);
    }
    
    ll ans = dp[N - 1][0];
    ans = max(ans,dp[N - 1][1]);
    ans = max(ans,dp[N - 1][2]);
    
    cout<<ans<<endl;
}

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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int s,w;
        cin>>s>>w;
        if(w>=s)
            cout<<"unsafe";
        else
            cout<<"safe";
        return 0;
    }


Measured memory_bytes: 3612
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;

int main()
{
  int N;

  cin >> N;

  vector<int> H(N);

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

  int mx = H[0];

  int cnt = 1;

  FOR(i,1,N)
    {
      
      if( mx <= H[i] )
	{
	  ++ cnt;

	  mx = H[i];
	  
	}

      
    }

  cout << cnt << endl;
  
  

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, s, t;
  in2(a, b);
  in2(s, t);
  rep(i, s - a)
    out('R');
  rep(i, t - b)
    out('U');
  rep(i, s - a)
    out('L');
  rep(i, t - b + 1)
    out('D');
  rep(i, s - a + 1)
    out('R');
  rep(i, t - b + 1)
    out('U');
  out('L');
  out('U');
  rep(i, s - a + 1)
    out('L');
  rep(i, t - b + 1)
    out('D');
  out('R');
  memi;
}

Measured memory_bytes: 256
import itertools

N, M, X = list(map(int, input().split()))
C = []
A = []

for i in range(N):
    input_line = list(map(int, input().split()))
    C.append(input_line[0])
    A.append(input_line[1:])

flag_i = False
min_cost = 10**7

for i in range(1, N+1):
    comb_list = list(itertools.combinations(range(N), i))
    
    for comb in comb_list:
        know = [0] * M
        cost = 0
        for book in comb:

            for i in range(M):
                know[i] += A[book][i]
            cost += C[book]
        
        #達成チェック
        flag = True
        for i in range(M):
            if (know[i] < X):
                flag = False
              
        
        if (flag):
            flag_i = True
            
            if (min_cost > cost):
                min_cost = cost
if (flag_i):
    print(min_cost)
    exit(0)

print(-1)

        


Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
int arr[100005];
int sum[100005];
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int d=a/c;
	int e=b/c;
	if(a%c==0)
	printf("%d\n",e-d+1); 
	else
	printf("%d\n",e-d);
}

Measured memory_bytes: 3808
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 15 20:54:34 2019

@author: Yamazaki Kenichi
"""

N = int(input()) 
A = list(map(int,input().split()))

A.sort()

for near0 in range(N):
    if A[near0] > 0:
        break

if near0 != 0:
    near0 -= 1

tmp = A[near0]
T = []
for i in range(near0+1,N-1):
    T.append([tmp,A[i]])
    tmp = tmp - A[i]

T.append([A[N-1],tmp])
tmp = A[N-1] - tmp
for i in range(near0):
    T.append([tmp,A[i]])
    tmp = tmp - A[i]

print(tmp)
for t in T:
    print(' '.join(map(str,t)))


Measured memory_bytes: 22172
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
s = input()
sl = []
for i in range(len(s)):
    sl.append(s[i])

Al = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
al = 'abcdefghijklmnopqrstuvwxyz'

for i in range(len(Al)):
    if sl[k-1] == Al[i]:
        sl[k-1] = (al[i])


print(''.join(sl))

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

const int N = 3e5;

int n, a[N];
vector <int> lst[30];
int64_t ans = 0;

main() {
    cin >> n;
    rep(i, 1, n + 1) scanf("%d", &a[i]);
    rep(j, 0, 30) {
        lst[j].push_back(0);
        lst[j].push_back(0);
    }
    rep(i, 1, n + 1) {
        rep(j, 0, 30) {
            if ((a[i]>>j) & 1) {
                lst[j].push_back(i);
            }
        }
        int l = 0;
        rep(j, 0, 30) {
            l = max(l, lst[j][(int)lst[j].size() - 2]);
        }
        ans += i - l;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 8944
A = int(input())
C = list(map(int, input().split()))
cnt = 0
for i in range(A-2):
    q = 0
    w = 0
    e = 0
    q = C[i]
    w = C[i + 1]
    e = C[i + 2]
    if q < w < e or e < w < q:
        cnt += 1

print(cnt)
        


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    char s[500005];
    ll n,ans=0;
    scanf("%s",s);
    n=strlen(s);
    // ll r=0,now=0;
    // rep(i,0,n){
    //     if(s[i]=='<'){
    //         if(r==0){
    //             ans+=now;
    //             now++;
    //         }else{
    //             ans+=now;
    //             if(now<0) r++;
    //             ans-=r*(now-0);
    //             r=0;
    //             now=1;
    //         }
    //     }else{
    //         ans+=now;
    //         r++;
    //         now--;
    //     }
    // }
    // if(s[n-1]=='<'){
    //     ans+=now;
    // }else{
    //     ans+=now;
    //     if(now<0) r++;
    //     ans-=r*(now-0);
    // }

    ll l[n+1],r[n+1];
    l[0]=0;
    r[n]=0;
    rep(i,0,n){
        if(s[i]=='<'){
            l[i+1]=l[i]+1;
            // r[i]=0;
        }else{
            l[i+1]=0;
            // r[i]=r[i]+1;
        }
    }
    rrep(i,n-1,0){
        if(s[i]=='>'){
            r[i]=r[i+1]+1;
        }else{
            r[i]=0;
        }
    }
    rep(i,0,n+1){
        ans+=max2(l[i],r[i]);
    }


    printf("%lld\n",ans);
    return 0;
}


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

//最大公約数の計算(ユークリッドの互除法)
long long int gcd(long long int a, long long int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
    return a / gcd(a, b) * b;
}

int main() {
    int m, n;
    cin >> n >> m;
    vector<lint> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }
    lint l = 1;
    for (int i = 0; i < n; i++) {
        l = lcm(l, a[i]);
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if ((l / a[i]) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    lint ans = m / l - m / (2 * l);
    cout << ans << endl;
}

Measured memory_bytes: 1024
// AtCoder Grand Contest 019
// B - Reverse and Compare

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


void manachar(const string &str, vector<int> &res) {
    string s(str.size() * 2 + 3, '_');
    int d;

    s[0] = '^';
    s[str.size() * 2 + 2] = '$';
    for (int i = 0; i < (int)str.size(); i++) {
        s[2 * i + 2] = str[i];
    }
    cout << s << endl;

    res.clear();
    res.resize(s.size(), 0);
    for (int c = 1; c < (int)s.size() - 1; c += d) {
        for (; s[c - res[c] - 1] == s[c + res[c] + 1]; res[c]++) {}
        for (d = 1; d <= res[c]; d++) {
            if (res[c - d] == res[c] - d) {
                res[c + d] = res[c] - d;
                break;
            }
            res[c + d] = min(res[c] - d, res[c - d]);
        }
    }

    return;
}


const int AZ = 26;

string A;
int N;
int cnt[AZ];

int main() {

    ll ans;

    cin >> A;
    N = A.size();
    memset(cnt, 0, sizeof(AZ));
    for (int i = 0; i < N; i++) {
        cnt[A[i] - 'a']++;
    }

    ans = (ll)N * (N - 1LL) / 2LL + 1;
    for (int i = 0; i < AZ; i++) {
        if (cnt[i] < 2) {
            continue;
        }
        ans -= (ll)cnt[i] * (cnt[i] - 1LL) / 2LL;
    }

    cout << ans << endl;

    return 0;

}



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

int main()
{
  int X, A, B;
  cin >> X >> A >> B;
  
  string ans;
  if (A >= B) ans = "delicious";
  else if (B - A <= X) ans = "safe";
  else ans = "dangerous";
  
  cout << ans << endl;
}

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

int main(){

  while(1){
    int h,w;cin >> h >> w;
    if(h==0) break;
    for(int i=0; i<h; i++){  
      for(int j=0; j<w; j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;

  }


}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>

long modpow(long a, long n, long mod){
  long size;
  for (long i = 1; ; i++) {
    if (pow(2,i) > n) {
      size = i;
      break;
    }
  }
  long bit[size];
  bit[0] = n;
  for (long i = 1; i < size; i++) {
    bit[i] = bit[i-1]/2;
    bit[i-1] %= 2;
  }
  long powa[size];
  powa[0] = a;
  for (long i = 1; i < size; i++) {
    powa[i] = powa[i-1]*powa[i-1];
    powa[i] %= mod;
  }
  long answer = 1;
  for (long i = 0; i < size; i++) {
    if (bit[i] == 1) {
      answer *= bit[i]*powa[i];
      answer %= mod;
    }
  }
  return answer;
}
long modCombination(long n, long r, long mod) {
  long answer;
  if (n-r < r) {
    r = n-r;
  }
  long nu = 1;
  long de = 1;
  for (long i = 1; i <= r; i++) {
    nu *= n+1-i;
    nu %= mod;
    de *= i;
    de %= mod;
  }
  answer = nu;
  answer *= modpow(de,mod-2,mod);
  answer %= mod;
  return answer;
}

int main(void) {

  long x,y;
  scanf("%ld %ld", &x, &y);
  long mod = pow(10,9)+7;
  if ((x+y)%3 != 0) {
    printf("0\n");
    return 0;
  }
  long move = (x+y)/3;
  if (x < move || y < move) {
    printf("0\n");
    return 0;
  }
  long move_a = y-move;
  if (move_a < 0) {
    printf("0\n");
    return 0;
  }
  printf("%ld\n", modCombination(move,move_a,mod));

  return 0;
}

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

int main()
{
	stack<char> x;
	string a;
	char ex='T';
	cin >> a;
	for(int i=0;i<a.length();i++)
	{
		x.push(a[i]);
		if (ex == 'S' && x.top() == 'T')
		{
			x.pop();
			x.pop();
		}
		if (x.size() == 0)ex = 'T';
		else
			ex = x.top();
	} 
	cout << x.size () << endl;
	return 0;
}


Measured memory_bytes: 3472
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;

int main(){
    int n,m,a,b,c;
    vector<pair<int, int> > vec;
    vector<int> arr;

    cin >> n >> m;
    for(int i=0;i<n;i++) {
        cin >> a;
        arr.push_back(a);
    }

    for(int i=0;i<m;i++){
        cin >> b >> c;
        pair<int, int> p = make_pair(c,b);
        vec.push_back(p);
    }

    sort(vec.begin(), vec.end());
    int acc = 0;
    for(int i=vec.size()-1;i>=0;i--) {
        for(int j=0;j<vec[i].second;j++){
            arr.push_back(vec[i].first);
        }
        acc += vec[i].second;
        if(acc > n) break;
    }

    sort(arr.begin(), arr.end(), greater<int>());
    long long int ans = 0;
    for(int i=0;i<n;i++){
        ans += arr[i];
    }

    cout << ans << endl;

}




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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

ll n,k,a[5005];
bool dp[5005];

bool ok(ll x){
  memset(dp,0,sizeof(dp));
  dp[0]=true;
  rep(i,n)for(ll j=k;j>=0;j--){
    if(i==x)continue;
    if(j+a[i]<=k&&dp[j])dp[j+a[i]]=true;
  }
  repl(i,max(0LL,k-a[x]),k){
    if(dp[i])return true;
  }
  return false;
}

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>k;
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  ll lb=-1,ub=n;
  rep(hoge,13){
    ll mid=(lb+ub)/2;
    if(ok(mid))ub=mid;
    else lb=mid;
  }
  cout<<ub<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int main(void){
    // Your code here!
    int N,L,sum = 0,max = -1;
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%d",&L);
        sum += L;
        if(max < L) max = L;
    }
    printf("%s\n",(sum-max > max)? "Yes":"No");
}


Measured memory_bytes: 128
tmp = [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]

n = int(input())

print(tmp[n-1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

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

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

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  vector<unsigned long long> t(N);
  for (int i = 0; i < N; ++i) {
    cin >> t[i];
  }

  if (N == 1) {
    cout << t[0] << endl;
    return 0;
  }

  unsigned long long ret = lcm(t[0], t[1]);
  for (int i = 2; i < N; ++i) {
    ret = lcm(ret, t[i]);
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

void warshall_floyd(ll N, vvll& d) {
  rep(k, N) rep(i, N) rep(j, N) chmin(d[i][j], d[i][k] + d[k][j]);
}

signed main() {
  init();
  ll N;
  cin >> N;
  vvll A(N, vll(N));
  cin >> A;
  vvll oA = A;
  warshall_floyd(N, A);
  rep(i, N) rep(j, N) if (oA[i][j] != A[i][j]) {
    COUT(-1);
    return 0;
  }

  vvll f(N, vll(N, 1));
  rep(k, N) rep(i, N)
      rep(j, N) if (A[i][k] + A[k][j] == A[i][j] && i != k && k != j) {
    f[i][j] = 0;
  }

  ll ans = 0;
  rep(i, N) rep(j, N) if (f[i][j]) ans += A[i][j];
  ans /= 2;
  ANS;
  return 0;
}

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

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

const int Maxn = 5005;

ll n;
int ga, sa, ba;
int gb, sb, bb;
ll res;

ll getCorns(ll was, int lost, int got)
{
    ll money = was / lost; was %= lost;
    return was + money * got;
}

ll getMax(ll n, vector <ii> &V)
{
    if (V.size() == 0) return n;
    if (V.size() == 1) return getCorns(n, V[0].first, V[0].second);
    if (V.size() == 2) {
        ll res = 0;
        for (int i = 0; i <= n; i++) {
            int j = n - i;
            res = max(res, getCorns(i, V[0].first, V[0].second) + getCorns(j, V[1].first, V[1].second));
        }
        return res;
    }
    ll res = 0;
    for (int i = 0; i <= n; i++)
        for (int j = 0; i + j <= n; j++) {
            int k = n - i - j;
            res = max(res, getCorns(i, V[0].first, V[0].second) +
                           getCorns(j, V[1].first, V[1].second) +
                           getCorns(k, V[2].first, V[2].second));
        }
    return res;
}

int main()
{
    scanf("%lld", &n);
    scanf("%d %d %d", &ga, &sa, &ba);
    scanf("%d %d %d", &gb, &sb, &bb);
    vector <ii> seq;
    if (ga < gb) seq.push_back(ii(ga, gb));
    if (sa < sb) seq.push_back(ii(sa, sb));
    if (ba < bb) seq.push_back(ii(ba, bb));
    n = getMax(n, seq);
    seq.clear();
    if (gb < ga) seq.push_back(ii(gb, ga));
    if (sb < sa) seq.push_back(ii(sb, sa));
    if (bb < ba) seq.push_back(ii(bb, ba));
    n = getMax(n, seq);
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int a[maxn];
int main()
{
	int n;
	ll ans, m, sum = 0;
	cin >> n;
	for (int i = 0; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	if (n == 0 && a[0] != 1 || (n > 0 && a[0] == 1))
	{
		cout<<-1<<endl;
		return 0;
	}
	ans = 1;
	m = 1;
	for (int i = 1; i <= n; i++)
	{
		m = min(m * 2, sum);
		if (a[i] > m)
		{
			cout << -1 << endl;
			return 0;
		}
		ans += m;
		m -= a[i];
		sum -= a[i];
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
const int maxn=200010;
const int mod=1e9+7;
int n;
vector<int> g[maxn], w[maxn], gg[maxn];
ll dp[maxn][3];
int dep[maxn], size[maxn], fa[maxn][20];
ll ans;
int a[maxn<<1];
stack<int> st;

ll Pow(ll x,ll y){
	ll ret=1;
	while(y){ if(y&1) ret=ret*x%mod; x=x*x%mod; y>>=1; }
	return ret;
}

int in[maxn], out[maxn], dfn;
void dfs(int x){
	in[x]=++dfn; 
	for(int i=0;i<g[x].size();i++) dfs(g[x][i]); 
	out[x]=dfn;
}

bool cmp(int x,int y){ return in[x]<in[y]; }
int lca(int x,int y){
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=19;i>=0;i--) if(dep[fa[x][i]]>=dep[y]) x=fa[x][i];
	if(x==y) return x;
	for(int i=19;i>=0;i--) if(fa[x][i]!=fa[y][i]) x=fa[x][i], y=fa[y][i];
	return fa[x][0];
}
void solve(){
	size[0]=1; w[0].push_back(0);
	for(int i=1;i<=n;i++) dep[i]=dep[fa[i][0]]+1, size[dep[i]]++, w[dep[i]].push_back(i);
	for(int d=0;d<=n;d++){
		if(!size[d]) break;
		int tot=0;
		for(int i=0;i<w[d].size();i++) a[++tot]=w[d][i];
		sort(a+1,a+1+tot,cmp);
		for(int i=tot;i>1;i--) a[++tot]=lca(a[i],a[i-1]);
		a[++tot]=0;
		sort(a+1,a+1+tot,cmp);
		tot=unique(a+1,a+1+tot)-a-1;
		while(!st.empty()) st.pop();
		st.push(0);
		for(int i=2;i<=tot;i++){
			while(!st.empty() && !(in[st.top()]<=in[a[i]] && out[a[i]]<=out[st.top()])) st.pop();
			gg[st.top()].push_back(a[i]);
			st.push(a[i]);
		}
		for(int i=tot;i>=0;i--){
			int now=a[i];
			dp[now][0]=dp[now][1]=0;
			if(dep[now]==d) dp[now][0]=dp[now][1]=1;
			if(dep[now]>=d) continue;
			ll dp1=0, dp2=0, dp0=1;
			for(int j=0;j<gg[now].size();j++){
				int v=gg[now][j];
				dp2=(dp2*dp[v][0]%mod+(dp2+dp1)*dp[v][1]%mod)%mod;
				dp1=(dp1*dp[v][0]%mod+dp0*dp[v][1]%mod)%mod;
				dp0=dp0*dp[v][0]%mod;
			}
			dp[now][0]=(dp0+dp2)%mod;
			dp[now][1]=dp1;
		}
		(ans+=dp[0][1]*Pow(2,n+1-size[d]))%=mod;
		for(int i=1;i<=tot;i++) gg[a[i]].clear();
	}
}

int main(){

	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&fa[i][0]), g[fa[i][0]].push_back(i);
	dfs(0);
	for(int j=1;j<=19;j++) for(int i=1;i<=n;i++) fa[i][j]=fa[fa[i][j-1]][j-1];
	solve();
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 60672
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int i, ans;
	string s, t;
	ans = 0;
	cin >> s;
	cin >> t;
	for (i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3924
import heapq
import sys
input = sys.stdin.readline
n = int(input())
sss = [input()[:-1] for _ in range(n)]

a = []
b = []
ss = 0
ii = 0
for i in sss:
    mi = 0
    ma = 0
    s = 0
    for j in i:
        if j == "(":
            s += 1
        else:
            s -= 1
        mi = min(mi, s)
        ma = max(ma, s)
    ss += s
    if s >= 0:
        a.append([s, mi, ma, ii])
    else:
        mi = 0
        ma = 0
        s = 0
        for j in reversed(i):
            if j == ")":
                s += 1
            else:
                s -= 1
            mi = min(mi, s)
            ma = max(ma, s)
        b.append([s, mi, ma, ii])
    ii += 1


if ss != 0:
    print("No")
    exit()
a.sort(reverse=1, key=lambda x: x[1])
b.sort(reverse=1, key=lambda x: x[1])


def ok(a):
    s = 0
    for i, j, _, _ in a:
        if s + j < 0:
            print("No")
            exit()
        s += i

ok(a)
ok(b)
print("Yes")


Measured memory_bytes: 265104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ggr getchar();getchar();return 0;
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int a[114514], b[114514], c[114514];
signed main() {
	int n,cnta,cntb,ans=0;
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)cin >> c[i];
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	rep(i, n) {
		cnta = lower_bound(a, a + n, b[i]) - a;
		cntb = n - (upper_bound(c, c + n, b[i]) - c);
		ans += cnta * cntb;
	}
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
  int max_n=0,min_n=9999999;
  for(int i=0;i<5;i++){
    int a;
    cin >> a;
    max_n = max(max_n,a);
    min_n = min(min_n,a);
  }
  int k;
  cin >> k;
  // cout << (max_n-min_n>k ? ":(" : "Yay!") << endl;
  if(max_n-min_n>k)cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
/*input
snuke
snekee
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main()
{
  string s1,s2;
  cin >> s1 >> s2;
  int n = s1.length();
  int m = s2.length();
  bool flag= 0;

  if(n == m - 1) {
  	for(int i = 0; i < n; i ++) {
  		if(s1[i] == s2[i]) {

  		}else {
  			flag = 1;
  			break;
  		}
  	}
  } else {
  	flag = 1;
  }

  if(flag) {
  	cout << "No";
  } else {
  	cout << "Yes";
  }
  return 0;
}

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

int daydream(string s) {
    string str = s, check;
    reverse(str.begin(), str.end());

    int cnt = 0;
    while (cnt < s.size()) {
        if (str.at(cnt) == 'm') {
            check += "maerd";
            cnt += 5;
        }
        else if (str.at(cnt) == 'e') {
            check += "esare";
            cnt += 5;
        }
        else if (str.at(cnt) == 'r') {
            if (str.at(cnt + 2) == 'm') {
                check += "remaerd";
                cnt += 7;
            }
            else {
                check += "resare";
                cnt += 6;
            }
        }
    }

    reverse(check.begin(), check.end());
    if (s == check) return true;
    else return false;
}

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

    if (daydream(S)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3832
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i]-'0');
	}
	return d;
}
int N;
void dfs(int length, int letter,string s) {
	if (length == N) {
		cout << s << endl;
		return;
	}

	rep(i, letter+2) {
		string t = s;
		t += ('a' + i);
		dfs(length + 1, max(letter, i), t);
	}
	return;
}

int main()
{
	cin >> N;
	dfs(1, 0, "a");

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int parent[100000];
int find(int x) {
    if (parent[x] < 0) return x;
    return parent[x] = find(parent[x]);
}
void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (parent[x] > parent[y]) swap(x, y);
    parent[x] += parent[y];
    parent[y] = x;
}
int main()
{
    int N, M; cin >> N >> M;
    for (int i = 0; i < N; i++) {
        parent[i] = -1;
    }
    for (int i = 0; i < M; i++) {
        int x, y, z; cin >> x >> y >> z;
        x--, y--;
        unite(x, y);
    }
    set<int> num;
    for (int i = 0; i < N; i++) {
        num.insert(find(i));
    }
    cout << num.size() << '\n';
    return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int num = sc.nextInt();
			if (isPrime(num)) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}

	private static boolean isPrime(int x) {
		if (x == 2) {
			return true;
		}

		if (x < 2 || x % 2 == 0) {
			return false;
		}

		int i = 3;

		while (i <= Math.sqrt(x)) {
			if (x % i == 0) {
				return false;
			}
			i = i + 2;
		}
		return true;
	}
}

Measured memory_bytes: 43748
#include<stdio.h>
typedef struct
{
  char mark;
  char num;
}cards;

void bubble(cards C[],int N)
{
  int i,j;
  for(i=0;i<N;i++)
    {
      for(j=N-1;j>=i;j--)
        {
          if(C[j].num<C[j-1].num)
            {
              cards b;
              b=C[j];
              C[j]=C[j-1];
              C[j-1]=b;
            }
        }
    }
}

void select(cards C[],int N)
{
  int i,j;
  for(i=0;i<N;i++)
    {
      int minv=i;
      for(j=i;j<N;j++)
        {
          if(C[j].num<C[minv].num) minv=j;
        }
      cards b;
      b=C[i];
      C[i]=C[minv];
      C[minv]=b;
    }
}

int isStable(cards A[],cards B[],int N)
{
  int i;
  for(i=0;i<N;i++)
    {
      if(A[i].mark!=B[i].mark)return 0;
    }
  return 1;
}

int main()
{
 cards A[100],B[100];
  int i,N;
  char card[3];
  char carda[3];
  char cardb[3];

  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%s",card);
      A[i].mark=card[0];
      A[i].num=card[1];
    }

  for(i=0;i<N;i++)
    {
      B[i]=A[i];
    }

  bubble(A,N);
  select(B,N);

  for(i=0;i<N;i++)
    {
      if(i>0)printf(" ");
      card[0]=A[i].mark;
      card[1]=A[i].num;
      printf("%s",card);
    }
  printf("\n");
  printf("Stable\n");
  for(i=0;i<N;i++)
    {
      if(i>0)printf(" ");
      card[0]=B[i].mark;
      card[1]=B[i].num;
      printf("%s",card);
    }
  printf("\n");
  if(isStable(A,B,N)==1)
    {
      printf("Stable\n");
    }
  else
    {
      printf("Not stable\n");
    }
  return 0;
}

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

int main() {
  int n,r,b;
  string s;
  cin>>n>>s;
  r=b=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='R')r++;
    else b++;
  }
  if(r>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		int count = 0;
		while (true) {
			boolean bre = false;
			int start = 0;
			for (int i = 0; i < n; i++) {
				if (h[i] != 0) {
					start = i;
					bre = true;
					break;
				}
			}
			if (!bre) {
				break;
			}
			for (int i = start; i < n; i++) {
				if (h[i] == 0) {
					break;
				} else {
					h[i]--;
				}
			}
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int main(){
	int i,n;
	cin >> n;
	long long a[10000],max = 0,min = 0,sum = 0;
	for(i = 0; i < n; i++){
		cin >> a[i];
	}
	max = a[0];
	min = a[0];
	for(int j = 0; j < n; j++){
		if(max < a[j]){
			max = a[j];
		}
		if(min > a[j]){
			min = a[j];
		}
		sum = sum + a[j];
	}
	cout << min << " " << max << " " << sum << endl;

}

Measured memory_bytes: 1244
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),K=in();
	double p = 0;
	for(int i=0;i<N;i++){
		int num = 0;
		int v = i+1;
		while(v<K){
			v <<= 1;
			num++;
		}
		p += pow(0.5,num)/N;
	}
	
	printf("%.12lf\n",p);
	return 0;
}


Measured memory_bytes: 256
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
vector<long long int> ans;
int dfs(long long int a){
  long long int b=a%10;
  ans.push_back(a);
  if(a*10+b<=3234566667){
  dfs(a*10+b);
  }
  if(b>=1 && a*10+(b-1)<=3234566667){
    dfs(a*10+(b-1));
  }
  if(b<=8 && a*10+(b+1)<=3234566667){
    dfs(a*10+(b+1));
  }
}
int main(){
  long long int i,k;
  scanf("%lld\n",&k);
  for(i=1;i<10;i++){
    dfs(i);
  }
  sort(ans.begin(),ans.end());
  printf("%lld\n",ans[k-1]);
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a), greater<ll>());
    priority_queue<ll> que;
    que.push(a[1]); que.push(a[1]);
    ll ans = a[0];
    FOR(i, 2, n){
        // pr(que.top());
        ans += que.top(); que.pop();
        rep(j, 2) que.push(a[i]);
    }
    pr(ans);
    return 0;}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
typedef long long ll;

int N;

bool test(int h, int n, int w){
  return ((4*h*n*w == N * (n*w + w*h + h*n)));
}

void solve()
{
  for (ll h = 1; h <= 3500; h++)
  {
    for (ll n = 1; n <= 3500; n++)
    {
      ll a = N * h * n;
      ll b = 4 * h * n - N * (n + h);
      if (b <= 0)
      {
        continue;
      }

      if (a % b == 0)
      {
        cout << h << " " << n << " " << a/b << endl;
        return;
      }
    }
  }
}


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

Measured memory_bytes: 256