akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cstring>

using namespace std;

int n;
int d[190], c[401];
int t[20][20];
set< vector<int> > S;

int abs(int x){ x > 0 ? x : -x; }

void search(int L, int R){
	if(L+1==R){
		vector<int> v;
		for(int i=0;i+1<n;i++)
			v.push_back(t[i][i+1]);
		S.insert(v);
		return ;
	}
	int idx = 0;
	while(c[d[idx]]==0) idx++;
	c[d[idx]]--;
	
	bool check = true;
	t[0][R-1] = t[R-1][0] = d[idx];
	for(int i=1;i<n;i++){
		if(L<i&&i<R) continue;
		if(c[t[i][R-1] = t[R-1][i] = abs(t[0][R-1]-t[0][i])]==0) check = false;
		c[t[i][R-1]]--;
	}
	if(check) search(L, R-1);
	for(int i=1;i<n;i++)
		if(i<=L||R<=i) c[t[i][R-1]]++;

	check = true;
	t[L+1][n-1] = t[n-1][L+1] = d[idx];
	for(int i=0;i+1<n;i++){
		if(L<i&&i<R) continue;
		if(c[t[i][L+1] = t[L+1][i] = abs(t[i][n-1]-t[L+1][n-1])]==0) check = false;
		c[t[i][L+1]]--;
	}
	if(check) search(L+1, R);
	for(int i=0;i+1<n;i++)
		if(i<=L||R<=i) c[t[i][L+1]]++;

	c[d[idx]]++;
}

int main(){
	while(cin >> n, n){
		S.clear();
		memset(c, 0, sizeof(c));
		for(int i=0;i<n*(n-1)/2;i++){
			cin >> d[i];
			if(i!=0) c[d[i]]++;
		}
		t[0][n-1] = t[n-1][0] = d[0];
		search(0, n-1);
		for(set< vector<int> >::iterator it=S.begin();it!=S.end();it++){
			for(int i=0;i+1<it->size();i++)
				cout << (*it)[i] << " ";
			cout << it->back() << endl;
		}
		puts("-----");
	}
}

