akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

 int main (){
    char cs[1201];
    scanf("%[^\n]",cs);

    for(int i=0;cs[i]!='\0';i++){
        if(islower(cs[i])){
            cs[i]=toupper(cs[i]);
        }
        else if(isupper(cs[i])){
            cs[i]=tolower(cs[i]);
        }
    }
    
    for(int i=0;cs[i]!='\0';i++){
        cout << cs[i];
    }
    cout << endl;
   
 }



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;

 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st s;
    cin>>s;
  ll k;
    cin>>k;
  ll ans=0;
  ll n=s.sz;
  ll count=1;
  ll head=0;
  ll end=0;
  FOR(i,1,n){
    
    if(s[i-1]==s[i]){
      count++;
    }
    
    else if(i==count){
      head=count;
      count=1;
    }
    
    else{
      ans+=count/2*k;
      count=1;
    }
    
    if(i==n-1){
      end=count;
    }  
  }

  if(count==n){
    ans=k*n/2;
  }
  
  else if(s[0]==s[n-1]){
    ans+=(head+end)/2*(k-1);
    ans+=head/2+end/2;
  }
  
  else{
    ans+=head/2*k;
    ans+=end/2*k;
  }
  
  cout<<ans<<endl;
  
}

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

int main()
{
	for(string s;cin>>s;){
		string t;
		for(char c:s){
			if(t.size() && t.back()=='S' && c=='T')
				t.pop_back();
			else
				t+=c;
		}
		cout<<t.size()<<endl;
	}
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define mper make_pair
#define PI 3.14159
#define F first
#define S second
#define ll long long
//#define forik(i, a, b) for(ll i = a; i <= b; ++i)
#define vl vector<ll>
#define pll pair<ll, ll>
//#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll f(ll n, ll x) {

    if(n % x == 0) {

        return (n * 2ll) - x;

    }

    else {

        ll N = n - (n % x);

        return (N * 2) + f(x, n % x);

    }

}

int main() {

ll n, x;

cin >> n >> x;

cout << f((n - x), x) + n;


return 0;
}


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;

const int MAX = int(1e5)+1;
int num[MAX];

int main() 
{
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n) num[i] = 0;

    queue<int> que;
    int r;
    int l;
    int base = 1;
    char last = 'N';
    rep(i,n) {
        char ch = s[i];

        if (last == 'R' && ch == 'L') {
            r = i-1;
            l = i;
        }

        if (i==n-1) que.push(i);

        if ((last == 'L' && ch == 'R') || i==n-1) {
            while(!que.empty()) {
                int x = que.front(); que.pop();
                if (base == 0) num[r]++;
                if (base == 1) num[l]++;
                base++;
                base%=2;
            }
            base = 0;
        } else if (ch == 'R') {
            base++;
            base%=2;
        }
        last = ch;
        que.push(i);        
    }
    rep(i,n) printf("%d%c", num[i], i==n-1?'\n':' ');
    return 0;
}


Measured memory_bytes: 1280
n = int(input())

string_list = [''.join(sorted(input())) for i in range(n)]

word_dict = dict()

counter = 0

for i in range(n):
  word_dict.setdefault(string_list[i], 0)
  word_dict[string_list[i]] += 1
  if word_dict[string_list[i]] != 1:
    counter += word_dict[string_list[i]] - 1
  
print(counter)
  

Measured memory_bytes: 19404
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define repr(i,a,n) for(int i = n-1;i >= a;i--)
#define ALL(v) v.begin(), v.end()
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

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

void YNout(bool check){
	if(check)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return;
}

