akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    int n;cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll ans1 =0,ans2=0;
    ll sum =0;
    rep(i,n){
        sum+=a[i];
        if(i%2==0){
            if(sum<=0){
                ans1+=abs(sum)+1;
                sum=1;
            }
        }
        else{
            if(sum>=0){
                ans1+=sum+1;
                sum=-1;
            }
        }
    }
    sum=0;
    rep(i,n){
        sum+=a[i];
        if(i%2==1){
            if(sum<=0){
                ans2+=abs(sum)+1;
                sum=1;
            }
        }
        else{
            if(sum>=0){
                ans2+=sum+1;
                sum=-1;
            }
        }
    }
    cout<<min(ans1,ans2)<<endl;
}


Measured memory_bytes: 4408
#include<iostream>
#include<string>
#include<math.h>
#include<vector>

using namespace std;

int main() {


	int n, k;
	int out = 1;


	cin >> n;
	cin >> k;


	for (int i = 0; i < n; i++) {
		if (out < k) {
			out *= 2;
		}
		else {
			out += k;
		}
	}
	
	cout << out;



	return 0;

}

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

int main() {
    int N, Z, W; cin >> N >> Z >> W;
    vector<int> a(N);
    rep(i, N){
        cin >> a[i];
    }

    if(N == 1){
        cout << abs(a[0] - W) << endl;
        return 0;
    }
    int ans = max(abs(a[N-1] - W), abs(a[N-2] - a[N-1]));
    cout << ans << endl;

    return 0;
}

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

int main() {
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	if (x-r < 0 || x+r > w || y-r < 0 || y+r > h) cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 3104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double[] A = new double[N];
    double total =0;
    for (int i=0; i<N; i++) {
      A[i] = 1 / sc.nextDouble();
      total += A[i];
    }
    System.out.print(1 / total);
  }
}

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

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

