akhauriyash/Code-Regression huggingface dataset:
import itertools
import copy
def main():
    H, W, K = map(int, input().split())
    board = [list(input()) for i in range(H)]
    ans = 0

    for i in range(H + 1):
        for j in range(W + 1):
            for row in itertools.combinations(range(H), i):
                for col in itertools.combinations(range(W), j):

                    paint = copy.deepcopy(board)
                    
                    if len(row) == 0:
                        pass
                    else:
                        for r in row:
                            for k in range(W):
                                paint[r][k] = "-"

                    if len(col) == 0:
                        pass
                    else:
                        for c in col:
                            for l in range(H):
                                paint[l][c] = "-"

                    count = 0
                    for k in range(H):
                        for l in range(W):
                            if paint[k][l] == "#":
                                count += 1

                    if count == K:
                        ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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

int main()
{
    int A, B, C, D, N, K;
    map<int, string> mp;
    vector<int> v(4);
    string left = "";
    mp[0] = "+";
    mp[1] = "-";
    cin >> N;
    for (int i = 3; i >= 0; --i)
    {
        v[i] = N % 10;
        N /= 10;
    }
    // int eval_left = v.at(0);

    for (int tmp = 0; tmp < (1 << 3); tmp++)
    {
        bitset<3> s(tmp);
        int eval_left = v.at(0);
        left = to_string(v.at(0));
        for (int i = 0; i < 3; ++i)
        {
            left += mp[s.test(2 - i)];
            left += to_string(v.at(i + 1));
            if (mp[s.test(2 - i)] == "+")
            {
                eval_left += v.at(i + 1);
            }
            if (mp[s.test(2 - i)] == "-")
            {
                eval_left -= v.at(i + 1);
            }
        }
        if (eval_left == 7)
        {
            cout << left << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == b[i] && b[i] == c[i] && c[i] == a[i]) {
            continue;
        } else if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
            ans += 2;
        } else {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;
    for (int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define int long long

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

int mod = 1000000007;
int fact[200001];
int factInv[200001];

void initFact() {
	fact[0] = 1;
	factInv[0] = 1;
	for (int i = 1; i < 200001; i++) {
		fact[i] = (i * fact[i - 1]) % mod;
		factInv[i] = powmod(fact[i], mod - 2, mod);
	}
}

int comb(int n, int k) {
	return fact[n] * factInv[k] % mod * factInv[n - k] % mod;
}

int n, m;

signed main() {
	cin >> n >> m;
	initFact();
	
	int i, t = m, ans = 1;
	for (i = 2; i * i <= t; i++) {
		int cnt = 0;
		while (t % i == 0) {
			t /= i;
			cnt++;
		}
		ans *= comb(cnt + n - 1, n - 1);
		ans %= mod;
	}
	if (t > 1) {
		ans *= comb(n, n - 1);
		ans %= mod;
	}
	
	cout << ans << endl;
	return 0;
}

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

int main(){
    int h, w, n;
    cin >> h >> w >> n;
    cout << (n + max(h, w) - 1) / max(h, w) << endl;
}


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

using namespace std;

int n, k, w[100000];

bool check(int p){
  int cnt = 1;
  long long total = 0;

  for(int i = 0;i < n;i++){
    if(total + w[i] <= p) total += w[i];
    else{
      cnt++;
      total = w[i];
    }
  }

  if(cnt <= k) return true;
  else return false;
}

int main(){
  long long left = 0, right = 100000 * 10000;

  cin >> n >> k;
  for(int i = 0;i < n;i++){
    cin >> w[i];
    left = max(left, (long long)w[i]);
  }

  while(left < right){
    int mid = (left + right) / 2;

    if(check(mid)) right = mid;
    else left = mid + 1;
  }

  cout << left << endl;

  return 0;
}




Measured memory_bytes: 3476
#include <bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int cal(int i,int j,vector<vector<int>>& dp,vector<vector<char>>& grid)
{
    if(i>=grid.size() || j>=grid[0].size())
    return 0;
    if(i==grid.size()-1 && j==grid[0].size()-1)
    return 1;
    if(dp[i][j]==-1)
    {
        if(grid[i][j]=='#')
        dp[i][j]=0;
        else
        dp[i][j]=(cal(i+1,j,dp,grid)%mod+cal(i,j+1,dp,grid)%mod)%mod;
    return dp[i][j];
    }
    else
    return dp[i][j];
}
int main()
{
int h,w;
cin>>h>>w;
vector<vector<char>> grid(h,vector<char>(w));
for(int i=0;i<h;i++)
{
    for(int j=0;j<w;j++)
    {
        cin>>grid[i][j];
    }
}
vector<vector<int>> dp(h,vector<int> (w,-1));
int ans=cal(0,0,dp,grid);
cout<<ans;
return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	long long N, M, X, A[100] = { 0 }, n[100] = { 0 }, l = 0, r = 0;
	int i, j = 0;

	cin >> N; cin >> M; cin >> X;
	for (i = 0; i < M; i++)
		cin >> A[i];


	for(j=0; j<M; j++){
		for (i = 1; i < N; i++) {
			if (i == A[j]) {
				n[i] = 1;
			}
		}
	}
	n[0] = 0;  n[N] = 0;  n[X] = 0;

	for (i = 1; i < X; i++) {
		l += n[i];
	}

	if (l < (M - l))
		cout << l << endl;
	else
		cout << M - l << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,m,ptr=1;
char s[200005],t[200005];
int main()
{
	scanf("%d%d%s",&n,&m,s+1);s[n+1]=s[1];s[n+2]=s[2];
	while(true) {
		if(s[ptr]=='A'&&s[ptr+1]=='A'&&s[ptr+2]=='A') m-=3;
		else if(s[ptr]=='A'&&s[ptr+1]=='A'&&s[ptr+2]=='B') m-=3;
		else if(s[ptr]=='A'&&s[ptr+1]=='B'&&s[ptr+2]=='A') m-=4;
		else if(s[ptr]=='A'&&s[ptr+1]=='B'&&s[ptr+2]=='B') m-=4;
		else if(s[ptr]=='B'&&s[ptr+1]=='A'&&s[ptr+2]=='A') m-=2;
		else if(s[ptr]=='B'&&s[ptr+1]=='A'&&s[ptr+2]=='B') m-=2;
		else if(s[ptr]=='B'&&s[ptr+1]=='B'&&s[ptr+2]=='A') m-=3;
		else if(s[ptr]=='B'&&s[ptr+1]=='B'&&s[ptr+2]=='B') m-=3;
		ptr+=2;
		if(m<0) {
			ptr-=2;
			if(s[ptr]=='A'&&s[ptr+1]=='A'&&s[ptr+2]=='A') m+=3;
			else if(s[ptr]=='A'&&s[ptr+1]=='A'&&s[ptr+2]=='B') m+=3;
			else if(s[ptr]=='A'&&s[ptr+1]=='B'&&s[ptr+2]=='A') m+=4;
			else if(s[ptr]=='A'&&s[ptr+1]=='B'&&s[ptr+2]=='B') m+=4;
			else if(s[ptr]=='B'&&s[ptr+1]=='A'&&s[ptr+2]=='A') m+=2;
			else if(s[ptr]=='B'&&s[ptr+1]=='A'&&s[ptr+2]=='B') m+=2;
			else if(s[ptr]=='B'&&s[ptr+1]=='B'&&s[ptr+2]=='A') m+=3;
			else if(s[ptr]=='B'&&s[ptr+1]=='B'&&s[ptr+2]=='B') m+=3;
			for(int i=ptr;i<=n;++i) t[i-ptr+1]=s[i];
			for(int i=n;i>n-ptr+1;--i) t[i]=((n-i)&1)+'A';
			while(m--) {
				int now=1,flag=1;
				while(now>0&&now<=n) {
					if(t[now]=='A') {t[now]='B';flag=-flag;now=now+flag;}
					else  {t[now]='A';now=now+flag;}
				}
			}
			printf("%s",t+1);return 0;
		}
		if(ptr==n+1||ptr==n) break;
	}
	if(ptr==n&&(s[n]=='A')) {putchar((m&1)+'A');for(int i=1;i<=n/2;++i) putchar('B'),putchar('A');}
	else if(ptr==n&&(s[n]=='B')) {putchar(((m+1)&1)+'A');for(int i=1;i<=n/2;++i) putchar('B'),putchar('A');}
	else for(int i=1;i<=n/2;++i) putchar('B'),putchar('A');
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K, X,l = 0, m = 0;
    cin >> K >> X;
    vector<int> num = {X};
    for(int i = 0; i < K-1; i++){
        int A = X - 1 - l;
        l++;
        num.push_back(A);
    }
    for(int j = 0; j < K-1; j++){
        int B = X + 1 + m;
        m++;
        num.push_back(B);
    }
    sort(num.begin(),num.end());
    for(int b = 0; b < num.size(); b++){
        cout << num.at(b) << " " ;
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		
		int n;
		
		int rank;
		
		boolean[] S = new boolean[14];
		boolean[] H = new boolean[14];
		boolean[] C = new boolean[14];
		boolean[] D = new boolean[14];
		
		for(int i=0;i<13;i++){
			S[i]= H[i]= C[i]= D[i]= false;
		}
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		
		for(int i=0;i<n;i++){
			
			String[] imp = br.readLine().split(" ");
			rank = Integer.parseInt(imp[1]);
			
			if("S".equals(imp[0])){
				S[rank]=true;
			}else if("H".equals(imp[0])){
				H[rank]=true;
			}else if("C".equals(imp[0])){
				C[rank]=true;
			}else if("D".equals(imp[0])){
				D[rank]=true;
			}
		}
			for(int j=1;j<14;j++){
				if(S[j]==false){
				System.out.println("S "+j);
				}
			}
			for(int j=1;j<14;j++){
				if(H[j]==false){
				System.out.println("H "+j);
				}
			}
			for(int j=1;j<14;j++){
				if(C[j]==false){
				System.out.println("C "+j);
				}
			}
			for(int j=1;j<14;j++){
				if(D[j]==false){
				System.out.println("D "+j);
				}
			}
			
				
			}
			
			
		}
		

Measured memory_bytes: 24264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, m, n) for (int i = m; i < n; ++i)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// vvi data(n, vi(m));
using vll = vector<long long>;
using vvll = vector<vll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x - a) % b << endl;
}


Measured memory_bytes: 256
// author - shreyanshjn (Shreyansh Jain)
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
/* #define input 1 */
#define INF 100000000000000000
#define endl '\n'
#define debug(x) cout<<#x<<": "<<x<<endl
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define rep(a,b,c) for(int a=b; a<c; a++)
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
const int mod = 1e9 + 7;
int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
string trim(const string& str) {
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}

vector<vector<int>> v;
vector<int> path;
vector<bool> vis;

void dfs(int i) {
    path[i] = 0;
    vis[i] = true;
    for(auto u : v[i]) {
        if(!vis[u]) {
            dfs(u);
        }
        path[i] = max(path[i], path[u] + 1);
    }
}

int main() { 
    #ifdef input
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(15);
    int n, m; cin >> n >> m;
    v.resize(n + 1);
    path.resize(n + 1);
    vis.assign(n + 1, false);
    fori(0, m) {
        int a, b; cin >> a >> b;
        v[a].push_back(b);
    }
    fori(1, n + 1) {
        if(!vis[i]) {
            dfs(i);
        }
    }
    int ans = path[1];
    fori(2, n + 1) {
        ans = max(ans, path[i]);
    }
    cout << ans << endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}

Measured memory_bytes: 11784
#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	long long a,s,sum;
	double b;
	scanf("%lld %lf",&a,&b);
	s=b*100+0.1;
	sum=(a*s)/100;
	printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1748
#include<iostream>
#include<map>

int main(void){
    int n;
    std::cin >> n;
    std::map<int, int> mp;
    int a;
    for(int i = 0; i < n; i++){
        std::cin >> a;
        mp[a] = i;
    }
    for(auto i = mp.begin(); i != mp.end(); i++){
        if(i != mp.begin()) std::cout << " ";
        std::cout << ++i->second;
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 8136
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <complex>
#include <bitset>
 
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define sz(a) (int)(a).size()
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
int main() {
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    
    
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    if (n > 23) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for (int mask = 0; mask < (1 << 24); ++mask) {
        if (!(mask & 1)) {
            continue;
        }
        int used = 1;
        bool flag = true;
        for (int i = 0; i < n; ++i) {
            if (!(used & (1 << d[i])) && (mask & (1 << d[i]))) {
                used |= (1 << d[i]);
                continue;
            }

            if (!(used & (1 << (24 - d[i]))) && (mask & (1 << (24 - d[i])))) {
                used |= (1 << (24 - d[i]));
                continue;
            }
            flag = false;
            break;
        }

        if (flag) {
            int last = 0;
            int cur = 24;
            for (int i = 1; i < 24; ++i) {
                if (mask & (1 << i)) {
                    cur = min(cur, i - last);
                    last = i;
                }
            }
            cur = min(cur, 24 - last);
            ans = max(ans, cur);
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>

using namespace std;
////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(int i=a;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_r(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) cout<<x<<endl
#define s_1(x) cin>>x
#define s_2(x,y) cin>>x>>y
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
/*imos???*/
/*????????¢?´¢*/
/*??±???????????¢?´¢*/
/*???????¨???????*/
///////////////////////
void log(int ban[])
{
	rep_to(1,i,7)cout<<ban[i]<<" ";
	cout<<endl;
}
int main()
{
	int N;
	char str[10000]={};

	while(1)
	{
		int sum=1;
		int ban[7]={0,1,2,3,4,5,6};
		s_1(N);
		if(N==0)break;
		rep(i,N)
		{
			s_1(str);
			if(strstr(str,"North")!=NULL)
			{
				swap(ban[1],ban[2]);
				swap(ban[2],ban[6]);
				swap(ban[6],ban[5]);
			}
			else if(strstr(str,"East")!=NULL)
			{
				swap(ban[1],ban[4]);
				swap(ban[4],ban[6]);
				swap(ban[6],ban[3]);
			}
			else if(strstr(str,"West")!=NULL)
			{
				swap(ban[1],ban[3]);
				swap(ban[3],ban[6]);
				swap(ban[6],ban[4]);
			}
			else if(strstr(str,"South")!=NULL)
			{
				swap(ban[1],ban[5]);
				swap(ban[5],ban[6]);
				swap(ban[6],ban[2]);
			}
			else if(strstr(str,"Right")!=NULL)
			{
				swap(ban[2],ban[3]);
				swap(ban[3],ban[5]);
				swap(ban[5],ban[4]);
			}
			else if(strstr(str,"Left")!=NULL)
			{
				swap(ban[2],ban[4]);
				swap(ban[4],ban[5]);
				swap(ban[5],ban[3]);
			}
			sum+=ban[1];
		}
		cout<<sum<<endl;
	}
	
	return 0;
}

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

int main(void) {
	int n, number;
	int cnt = 0;
	int i, j;
	int tr = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &number);

		if (number == 2) {
		}
		else if (number < 2 || number % 2 == 0) {
			tr = 1;
		} else {
			for (j = 3; j <=  sqrt(number); j += 2) {
				if (number % j == 0) {
					tr = 1;
					break;
				}
			}
		}

		if (tr == 0) {
			cnt++;
		}
		tr = 0;
	}

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


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

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

fn solve(n: usize) {
    fn _solve(n: usize, m: usize, s: String) {
        for i in 0..m {
            if s.len() > 0 {
                let mut chars: Vec<char> = s.chars().collect();
                chars.sort();
                let last_c = chars[chars.len()-1] as u8 - 'a' as u8;
                if i > last_c as usize + 1 {
                    break;
                }
            }
            let mut s = s.clone();
            let c: char = ('a' as u8 + i as u8) as char;
            s.push(c);
            if n == m {
                println!("{}", s);
            } else {
                _solve(n, m+1, s);
            }
        }

    }
    let s: String = "".to_string();
    _solve(n, 1, s);
}

fn main() {
    let n: usize = read();
    solve(n);
}


Measured memory_bytes: 5500
# https://atcoder.jp/contests/abc085/tasks/abc085_c
# 10000a+5000b+1000c=Yが成り立つa,b,cでa+b+c=Nとなる組み合わせが存在するか？

# O(N**2)で全探索すれば良い
# c=(Y-(10000a+5000b))//1000

N, Y = map(int, input().split())

for a in range(N + 1):
    if Y - a * 10000 < 0:
        break
    for b in range(N + 1):
        c = (Y - 10000 * a - 5000 * b) // 1000
        if c < 0:
            break
        if a + b + c == N:
            print(a, b, c)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 9176
#include <iostream>
using namespace std;
int main(){
    int m,max=-10000000,min=10000000,n;
    long sum=0;
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>n;
        sum=sum+n;
        if(n>max){
            max=n;
        }
        if(n<min){
            min=n;
        }
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL a;
    LL b;
    LL ans=0;
    cin >> n >> a >> b;
    for(LL i=1; i<=n; i++){
        LL tmp=i;
        LL sum=0;
        while(tmp>0){
            sum+=tmp%10;
            tmp/=10;
        }
        //cout << i << sum << endl;
        if(sum>=a && sum<=b){
            ans+=i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  string s;
  cin>>s;
  reverse(s.begin(), s.end());
  for(int i=0; i < 4; i++)
    reverse(divide[i].begin(), divide[i].end());
  bool can = true;
  for(int i=0; i < s.size();){
    bool can2 = false;
    for(int j=0; j < 4; j++){
      string d = divide[j];
      if(s.substr(i, d.size())==d){
        can2=true;
      	i+=d.size();
      }
    }
    if(!can2){
      can=false;
      break;
    }
  }
  if(can)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  
  return 0;
}

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

int char_to_int(char c){
	return (int)(c - 'a');
}

signed main(){
	int i, j;
	string s, t;
	cin >> s;
	cin >> t;
	string ss = s + s;
	vector<vector<int>> next(ss.size() + 1, vector<int>(26, ss.size()));
	for(i = ss.size() - 1; i >= 0; i--){
		for(j = 0; j < 26; j++){
			if(char_to_int(ss[i]) == j){
				next[i][j] = i;
			}
			else{
				next[i][j] = next[i + 1][j];
			}
		}
	}
	int ans = 0, now = -1;
	for(i = 0; i < t.size(); i++){
		now = next[now + 1][char_to_int(t[i])];
		if(now == ss.size()){
			printf("-1\n");
			return 0;
		}
		if(now >= s.size()){
			ans += s.size();
			now -= s.size();
		}
	}
	printf("%lld\n", ans + now + 1);
	return 0;
}

Measured memory_bytes: 49024
#include<bits/stdc++.h>
using namespace std;
int N,K;
string s;
bool f[10];
int ans=1e9;

void dfs(int pos,int num){

  if( N <= num){
    ans=min(ans,num);
    return;
  }
  
  if(pos==1+(int)s.size())return;

  
  for(int i=0;i<10;i++){
    if(f[i])continue;
    dfs(pos+1,num*10+i);
  }
}

int main(){
  cin>>s>>K;
  stringstream ss;
  ss<<s;
  ss>>N;
  
  for(int i=0;i<K;i++){
    int num;
    cin>>num;
    f[num]=true;
  }
  dfs(0,0);
  cout<<ans<<endl;  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int result = 0;
		if(n%2!=0) {
			result = (n/2)+1;
		}else {
			result = n/2;
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

int128_t imax(const int128_t a, const int128_t b) { return std::max(a, b); } // std::max, std::min は型が違うとエラーになるため、ラッパーを作る。
int128_t imin(const int128_t a, const int128_t b) { return std::min(a, b); }

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

#define input1(begin, end, v1) v1.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i]; }
#define input2(begin, end, v1, v2) v1.resize((end)+1); v2.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i]; } 
#define input3(begin, end, v1, v2, v3) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i]; } 

std::vector<int> irange(const int begin, const int end) {
    std::vector<int> ret; for (int i = begin; i <= end; i++) { ret.push_back(i); }
    return ret;
}

template <typename T>
void printvec(const std::vector<T>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int N;
//int128_t ;
std::vector<int64_t> H, P;
//std::vector<int128_t> A, B;
//std::string ;
//std::vector<std::string> ;
//double ;
//std::vector<double> ;

const int MAX_N = 5010;

int64_t dp[MAX_N][MAX_N] = {};
const int64_t INF = std::numeric_limits<int64_t>::max();

int main(int argc, char **argv){
    std::cin >> N;

    input2(1, N, H, P);

    std::vector<int> vec = irange(1, N);
    std::sort(vec.begin(), vec.end(), [&](int i, int j){
        return H[i] + P[i] < H[j] + P[j];
    });
    
    auto Ht = H;
    auto Pt = P;

    rep (i, 1, N) {
        H[i] = Ht[vec[i - 1]];
        P[i] = Pt[vec[i - 1]];
    }

    rep (i, 0, N) {
        rep (j, 0, N) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;
    rep (i, 1, N) {
        rep (j, 0, i) {
            dp[i][j] = dp[i-1][j];
            if (1 <= j && dp[i-1][j-1] <= H[i]) {
                dp[i][j] = imin(dp[i][j], dp[i-1][j-1] + P[i]);
            }
        }
    }

    rev (i, N, 1) {
        if (dp[N][i] != INF) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    assert(false);
    return 0;
}



Measured memory_bytes: 196224
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] rank = { "ABC", "ARC", "AGC" };
            int R = Convert.ToInt32(Console.ReadLine());
            if (R < 1200)
            {
                Console.WriteLine(rank[0]);
            }
            else if (R < 2800)
            {
                Console.WriteLine(rank[1]);
            }
            else
            {
                Console.WriteLine(rank[2]);
            }

        }
    }
}


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

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define reP(i, x, n) for(int i=x; i<n; i++)
#define aLL(x) x.begin(), x.end()
#define pB push_back
#define eB emplace_back
#define tRav(a, x) for(auto& a: x)
#define fI first
#define sE second
#define lB lower_bound
#define uB upper_bound
#define MOD 1000000007

typedef vector<int> vec;
typedef long long ll;
typedef unsigned long long ull;

int main(){
	fast_cin();
	ll n, m;cin>>n>>m;
	vec s1(m), c(m);
	reP(i, 0, m)
	cin>>s1[i]>>c[i];
	reP(i, 0, 1000){
		string s = to_string(i);
		bool va = true;
		if(s.size()==n){
		reP(j, 0, m){
			if(s[s1[j]-1]!=(char)c[j]+'0')
				va = false;
		}
		if(va){
			cout<<s<<endl;
			return 0;
		}
	}

	}
	cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{

    int a,b;
    cin >>a >>b;

    if(a >= 10 || b >= 10){
        printf("-1\n");
    }else{
        printf("%d\n", a*b);
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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(){
    ll n;cin >> n;
    vl v(n);
    rep(i,n)cin >>v[i];
    sort(all(v));
    vl cum(n,0);
    cum[0]=v[0];
    rep(i,n-1)cum[i+1]+=cum[i]+v[i+1];
    ll ans=1;
    per(i,n-1){
        if(v[i+1]<=cum[i]*2)ans++;
        else break;
    }
    cout << ans <<endl;
}

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

using namespace std;

int main(){
    int N;
    string S,T;
    cin >> N;
    cin >> S >> T;
    for(int i=0;i<2*N;i++){
        if(i%2==0){
            cout << S[i/2];
        }else{
            cout << T[i/2];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	long long int X, m, ans;
	m = 100;
	ans = 0;

	scanf("%lld", &X);

	for(; ;){

		ans++;
		m = m + m / 100;

		if(m >= X){
			break;
		}

	}

	printf("%lld", ans);

	return 0;
}

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

int main() {
	long long n, m = 26;
	cin >> n;
	string s = "";
	while(n > 0) {
		int mod = (n-1) % 26;
		s = " " + s;
		s[0] = ('a' + mod);
		n = (n-1) / m;
	}
	cout << s << "\n"; 
	return 0;
}


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

int main(){
	while(1){
		int x, y, s;
		int ans=0;
		
		scanf(" %d %d %d", &x,&y, &s);
		if(x==0) break;
		for(int i=1; i<s; ++i){//税抜き
			int p1=i*(100+x)/100;
						
			for(int j=s; j>0; --j){//税抜き
				int p2=j*(100+x)/100;
				if(p1+p2==s){
					int tmp=i*(100+y)/100 + j*(100+y)/100;		
					if(tmp>ans) ans=tmp;
					break;
				}
			}
		}
		
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1188
#ABC049

s = input()

while len(s) != 0:
    
    if s[-5:] == "dream":
        s = s[:-5]
    elif s[-7:] == "dreamer":
        s = s[:-7]
    elif s[-5:] == "erase":
        s = s[:-5]
    elif s[-6:] == "eraser":
        s = s[:-6]
    else:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 3188
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


# def fib_bad(n):
#     if not n or n == 1:
#         return 1
#     return fib_bad(n - 2) + fib_bad(n - 1)


def fib_dp(n):
    fib_list[:1] = [1, 1]
    for i in range(2, n + 1):
        fib_list[i] = fib_list[i - 2] + fib_list[i - 1]
    return fib_list.pop()


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    index = int(_input[0])
    fib_list = [None] * index
    print(fib_dp(index))

Measured memory_bytes: 7696
#include <stdio.h>


int main()
{
  long N, A, B, divi, remaind,result;
 
  scanf("%ld %ld %ld", &N, &A, &B);
 
  divi = N / (A + B);
  remaind = N % (A + B);
  
  if(remaind < A)
  {
    result = A * divi + remaind;
  }
  else
  {
      result = A * divi + A;
  }
  
  printf("%ld\n", result);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            l = [a[i], a[j], a[k]]
            l.sort()
            if(l[0]+l[1] > l[2] and l[0]!=l[1] and l[1]!=l[2]):    ans+=1
print(ans)

Measured memory_bytes: 73852
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef long long ll;
ul gcd(ul a, ul b){return b? gcd(b, a%b):a;}
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    int A, B, C, D;
    A = a/1000;
    a -= A*1000;
    B = a/100;
    a -= B*100;
    C = a/10;
    a -= C*10;
    D = a;
    string ans = "";
    stringstream ss;
    for(int i =0; i < 2; i++){
        for(int j = 0;j <2;j++){
            for(int k = 0; k < 2; k++){
                if(i==0&&j==0&&k==0){
                    if(A+B+C+D == 7){
                        ss << A << "+" << B << "+" << C << "+" <<D <<"=7";
                        ans = ss.str();
                        i = j = k = 2;
                    }
                }else if(i==0&&j==0&&k==1){
                    if(A+B+C-D == 7){
                        ss << A << "+" << B << "+" << C << "-" <<D <<"=7";
                        ans = ss.str();
                        i = j = k = 2;                        
                    }
                }else if(i==1&&j==0&&k==0){
                    if(A-B+C+D == 7){
                        ss << A << "-" << B << "+" << C << "+" <<D <<"=7";
                        ans = ss.str();
                        i = j = k = 2;                        
                    }
                }else if(i==1&&j==0&&k==1){
                    if(A-B+C-D == 7){
                        ss << A << "-" << B << "+" << C << "-" <<D <<"=7";
                        ans = ss.str();
                        i = j = k = 2;                        
                    }
                }else if(i==0&&j==1&&k==0){
                    if(A+B-C+D == 7){
                        ss << A << "+" << B << "-" << C << "+" <<D <<"=7";
                        ans = ss.str();
                        i = j = k = 2;                        
                    }
                }else if(i==0&&j==1&&k==1){
                    if(A+B-C-D == 7){
                        ss << A << "+" << B << "-" << C << "-" <<D <<"=7";
                        ans = ss.str();
                        i = j = k = 2;                        
                    }
                }else if(i==1&&j==1&&k==0){
                    if(A-B-C+D == 7){
                        ss << A << "-" << B << "-" << C << "+" <<D <<"=7";
                        ans = ss.str();
                        i = j = k = 2;                        
                    }
                }else if(i==1&&j==1&&k==1){
                    if(A-B-C-D == 7){
                        ss << A << "-" << B << "-" << C << "-" <<D <<"=7";
                        ans = ss.str();
                        i = j = k = 2;                        
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x,k,q,t,a,mx[100005],mn[100005],dt[100005],rv[100005],ans;
int main()
{
	scanf("%d%d",&x,&k);mx[0]=x;mn[0]=0;dt[0]=0;
	for(int i=1;i<=k;i++) scanf("%d",&rv[i]);
	for(int i=1;i<=k;i++)
	{
		mx[i]=mx[i-1];mn[i]=mn[i-1];int tmp=rv[i]-rv[i-1];
		if(i&1) mn[i]=max(mn[i],min(mx[i],tmp-dt[i-1])),dt[i]=max(mn[i-1]+dt[i-1]-tmp,0)-mn[i];
		else mx[i]=min(mx[i],max(mn[i],x-tmp-dt[i-1])),dt[i]=min(mx[i-1]+dt[i-1]+tmp,x)-mx[i];
	}
	for(scanf("%d",&q);q--;printf("%d\n",ans))
	{
		scanf("%d%d",&t,&a);int pos=upper_bound(rv+1,rv+k+1,t)-rv-1;
		if(a<=mn[pos]) a=mn[pos];else if(a>=mx[pos]) a=mx[pos];
		ans=a+dt[pos];int tmp=t-rv[pos];
		if(pos&1) ans=min(x,ans+tmp);else ans=max(0,ans-tmp);
	}
}

Measured memory_bytes: 2816
N=int(input())
x=list(map(int,input().split()))

ans=[0]*(N**2)
x=[(x[i]-1,i+1) for i in range(N)]
x.sort()

for i in range(N):
    p,v=x[i]
    ans[p]=v

pos=0
for i in range(N):
    val,count=x[i]
    count-=1
    while count:
        while ans[pos]:
            pos+=1
        if pos>=val:
            print("No")
            exit()
        else:
            ans[pos]=x[i][1]
            count-=1


pos=N**2-1
for i in range(N-1,-1,-1):
    val,count=x[i]
    count-=1
    count=N-1-count
    while count:
        while ans[pos]:
            pos-=1
        if val>=pos:
            print("No")
            exit()
        else:
            ans[pos]=x[i][1]
            count-=1


print("Yes")
print(*ans)

Measured memory_bytes: 53540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin>>s;
    if(s=="SSS")cout<<0<<endl;
    else if(s=="SRR"||s=="RRS")cout<<2<<endl;
    else if(s=="RRR")cout<<3<<endl;
    else cout<<1<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    int n;
    int x = 0 , y = 1;
    cin >> n;
    int a[n];
    for( int i = 0 ; i < n ; i++ ) cin >> a[i];
    sort( a , a + n );
    for( int i = 0 ; i < n ; i++ ) {
        y = 1;
        if( i == n - 1 && a[i] != y ) {
            x += y;
            break;
        } else {
            for( int j = i + 1 ; j < n ; j++ ) {
                if( a[j] == a[i] ) {
                    y++;
                    if( j == n - 1 ) {
                        if( a[i] < y ) x += y - a[i];
                        else if( a[i] > y ) x += y;
                        i = j;
                        break;
                    }
                } else {
                    if ( a[i] > y ) x += y;
                    if ( a[i] < y ) x += y - a[i];
                    i = j - 1;
                    break;
                }
            }
        }
    }
    cout << x;
}

Measured memory_bytes: 3996
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    a=LIST()
    ans=[1,2,3,4,5]
    for i in ans:
        if not i in a:
            print(i)
if __name__ == '__main__':
    do()

Measured memory_bytes: 9008
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
ll MOD = 1e9+7;
ll fact(ll a){
    if(!a)return 1;
    return (a*fact(a-1) % MOD)%MOD;
}
main(){
    ll N,M;
    cin >> N >> M;
    if(abs(N-M) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll cnt = (fact(N)*fact(M)) % MOD;
    if(N == M){
        cnt = cnt*2%MOD;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <cstdlib>
using namespace std;

struct Node {
    int key;
    Node *left,*right,*parent;
};

Node *gRoot,*NIL;

Node* getMinimumTree(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}

Node* getTreeSuccessor(Node *x){
    if(x->right != NIL)return getMinimumTree(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}

void deleteTree(Node *z){
    Node *y;    // 削除対象Node
    Node *x;    // yの子
    
    // 子がない場合はまたは一つしか子がない場合は対象の節点をそのまま消す
    if(z->left == NIL || z->right == NIL){
        y = z;
    }
    else{
        y = getTreeSuccessor(z);
    }
    
    // yの子xを求める
    if(y->left != NIL){
        x = y->left;
    }
    else{
        x = y->right;
    }
    
    if(x != NIL){
        x->parent = y->parent;
    }
    
    if(y->parent == NIL){
        gRoot = x;
    }else{
        if(y == y->parent->left){
            y->parent->left = x;
        }else{
            y->parent->right = x;
        }
    }
    
    if(y != z){
        z->key = y->key;
    }
    free(y);
}

Node *find(Node* u,int value){
    while(u != NIL && value != u->key){
        if(value < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int value){
    Node *y = NIL;
    // 親
    Node *x = gRoot;
    // 自身
    Node *z;
    z = (Node*)malloc(sizeof(Node));
    z->key = value;
    z->left = NIL;
    z->right = NIL;
    
    // rootから自身を挿入する場所を探す
    while(x != NIL){
        // rootから検索
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    // 親に子を持たせる
    if(y == NIL){
        gRoot = z;
    }else{
        if(z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }
}
// 先行順巡回
void preOrder(Node *u){
    if(u == NIL)return;
    printf(" %d",u->key);
    preOrder(u->left);
    preOrder(u->right);
}

// 中間順巡回
void inOrder(Node *u){
    if(u == NIL)return;
    inOrder(u->left);
    printf(" %d",u->key);
    inOrder(u->right);
}

int main(){
    int n,x;
    string com;
    
    cin >> n;
    for(int i = 0;i < n;++i){
        cin >> com;
        if(com[0] == 'f'){
            cin >> x;
            Node *t = find(gRoot,x);
            if(t != NIL) cout << "yes\n";
            else cout << "no\n";
        }
        if(com == "insert"){
            cin >> x;
            insert(x);
        }
        else if(com == "print"){
            inOrder(gRoot);
            cout << "\n";
            preOrder(gRoot);
            cout << "\n";
        }
        else if(com == "delete"){
            cin >> x;
            deleteTree(find(gRoot,x));
        }
    }
    return 0;
}


Measured memory_bytes: 21888
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var q = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < q; i++)
        {
            var k = int.Parse(Console.ReadLine().Trim());
            var ans = LowerBound(a, k);
            if (ans < 0) ans = ~ans;
            Console.WriteLine(ans);
        }
    }
    public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) < 0)
                low = mid + 1;
            else
                high = mid;
        }
        return low;
    }
    public static int LowerBound<T>(T[] arr, T value) where T : IComparable
    {
        return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    }
}



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


int main(){
  int h, w, k;
  cin >> h >> w >> k;
  char c[h][w];
  rep(i, h){
    rep(j, w){
      cin >> c[i][j];
    }
  }
  int ans = 0;
  rep(i, (1<<h)){
    rep(j, (1<<w)){
      int cnt = 0;
      rep(ih, h){
        rep(iw, w){
          if(c[ih][iw] == '#' && ((i>>ih)&1) == 0 &&
             ((j>>iw)&1) == 0) cnt++;
        }
      }
      if(cnt == k) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = input[0][0];

  return new Set(S).size === 3 ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29584
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;//複数辺があるとき用。基本使わない
typedef vector<Edges> Graph;//G[頂点]がEdges(つまりベクトル)になるのでここに辺をつっこむ。
//
ll N;
int K;
ll dp[114514]={0};
ll dp_b[114514]={0};
ll nums[114514]={0};// floor(n/j)==iなるjの数 (i>=1)
int main(){
	cin>>N;
	cin>>K;
	//K--;
	int sn=0;
	while(sn*sn<=N)sn++;
	sn--;
	int memo;
	for(int i=1;i<=sn+1;i++){
		int lef=N/i,rig=N/(i+1);
		nums[i]=lef-rig;
		//cout<<i<<" "<<nums[i]<<endl;
		dp[i]=1;
		dp_b[i]=nums[i];
		//if(nums[i]>1)memo=i;
	}
	//sn=memo;
	while(K--){
		ll ndp[114514];
		ll sum=0;
		ll sumb=0;
		for(int i=1;i<=sn;i++){
			sum+=dp[i];
			sum%=MOD;
		}
		for(int i=1;i<=(N/(sn+1));i++){
			sumb+=dp_b[i];
			sumb%=MOD;
		}

		for(int i=1;i<=sn;i++){
			ndp[i]=sum+sumb;
			ndp[i]%=MOD;
			sumb-=dp_b[i];
			sumb+=MOD;
			sumb%=MOD;
		}
		ll sum_hoge=0;
		for(int i=1;i<=sn;i++){
			sum_hoge+=dp[i];
			sum_hoge%=MOD;
			dp_b[i]=sum_hoge*nums[i];
			dp_b[i]%=MOD;
		}
		rep(i,sn+1)dp[i]=ndp[i];
		// rep(i,sn+1){
		// 	cout<<dp[i]<<" ";
		// }
		// cout<<endl;
		// rep(i,N/sn + 1){
		// 	cout<<dp_b[i]<<" ";
		// }
		// cout<<endl;
	}
	cout<<dp[1]<<endl;


}

Measured memory_bytes: 1280
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[]args) {
        FastScanner sc=new FastScanner();
        String n=sc.next();
        System.out.println(n.contains("7")?"Yes":"No");
    }
}

//高速入力コピペ
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 32448