void Yayout(bool check){
	if(check) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	
	return;
}
/*
template <typename T>
void vecout(vector<T>& vecout_vec){
	
	rep(i,0,vecout_vec.size()){
		cout << vecout_vec.at(i) << endl;
	}
	
	return ;
}

template <typename T>
void vecin(vector<T>& vecin_vec, ll n){
	
	ll temp ;
	
	rep(i,0,n){
		cin >> temp;
		vecin_vec.push_back(temp);
		
	}
}

template <typename T>
void in(T& literal_in, T& literal_in2, ...){
	cin >> literal_in;
	in(literal_in2, ...);
	
	return;
}

template <typename T>
void in(T& literal_in){
	
	cin >> literal_in;
	
	return;
}

template <typename T>
void out(T& literal_out, T& literal_out2, ...){
	cout << literal_out << endl;
	out(literal_out2, ...);
	
	return;
}

template <typename T>
void out(T& literal_out){
	
	cout << literal_out << endl;
	
	return;
}
*/
signed main(){
	ll r,d,x;
	
	cin >>r >> d >> x;
	rep(i,0,10){
		x *= r;
		x -= d;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
constexpr int INF = 1001001001;
constexpr int DEBUG = 0;
using ll = long long;
using namespace std;
int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    
    int maxA = 0;
    for (int i = 0; i < n; i++)
        maxA = max(maxA, a[i]);
        
    vector<int> dp(h + maxA, 0);
    for (int i = 1; i < h + maxA; i++) {
        int m = INF;
        for (int j = 0; j < n; j++) {
            m = min(m, dp[max(0, i - a[j])] + b[j]);
        }
        dp[i] = m;
    }
    
    if(DEBUG >= 1) {
        for (int i = 0; i < dp.size(); i++)
            cout << dp[i] << " ";
        cout << endl;
    }
    
    int ans = INF;
    for (int i = h; i < h + maxA; i++)
        ans = min(ans, dp[i]);
    
    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);
		String red = sc.next();
		String blue = sc.next();
		int redN = sc.nextInt();
		int blueN = sc.nextInt();
		String either = sc.next();

		if(either.equals(red)) {
			redN--;
		}else {
			blueN--;
		}

		System.out.println(redN + " " + blueN);
	}
}

Measured memory_bytes: 21844
N = input()
S = raw_input()

count_l = [0]
count_r = [0]


for i in range(N):
    if S[i] == 'W':
        tmp = count_l[i] + 1
    else:
        tmp = count_l[i]
    count_l.append(tmp)
    if S[N-1-i] == 'E':
        tmp = count_r[i] + 1
    else:
        tmp = count_r[i]
    count_r.append(tmp)

count_r.reverse()

Ans = count_l

for i in range(N+1):
    Ans[i] = count_r[i] + count_l[i]

print(min(Ans))

Measured memory_bytes: 31576
/*
 * main.c
 *
 *  Created on: 2019/02/09
 *      Author: londo
 */

#include<stdio.h>

int main(){
	int L,M,N;
	scanf("%d %d %d",&L,&M,&N);
	if((L<M)&&(M<N)) printf("Yes\n");
	else printf("No\n");

	return 0;
}



Measured memory_bytes: 2100
def count_num_light(a):
  ret = [0 for _ in range(len(a))]
  n = len(a)
  for i in range(n):
    start = max(0, i-a[i])
    end = min(n-1, i+a[i])
    ret[start] += 1
    if end+1 < n:
      ret[end+1] -= 1
  for i in range(1,n):
    ret[i] += ret[i-1]
  
  return ret
                  
n, k = map(int, input().split())
a = list(map(int, input().split()))
num_light = count_num_light(a)
 
for i in range(k-1):
  num_light = count_num_light(num_light)
  if sum(num_light) == n**2:
    break
    
print(*num_light)


Measured memory_bytes: 168352
#include<stdio.h>

int A[500000],count = 0;

void merge(int left,int mid,int right){
  int i,j,k,n1,n2;

  n1 = mid - left;
  n2 = right - mid;

  int L[n1],R[n2];

  for(i = 0;i < n1;i++) L[i] = A[left + i];
  for(i = 0;i < n2;i++) R[i] = A[mid + i];

  L[n1] = R[n2] = 1000000005;

  i = 0; j = 0;
  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
      count++;
    }
    else {
      A[k] = R[j];
      j++;
      count++;
    }
  }
}

void mergeSort(int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(left,mid);
    mergeSort(mid,right);
    merge(left,mid,right);
  }
}


int main(){
  int n,i,data;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&data);
    A[i] = data;
  }

  mergeSort(0,n);

  for(i = 0;i < n;i++){
    if(i > 0) printf(" ");
    printf("%d",A[i]);
  }printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 5760
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