int main() {
    int k, x; cin >> k >> x;
    int l = max(x - k + 1, -1000000);
    int r = min(x + k - 1, +1000000);
    for(int i=l; i<r+1; i++) cout << i << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
 int N,K;cin>>N>>K;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  for(int i=0;i<N-K;i++)
    if(0<A.at(K+i)-A.at(i))
      cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


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

typedef long long ll;

using namespace std;

int main()  {
    // N = players  K = points at the begining   Q = Total answered
    int n, k, q,ans, inp;
    cin >> n>> k >> q;
    std::vector<ll> v(n,k -q);
    for (int i = 0; i < q; i++){
        cin >> inp;
        ans  = inp -1;
        v[ans] ++;
    }
    for (auto m: v) {
        if (m > 0) cout << "Yes\n";
        else cout<< "No\n";
    }
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int a, b;

int solve() {
    if (a < 10 && b < 10) {
        return a * b;
    }
    return -1;
}

void input() {
    cin >> a >> b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
int main()
{
	int a,b,c;
	int N;
	while(std::cin>>a>>b>>c,a|b|c){
		std::cin>>N;
		int data[1024][4];
		int check[301];
		for(int i=0; i<301; i++)check[i]=2;
		for(int i=0; i<N; i++){
			scanf("%d%d%d%d",&data[i][0],&data[i][1],
								  &data[i][2],&data[i][3]);
			if( data[i][3]==1 ){
				check[data[i][0]]=1;
				check[data[i][1]]=1;
				check[data[i][2]]=1;
			}
		}
		for(int i=0; i<N; i++){
			if( data[i][3]==0 ){
				int sum = 0;
				if( check[data[i][0]]==1 )sum++;
				if( check[data[i][1]]==1 )sum++;
				if( check[data[i][2]]==1 )sum++;
				if( sum==2 ){
					for(int j=0; j<3; j++){
						if( check[data[i][j]]!=1 )
							check[data[i][j]]=0;
					}
				}
			}
		}
		for(int i=0; i<a+b+c; i++){
			printf("%d\n",check[i+1]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,count=0;
  cin >>n;
  int h[n];
  for(int i=0;i<n;i++)cin >>h[i];
  for(int i=0;i<n;i++){
    bool ok=true;
    for(int j=0;j<i;j++){
      if(h[i]<h[j])ok=false;
    }
    if(ok)count++;
  }
  cout <<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 12;
const int mo = 1e9 + 7;

int n, m, p[maxn];
vector<int> s[maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int k, v;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v;
			s[i].push_back(v-1);
		}
	}

	for (int i = 0; i < m; ++i)
		cin >> p[i];

	int ans = 0;
	for (int i = (1<<n)-1; i >= 0; --i) {
		bool ok = true;
		for (int j = 0; j < m; ++j) {
			int cnt = 0;
			for (int k = 0; k < s[j].size(); ++k) {
				int tmp = s[j][k];
				if (i & (1<<tmp))
					++cnt;
			}

			if (cnt % 2 != p[j]) {
				ok = false;
				break;
			}
		}

		if (ok)
			++ans;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import re
s = input()
if re.fullmatch(r"[0-9]*(2|4|5|7|9)",s):
    print("hon")
elif re.fullmatch(r"[0-9]*(0|1|6|8)",s):
    print("pon")
elif re.fullmatch(r"[0-9]*3",s):
    print("bon")

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

#define INF 0x3f3f3f3f
#define MMS(x, y) memset((x), (y), sizeof(x))
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define EPS 1e-9

#define MAXN 100010

using namespace std;

int N;
int A[MAXN];

int main() {
    cin >> N;
    for (int i = 0, a; i < N; i++) {
        cin >> A[i];
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == i + 1) {
            cnt++;
            if (i < N - 1) swap(A[i], A[i + 1]);
        }
    }
    cout << cnt << "\n";
}


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

int main() {
  int N;
  int M;
  cin >> N >> M;
  
  vector<int> a(M);
  vector<int> b(M);
  for (int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  for (int j = 0; j < N; j++) {
    int count = 0;
    for (int k = 0; k < a.size(); k++) {
      if (a.at(k) == j + 1) {
        count++;
      }
      else if (b.at(k) == j + 1) {
        count++;
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
s = input()
e = [0]
w = [0]
for i in range(len(s)):
    if s[i] == 'E':
        e.append(e[i]+1)
        w.append(w[i]+0)
    if s[i] == 'W':
        e.append(e[i]+0)
        w.append(w[i]+1)

ans = float('INF')
for i in range(n):
    iya = (w[i])+(e[n] - e[i+1])
    ans = min(ans,iya)
print(ans)

Measured memory_bytes: 27116
fn main() {
    let s: String = read_line_as_value();
    let ans = match &*s {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        "SAT" => 1,
        _ => -1
    };
    println!("{}", ans);
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll dp[200020][2];
ll mod = 1000000007LL;
int main() {
  string s;
  cin >> s;
  int n = sz(s);
  dp[0][0] = 1;

  rep(i,n){
    (dp[i+1][1]+=3*dp[i][1])%=mod;
    if(s[i] == '1'){
      (dp[i+1][1]+=dp[i][0])%=mod;
      (dp[i+1][0]+= 2*dp[i][0])%=mod;
    }
    else{
      (dp[i+1][0]+=dp[i][0])%=mod;
    }
  }
  cout<<(dp[n][0]+dp[n][1])%mod<<endl;
  return 0;
}

Measured memory_bytes: 5320
from sys import maxsize


def read_adj():
    n = int(input())
    adj_list = [[] for _ in range(n + 1)]
    for _ in range(1, n + 1):
        u, _, *adj = [int(x) for x in input().split()]
        adj_list[u] = adj
    return n, adj_list


def shortest_paths(n, adj_list, ini_key):
    dist = [maxsize] * (n + 1)

    S = [ini_key]
    dist[ini_key] = 0

    while S != []:
        key = S.pop()
        d = dist[key] + 1
        for k in adj_list[key]:
            if d < dist[k]:
                dist[k] = d
                S.append(k)

    return dist


def print_dist(n, dist):
    for i in range(1, n + 1):
        if dist[i] == maxsize:
            print(i, -1)
        else:
            print(i, dist[i])


def main():
    n, adj_list = read_adj()
    dist = shortest_paths(n, adj_list, 1)
    print_dist(n, dist)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5628
C = [list(map(int, input().split())) for i in range(3)]
def thr_check(a, b, c):
  if a==b and b==c and c==a:
    return True
  else:
    return False
s1 = thr_check(C[0][0] - C[0][1], C[1][0] - C[1][1], C[2][0] - C[2][1])
s2 = thr_check(C[0][1] - C[0][2], C[1][1] - C[1][2], C[2][1] - C[2][2])
s3 = thr_check(C[0][2] - C[0][0], C[1][2] - C[1][0], C[2][2] - C[2][0])
s4 = thr_check(C[0][0] - C[1][0], C[0][1] - C[1][1], C[0][2] - C[1][2])
s5 = thr_check(C[1][0] - C[2][0], C[1][1] - C[2][1], C[1][2] - C[2][2])
s6 = thr_check(C[2][0] - C[0][0], C[2][1] - C[0][1], C[2][2] - C[0][2])
if s1 and s2 and s3 and s4 and s5 and s6:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    
    vector<int> e(n+1,0),w(n+1,0);
    for(int i=0;i<n;i++){
        e[i+1]=e[i];
        w[i+1]+=w[i];
        if(s[i]=='W'){
            w[i+1]++;
        }
        if(s[i]=='E'){
            e[i+1]++;
        }
    }
 
    int ans=1000000;
    for(int i=1;i<=n;i++){
        int now=w[i-1]+e[n]-e[i];
        if(ans>now)ans=now;
    }
 
    cout<<ans<<endl;
 
}

Measured memory_bytes: 3076
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  int x, a, b;
  char s[100];
  stack<int> st;

  while (scanf("%s", s) != EOF) {
    if (s[0] == '+') {
      b = st.top();
      st.pop();
      a = st.top();
      st.pop();
      st.push(a + b);
    } else if (s[0] == '-') {
      b = st.top();
      st.pop();
      a = st.top();
      st.pop();
      st.push(a - b);
    } else if (s[0] == '*') {
      b = st.top();
      st.pop();
      a = st.top();
      st.pop();
      st.push(a * b);
    } else {
      x = atoi(s);
      st.push(x);
    }
  }
  cout << st.top() << endl;
  return 0;
}



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

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

    int N; cin >> N;

    int H; cin >> H;
    int max = H;
    bool ans = true;
    rep(i,N-1) {
        cin >> H;
        if (H <= max - 2) ans = false;
        if (H > max) max = H;
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  int N,M,X;
  cin>>N>>M>>X;
  vector<int> c(N);
  vector<vector<long>> a(N, vector<long>(M));

  for(int i=0;i<N;i++){
    cin>>c[i];
    for(int j=0;j<M;j++){
      cin>>a[i][j];
    }
  }
  int ans=1234567890;
  for(int bit=0;bit<(1<<N);bit++){
    int sum=0;
    vector<int> s(M);
    // 全完する難易度を決める
    for(int i=0;i<N;i++){

      // ex.i=5=101であれば2問目のみfalseになる
      if(bit&(1<<i)){
        sum += c[i];
        for(int j=0;j<M;j++){
          s[j] += a[i][j];

        }
      }
    }
    long flg=0;
    for(int i=0;i<M;i++){
      if(s[i]>=X) flg++;
    }
    if(flg==M){
      ans=min(ans,sum);
    }
}
if(ans!=1234567890) cout<<ans<<endl;
else cout<<-1<<endl;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    int ans = 0;
    REP1 (n, N)
    {
        if (n % 2 == 0)
            continue;
        int d = 0;
        for (int i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
                d += 2;
        }
        if (d == 8)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int a,b,c,d,p,ans;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
    a=a*p;
    if(p-c>0){
        b=b+(p-c)*d;
    }
    ans=fmin(a,b);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N, M;
	cin >> N >> M;

	priority_queue<ll> A;
	for (int i = 0; i < N; i++) {
		ll temp;
		cin >> temp;
		A.push(temp);
	}

	for (int i = 0; i < M; i++) {
		ll temp = A.top() / 2;
		A.pop();
		A.push(temp);
	}

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += A.top();
		A.pop();
	}

	cout << ans;



}



Measured memory_bytes: 1400
n, m = map(int, input().split())
a = list(map(int, input().split()))
from collections import Counter
c = Counter()
sum_val = 0
c[sum_val] += 1
for i in range(n):
    sum_val += a[i]
    sum_val %= m
    c[sum_val] += 1
ans = 0
for v in c.values():
    ans += v*(v-1)//2
print(ans)




Measured memory_bytes: 20728
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    set<string> ss;
    ss.insert("a");
    for(int i = 1; i < n; i++){
        set<string> next;
        for(auto& s : ss){
            for(int j = 0; j <= i; j++){
                string s2 = "a";
                for(auto& c : s){
                    s2 += c == 'a' + j ? 'a' :
                        c > 'a' + j ? c : c + 1;
                }
                next.insert(s2);
            }
        }
        next.swap(ss);
    }
    for(auto& s : ss){
        cout << s << '\n';
    }
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    ll n; cin >> n;
    ll odd = 0;
    rep(i, 0, n){
        ll a; cin >> a;
        if(a%2 != 0) odd++;
    }
    if(odd%2 != 0) puts("NO");
    else puts("YES");
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define INF 2000000000
#define watch(x) cout << setw(10) << "[" << (#x) << ":] " << (x) 
#define FORE(i,v,n) for(int i=v;i<n;i++)
#define FORI(i,v,n) for(int i=v;i<=n;i++)


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<string, int> msi;


//typedef tree <int, null_type, less<int> rb_tree_tag, tree_order_statistics_node_update> indexed_set;

int const MOD = 1000000007;

int test_case(){
	int a,b;
	cin >> a >> b;
	float answer;
	FORE(i,1,10002){
		if(floor(0.08*i) ==a && floor(0.1*i) == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int test=1;
	//cin >> test;
	for(int i=0;i<test;i++){
		test_case();
	}
	return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define minit(a,b) memset(a, b, sizeof(a))

typedef pair< int, int > pii;

int n, q, A[1000010];

int main() {
	cin >> n >> q;
	
	minit(A, 0);
	priority_queue< pii > que;
	
	for_(i,0,q) {
		int a, v;
		cin >> a >> v;
		
		A[a-1] += v;
		que.push(pii(A[a-1], -a));
		
		while (1) {
			pii p = que.top();
			int id = -p.second;
			int AA = p.first;
			
			if (A[id-1] == AA) {
				cout << id << " " << AA << endl;
				break;
			} else {
				que.pop();
			}
		}
	}
}

Measured memory_bytes: 6016
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string S, T;

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

  if (T.size() - S.size() == 1) {
    T.pop_back();
    if (T == S) {
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define inf 2147483647
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
int n,m,ck,ans,a,b,arr[103],brr[103],cnt,check[103];
void find(int p,int sum,int q)
{
	if(q==n) 
	{
		cnt++; if(sum==p) ck=1; return; 
	} for(int i=1;i<=n;i++) if(!check[i])
	{
		check[i]=1; sum*=10; sum+=i; find(p,sum,q+1);
		check[i]=0; sum/=10; if(ck) return;
	}
}
main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int imsi; a*=10; 
		scanf("%d",&imsi); a+=imsi;  
	} for(int i=0;i<n;i++) 
	{
		int imsi; b*=10;
		scanf("%d",&imsi); b+=imsi;
	} find(a,0,0); int lena=cnt;
	cnt=0; ck=0; find(b,0,0); int lenb=cnt;
	printf("%d",abs(lena-lenb));
}

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

using ll=int64_t;
//#define int ll
#define int __int128

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read(),X=read();
	vi x(n+1,0);
	FOR(i,1,n+1)
		x[i]=x[i-1]+read();
	int ans=inf;
	FOR(i,1,n+1){
		int cost=(n+i)*X;
		int p=n;
		REP(j,n){
			if(p==0)break;
			int q=max(p-i,int(0));
			int w=j==0?5:j*2+3;
			cost+=(x[p]-x[q])*w;
			p=q;
		}
		chmin(ans,cost);
	}
	print(ans);
}


Measured memory_bytes: 3456
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>
#include<set>

#include <memory>

const double PI = 3.14159265358979323846;

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;

ll MOD = 1000000007;

double a, b, x;

bool check(double angle)
{
	double tn = tan(PI*angle/180);
	double w = sqrt(2 * x*tn / a);
	if (w < a)
	{
		return w / tn <= b;
	}
	return (x / a + a*a / tn / 2) / a <= b;

}


int  main()
{
	cin >> a >> b >> x;
	double G = 90;
	double l = 0;

	for (int i = 0; i < 30; ++i)
	{
		double mid = (G + l) / 2;
		if (check(mid))
		{
			G = mid;
		}
		else
		{
			l = mid;
		}
	}

	printf("%.7f\n",90-l);

	return 0;
}

Measured memory_bytes: 512
void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1];
    writeln(b % a == 0 ? a + b : b - a);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, M = getNM()
optmax = M // N
for i in range(optmax, 0, -1):
    if M % i == 0:
        print(i)
        break

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		String p = br.readLine();
		String ring = s + s;
		if (ring.indexOf(p) == -1) System.out.println("No");
		else System.out.println("Yes");
	}
}

Measured memory_bytes: 24432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(int x, int y, int mod){
    int ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << "No" << endl;
    exit(0);
}

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





int main(){
    sonic();
    int n, A=0, B=0, AB=0, ans=0;
    R n;
    rep(i, n) {
        string s;
        R s;
        int l = s.length();
        if ((s[l - 1] == 'A') && (s[0] == 'B'))AB += 1;
        else {
            if (s[l - 1] == 'A')A += 1;
            else if (s[0] == 'B')B += 1;
        }
        rep(j, l - 1)if(s[j] == 'A' && s[j + 1] == 'B')ans += 1;
    }
    if(AB){
        ans+=AB-1;
        if(A){
            A-=1;
            ans+=1;
        }
        if(B){
            B-=1;
            ans+=1;
        }
    }
    ans+=min(A,B);
    co(ans);
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
 
template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int counter=0;
	string S;

	cin>>S;
	FOR(i,1,(int)S.length()){
		if(S[i]!=S[i-1]) counter++;
	}
	cout<<counter<<endl;
	return 0; 
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define all(v) v.begin(),v.end()
# define pl(s)  std::cout << s << endl;

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

    vector<int> x(n);
    vector<int> y(n);
    vector<int> h(n);

    REP(i, n) cin >> x[i] >> y[i] >> h[i];

    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            REP(i, n) {
                if (h[i] == 0) continue;
                int H = h[i] + abs(cx - x[i]) + abs(cy - y[i]);

                bool flg = true;
                REP(j, n) {
                    if (max(H - abs(cx - x[j]) - abs(cy - y[j]), 0) != h[j]) {
                        flg = false;
                        break;
                    }
                }
                if (flg) {
                    printf("%d %d %d\n", cx, cy, H);
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }


#define MAX_V 100
int V;//頂点数
int d[MAX_V];//頂点sからの最短距離



int main() {
    cin >> V;
    int E;
    cin >> E;
    vei va(E), vb(E), vc(E);

    int dp[205][205];
    rep(i,V) rep(j,V) {
        if(i == j) dp[i][j] = 0;
        else dp[i][j] = INF;
    }

    rep(i,E) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dp[a][b] = dp[b][a] = c;
        va[i] = a; vb[i] = b; vc[i] = c;
    }
    

    rep(k,V) rep(i,V) rep(j,V) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    
    int ans = E;
    rep(i,E) {
        bool dist = false;
        rep(j,V) {
            if(dp[j][va[i]] + vc[i] == dp[j][vb[i]]) dist = true;
        }
        if(dist) ans--;
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
N, K = map(int, input().split())
X = list(map(int, input().split()))

# Calculate numbers of bits
bits = [0] * 40
for k in range(40):
    for v in X:
        bits[k] += v >> k & 1

# Take larger # of bits
ctr = [0] * 41
for k in range(40):
    ctr[k + 1] = ctr[k] + (max(N - bits[k], bits[k]) << k)

res = 0
cnt = 0
for i in reversed(range(40)):
    if K >> i & 1:
        res = max(res, cnt + (bits[i] << i) + ctr[i])
        cnt += (N - bits[i]) << i
    else:
        cnt += bits[i] << i

print(max(res, cnt))


Measured memory_bytes: 86584
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi l(n); rep(i, n) cin >> l[i];
  sort(all(l));

  ll ans = 0;
  //c < a + b を満たすcを探す
  for(int a = 0; a < n; a++) for(int b = a+1; b < n; b++){
    // k は初めてダメになるindex
    int k = lower_bound(all(l),l[a] + l[b]) - l.begin();
    //求める個数は[b+1,k)内の整数の個数
    ans += k - (b+1);
  }
  std::cout << ans << '\n';
}


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

int main(void){
  int a , b;
  cin >> a >> b;
  if ( (a * b) % 2 == 0 ){
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  return 0;
}
  


Measured memory_bytes: 256
N, X = map(int, input().split())
Ls   = map(int, input().split())

D = 0
Ds = [0]
for i in Ls:
    # print(i)
    res = D + i
    Ds.append(res)
    D = res

res_list = [i for i in Ds if i <= X]
# print(Ds)
# print(res_list)
print(len(res_list))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
const int maxn=2e5+5;
int lg[maxn];
int main()
{
	int a,s;
	cin>>a;
	for(int i=2;i<=105;i=i*2) lg[i]=1;
	for(int i=1;i<=a;i++) lg[i]=lg[i]+lg[i-1];
	s=(1<<lg[a]);
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
from math import ceil
n, k, *A = map(int, open(0).read().split())
t = sum(A) / (n+k)
A = [a for a in A if int(a/t) >= 1]
c = k - sum(int(a/t)-1 for a in A)
X = []
for a in A:
    X.append(ceil(a / ceil(a/t)))
    X.append(ceil(a / int(a/t)))
X.sort()
print(X[-c-1])

Measured memory_bytes: 34736
def sumOfDegits(n, p=10): #p進法での各位の和
	sum = 0
	while n > 0:
		sum += n % 10
		n //= 10
	return sum

n = int(input())

smallest = 9999999999
for i in range(1,n//2+1):
	a = i
	b = n - i
	if sumOfDegits(a) + sumOfDegits(b) < smallest:
		smallest = sumOfDegits(a) + sumOfDegits(b)
print(smallest)

Measured memory_bytes: 3060
N = int(input())
h = list(map(int, input().split())) #1-index

dp = [float('inf')]*(N)

def chmin(a,b):
    if a >= b:
        return b
    else:
        return a

dp[0] = 0
for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    
    if i >= 2:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
    
print(dp[N-1])

Measured memory_bytes: 13928
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

S = raw_input()
sz = len(S)

A = [0 for i in range(sz)]
C = [0 for i in range(sz)]

cnt = 0
for i in range(sz):
    if S[i] == 'A':
        cnt += 3
    if S[i] == '?':
        cnt += 1
    A[i] = cnt

cnt = 0
for i in range(sz - 1, -1, -1):
    if S[i] == 'C':
        cnt += 3
    if S[i] == '?':
        cnt += 1
    C[i] = cnt

ans = 0
MOD = 10 ** 9 + 7
for i in range(1, sz - 1):
    if S[i] == 'B':
        ans += A[i - 1] * C[i + 1] * 3
        ans %= MOD
    if S[i] == '?':
        ans += A[i - 1] * C[i + 1]
        ans %= MOD

def inv(n):
    POW = MOD - 2
    mul = n
    ret = 1
    while POW > 0:
        if POW % 2 == 1:
            ret *= mul
            ret %= MOD
        mul *= mul
        mul %= MOD
        POW /= 2
    return ret

q_num = S.count('?')
if q_num < 3:
    ans *= inv(3 ** (3 - q_num))
    ans %= MOD
else:
    for i in range(q_num - 3):
        ans *= 3
        ans %= MOD
print ans

Measured memory_bytes: 12476
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val _, x :: xs = sc.next().toList
  val (_, compressed) = xs.foldLeft((x, Vector(x))) {
    case ((before, acc), char) =>
      if (before == char) before -> acc else char -> (acc :+ char)
  }
  println(compressed.length)
}


Measured memory_bytes: 62148
#include <iostream>

using namespace std;

int main() {
    string s; cin >> s;
    int i=0, j=(int)(s.length()-1);
    while (s[i] != 'A') i++;
    while (s[j] != 'Z') j--;
    cout << j-i+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
using namespace std;

int a[3];

int main(){

	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);

	cout << a[0] * a[1] / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,e,f;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	e=a*b;
	f=c*d;
	if(e>=f)    printf("%d\n",e);
	else        printf("%d\n",f);
	return 0;
}

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

N = int(input())
A = list(map(int, input().split()))
ans = 0
MOD = 10**9+7

for i in range(63):
    one, zero = 0, 0
    
    for Aj in A:
        if (Aj>>i)&1:
            one += 1
        else:
            zero += 1
    
    ans += 2**i*one*zero
    ans %= MOD

print(ans)

Measured memory_bytes: 123132
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if(a < b  && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");            
        }
    }
    
}


Measured memory_bytes: 26104
#include<stdio.h>
#include<string.h> 
#include<stdlib.h>


int main(void){

	long int a,b;
	int k;
	int i;

	scanf("%ld %ld %d",&a,&b,&k);

	for(i=0;i<k;i++){
		if(i%2==0){
//			if(a%2 == 1){
//				a--;
//			}
			b += a/2;
			a /= 2;
		}else{
			a += b/2;
			b /= 2;

		}
	}

	printf("%ld %ld\n",a,b);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
namespace mp = boost::multiprecision;
using namespace std;
typedef mp::cpp_int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(int argc, const char * argv[]) {
   	cin.tie(0); ios::sync_with_stdio(false);
    // source code
    string s, t;
    cin >> s >> t;
    cout << t << s << "\n";    
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static class Graph {
        public final int V_NUM;
        public final int[][] edges;

        public Graph(int V_NUM) {
            this.V_NUM = V_NUM;
            this.edges = new int[V_NUM][V_NUM];
            for (int i = 0; i < V_NUM; i++) {
                Arrays.fill(this.edges[i], Integer.MAX_VALUE);
            }
        }

        public void setDist(int src, int dest, int dist) {
            this.edges[src][dest] = dist;
        }

    }

    public static class TSP {
        public final Graph g;
        long[][] dp;

        public TSP(Graph g) {
            this.g = g;
        }

        public long solve() {
            int N = g.V_NUM;
            dp = new long[1 << N][N];
            // init dp[][] with MAX
            for (int i = 0; i < dp.length; i++) {
                Arrays.fill(dp[i], -1);
            }

            long ret = recurse(0, 0);
            return ret == Integer.MAX_VALUE ? -1 : ret;
        }

        private long recurse(int state, int v) {
            int ALL = (1 << g.V_NUM) - 1;
            if (dp[state][v] >= 0) {
                return dp[state][v];
            }
            if (state == ALL && v == 0) {
                dp[state][v] = 0;
                return 0;
            }
            long res = Integer.MAX_VALUE;
            for (int u = 0; u < g.V_NUM; u++) {
                if ((state & (1 << u)) == 0) {
                    res = Math.min(res, recurse(state | 1 << u, u) + g.edges[v][u]);
                }
            }
            dp[state][v] = res;
            return res;

        }

    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int V = in.nextInt();
        int E = in.nextInt();
        Graph g = new Graph(V);
        while (E > 0) {
            int src = in.nextInt();
            int dest = in.nextInt();
            int dist = in.nextInt();
            g.setDist(src, dest, dist);
            E--;
        }
        System.out.println(new TSP(g).solve());
    }
}


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

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

typedef long long ll;

const int MAX = 2001001;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(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;
}

//これを使うときにはCOMinit();を忘れずに

int main(void){
    COMinit();
    ll K; cin >> K;
    string S; cin >> S;
    vector<ll> pow25(2000001, 1), pow26(2000001, 1);
    for(int i = 1; i <= 2000000; i++){
        pow25[i] = pow25[i-1]*25 % MOD;
        pow26[i] = pow26[i-1]*26 % MOD;
    }
    ll ans = 0;
    int lenS = S.length();
    for(int i = lenS; i <= lenS+K; i++){
        ll val = pow26[(lenS + K) - i];
        //i-1箇所でlenS-1文字が1通り,残りは25通り
        val = ((val * COM(i-1, lenS-1) % MOD) * pow25[i-lenS]) % MOD;
        ans = (ans + val) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 82556
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
judge = "YES"
if N % 2 == 1:
	if A[0] != 0:
		judge = "NO"
	for i in range(int(N // 2)):
		if A[2 * i + 1] != 2 * i + 2 or A[2 * i + 2] != 2 * i + 2:
			judge = "NO"
			break

else:
	for i in range(int(N // 2)):
		if A[2 * i] != 2 * i + 1 or A[2 * i + 1] != 2 * i + 1:
			judge = "NO"
			break

if judge == "NO":
	print(0)
else:
	c = 1
	for i in range(int(N // 2)):
		c = (2 * c) % 1000000007
	print(c)

Measured memory_bytes: 14004
using System;
using System.Linq;

namespace ABC47B
{
    class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var W = int.Parse(input[0]);
            var H = int.Parse(input[1]);
            var N = int.Parse(input[2]);

            var map = new bool[H, W];
            for (var i = 0; i < N; i++)
            {
                var query = Console.ReadLine().Split(' ');
                var X = int.Parse(query[0]);
                var Y = int.Parse(query[1]);
                var A = int.Parse(query[2]);

                var lx = 0;
                var rx = W;
                var ty = H;
                var by = 0;

                if (A == 1) rx = X;
                if (A == 2) lx = X;
                if (A == 3) ty = Y;
                if (A == 4) by = Y;

                for (var y = by; y < ty; y++)
                for (var x = lx; x < rx; x++)
                {
                    map[y, x] = true;
                }
            }

            Console.WriteLine(map.Cast<bool>().Count(b => !b));
        }
    }
}

Measured memory_bytes: 11220
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
#define mod 1000000007
int n,m,ans,a[2005],a1[2005],a2[2005];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
			a1[i]+=(a[j]<a[i]);
		for(int j=i-1;j>=1;j--)
			a2[i]+=(a[j]<a[i]);
		ans=int((1ll*ans+1ll*(m)*(m+1)/2%mod*a1[i]%mod
			+1ll*(m)*(m-1)/2%mod*a2[i]%mod)%mod);
	}
	printf("%d",ans);
}

Measured memory_bytes: 128