Measured memory_bytes: 0
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(int argc, const char * argv[]) {
    /////////////////////
    // Write code below /
    /////////////////////
    int N, K;
    cin >> N >> K;
    int currentNumber = 1;  // 初期値
    for (int i = 0; i < N; i++) {
        int numberOfAfterA = currentNumber * 2;
        int numberOfAfterB = currentNumber + K;
        if (numberOfAfterA < numberOfAfterB) {
            currentNumber = numberOfAfterA;
        } else {
            currentNumber = numberOfAfterB;
        }
    }
    
    cout << currentNumber << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
def main():
    from fractions import gcd

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

    t = A[0]
    n = 1
    while t % 2 == 0:
        n *= 2
        t //= 2

    for a in A:
        if a % n != 0 or (a // n) % 2 == 0:
            print(0)
            return

    lcm = 1
    for a in A:
        lcm = lcm * a // gcd(lcm, a)
        if lcm // 2 > M:
            print(0)
            return

    print((M - lcm // 2) // lcm + 1)


main()


Measured memory_bytes: 16280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
ll ans[10];

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

    map<pair<ll, ll>, ll> x;
    rep(i, 0, n){
        pair<ll, ll> t;
        cin >> t.first >> t.second;
        t.first--;
        t.second--;
        rep(i, 0, 3){
            rep(j, 0, 3){
                if(t.first - i < 0 || t.second - j < 0 || h - t.first + i < 3 || w - t.second + j < 3) continue;
                x[pair<ll,ll>(t.first - i, t.second - j)]++;
            }
        }
    }

    ll sum = 0;
    fore(a, x){
        ans[a.second]++;
    }

    rep(i, 1, 10){
        sum += ans[i];
    }

    ans[0] = (h - 2) * (w - 2) - sum;
    rep(i, 0, 10){
        cout << ans[i] << endl;
    }

    return 0;
}


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

using namespace std;

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

void solve(int a, int b, int c) {
  int depth = 0;
  while(a%2 == 0 && b%2 == 0 && c%2 == 0 && depth < 1000) {
    int na = b/2 + c/2;
    int nb = a/2 + c/2;
    int nc = a/2 + b/2;
    a=na;
    b=nb;
    c=nc;
    depth++;
  }
  if(depth == 1000) depth = -1;
  cout << depth << endl;
}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  solve(a, b, c);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


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

int main(){
    string s;
    cin>>s;
    int ans = 700;
    rep(i,3)if(s[i]=='o')ans += 100;
    cout << ans << endl;
    return 0;
}

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

int main(){

    int n, q;
    cin >> n >> q;

    vector<priority_queue<int>> que(n);
    for(int i = 0; i < q; ++i){
        int com, t;
        cin >> com >> t;
        if(com == 0){
            int x;
            cin >> x;
            que[t].push(x);
        }
        else if(com == 1){
            if(!que[t].empty()){
                cout << que[t].top() << endl;
            }
        }
        else if(com == 2){
            if(!que[t].empty()){
                que[t].pop();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4068
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    X = int(readline())

    if X <= 3:
        print(1)
        return

    ans = 0
    for n in range(2, X):
        p = 2
        while pow(n, p) <= X:
            if ans < pow(n, p):
                ans = pow(n, p)
            p += 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9136
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e5 + 17;

int n;
int a[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	forn (i, n)
		scanf("%d", a + i);

	return true;
}

void solve()
{
	map<int, int> mp;
	vector< pair<int, int> > v2, v4;

	forn (i, n)
		++mp[a[i]];

	for (auto i : mp)
		if (i.second >= 4)
			v4.push_back(i);
		else
			if (i.second >= 2)
				v2.push_back(i);

	llong ans = 0ll;

	if (!v4.empty())
		ans = max(ans, 1ll * v4.back().first * v4.back().first);

	if (!v4.empty() && !v2.empty())
		ans = max(ans, 1ll * v4.back().first * v2.back().first);

	if (size(v2) >= 2)
		ans = max(ans, 1ll * v2.back().first * v2[size(v2) - 2].first);

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

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>

int main(void)
{
	int i,n,b,f,r,v,j,k,l,z,house[4][3][10] = {{{0}}};
	scanf("%d",&n);
	for(i = 0;i < n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		house[b - 1][f - 1][r - 1] += v;
	}
	for(j = 0;j < 4;j++){
		if(j != 0){
			printf("\n");
			for(z = 0;z < 20;z++){
				printf("#");
			}printf("\n");
		}
		for(k = 0;k < 3;k++){
			if(k != 0)printf("\n");
			for(l = 0;l < 10;l++){
				printf(" %d",house[j][k][l]);
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        long[][] comb = new long[n + 1][n + 1];
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i) {
                    comb[i][j] = 1;
                } else {
                    comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
                }
            }
        }
        TreeMap<Long, Integer> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            long x = - sc.nextLong();
            if (map.containsKey(x)) {
                map.put(x, map.get(x) + 1);
            } else {
                map.put(x, 1);
            }
        }
        int count = 0;
        long total = 0;
        for (Map.Entry<Long, Integer> entry : map.entrySet()) {
            int value = entry.getValue();
            if (count + value >= a) {
                if (total == 0) {
                    long sum = 0;
                    for (int i = a; i <= value && count + i <= b; i++) {
                        sum += comb[value][i];
                    }
                    System.out.println(- entry.getKey());
                    System.out.println(sum);
                    return;
                }
                System.out.println((total + - entry.getKey() * (a - count)) / (double)a);
                System.out.println(comb[value][a - count]);
                return;
            }
            count += value;
            total -= value * entry.getKey();
        }
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 2005
#define MOD 99994711
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int N,sumE,head[MAXN],dep[MAXN],K,fa[MAXN],ans,cnt[MAXN];
vector<pii > Ed;
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u) {
    cnt[dep[u]]++;
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa[u]) {
            fa[v] = u;
            dep[v] = dep[u] + 1;
            dfs(v);
        }
    }
}
void Solve() {
    read(N);read(K);
    int a,b;
    for(int i = 1 ; i < N ; ++i) {
    	read(a);read(b);
    	add(a,b);add(b,a);
        Ed.pb(mp(a,b));
    }
    int ans = N;
    for(int i = 1 ; i <= N ; ++i) {
        int u = i;
        fa[u] = 0;dep[u] = 0;
        memset(cnt,0,sizeof(cnt));
        dfs(u);
        int res = 0;
        for(int j = K / 2 + 1 ; j <= N ; ++j) res += cnt[j];
        ans = min(ans,res);
    }
    if(K % 2 == 0) --K;
	for(auto t : Ed) {
        fa[t.fi] = t.se;fa[t.se] = t.fi;dep[t.fi] = dep[t.se] = 0;
        memset(cnt,0,sizeof(cnt));
        dfs(t.fi);dfs(t.se);
        int res = 0;
        for(int i = K / 2 + 1 ; i <= N ; ++i) res += cnt[i];
        ans = min(ans,res);
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

int N, X;

int main() {
  cin >> N >> X;
  if(X == 1 || X == 2 * N - 1) cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    if(N == 2) {
      cout << 1 << endl << 2 << endl << 3 << endl;
    } else {
      set<int> S;
      for(int i = 1; i <= 2 * N - 1; ++i) S.insert(i);
      if(X >= 3) {
        S.erase(X - 2); S.erase(X);
        S.erase(X + 1); S.erase(X - 1);
      } else {
        S.erase(3); S.erase(1);
        S.erase(2); S.erase(4);
      }
      for(int p = 0; p < N - 2; ++p) {
        cout << *S.begin() << endl; S.erase(S.begin());
      }
      if(X >= 3) {
        cout << X - 2 << endl << X << endl
          << X + 1 << endl << X - 1 << endl;
      } else {
        cout << 3 << endl << 1 << endl
          << 2 << endl << 4 << endl;
      }
      for(int p = 0; p < N - 3; ++p) {
        cout << *S.begin() << endl; S.erase(S.begin());
      }
    }
  }
  return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
#include <stdio.h>
#include <ios>     
#include <iomanip> 

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  int N;
  cin >> N;
  vector<int> p(N,0);
  for(int i=0; i<N; i++){
    cin >> p[i];
  }
  
  //main
  int count = 0;
  for(int i=0; i<N; i++){
    if(p[i] != i+1){count ++;} 
  }
  
  // output
  if(count <= 2){cout << "YES" << endl;}
  else{cout << "NO" << endl;}

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>

using namespace std;

int const N = 205;

vector<int> G[N];
int n;

int BFS(int S) {
	static bool vis[N];
	static int f[N];
	fill(vis + 1, vis + n + 1, 0);
	auto q = queue<int>();
	q.push(S);
	f[S] = 1;
	vis[S] = 1;
	while (!q.empty()) {
		int now = q.front();
		q.pop();
		for (auto y : G[now])
			if (vis[y] == 0) {
				f[y] = f[now] + 1;
				vis[y] = 1;
				q.push(y);
			}
	}
	int ret = *max_element(f + 1, f + n + 1);
	for (int i = 1; i <= n; ++i) 
		for (auto y : G[i])
			if (abs(f[y] - f[i]) != 1)
				ret = -1;
	return ret;
}


int main() {
	cin >> n;
	string s;
	for (int i = 1; i <= n; ++i) {
		cin >> s;
		for (int j = 1; j <= n; ++j)
			if (s[j - 1] == '1')
				G[i].push_back(j);
	}
	int ans = -1;
	for (int i = 1; i <= n; ++i) {
		auto anss = BFS(i);
		ans = max(ans, anss);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 512
use std::io;
use std::collections::HashMap;


/// https://beta.atcoder.jp/contests/agc023/tasks/agc023_a
fn main() {
    let n = read_one::<usize>();
    let an = read::<isize>();
    let mut sn = vec![0; n + 1];
    for i in 0..n {
        sn[i + 1] = sn[i] + an[i];
    }

    let mut hm = HashMap::new();
    for s in &sn {
        *hm.entry(s).or_insert(0) += 1;
    }

    let ans = hm.values()
        .filter(|n| **n > 1)
        .map(|&n| ncr(n as usize, 2)).sum::<usize>();

    println!("{}", ans);
}

fn ncr(n: usize, r: usize) -> usize {
    match (n, r) {
        (0, _) | (_, 0) => 1,
        _ => ncr(n, r - 1) * (n - r + 1) / r,
    }
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 20492
#include <stdio.h>
 
int main(int argc, char** argv)
{
    char s[101], p[100];
    int i, j, k;
 
    scanf("%s", s);
    scanf("%s", p);
 
    int a = 0;
    i = j = k = 0;
 
    for (i = 0; s[i] != '\0'; i++) {
        if (s[i] == p[0]) {
            a = 1;
            j = 1;
            k = i + j;
 
            while (p[j] != '\0') {
                if (s[k] == '\0' && p[j] != '\0') {
                    k = 0;
                }
 
                if (s[k] == p[j]) {
                    j++;
                    k++;
                }
                else {
                    a = 0;
                    break;
                }
            }
 
            if (a) {
                break;
            }
        }
    }
 
    printf("%s\n", a ? "Yes" : "No");
    return 0;
}
 

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define lf long double
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <pair <ll,ll> >vii;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x;
    cin>>n>>x;
    vi a(n);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll c=1;
    ll x1=0;
    for(ll i=0;i<n;i++)
    {
        x1+=a[i];
        if(x1<=x)
        {
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  a += b; c += d;
  if(a == c) cout << "Balanced" << endl;
  else if(a < c) cout << "Right" << endl;
  else if(a > c) cout << "Left" << endl;
}

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

using namespace std;

int main()
{
	int n, c[555], s[555], f[555];
	cin >> n;
	for (int i = 0; i < n - 1; i++)
		cin >> c[i] >> s[i] >> f[i];
	for (int i = 0; i < n; i++) {
		int t = 0;
		for (int j = i; j < n - 1; j++) {
			int m = t <= s[j] ? 0 : (t * 2 - s[j] * 2 - 1) / (f[j] * 2) + 1;
			t = s[j] + f[j] * m + c[j];
		}
		cout << t << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B;
    cin >> N >> A >> B;
    ll a1 = min(A,B);
    ll a2 = max(0LL, A+B-N);
    cout << a1 << " " << a2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int h,w;
    string s;
    cin >> h >> w;
    REP(i,0,h) REP(j,0,w) {
        cin >> s;
        if (s == "snuke") cout << char('A' + j) << i + 1 << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations

march = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}

for _ in range(int(input())):
    name = input()
    if name[0] in march:
        march[name[0]] += 1

count = 0
for i in combinations(march.keys(), 3):
    count += march[i[0]] * march[i[1]] * march[i[2]]

print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
const int N = 5e5 + 5;
struct node
{
    vi cnt;
    node()
    {
        int i;
        FOR0(i, 26) cnt.pb(0);
    }
};
vector < node > st(4*N);
int left(int i)
{
    return i<<1;
}
int right(int i)
{
    return (i<<1)+1;
}
void merge(int p)
{
    int i;
    int l = left(p) , r = right(p);
    FOR0(i, 26)
        st[p].cnt[i] = st[l].cnt[i] + st[r].cnt[i];
}
void update(int p, int l, int r, int pos, int val)
{
    if(r < pos || pos < l) return;
    if(l==r)
    {
        int i;
        FOR0(i, 26) st[p].cnt[i] = 0;
        st[p].cnt[val] = 1;
        return ;
    }
    int mid= (l+r)/2;
    update(left(p), l, mid, pos, val);
    update(right(p), mid+1, r, pos, val);
    merge(p);
}
vi rq(int p,int l, int r, int i , int j)
{
    if(i>r|| j<l)
    {
        vi temp(26, 0);
        return temp;
    }
    if(l>=i&&r<=j)
        return st[p].cnt;
    int mid=(l+r)/2;
    vi lv, rv;
    int k;
    vi ans(26, 0);
    lv = rq(left(p), l, mid, i, j);
    rv = rq(right(p), mid+1, r, i, j);
    FOR0(k, 26) 
        ans[k] = lv[k] + rv[k];
    return ans;
}

int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i;
    FOR0(i, n)
    {
        update(1, 0, n-1, i, s[i]-'a');
    }
    int q;
    cin>>q;
    while(q--)
    {
        int t;
        cin>>t;
        if(t == 1)
        {
            int pos;
            char c;
            cin>>pos>>c;
            pos--;
            update(1, 0, n-1, pos, int(c-'a'));
        }
        else 
        {
            int l, r;
            cin>>l>>r;
            l--;r--;
            vi ans = rq(1, 0, n-1, l, r);
            int val = 0;
            FOR0(i, 26) if(ans[i]) val++;
            cout<<val<<endl;
        }
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 331036
#include <iostream>
#include <map>
#include <string>

using namespace std;

int
main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    map<string, bool> msb;
    while (n--) {
        string order, text;
        cin >> order >> text;
        if (order == "insert") {
            msb.insert(pair<string, bool>(text, true));
        } else if (order == "find") {
            auto iter = msb.find(text);
            if (iter != msb.end()) cout << "yes";
            else cout << "no";
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 36312
// #pragma GCC optimize(3)
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cstring>
#include <iostream>
#include <algorithm>
#define maxn 100010
// #define int long long
using namespace std;
void write(int x){if(x<0){putchar('-');x=-x;}if(x>9) write(x/10);putchar(x%10+'0');}
int read(){int d=0,w=1;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')
w=-1;for(;c>='0'&&c<='9';c=getchar())d=(d<<1)+(d<<3)+c-48;return d*w;}
void wln(int x){write(x);putchar('\n');}
void wrs(int x){write(x);putchar(' ');}
int n,a[maxn],cnt;
signed main()
{
	// freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;a[i++]=read());
	sort(a+1,a+n+1);
	if(a[n]-a[1]>1)
	{
		puts("No");
		return 0;
	}
	if(a[n]==a[1])
	{
		if(a[1]==n-1)
		{
			puts("Yes");
			return 0;
		}
		else
		{
			puts(n>>1>=a[1]?"Yes":"No");
			return 0;
		}
	}
	if(a[n]!=a[n-1])
	{
		puts("No");
		return 0;
	}
	for(int i=1;a[i]==a[1];i++)
		cnt++;
	puts(cnt+(n-cnt>>1)>=a[n]&&cnt<a[n]?"Yes":"No");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b;
	cin>>a>>b;
	for(ll i=1;i<=1000000;i++){
		ll now=i;
		if(ll(now*1.08-now)==a){
			if(ll(now*1.1-now)==b){
				cout << now;
				return 0;
			}
		}
	}
	cout << -1;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
//Never stop chasing!-MD.SOURAV.

// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll             long long int
#define li             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())

using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpii;
typedef map<ll,ll> mpllll;
typedef map<char,ll> mpchll;
typedef map<string,ll>mpsll;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

       int a,b,c;
       cin>>a>>b>>c;
       int cnt=0;
       for(int i=a;i<=b;i++)
	   {
	   	if(i%c==0)
		{
			cnt++;
		}
	   }
	   cout << cnt << endl;



}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

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

using namespace std;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define z cout<<"\n";


int main()
{
    optimize();

    long long x,r,sum=0,rem;
    cin>>x;
    r=x/500;
    sum=sum+(r*1000);
    rem=x%500;
    r=rem/5;
    sum=sum+(r*5);
    cout<<sum;
    z;


    return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int& i:h)
		cin>>i;

	vector<int> dp(n,INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<=i+k;j++)
			if(j<n)
				dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));

	cout<<dp[n-1];

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	static ArrayList<Integer> list;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		list = new ArrayList<Integer>();
		makeList();
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			int counter = 0;
			for(int i = 0; i < list.size(); i++) {
				if(list.get(i) > n && list.get(i) <= 2 * n) {
					counter++;
				}
			}
			System.out.println(counter);
		}
		
		
	}
	
	public static void makeList() {
		boolean[] isPrime = new boolean[123456*2+1];
		for(int i = 2; i < 123456*2+1; i++) {
			isPrime[i] = true;
		}
		for(int i = 2; i < 123456*2+1; i++) {
			if(isPrime[i] == true) {
				list.add(i);
				for(int j = i + i; j < 123456*2+1; j+=i) {
					isPrime[j] = false;
				}
			}
		}
		
	}
}

Measured memory_bytes: 23068
def min(a,b); a < b ? a : b ; end
N = gets.to_i
H = gets.split.map(&:to_i)
s = 1 << 30
puts H.reverse_each.all?{|h| (s >= h - 1).tap{ s = min(s,h) } } ? 'Yes' : 'No'


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

public class Main {
	public void maain(){

	}

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????

		//1???????????\????????¢
	       StringBuilder buider = new StringBuilder();

	       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String n = br.readLine();
        int key = 0;
        int kari = 0;


        //2???????????\????????¢
        String[] input2 = br.readLine().split(" ");

        //???????????????
        int[] num = new int[Integer.parseInt(n)];

        for(int set = 0; set < num.length; set++){
        	num[set] = Integer.parseInt(input2[set]);
        }

        //???????????????????????¨???
        for(int out = 1;out  <  num.length; out++){
        	key = num[out];
        	kari = out -1;
        	//???????????\
        	for(int set = 0; set < num.length; set++){
        		buider.append(num[set]);
        		if(set != num.length -1){
        			buider.append(" ");
        		}
        	}
        	System.out.println(buider.toString());

        	//????????¢?????????
        	buider.setLength(0);

        	//????????????
        	while(kari >= 0 && num[kari] > key){
        		num[kari + 1] = num[kari];
        		kari--;
        	}

        	//while?????\???????????´???
        	num[kari + 1] = key;
        }

        //??????????????¢??¨???
    	for(int set = 0; set < num.length; set++){
    		buider.append(num[set]);
    		if(set != num.length -1){
    			buider.append(" ");
    		}
    	}
    	System.out.println(buider.toString());
	}
}

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

using namespace std;

int main()
{
    int a[105];
    int n, x;
    cin >> n >> x;
    int minn= 0x3f3f3f3f;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        minn = min(minn, a[i]);
        x -= a[i];
    }
    int cnt = n;
    printf("%d\n", cnt + x / minn);
    return 0;
}


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

long n, m = 1;
long a[100001], b[100001];
const long INF = 1000000001;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for(int i = 0; i < n + 1; i++)
		b[i] = INF;

	for (int i = 0; i < n; i++)
		*lower_bound(b, b + n, a[i]) = a[i];

	cout << lower_bound(b, b + n, INF) - b << endl;

	return 0;
}


Measured memory_bytes: 4648
#include <stdio.h>
int main(void){
    int W,H,i,j;
    
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(i=0;i<W;i++){
            printf("#");
        }
        printf("\n");
        for(j=1;j<(H-1);j++){
            printf("#");
            for(i=1;i<(W-1);i++){
                printf(".");
            }
            printf("#");
            printf("\n");
        }
        for(i=0;i<W;i++){
            printf("#");
        }
        printf("\n\n");
        
    }
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int main()
{
	int r,c,i,j,k;
	long long int sps[1000][1000];


	//行数と列数を入力する
	scanf("%d %d",&r,&c);

	//r*cの表を作成する

	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
		     scanf("%lld",&sps[i][j]);
		    sps[r][c] += sps[i][j];//表全体の合計を右下に追加
		    sps[r][j] += sps[i][j];//各列の合計を右端に追加
		    sps[i][c] += sps[i][j];//各行の計を下に追加
		}
	}
	
	

	for(i=0;i<r+1;i++){
		for(j=0;j<c+1;j++){
			printf("%lld",sps[i][j]);
			if(j!=c)printf(" ");
		}
		printf("\n");
	}

}


Measured memory_bytes: 2184
#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(){
    string st;
    cin >> st;
    string ans = "";
    rep(i, st.size()){
        if(st.at(i) == '0'){
            ans += '0';
        }else if(st.at(i) == '1'){
            ans += '1';
        }else{
            if(ans.size() > 0){
                ans.erase(ans.size()-1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> c(n);
  for (auto&& e : a) {
    cin >> e;
    --e;
    ++c[e];
  }
  long long res = 0;
  for (auto e : c) {
    res += e * (e - 1) / 2;
  }
  for (int e : a) {
    res -= c[e] * (c[e] - 1) / 2;
    res += (c[e] - 1) * (c[e] - 2) / 2;
    cout << res << '\n';
    res -= (c[e] - 1) * (c[e] - 2) / 2;
    res += c[e] * (c[e] - 1) / 2;
  }
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 1e5+10;
int f(int n){
    if(n<10)
        return n;
    return 9+f(n/10);
}
main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin>>n;
    cout<<f(n+1)-1;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    string s;
    cin >> s;
    s[3] = '8';
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int k = reader.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = reader.nextInt();
        }
        System.out.println(solve(a, k));
    }

    private static int solve(int[] a, int k) {
        return findMinIt(a, k);
    }

    private static int findMinIt(int[] a, int k) {
        int[] dp = new int[a.length];
        for (int i = a.length - 2; i >= 0; --i) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = i + 1; j < i + k + 1 && j < a.length; ++j) {
                dp[i] = Math.min(dp[j] + Math.abs(a[i] - a[j]), dp[i]);
            }
        }
        return dp[0];
    }
}


Measured memory_bytes: 50744
#include<iostream>
 
using namespace std;
 
int solve(const string& s1, const string& s2, int l1, int l2){
  int tmp = 0;
  int res = 0;
  int len = min(s2.length()-l2,s1.length()-l1);
  for(int i = 0; i < len; i++){
    if(s1[l1+i] != s2[l2+i]){
      res = max(res,tmp);
      tmp = 0;
    }else{
      tmp++;
    }
  }
  return max(tmp,res);
}
 
int main(){
   
  string s1,s2;
  int l1,l2,ans;
  int i = 0;
  while(1) {
  	cin >> s1;
  	cin >> s2;
  	l1 = s1.length();
  	l2 = 0;
  	ans = 0;
  	while(l1 != 0 || l2 <= s2.length()) {

      if(l1 != 0){
      	l1--;
      } else {
      	l2++;
      }
      ans = max(ans,solve(s1,s2,l1,l2));
  	}
    cout << ans << endl;
    if (i==9) {
    	break;
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 1208
// 
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=105;
typedef long long ll;

int n,m,ans,x;
int a[maxn];

int main()
{
	int i,j,k,T;
	cin>>n>>m>>x;
	for(i=1;i<=m;++i)
	{
		cin>>j;
		a[j]=1;
	}
	
	int now=0;
	for(i=x+1;i<=n;++i)
	{
		if(a[i])
		now++;
	}
	ans=now;
	now=0;
	for(i=0;i<x;++i)
	{
		if(a[i])
		now++;
	}
	
	ans=min(ans,now);
	
	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);
    while(true){
      int n = sc.nextInt();
      if(n==0)break;
      int sum = 0;
      for(int i=0;i*4<n;i++){
        sum += sc.nextInt();
      }
      System.out.println(sum);
    }
  }
}

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


const int MAX = 10000;
const int NIL = -1;

struct Node {
    int p;
    int l;
    int r;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d){
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].l, d+1);
    setDepth(T[u].r, d+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].l != NIL) h1 = setHeight(T[u].l) + 1;
    if(T[u].r != NIL) h2 = setHeight(T[u].r) + 1;
    return H[u] = max(h1, h2);
}

int getDegree(int u){
    int degree = 0;
    if(u == NIL) return NIL;
    if(T[u].l != NIL) degree++;
    if(T[u].r != NIL) degree++;
    return degree;
}

int getSibling(int u){
    int p = T[u].p;
    if( p == NIL ) return NIL;
    if(T[p].r != NIL && T[p].l != NIL) return T[p].l + T[p].r - u;
    else return NIL;
}

void printPreorder(int u){
  if (u == NIL) return;
  cout << " " << u;
  printPreorder(T[u].l);
  printPreorder(T[u].r);
}

void printInorder(int u){
  if (u == NIL) return;
  printInorder(T[u].l);
  cout << " " << u;
  printInorder(T[u].r);
}

void printPostorder(int u){
  if (u == NIL) return;
  printPostorder(T[u].l);
  printPostorder(T[u].r);
  cout << " " << u;
}



int main(){
    int v, l, r, root = 0;
    cin >> n;

    for(int i=0; i<n; i++) T[i].p = NIL;

    for(int i=0; i<n; i++){
        cin >> v >> l >> r;
        T[v].l = l;
        T[v].r = r;
        if(l != NIL) T[l].p = v;
        if(r != NIL) T[r].p = v;
    }

    for(int i=0; i<n; i++) {
        if(T[i].p == NIL) root = i;
    }

    cout << "Preorder\n";
    printPreorder(root);
    cout << "\n";
    cout << "Inorder\n";
    printInorder(root);
    cout << "\n";
    cout << "Postorder\n";
    printPostorder(root);
    cout << "\n";


    return 0;
}

Measured memory_bytes: 1168
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = a - 1; i >= b; i--)
#define rrep(i, a) rFOR(i, a, 0)
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

//組み合わせを線形で
//参考:https://drken1215.hatenablog.com/entry/2018/06/08/210000

const int MXN = 1000001;//変更可
long long fac[MXN], inv[MXN], finv[MXN];

void COMinit(int M){
    fac[0] = fac[1] = 1;
    inv[1] = 1;
    finv[0] = finv[1] = 1;
    for(int i = 2; i < MXN; i++){
        fac[i] = fac[i-1] * i % M;
        inv[i] = M - M / i * inv[M%i] % M;
        finv[i] = finv[i-1] * inv[i] % M;
    }
}

long long COMBI(int N, int K, int M){
    if(N < K){
        return 0;
    }
    if(N < 0||K < 0){
        return 0;
    }
    return fac[N] * finv[N-K] % M * finv[K] % M;
}

long long PERMU(int N, int K, int M){
    if(N < K){
        return 0;
    }
    if(N < 0||K < 0){
        return 0;
    }
    return fac[N] * finv[N-K] % M;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll S;
    cin >> S;
    COMinit(MOD);
    ll ans=0;
    FOR(i,1,S+1){
        ans+=COMBI(S-3*i+i-1,i-1,MOD);
        ans%=MOD;
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 27080
#include <stdio.h>
#define MAX 100000

int main()
{
  int l, r, m, n, S[MAX], q, T[MAX], i, j, c = 0;

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

  for(i = 0; i < q; i++){
    scanf("%d", &T[i]);
    r = n;
    l = 0;
    while(l < r){
      m = (l + r) / 2;
      if(S[m] == T[i]){
	c++;
	break;
      }
      else if(T[i]< S[m]) r = m;
      else l = m + 1;
    }
  }
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;
  ll i,j,k;
  vector<ll> B(N-1);
  for(i=0;i<N-1;i++){
    cin >> B[i];
  }
  ll ans = B[0] + B[N-2];
  for(i=0;i<N-2;i++){
    ans += min(B[i],B[i+1]);
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main()
{
	int n, m;
	cin >>n >>m;
	int ans = 1;
	for (int i = 1; i <= n; i++){
		ans = min(ans + m, 2 * ans);
	}
	cout <<ans <<endl;
	return 0;
}

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

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

long H;
//vector<long> dp(pow(10, 5) +10, 0);


long rec(long h){
	if (h==1) return 1;
	//if (dp.at(h) > 0 ) return dp.at(h);

	return rec((long)h/2)*2 + 1;
}



int main(){
	cin >> H;
	
	cout << rec(H) << endl;

	return 0;
}

Measured memory_bytes: 256
S = input()

tmp = len(S)

while len(S) > 0:
  if len(S) < 5:
    print('NO')
    exit()
  elif len(S) == 5:
    if S[len(S)-5:len(S)] == 'dream':
      S = S[:len(S)-5]
    elif S[len(S)-5:len(S)] == 'erase':
      S = S[:len(S)-5]
  elif len(S) == 6:
    if S[len(S)-6:len(S)] == 'eraser':
      S = S[:len(S)-6]
  elif len(S) == 7:
    if S[len(S)-7:len(S)] == 'dreamer':
      S = S[:len(S)-7]
  else:
    if S[len(S)-7:len(S)] == 'dreamer':
      S = S[:len(S)-7]
    elif S[len(S)-6:len(S)] == 'eraser':
      S = S[:len(S)-6]
    elif S[len(S)-5:len(S)] == 'dream':
      S = S[:len(S)-5]
    elif S[len(S)-5:len(S)] == 'erase':
      S = S[:len(S)-5]
      
  if tmp == len(S):
    print('NO')
    exit()
  else:
    tmp = len(S)
    
print('YES')

Measured memory_bytes: 133880
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

#define PI 3.14159265

using namespace std;

int n, k;
string s;

int main(){
    cin >> n >> k >> s;
    vector<char> v;

    for(int i = 0; i < s.length(); i++){
        v.push_back(s[i]);
    }

    v[k-1] = tolower(v[k-1]);

    for(int i = 0; i < n; i++){
        cout << v[i];
    }




}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int a[N],n,ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n-1;j++)
        {
            int y=lower_bound(a+1+j,a+1+n,a[i]+a[j])-a-1;
            if(y==n+1)continue;
            ans+=y-j;
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n, mod = int(input()), 10**9 +7
memo = [{} for i in range(n+1)]

def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i-1], t[i] = t[i], t[i-1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == n:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3 + c):
            ret = (ret + dfs(cur+1,last3[1:] + c)) % mod
    memo[cur][last3] = ret
    return ret

print(dfs(0, 'TTT'))

Measured memory_bytes: 3884
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)

	valsNumber := make([]int64, n)
	valsMark := make([]string, n)
	for i := int64(0); i < n; i++ {
		valsMark[i] = nextString(sc)
		valsNumber[i] = nextInt(sc)
	}

	m := make(map[int64]bool, n)

	for i := int64(0); i < n; i++ {
		p := valsNumber[i]
		switch valsMark[i] {
		case "H":
			p += 13
		case "C":
			p += 26
		case "D":
			p += 39
		}
		m[p] = true
	}

	for i := int64(1); i <= 52; i++ {
		if _, ok := m[i]; !ok {
			cn := (i-1)%13 + 1
			var cm string
			if i > 39 {
				cm = "D"
			} else if i > 26 {
				cm = "C"
			} else if i > 13 {
				cm = "H"
			} else {
				cm = "S"
			}
			fmt.Printf("%s %d\n", cm, cn)
		}
	}
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1152
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i <= X + K - 1; ++i) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i >= 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll lim=1e18;

int main() {
	int n,k; cin >> n >> k;
	vint h(n);
	rep(i,n) cin >> h[i];
	sort(be(h)); reverse(be(h));
	ll ans=0;
	for(int i=k;i<n;i++) ans+=h[i];
		cout << ans << endl;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

bool ans = false;

void dfs(int A, int B, int C, int K) {
    if (K == -1) return;
    if (A < B && B < C) ans = true;
    dfs(A * 2, B, C, K - 1);
    dfs(A, B * 2, C, K - 1);
    dfs(A, B, C * 2, K - 1);
}

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    dfs(A, B, C, K);
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3620