//解説
//ソートして上から取ることでパターンごとのNlogNにできる．
//当たり前だが重さが全部1であるようなナップサックはソートで解けるので二度手間しないように注意
//ちなみにソートした時に上からM番目をO(N)で探すこともできる
int N,M;
int xyz[3][1005];
signed main(){
    scanf("%lld %lld",&N,&M);
    rep(i,N){
        scanf("%lld %lld %lld",&xyz[0][i],&xyz[1][i],&xyz[2][i]);
    }
    int ans=-LLINF;
    rep(p,8){
        int plus[1005];
        rep(i,N){
            plus[i]=0;
            rep(t,3){
                if((p>>t)%2==1)plus[i]+=xyz[t][i];
                else plus[i]-=xyz[t][i];
            }
        }
        sort(plus,plus+N,greater<int>());
        int sans=0;
        rep(i,M)sans+=plus[i];
        ans=max(ans,sans);
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 1764
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll gcd(ll u, ll v){
    while (v != 0) {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}

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

int main(){
    int n;
    ll com_mul = 1;
    cin >> n;
    REP(i, n){
        ll t;
        cin >> t;
        com_mul = lcm(com_mul, t);
    }
    cout << com_mul << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
using namespace std;

const int lim=100005;

ll t[lim];

int n,w;
ll a;
int b,wyn;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>w;
	
	for(int i=1;i<=100000;i++) t[i]=-1;
	
	while(n--){
		cin>>a>>b;
		for(int i=100000;i>=b;i--){
			if(t[i-b]!=-1 && w>=t[i-b]+a) {
		//		printf("%d %d %lld %lld %lld",i,b,t[i-b],t[i],a);
				if(t[i]==-1) t[i]=t[i-b]+a; else t[i]=min(t[i],t[i-b]+a);
				wyn=max(wyn,i);
			//	printf("%lld\n",t[i]);
			}
		}
	}	
	cout<<wyn;
	return 0;
}

Measured memory_bytes: 1024
use std::cmp::{min, Reverse};
use std::collections::BinaryHeap;

const INF: u64 = 1 << 50;
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let r: usize = sc.read();
    let seq: Vec<usize> = (0..r).map(|_| sc.read::<usize>() - 1).collect();
    let mut dist = vec![vec![INF; n]; n];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        let c: u64 = sc.read();
        dist[a - 1][b - 1] = c;
        dist[b - 1][a - 1] = c;
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
            }
        }
    }

    let mut heap = BinaryHeap::new();
    let mut dp = vec![vec![INF; r]; 1 << r];
    for i in 0..r {
        let mask = 1 << i;
        heap.push((Reverse(0), mask, i));
        dp[mask][i] = 0;
    }
    while let Some((_, mask, prev)) = heap.pop() {
        for i in 0..r {
            if mask & (1 << i) != 0 {
                continue;
            }
            let next_mask = mask | (1 << i);
            let next = seq[i];
            let prev_v = seq[prev];
            let cost = dist[next][prev_v];
            if dp[next_mask][i] > dp[mask][prev] + cost {
                dp[next_mask][i] = dp[mask][prev] + cost;
                heap.push((Reverse(dp[next_mask][i]), next_mask, i));
            }
        }
    }

    let mut ans = INF;
    for i in 0..r {
        ans = min(ans, dp[(1 << r) - 1][i]);
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2464
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  while(true){
    ll n=s.size();
    if(n>=7&&s.substr(n-7)=="dreamer")s.erase(n-7);
    else if(n>=5&&s.substr(n-5)=="dream")s.erase(n-5);
    else if(n>=6&&s.substr(n-6)=="eraser")s.erase(n-6);
    else if(n>=5&&s.substr(n-5)=="erase")s.erase(n-5);
    else break;
  }
  if(s.size()==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cctype>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include <map>
#include <set>

using namespace std;

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 100000000

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

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main(void){
	int H, W;
    int cost[10][10];
    cin >> H >> W;
    REP(i, 10){
        REP(j, 10){
            cin >> cost[i][j];
        }
    }
    int a[H][W];
    REP(i, H){
        REP(j, W){
            cin >> a[i][j];
        }
    }

    REP(k, 10){
        REP(i, 10){
            REP(j, 10){
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    int res = 0;
    REP(i, H){
        REP(j, W){
            if(a[i][j] != -1){
                res += cost[a[i][j]][1];
            }
        }
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include <string>
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(int argc, char const *argv[])
{
    //重要なのは，掛けた途中で64bit整数を超えるとオーバーフローする
    //そのため，掛ける前に10^18を超えるかどうか判断する
    ull N;
    cin >> N;
    ull ans=1;
    ull a=1;
    ull i;
    vector<ull> A(N,1);
    int flg = 1;
    for (i = 0; i < N; i++)
    {
        cin >> a;
        A[i] = a;
        if (a==0)
        {
            flg = 0;
        }  
    }
    if (flg!=0)
    {
        for (ull i = 0; i < N; i++)
        {
            if (A[i] <= 1000000000000000000/ans )
            {
                ans*=A[i];
            }
            else
            {
                flg = -1;
            }
        }
    }
    if (flg == -1)
    {
        cout << -1;
    }
    else if (flg == 0)
    {
        cout << 0;
    }
    else
    {
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 3948
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val h = (0 until n).map { sc.next().toInt() }
    println(problem124a(n, h))
}

fun problem124a(n: Int, h: List<Int>): Int {
    val dp = (0 until n).map { 0 }.toMutableList()
    var count = 1
    dp[0] = h[0]
    for (i in 1 until n) {
        if (dp[i - 1] <= h[i]) count++
        dp[i] = Math.max(dp[i - 1], h[i])
    }
    return count
}

Measured memory_bytes: 29480
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int N; 
	cin >> N;
    long long int a[N]; 
    	for(int i=0;i<N;i++){
    	cin >> a[i];
    	}
    long long b = a[0];
    long long c = a[0];
  	for(int i=1;i<N;i++){
    		if(b < a[i]){
			b = a[i];
			}
    		if(c > a[i]){
			c = a[i];
			}
    	}
	if(b-c >= 2){
      	cout << "No" << endl;
    	}
  	if(b == c){
      		if(N >= 2*b){
      		cout << "Yes" << endl;
    		}else if(b == N-1){
      		cout << "Yes" << endl;
    		}else{
            cout << "No" << endl;
            }
    	}
	if(b-c == 1){
		long long x = 0;
        long long y = 0;
        for(int i=0;i<N;i++){
    		if(b == a[i]){
			x = x + 1;
			}
    		if(c == a[i]){
			y = y + 1;
			}
    	}
        if(b > y && x >= 2 * (b-y)){
      		cout << "Yes" << endl;
    	}else{
            cout << "No" << endl;
    	} 
    }
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class283
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string r = Console.ReadLine();
            var used = new List<string>();
            used.Add(r);

            char last = r.Last();
            bool frag = true;
            for(int i = 1; i < N; i++)
            {
                var w = Console.ReadLine();
                if (!used.Contains(w) && w.First() == last)
                {
                    last = w.Last();
                    used.Add(w);
                    continue;
                }

                frag = false;
            }

            Console.WriteLine(frag?"Yes":"No");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

const ll large_P = 1e9 + 7;


int main(){
  int K, S;
  cin >> K >> S;
  
  ll res;
  rep(i, K+1){
    rep(j, K+1){
      if(0 <= S-i-j && S-i-j <= K) res++;
      //else break;
    }
  }
  
  
  cout << res;
}

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

void show(int nums[], int n) {
    for (int k = 0; k < n; ++k) {
        if( k == n - 1) {
            cout << nums[k];
        } else {
            cout << nums[k] << " ";
        }
    }
    cout << endl;
}

void bubble_sort(int nums[], int n) {
    int flag = 1;
    int count = 0;
    while(flag) {
        flag = 0;
        for (int i = n - 1; i >= 1 ; --i) {
           if(nums[i] < nums[i - 1]) {
               int temp = nums[i];
               nums[i] = nums[i - 1];
               nums[i - 1] = temp;
               flag = 1;
               count++;
           }
        }
    }
    show(nums, n);
    cout << count << endl;
}

int main()
{
    int n;
    cin >> n;
    int nums[n];
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    bubble_sort(nums, n);
    return 0;
}

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

using namespace std;

const int Mod = 1e9 + 7;
const int N = 3e5 + 10;

int n, a[N];
stack<int> ans;

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = n; i >= 1; i--) {
    int pos = 0;
    for (int j = i; j >= 1; j--) {
      if (a[j] == j && a[j] <= i) {
        pos = j;
        break;
      }
    }
    // cout << pos << endl;
    if (!pos) {
      puts("-1");
      return 0;
    }
    ans.push(pos);
    for (int j = pos; j < i; j++) {
      a[j] = a[j + 1];
    }
  }
  while (ans.size()) {
    printf("%d\n", ans.top());
    ans.pop();
  }
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
using namespace std;

void solve() {
  int n;
  cin >> n;

  vector<int> rates(9, 0);

  while (n--) {
    int rate;
    cin >> rate;
    if (rate >= 3200)
      rates.at(8)++;
    else
      rates.at(rate / 400)++;
  }

  int kind = 0;
  for (size_t i = 0; i < rates.size() - 1; i++) {
    if (rates.at(i) != 0)
      kind++;
  }

  // all rate are over 3200, minv is 1 ?
  cout << max(kind, 1) << " " << kind + rates.back() << endl;
}

void wrapper() {
  rep(i, 4) {
    cout << "[TEST " << (i + 1) << "]\n";
    solve();
    cout << "\n";
  }
}

int main() {
  fastIO;
#ifdef _DEBUG
  wrapper();
#else
  solve();
#endif
}


Measured memory_bytes: 3660
#include <iostream>
#include <string>

using namespace std;

int main(){
  string  S;
  cin >> S;
  
  bool app[26];
  for(int i=0;i<26;i++){
    app[i] = false;
  }
  
  for(int i=0;i<S.size();i++){
	app[S[i] - 'a'] = true;
  }
  
  string s;
  
  for(int i=0;i<26;i++){
	  if(app[i] == false){
        s = (char)(i + 'a');
        break;
    }
    s = "None";
  }
  
  cout << s << endl;
  return 0;
}
      

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

n, w = map(int, input().split())
v = 100*10**3
item = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] + [float("inf")]*v] + [[float("inf")]*(v+1) for _ in range(n)]
wei, val = 0, 1

for i in range(n):
    for j in range(v+1):
        if item[i][val] <= j:
            dp[i+1][j] = min(dp[i][j], dp[i][j-item[i][val]] + item[i][wei])
        else:
            dp[i+1][j] = dp[i][j]

for i in range(v+1):
    if (dp[n][i] <= w):
        ans = i
print(ans)

Measured memory_bytes: 311288
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n = n_in()
print(sum(i for i in range(n+1) if i%3 != 0 and i%5 != 0))


Measured memory_bytes: 67528
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(int a, int b)
{
   return a < b;
}
std::priority_queue<int, std::vector<int>, std::function<bool(int, int)>> pq(Compare);

vi pr;
void seive(){
	int p[100005]={0};
	f(i,2,100005){
		if(p[i]==0){
			pr.pb(i);
			for(int j=i*2;j<100005;j+=i) p[i]=1;
		}
	}
}


void solve(){
	int d; cin>>d;
	int n; cin>>n;
	int cnt=0;
	int curr=1;
	while(true){
		int c=curr;
		int xp=0;
		while(c%100==0){
			++xp;
			c/=100;
		}
		cnt+=xp==d;
		if(cnt==n){
			cout<<curr;
			return ;
		}
		++curr;
	}
}


int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll; 
typedef long double ld; 
const ll mod = 1e9+7;
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); 
    int N;
    cin>>N;
    vector <int> v(N);
    for(int &x : v)
		cin>>x;
		
	vector <int> cost(N);
	cost[0] = 0; cost[1] = abs(v[1] - v[0]);
	for(int i = 2; i < N ; i++ )
		cost[i] = min(cost[i-1] + abs(v[i] - v[i-1]),cost[i-2] + abs(v[i] - v[i-2]) );
	
	cout<<cost[N-1];
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a==5&&b==5&&c==7) cout<<"YES";
        else if (a==5&&b==7&&c==5) cout<<"YES";
        else if (a==7&&b==5&&c==5) cout<<"YES";
        else cout<<"NO";
}

Measured memory_bytes: 256
using System;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var cards = new bool[53];
            for (var i = 0; i < 53; i++)
            {
                cards[i] = true;
            }

            var n = int.Parse(Console.ReadLine());

            for (var i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Split(' ');
                var suit = line[0];
                var num = int.Parse(line[1]);
                if (suit == "S")
                {
                    cards[num] = false;
                }
                else if (suit == "H")
                {
                    cards[13+num] = false;
                }
                else if (suit == "C")
                {
                    cards[26+num] = false;
                }
                else{
                    cards[39+num] = false;
                }
            }

            var suits = new string[] {"S", "H", "C", "D"};
            for (var i = 0; i < 4; i++)
            {
                for (var m = 1; m <= 13; m++)
                    {
                        if (cards[13*i+m])
                        {
                            Console.WriteLine($"{suits[i]} {m}");
                        }
                    }
            }
        }
    }
}



Measured memory_bytes: 15988
#include <stdio.h>

int main(){
	int n,ans,a,b,c,d;

	while( scanf("%d", &n)!=EOF ){
		ans = 0;
			for(a=0 ; a<=9 ; a++){
				for(b=0 ; b<=9 ; b++){
					for(c=0 ; c<=9 ; c++){
						for(d=0 ; d<=9 ; d++){
							if((a+b+c+d)==n){
								ans++;
							}
						}
					}
				}
			
		}
		printf("%d\n",ans);
	}
	return 0;
}  

Measured memory_bytes: 596
#include<bits/stdc++.h>
#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) ;
// Use cout.flush() for interactive problems.
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;
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;
int main()
{
    she_told_me_dont_worry
    int a[3]={};
    string s;
    cin>>s;
    int n = s.size();
    int i;
    FOR0(i, n) a[s[i]-'a']++;
    FOR0(i,3) if(!a[i]) break;
    if(i==3)cout<<"Yes";
    else cout<<"No";

}

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

	ll n, a, b;
	cin >> n >> a >> b;
	if((b-a)%2 == 0){
        cout << (b-a)/2 << "\n";
        return 0;
	}
	ll t1 = a;
	ll b1 = b-t1;
	t1 += (b1-1)/2;
	ll t2 = n-b+1;
	ll a1 = a+t2;
	t2 += (n-a1)/2;
	cout << min(t1, t2);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
	    int b = sc.nextInt();
		int c=0;
		if((a+b)==15)
			c=1;
		else if((a*b)==15)
			c=2;
		else
			c=3;
		
		switch(c){
			case 1:
					System.out.print("+");	
					break;
			case 2:
					System.out.print("*");	
					break;
			case 3:
					System.out.print("x");	
					break;
		}
	}
}

Measured memory_bytes: 20820
#include <iostream>
#include <string>

using namespace std;

int main() {
	string op;
	string ABCD;
	int seven;
	int a, b, c, d;

	cin >> ABCD;

	a = ABCD[0] - '0';
	b = ABCD[1] - '0';
	c = ABCD[2] - '0';
	d = ABCD[3] - '0';

	for (int bit = 0; bit < (1 << 3); bit++) {
		op = "---";
		seven = 0;
		for (int i = 0; i < 3; i++) {
			if (bit & (1 << i)) op[i] = '+';
		}
		if (op[0] == '+') seven += a + b;
		else seven += a - b;
		if (op[1] == '+') seven += c;
		else seven -= c;
		if (op[2] == '+') seven += d;
		else seven -= d;
		if (seven == 7) break;
	}

	cout << a << op[0] << b << op[1] << c << op[2] << d << "=7" << endl;

	return 0;
}

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

char s[101];

int main(){
  cin >> s;
  for(int i = 0; s[i]; i++){
    s[i] = 'x';
  }
  cout<< s << endl;
  
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
const ll mod=998244353;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
int n;
void solve()
{
	n = read();
	ll ans = 0;
	for(int i=1; i<=n; i++) {
		ans += (n-1) / i;
	}
	cout << ans << endl;
}
int main()
{
	int T=1;
	while(T--) solve();
}

Measured memory_bytes: 3644
/*/ Author:amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)    sort(all(v)); (v).erase(unique(all(v)),(v).end())
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
#define int long long
/*/-----------------------------Code begins----------------------------------/*/
int binpow(int a,int b){
int res=1;
while(b){
    if(b&1)
        res=res*a;
    a=a*a;
    b>>=1;}
    return res;
}
int32_t main(){
fio;
int h;
cin>>h;
int n=h,c=0;
while(n){
    c++;
    n/=2;
}
cout<<(binpow(2,c))-1;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

const MOD: usize = 998244353;

fn main() {
    input! {a:usize,b:usize,c:usize,d:usize}
    let mut dp = vec![vec![1; d + 1]; c + 1];

    for i in a + 1..=c {
        dp[i][b] *= dp[i - 1][b] * b;
        dp[i][b] %= MOD;
    }
    for i in b + 1..=d {
        dp[a][i] = dp[a][i - 1] * a;
        dp[a][i] %= MOD;
    }

    for i in a + 1..=c {
        for j in b + 1..=d {
            dp[i][j] = dp[i - 1][j] * j + dp[i][j - 1] * i;
            dp[i][j] %= MOD;
            dp[i][j] += MOD;
            dp[i][j] -= ((i - 1) * (j - 1) * dp[i - 1][j - 1]) % MOD;
            dp[i][j] %= MOD;
        }
    }
    println!("{}", dp[c][d]);
}


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

int main()
{
	string s;
	int a,b;
	cin>>a>>b>>s;
	if (s.size()!=a+b+1){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<s.size();i++)
		if ((i==a && s[i]!='-')||(i!=a && (s[i]>'9' || s[i]<'0'))){
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;
const int maxn = 1e6+100;
const int MOD = 1e9+7;
const double Pi = 3.141592654;
typedef long long ll;
typedef unsigned long long ull;

int n;
ll a, b;
ll h[maxn];

bool Judge(ll u)
{
    ll t = u*b;
    ll d = a-b;
    ll sum = 0;
    for(int i=n ; i>=1 ; --i)
    {
        if(h[i] > t)
        {
            if((h[i]-t)%d) sum += (h[i]-t)/d+1;
            else sum += (h[i]-t)/d;
        }
    }
    if(sum <= u) return 1;
    return 0;
}

int main()
{
    cin >> n;
    cin >> a >> b;
    ll r = 0, l = 1;
    for(int i=1 ; i<=n ; ++i)
    {
        cin >> h[i];
        r += h[i]/b+1;
    }
    sort(h+1, h+1+n);
    while(l < r)
    {
        ll m = (l+r)>>1;
        if(Judge(m)) r = m;
        else l = m+1;
    }
    cout << l << endl;
}


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

class Program
{
    public static void Main()
    {


        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var K = line[0];
        var X = line[1];

        var ans = "";

        for (int i = X - (K - 1); i <= X + (K - 1); i ++)
        {
            if (i != (X + (K - 1)))
            {
                ans = ans + i + " ";
            }
            else
            {
                ans = ans + i;
            }
        }


        Console.WriteLine(ans);


    }
}

Measured memory_bytes: 11348
def extGCD(a,m):
  if(m==0):
    return a,1,0
  d,s,t = extGCD(m,a%m)
  y=s-(a//m)*t
  x = t
  return d,x,y

def invmod(a,m):
  _,x,_ = extGCD(a,m)
  return x%m
  

S = int(input())
mod_num=int(1.0e+9+7)
max_count = S//3
ans_count=0
for i in range(max_count):
  if(i==0):
    ans_count+=1
    continue
  temp = (i+1)*3
  rest = S-temp+i
  ans_temp=1
  divide_temp = 1
  for j in range(i):
    ans_temp*=rest-j
    ans_temp%=mod_num
    divide_temp*=j+1

  inv_num = invmod(divide_temp,mod_num)

  ans_temp = (ans_temp*inv_num)%mod_num

  ans_count+=ans_temp

print(int(ans_count)%mod_num)


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin >>n>>m;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout<<ans<<endl;
    if(n+m >= 10)cout << "error" <<endl;
    else cout << m+n <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 N,A,B,C,D;


i64 MOD = 1e9 + 7;

// Eucli
i64 inv_mod(i64 a, i64 m = MOD) {
  i64 b, x, u, q, abs_m, tmp;

  abs_m = (m < 0) ? -m : m;
  b = m;
  x = 1;
  u = 0;
  while (b > 0) {
    q = a / b;
    tmp = u;
    u = x - q * u;
    x = tmp;
    tmp = b;
    b = a - q * b;
    a = tmp;
  }

  return (x < 0) ? abs_m + x : x;
}

i64 fact[100010];
i64 inv_fact[100010];

i64 nCr(int n, int r) {
  return (fact[n] * inv_fact[r] % MOD * inv_fact[n - r] % MOD) % MOD;
}

//重複組み合わせ
i64 nHr(int n, int r) { return (nCr(n + r - 1, r)) % MOD; }

i64 dp[1010][1010];

i64 ipow(i64 a,i64 k){
  i64 ans = 1;
  while(k > 0){
    if(k & 1) ans = ans * a % MOD;
    a = a * a % MOD;
    k >>= 1;
  }
  return ans;
}

int main(){
  fact[0] = 1;
  rep(i,1,100010 - 1){
    fact[i] = fact[i - 1] * i % MOD;
  }
  inv_fact[100010 - 1] = inv_mod(fact[100010 - 1]);
  for(int i = 100010 - 1;i >= 1;i--){
    inv_fact[i - 1] = inv_fact[i] * i % MOD;
  }
  cin >> N >> A >> B >> C >> D;
  dp[A - 1][N] = 1;

  rep(i,A,B){
    rep(j,0,N){
      dp[i][j] = dp[i - 1][j];
      i64 r = ipow(inv_fact[i],C); 
      for(int k = C;k <= D && i * k <= j;k++){
        (dp[i][j - i * k] += dp[i - 1][j] * fact[j] % MOD * inv_fact[j - i * k] % MOD * r % MOD * inv_fact[k]) %= MOD;
        r = r * inv_fact[i] % MOD;
      }
    }
  }
  cout << dp[B][0] << endl;
}



Measured memory_bytes: 9728
a = input()
if int(a[:2]) < 13 and int(a[:2]) > 0:
    if int(a[2:4]) < 13 and int(a[2:4]) > 0: print('AMBIGUOUS')
    else: print('MMYY')
elif int(a[2:]) < 13 and int(a[2:]) > 0: print('YYMM')
else: print('NA')

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define ll long long
#define mod (ll)1000000007
using namespace std;
int dp[3005][3005];
int n,m;
string s,t;
int rec(int i, int j)
{
	if(i == n || j == m)
		return 0;

	if(dp[i][j] != -1)
		return dp[i][j];

	int ans = 0;

	if(s[i] == t[j])
	{
		ans = 1+rec(i+1,j+1);
	}
	else
	{
		ans = max(rec(i,j+1),rec(i+1,j));
	}

	dp[i][j] = ans;

	return ans;
}

string ans = "";

void generate(int i,int j)
{
	if(i >= n || j >= m)
		return;
	if(s[i] == t[j])
	{
		ans+=s[i];
		// if(i+1 < n && j+1 < m)
			generate(i+1,j+1);
	}
	else
	{
		if(i+1 < n && dp[i+1][j] == dp[i][j])
		{
			generate(i+1,j);
		}
		else if(j+1 < m && dp[i][j+1] == dp[i][j])
		{
			generate(i,j+1);
		}
	}
}
int main()
{
	// string s,t;
	cin>>s>>t;
	memset(dp,-1,sizeof(dp));
	n = s.size();
	m = t.size();
	rec(0,0);
	// for(int i = 0; i < n; i++)
	// {
	// 	for(int j = 0; j < m; j++)
	// 		cout<<dp[i][j]<<" ";
	// 	cout<<"\n";
	// }
	generate(0,0);
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 35840
#include <stdio.h>

int data[100];
int sp = 0;
void push(int v){
    data[sp] = v;
    sp++;
}
void pop(){
    sp--;
}
int main(){
    int i,n,d;
    while(1){
        d = scanf("%d",&n);
        if(d == EOF)break;
        if(n==0){
            pop();
            printf("%d\n",data[sp]);
        }
        else{
            push(n);
        }
    }
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll maxn=110000;
ll dp[maxn];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  fill(dp,dp+maxn,n);
  dp[0]=0;
  rep(i,n){
    for(ll j=1; i+j<=n; j*=6){
      chmin(dp[i+j],dp[i]+1);
    }
    for(ll j=1; i+j<=n; j*=9){
      chmin(dp[i+j],dp[i]+1);
    }
  }
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	int n, m;
	cin >> n >> m;

	int p, y;
	map<int, int> id_to_year;
	vector<vector<int> > prefecture(n + 1, vector<int> ());
	for (int i = 0; i < m; ++i) {
		cin >> p >> y;
		prefecture[p].push_back(y);
		id_to_year[i + 1] = y;
	}

	map<int, string> all_labels;
	for (int i = 1; i <= n; ++i) {
		sort(prefecture[i].begin(), prefecture[i].end());
		string is = to_string(i);
		string p_label = string(6 - is.size(), '0') + is;
		for (int j = 0; j < (int) prefecture[i].size(); ++j) {
			string js = to_string(j + 1);
			string city_label = p_label + string(6 - js.size(), '0') + js;
			all_labels[prefecture[i][j]] = city_label;
		}
	}

	for (int i = 1; i <= m; ++i) {
		cout << all_labels[id_to_year[i]] << "\n";
	}	

	return 0;

}

Measured memory_bytes: 24192