akhauriyash/Code-Regression huggingface dataset:
N, k = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
x = k
for i in range(len(bin(k)) - 1):
    if x <= k:
        tem = 0
        for a in A:
            tem += a ^ x
        ans = max(ans, tem)
    x = list(format(x, '045b'))
    c = 0
    for a in A:
        c += a >> i & 1
    if N <= 2 * c:
        x[-1 - i] = '0'
    else:
        x[-1 - i] = '1'
    x = int('0b' + ''.join(x), 0)
print(ans)

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

using ll=int64_t;
#define int ll

#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()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,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;
}

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

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

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

void print(int 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(a>b)
		a=b;
}

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

const int inf=LLONG_MAX/3;

int a[2][110];

signed main(){
	int n=read();
	REP(i,2)REP(j,n){
		if(i>0)chmax(a[i][j],a[i-1][j]);
		if(j>0)chmax(a[i][j],a[i][j-1]);
		a[i][j]+=read();
	}
	cout<<a[1][n-1]<<endl;
}

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

int main()
{
    int n,m;
    cin >> n>>m;
    // queue<int> a;
    int b;
    for (size_t i = 0; i < m; i++)
    {
        /* code */
        cin>>b;
        n -= b;
    }

    if (n>=0)
    {
        cout<<n;
    }
    else
    {
        cout<< -1;
    }
    

    
}

Measured memory_bytes: 3624
#include <cstdio>
using namespace std;
long long x,wubai,wukuai;
int main()
{
	scanf("%lld",&x);
	wubai=x/500;
	wukuai=(x%500)/5;
	printf("%lld",wubai*1000+wukuai*5);
	return 0;
}

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

#define mod 998244353

long long X[300], Y[300], P[300];
int N;

int main() {
    // freopen("input.in","r",stdin);
    // freopen("output.out","w",stdout);

    cin>>N;
    for(int i = 0;i < N;i++) cin>>X[i]>>Y[i];
    P[0] = 1;
    for(int i = 1;i <= N;i++) P[i] = (2*P[i-1]) % mod;

    long long answer = (P[N]-1-N+mod) % mod;
    // cout << answer << endl;

    for(int i = 0;i < N;i++) {
        for(int j = i+1;j < N;j++) {
            int counter = 0;
            for(int k = j+1;k < N;k++) {
                if((Y[j]-Y[i])*(X[k]-X[i]) == (Y[k]-Y[i])*(X[j]-X[i])) {
                    counter += 1;
                }
            }

            answer = (answer - P[counter] + mod) % mod;
        }
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define BR cerr<<endl
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
	#ifndef ONLINE_JUDGE
        freopen("inputf.in", "r", stdin);
    #endif
    fastio();

    ll a, b, k;
    cin >> a >> b >> k;
    ll p, q;
    if(k <= a){
    	p = a - k;
    	q = b;
    }
    else{
    	p  = 0;
   		k -= a;
   		if(k <= b){
   			q = b - k;
   		}
   		else{
   			q = 0;
   		}
    }
    cout << p << " " << q;

    return 0;
}

/*

*/

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

int n;
double dp[305][305][305];

double dfs(int a, int b, int c) {
    if(a + b + c == 0) return 0.0;
    if(dp[a][b][c] > -0.5) return dp[a][b][c];
    double ev = (double) n / (a + b + c);
    if(a) ev += dfs(a-1, b, c) * ( (double) a / (a + b + c) );
    if(b) ev += dfs(a+1, b-1, c) * ( (double) b / (a + b + c) );
    if(c) ev += dfs(a, b+1, c-1) * ( (double) c / (a + b + c) );
    return dp[a][b][c] = ev;
}

int main() {
    cin>>n;
    int cnt[4] = {0};
    for(int i=0; i<n; i++) {
        int temp;
        cin>>temp;
        cnt[temp]++;
    }
    for(int i=0; i<=n; i++) for(int j=0; j<=n; j++) for(int k=0; k<=n; k++)
        dp[i][j][k] = -1;
    cout<< setprecision(16) << dfs(cnt[1], cnt[2], cnt[3]) <<endl;
    return 0;
}


Measured memory_bytes: 219392
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main() {
  ll n, ans=0, cnt;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a.at(i) >> b.at(i);
  reverse(all(a));
  reverse(all(b));
  rep(i, n) {
    cnt = (b.at(i) - (a.at(i) + ans) % b.at(i));
    if(cnt == b.at(i)) cnt=0;
    ans += cnt;
  }
  cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  ll A[N];
  ll now[N];
  ll ans = 0;
  now[0] = 1;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 1; i < N; i++) {
    if (A[i] == now[i-1] + 1) {
      now[i] = now[i-1] + 1;
    } else {
      now[i] = now[i-1];
    }
  }
  ans += (A[0] - 1);
  for (int i = 1; i < N; i++) {
    ans += (A[i] - 1) / (now[i] + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5156
def main():
    n=int(input())
    cnt=[50]*26
    tmp=[0]*26
    for i in range(n):
        s=input()
        for j in range(len(s)):
            tmp[ord(s[j])-97]+=1
        for j in range(26):
            cnt[j]=min(cnt[j],tmp[j])
            tmp[j]=0
    ans=""
    for i in range(26):
        if cnt[i]!=0:
            ans+=chr(97+i)*cnt[i]
    print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> list(N);
  int cur = 0;
  int max = 0;
  int now = 0;
  int old = 0;
  for (int i = 0; i < N; i++) {
    old = now;
    cin >> now;
    if (old >= now) {
      cur++;
      if (cur > max) {
        max = cur;
      }
    } else {
      cur = 0;
    }
  }
  cout << max;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
    //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105,p=1000000007;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,m,K,a[N];
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
typedef pair<int,int> pr;
pr work(int dep,int l,int r){
	int d=0x3f3f3f3f,las=l;
	pr ans=make_pair(2,1);
	for (int i=l;i<=r;i++) d=min(d,a[i]);
	for (int i=l;i<=r;i++)
	if (a[i]==d) {
		check(ans.second,ans.second);
		if (las<i){
			pr t=work(d+1,las,i-1);
			ans.first=(ll)ans.first*t.first%p;
			ans.second=(ll)ans.second*(t.second+t.first)%p;
		}
		las=i+1;
	}
	if (las<=r){
		pr t=work(d+1,las,r);
		ans.first=(ll)ans.first*t.first%p;
		ans.second=(ll)ans.second*(t.second+t.first)%p;
	}
	check(ans.second,p-ans.first);
	ans.first=(ll)ans.first*qpow(2,d-dep)%p;
	check(ans.second,ans.first);
	return ans;
}
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read();
	printf("%d\n",work(1,1,n).second);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> d(h+1, vector<char>(w+1));
    queue<vector<int>> que;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0;j < w; j++)
        {
            cin >> d[i][j];
            if(d[i][j] == '#')
            {
                que.push({i,j,0});
            }
        }
    }

    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    int ans = 0;
    while(!que.empty())
    {
        vector<int> v = que.front();
        que.pop();
        for(int i = 0; i < 4; i++)
        {
            for(int j = 0; j < 4; j++)
            {
                int nx = v[0] + dx[i];
                int ny = v[1] + dy[i];
                if(nx >= 0 && nx < h && ny >= 0 && ny < w && d[nx][ny] == '.')
                {
                    d[nx][ny] = '#';
                    que.push({nx, ny, v[2]+1});
                    ans = max(ans, v[2] + 1);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 56756
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define ld long double
typedef pair<ld,ld> pll;
typedef pair<pll,ll> ppll;
typedef vector <pll> vi;
#define out(x) return cout<<x,0;
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define lc(n) 2*n+1
#define rc(n) 2*n+2
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

int main() {
    FAST;
    ll n, k, m, z = 0, x = 0, y = 0, ans = 0, j, t = 0, c = 0,i;
    cin >> n >> m >> k;
    if ( n < m ) swap( n , m );
    ans = k / n ;
    x = k % n ;
    if ( x != 0 ) ans++;
    cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
  for(int i=0;i<10000;i++){
	  int x,y;
	  scanf("%d%d",&x,&y);
	  if(x==0&&y==0){
		  break;
	  }
	  if(x<y){
      printf("%d %d\n",x,y);
	  }else{
	  printf("%d %d\n",y,x);
   }
  }
}

Measured memory_bytes: 2728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc068/tasks/abc068_b

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

    int max = -1;
    int ans = 0;
    REP(i, N) {
        int a = i+1;
        int count = 0;
        while(a % 2==0) {
            a = a /2;
            count++;
        }

        if (count > max) {
            max = count;
            ans = i+1;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int a,b,c; cin >> a>> b>> c;
  if (a+b+c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
#define int long long
#define DEBUG(x) cerr << #x << " = " << x << endl

pair<int, int> solve(const int d, const int n) {
  // cerr << "solve(" << d << ", " << n << ")" << endl;
  if (d == 0) {
    return pair<int, int>(n - 1, 0);
  }
  int k = (10 + d - 1) / d;
  if (n < k) {
    return pair<int, int>(n - 1, d * n);
  }
  int c = n / k;
  int rem = n % k;
  int d10 = (d * k) / 10;
  int d1 = (d * k) % 10;
  auto r = solve(d10 + d1, c);
  int a = (1 + k - 1) * c;
  a += r.first;
  if (rem > 0) {
    a += rem;
    int b = d * rem + r.second;
    int b10 = b / 10;
    int b1 = b % 10;
    if (b >= 10) {
      a += 1;
      b = b10 + b1;
    }
    return pair<int, int>(a, b);
  }
  return pair<int, int>(a, r.second);
}

signed main() {
  int M; cin >> M;
  int ans = -1;
  int rem = 0;
  for (int i = 0; i < M; i++) {
    int d, c; cin >> d >> c;
    auto r = solve(d, c);
    // cerr << "r = (" << r.first << ", " << r.second << ")" << endl;
    rem += r.second;
    ans += r.first + 1;
    if (rem >= 10) {
      rem = (rem / 10) + (rem % 10);
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(M);
    vector<int> d(M);
    for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
    for (int i = 0; i < M; i++) cin >> c[i] >> d[i];
    for (int i = 0; i < N; i++) {
        int ans = 0;
        int ans_dist = -1;
        for (int j = 0; j < M; j++) {
            int dist = abs(c[j]-a[i]) + abs(d[j]-b[i]);
            if (dist < ans_dist || ans_dist == -1) {
                ans = j+1;
                ans_dist = dist;
            }
        }
        cout <<ans << endl;
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			scanner.nextLine();
			List<Store> list = new ArrayList<>();
			for (int i = 0; i < n; i++) {
				Store store = new Store();
				store.price = scanner.nextInt();
				store.amount = scanner.nextInt();
				list.add(store);
				scanner.nextLine();
			}
			List<Store> newList = list.stream().sorted((x, y) -> x.price - y.price).collect(Collectors.toList());
			long sum = 0;
			for (int i = 0; i < newList.size(); i++) {
				Store store = newList.get(i);
				if (store.amount >= m) {
					sum += (long) store.price * m;
					break;
				} else {
					sum += (long) store.price * store.amount;
					m -= store.amount;
				}
			}
			System.out.println(sum);
		}
	}

	private static class Store {
		int price;
		int amount;
	}
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i,n){
        if(s[i]=='R') a[i] = 0;
        if(s[i]=='G') a[i] = 1;
        if(s[i]=='B') a[i] = 2;
    }
    vector<ll> cnt(3);
    rep(i,n) cnt[a[i]]++;
    ll ans = 1;
    rep(i,3) ans *= cnt[i];
    rep(j,n)rep(i,j){
        int k = j+(j-i);
        if(k<n){
            if(a[i]==a[j]) continue;
            if(a[i]==a[k]) continue;
            if(a[k]==a[j]) continue;
            ans --;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
int main()
{
ios_base::sync_with_stdio(false);
ll n;
cin>>n;
ll ans[n+1]={0};
ans[1]=1;
ans[0]=0;
for(ll i=2;i<=n;++i)
{
    ans[i]=ans[i-1]+1;
    ll j=6;
    while(j<=i)
    {
        if(ans[i-j]+1<ans[i])
            ans[i]=ans[i-j]+1;
        j*=6;
    }
    j=9;
    while(j<=i)
    {
        if(ans[i-j]+1<ans[i])
            ans[i]=ans[i-j]+1;
        j*=9;
    }
}
cout<<ans[n];
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

s = 1000
c = 0
upflg = 0
dwnflg = 0
for i in range(n-1):
  if a[i+1] > a[i]:
    dwnflg = 0
    if upflg == 1:
      continue
    c = s//a[i]
    s -= c*a[i]
    upflg = 1
  elif a[i+1] == a[i]:
    continue
  else:
    upflg = 0
    if dwnflg == 1:
      continue
    s += c*a[i]
    dwnflg = 1
  # print (s)
if upflg == 1:
  s += c*a[-1]
print(max(s,1000))

Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin>>n;
    int a[200001]={};
    for(int i=0;i<n-1;i++){
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 4420
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222


void dfs(string cur, ll used) {
  if (cur.length() > 10) return;
  ll num = stol(cur);
  if (num > n) return;
  else if (used == 7) ans++;
  string x = "1";
  x[0] = '3';
  dfs(cur + x, used | 1);
  x[0] = '5';
  dfs(cur + x, used | 2);
  x[0] = '7';
  dfs(cur + x, used | 4);
}
 

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


  cin >> n;
  dfs("3", 1);
  dfs("5", 2);
  dfs("7", 4);
  cout << ans << endl;


  return 0;
}



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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3628
def main():
    offset = 55555
    primes = [True for i in range(offset + 1)]
    primes[2] = True
    c=2
    while c <= offset:
        if primes[c] == True:
            count = 2 * c
            while count <= offset:
                primes[count] = False
                count += c
            c += 1
        else:
            c += 1
    pc = 0
    array_of_primes=[]
    for i in range(2, offset + 1):
        if primes[i]:
            pc += 1
            array_of_primes.append(i)

    n = int(input())
    arr = []
    count = 0
    for i in array_of_primes:
        if count == n:
            break
        if i % 5 == 1:
            arr.append(i)
            count += 1
    for i in arr:
        print(i, end= " ")
                

main()


Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <map>
#define P pair<int,string>
#define PV(w,s,n) multimap< int,P >::value_type((w), P((s),(n)))
using namespace std;
int main()
{
  int n;
  for(;;){
    cin >> n;
    if(n==0) break;
    multimap< int,P,greater<int> > m;
    string l;
    int w,s,t=0;
    while(n--){
      cin >> l >> w >> s;
      m.insert( PV(w,s,l) );
      t += w;
    }
    multimap< int,P >::iterator it;
    while(!m.empty()){
      it = m.begin();
      while(it != m.end()){
	if((*it).second.first >= t - (*it).first){
	  cout << (*it).second.second << endl;
	  t -= (*it).first;
	  m.erase(it);
	  break;
	}
	it++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      char x = sc.next().charAt(0);
      char y = sc.next().charAt(0);
      if(x > y)
         System.out.println(">");
      else if(x < y){
         System.out.println("<");
      }
      else {
         System.out.println("=");
      }       
   }
}

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

int ans[510*510][4];

int main() {
  int H,W;
  cin >> H >> W;
  vector< vector< int > > a( H, (vector<int>)(W) );
  REP(y,H) {
    REP(x,W) {
      cin >> a[y][x];
      a[y][x] = a[y][x] % 2;
    }
  }
  int n = 0;
  REP(y,H) {
    int pre_o = -1;
    REP(x,W) {
      if ( a[y][x] == 1 ) {
        if (pre_o != -1) {
          for( int i=pre_o; i<x; i++ ) {
            ans[n][0] = y;
            ans[n][1] = i;
            ans[n][2] = y;
            ans[n][3] = i+1;
            n++;
          }
          pre_o = -1;
        } else {
          pre_o = x;
        }
      }
    }
    if ((pre_o != -1) && (y!=H-1)) {
      ans[n][0] = y;
      ans[n][1] = pre_o;
      ans[n][2] = y+1;
      ans[n][3] = pre_o;
      n++;
      a[y+1][pre_o] = (a[y+1][pre_o]==0) ? 1 : 0;
    }
  }
  cout << n << endl;
  REP(i,n) {
    cout << (ans[i][0]+1) << " " << (ans[i][1]+1) << " " << (ans[i][2]+1) << " " << (ans[i][3]+1) << endl;
  }
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a=="H"){
    if(b=="H")cout<<"H"<<endl;
    else cout<<"D"<<endl;
  }
  else{
    if(b=="H")cout<<"D"<<endl;
    else cout<<"H"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int t[100005][2],nt=1;
char _s[100005];
int n;ll l,r;

void ins(string s){
	int k=0;
	for(char c:s){
		int d=c-'0';
		if(!t[k][d])t[k][d]=nt++;
		k=t[k][d];
	}
}

void dfs(int x, int d){
	if(!t[x][0]&&!t[x][1])return;
	if(!t[x][0]||!t[x][1]){
		ll a=l-d;
		if(a)r^=a&-a;
	}
	if(t[x][0])dfs(t[x][0],d+1);
	if(t[x][1])dfs(t[x][1],d+1);
}

int main(){
	scanf("%d%lld",&n,&l);
	while(n--){
		scanf("%s",_s);
		ins(string(_s));
	}
	dfs(0,0);
	puts(r?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 3584
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr, intersperse)
import Data.Monoid
import Control.Monad
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Builder as BSB
import System.IO (stdout)

main = do
  [n,q] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM (n-1) $ do
    [a,b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1)
  operations <- U.replicateM q $ do
    [p,x] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (p-1,x)
  let neighbors :: V.Vector [Int]
      neighbors = V.create $ do
        vec <- VM.replicate n []
        U.forM_ edges $ \(a,b) -> do
          VM.modify vec (b:) a
          VM.modify vec (a:) b
        return vec
      values :: U.Vector Int
      values = U.create $ do
        vec <- UM.replicate n 0
        U.forM_ operations $ \(p,x) -> do
          UM.modify vec (+ x) p
        return vec
      result :: U.Vector Int
      result = U.create $ do
        vec <- UM.new n
        let dfs !parent !q !acc = do
              let !acc' = acc + values U.! q
              UM.write vec q acc'
              forM_ (neighbors V.! q) $ \i -> do
                when (i /= parent) $ do
                  dfs q i acc'
        dfs (-1) 0 0
        return vec
  BSB.hPutBuilder stdout $ (mconcat $ intersperse (BSB.char7 ' ') $ map BSB.intDec $ U.toList result) <> BSB.char7 '\n'


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

struct Sieve{
    ll n;
    vector<ll> f;
    Sieve(int n=1): n(n), f(n+1){
        f[0] = f[1] = -1;
        for(ll i=2;i<=n;i++){
            if(f[i]) continue;
            f[i] = i;
            for(ll j=i*i;j<=n;j+=i){
                if(!f[j]) f[j] = i;
            }
        }
    }

    bool isPrime(ll x){return f[x]==x;}

    //素因数分解
    vector<int> factorlist(int x){
        vector<int> primelist;
        int nx=x;
        while(nx!=1){
            primelist.push_back(f[nx]);  //xの素因数が小さい順に並ぶ
            nx /= f[nx];
        }
        
        return primelist;
    }

    vector<pair<int,int>> factornum(int x){
        vector<int> fl = factorlist(x);
        if(fl.size()==0) return {};
        vector<pair<int,int>> vec(1,make_pair(fl[0],0));
        for(int p : fl){
            if(vec.back().first==p){
                vec.back().second++;
            }else{
                vec.emplace_back(p,1);
            }
        }

        return vec;
    }


};

int main(void){
    int x;
    cin >> x;
    Sieve s(100005);
    while(!s.isPrime(x)) x++;
    cout << x << endl;
}

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

int main(){

  int a, cnt[101]={}, maxn=0;

  while(cin>>a){
    cnt[a]++;
    if(maxn<cnt[a]) maxn=cnt[a];
  }

  for(int i=1;i<=100;i++){
    if(maxn==cnt[i]) cout<<i<<endl;
  }

  return 0;
}

Measured memory_bytes: 3048
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

n, k = map(int, input().split())
A = list(map(int, input().split()))

for i in range(n-k):
    if A[i] < A[i+k]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 94532
import java.util.Scanner;
import java.util.function.Function;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mountains = Integer.parseInt(sc.next());
        int[] damRain = new int[mountains];
        int totalRain = 0;
        for (int i = 0; i < mountains; i++) {
            damRain[i] = Integer.parseInt(sc.next());
            totalRain += damRain[i];
        }

        Function<int[], Integer> getEvenRain = damRainArr -> {
            int evenRain = 0;
            for (int i = 1; i < mountains; i += 2) {
                evenRain += damRainArr[i];
            }
            return evenRain;
        };

        int[] mountainRain = new int[mountains];

        mountainRain[0] = totalRain - (2 * getEvenRain.apply(damRain));
        
        for (int i = 1; i < mountains; i++) {
            mountainRain[i] = (2 * damRain[i - 1]) - mountainRain[i - 1];
        }

        for (Integer rain : mountainRain) {
            System.out.print(rain.toString() + " ");
        }
    }
}

Measured memory_bytes: 49020
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<pair<int, vector<int>>> v(n);
    int c;
    REP(i, n) {
        cin >> c;
        vi a(m);
        REP(j, m) cin >> a[j];
        v[i] = make_pair(c, a);
    }
    int ans = INF;
    for (int i = 0; i < 1 << n; i++) {
        int t = 0;
        vi z(m);
        for (int j = 0; j < n; j++) {
            if ((1 & i >> j) == 1) {
                t += v[j].first;
                REP(k, m) {
                    z[k] += (v[j].second)[k];
                }
            }
        }
        bool ok = true;
        REP(j, m) if (z[j] < x) ok = false;
        if (ok) chmin(ans, t);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	cout<<((a==b&&b==c&&c==a)?"Yes":"No")<<"\n";
	return 0;
}

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

int main() {
  int n, m, o = 0;
  scanf("%d %d", &n, &m);
  vector<vector<int>> p(m);
  priority_queue<int> que;
  for(int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if(a > m) continue;
    p[m - a].push_back(b);
  }
  for(int i = m - 1; i >= 0; i--) {
    for(auto x : p[i]) que.push(x);
    if(!que.empty()) {
      auto q = que.top();
      que.pop();
      o += q;
    }
  }
  printf("%d\n", o);
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, m, a[1005], b, c[1005], t, cs[5005], ans;
int main(){
	scanf("%d%d", &n, &m);
	fill(cs+1, cs+(1<<n), 1e9);
	rep(i,m){
		scanf("%d%d", a+i, &b);
		rep(j,b){
			scanf("%d", &t);
			c[i] |= 1<<(t-1);
		}
	}
	rep(i,1<<n) if(i) rep(j,m) cs[i] = min(cs[i], a[j] + cs[i-(i&c[j])]);
	ans = cs[(1<<n)-1];
	printf("%d\n", ans == 1e9 ? -1 : ans);
}

Measured memory_bytes: 256
a, b = map(int, input().split())
c = []
d = ""
for i in range(a):
    c.append(list(input()))
for i in range(b):
    d += input()
e = []
for i in range(a-b+1):
    for j in range(a-b+1):
        f = ""
        for k in range(b):
            for l in range(b):
                f += c[i+k][j+l]
        e.append(f)
print("Yes" if d in e else "No")


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

int N, W;
vector<int> value;
vector<int> weight;
int weight_all = 0;

int dp[101][10001];

int put(int now, int weight_now){
    if(dp[now][weight_now] != -1){
        return dp[now][weight_now];
    }else if(now == N){
        return dp[now][weight_now] = 0;
    }else if(weight_now + weight[now] > W){
        return dp[now][weight_now] = put(now + 1, weight_now);
    }else{
        return dp[now][weight_now] = max(put(now + 1, weight_now), put(now + 1, weight_now + weight[now]) + value[now]);
    }
}
 
int main(){
    cin >> N >> W;
    for(int i = 0; i < N; i++){
        int v, w;
        cin >> v >> w;
        value.push_back(v);
        weight.push_back(w);
    }
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 10001; j++){
            dp[i][j] = -1;
        }
    }
    cout << put(0, 0) << endl;
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 55;

int n,a[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];

    sort(a+1,a+1+n);
    double sum=(double)((double)a[1]+(double)a[2])/2.0;

    for(int i=3;i<=n;i++){
        sum=(double)(sum+(double)a[i])/2.0;
    }

    cout<<fixed<<setprecision(9)<<sum;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
XYC = [list(map(int,input().split())) for _ in [0]*N]
eps = 1e-7
def f(x,y,t):
    ret = 0
    for X,Y,C in XYC:
        if ((x-X)**2+(y-Y)**2)<=(t/C)**2+eps: ret += 1
    return ret

def get_cross_section(x1,y1,r1,x2,y2,r2):
    d = ((x1-x2)**2+(y1-y2)**2)**0.5
    X = (d*d+r1*r1-r2*r2)/(2*d)
    Y = max(0,(r1*r1-X*X))**0.5
    dx = (x2-x1)/d
    dy = (y2-y1)/d
    ret = [(x1+X*dx+Y*dy,y1+X*dy-Y*dx)]
    if Y>0 : ret.append((x1+X*dx-Y*dy,y1+X*dy+Y*dx))
    return ret
def check(t):
    kouho = []
    for i in range(N):
        x1,y1,c1 = XYC[i]
        kouho.append((x1,y1))
        for j in range(i+1,N):
            x2,y2,c2 = XYC[j]
            tmp = get_cross_section(x1,y1,t/c1,x2,y2,t/c2)
            for tmp2 in tmp:
                kouho.append(tmp2)
    for tmp in kouho:
        if f(tmp[0],tmp[1],t) >= K:return True
    return False

l=0
r=1000000
for _ in range(100):
    i = (l+r)/2
    if check(i):
        r = i
    else:
        l = i
print(r)

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

int main() {
  int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
 int sum=0;
 int M=0;
  int A=(a-1)%10;
  int B=(b-1)%10;
  int C=(c-1)%10;
  int D=(d-1)%10;
  int E=(e-1)%10;
  sum=(a+9)/10*10+(b+9)/10*10+(c+9)/10*10+(d+9)/10*10+(e+9)/10*10;
M=min({A,B,C,D,E});
  cout<<sum-9+M<<endl;
}


  

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main()
{
	string s, y = "YAKI";
	cin >> s;
	for (int i = 0; i < 4; i++) {
		if (s[i] != y[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
def main():
    S = input()
    a, b, c, d = (int(i) for i in S)
    ans = 0
    sign = []
    flag = False
    #op == 0 : plus, op == 1: minus
    for op1 in range(2):
        for op2 in range(2):
            for op3 in range(2):
                ans = 0
                sign = []
                if op1 == 0:
                    ans = a + b
                    sign.append('+')
                else:
                    ans = a - b
                    sign.append('-')
                if op2 == 0:
                    ans += c
                    sign.append('+')
                else:
                    ans -= c
                    sign.append('-')
                if op3 == 0:
                    ans += d
                    sign.append('+')
                else:
                    ans -= d
                    sign.append('-')
                if ans == 7:
                    flag = True
                    break
            if flag:
                break
        if flag:
            break
    for n,op in zip(S,sign):
        print(n+op,end="")
    else:
        print(S[-1]+'=7')


if __name__ == '__main__':
    main()

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int A, B, C;

    cin >> A >> B >> C;

    if (C >= A - B)
    {
        OP(C - (A - B))
    }
    else
    {
        OP(0)
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void gcd_lcm(int, int);

int main() {

	int a, b;

	while(cin >> a >> b) {
		if(a>2000000000||b>2000000000)
			continue;
		gcd_lcm(a, b);
	}

}

void gcd_lcm(int a, int b) {
	int i=2, gcd=1;
	if(a<b) {
		int t=a;
		a=b;
		b=t;
	}

	while(i<=a) {
		if(a%i==0&&b%i==0) {
			gcd*=i;
			a/=i;
			b/=i;
			continue;
		}
		i++;
	}
	
	cout << gcd << " " << a*b*gcd << endl;
}

Measured memory_bytes: 0
N, Y = map(int, input().split())
Y /= 1000

def otoshidama():
    for x in range(N+1):
        resY = Y - 10*x
        if resY < 0:
            return print('-1 -1 -1')
        for y in range(N-x+1):
            if  resY < 5*y:
                break
            if 5*y + (N-x-y) == resY:            
                return print(x, y, N-x-y)
    return  print('-1 -1 -1')


otoshidama()  

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

int main()
{
    int n;
    cin>>n;
    if(n==0||n==1)
        return 0;
    vector<int> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    vector<int> dp(n,0);
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}


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

vector< vector<int> > matrix_product(vector< vector<int> > &A, vector< vector<int> > &B, int M){
  int n = A.size(), m = B[0].size(), l = A[0].size();
  vector< vector<int> > ret(n,vector<int>(m));
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      ret[i][j] = 0;
      for(int k = 0; k < l; ++k){
        ret[i][j] += (A[i][k]*B[k][j])%M;
        ret[i][j] %= M;
      }
    }
  }
  return ret;
}

vector< vector<int> > matrix_pow(vector< vector<int> > &P, int N, int M){
  vector< vector<int> > ret(P.size(),vector<int>(P.size(),0)), t = P;
  for(int i = 0; i < P.size(); ++i) ret[i][i] = 1;
  int k = 0;
  while((1<<k) <= N){
    if((N>>k)&1){
      ret = matrix_product(ret,t,M);
    }
    ++k;
    t = matrix_product(t,t,M);
  }
  return ret;
}

int main(){
  int N, M, A, B, C, T;
  while(cin >> N >> M >> A >> B >> C >> T, N){
    vector< vector<int> > S(N,vector<int>(1));
    for(int i = 0; i < N; ++i) cin >> S[i][0];
    vector< vector<int> > P(N,vector<int>(N,0));
    for(int i = 0; i < N; ++i) P[i][i] = B;
    for(int i = 1; i < N; ++i) P[i][i-1] = A;
    for(int i = 0; i < N-1; ++i) P[i][i+1] = C;
    vector< vector<int> > P_ = matrix_pow(P,T,M);
    vector< vector<int> > ans = matrix_product(P_,S,M);
    for(int i = 0; i < N; ++i){
      cout << ans[i][0];
      if(i < N-1) cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int prime[1005]= {};
void seive()
{
    prime[1] = 1;
    for(int i = 2; i <= sqrt(1000); i++)
    {
        for(int j = i *i; j <= 1000;j += i)
        {
            prime[j] = 1;
        }
    }
}
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int m = max(a, b);
    int v = ceil((double)c/m);
    cout << v << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var k = new List<String>();
		string s = "";
		for(int i = 0; i < p[1]; i++)
			s += p[0].ToString();
		k.Add(s);
		
		s = "";
		for(int i = 0; i < p[0]; i++)
			s += p[1].ToString();
		k.Add(s);
		k.Sort();
		Console.WriteLine(k[0]);
		
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			string[] array = Console.ReadLine().Split(' ');
			char X = array[0][0];
			char Y = array[1][0];

			if (X < Y) {
				Console.WriteLine($"<");
			} else if (X > Y) {
				Console.WriteLine($">");
			} else {
				Console.WriteLine($"=");
			}
			

			Console.ReadKey();
		}
	}
}

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

/// Defining variable types.
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

/// Defining usable key words
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

/// Defining constant variables.
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

/// Defining some useful lines.
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);


/// Code of debugger.
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


int main()
{
    optimize();


    int n;
    string a,b,c;

    cin>>n;
    cin>>a>>b;

    for(int i=0; i<n; i++)
    {
        c=c+a[i]+b[i];
    }

    cout<<c<<'\n';












    return 0;
}


Measured memory_bytes: 384
while True:
    n = int(input())
    if n == 0:
        break

    lst = [0]*4001
    elst = []
    ans = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if lst[e]:
            pass
        else:
            elst.append(e)

        lst[e] = lst[e] + p*q

    for i in elst:
        if lst[i] >= 1000000:
            ans.append(i)

    if ans == []:
        print('NA')
    
    else:
        for i in ans:
            print(i)


Measured memory_bytes: 5832
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<cctype>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

  int i;
 
  /* 文字 */
  char moji;
 
  /* 文字を入力 */
  scanf("%c", &moji);
 
  /* アルファベットの小文字か大文字かを判定 */
  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else if((moji>= 'A') && (moji<='Z')){
      printf("A\n");
  }
 
  return 0;

}   


Measured memory_bytes: 3660
N, D = gets.split(' ').map(&:to_i)

dots = []
cnt = 0

N.times do
  dots.push(gets.split(' ').map(&:to_i))
end

(N - 1).times do |i|
  (N - 1).step(i + 1, -1) do |j|
    distance = 0
    D.times do |idx|
      distance += (dots[i][idx] - dots[j][idx])**2
    end
    distance = Math.sqrt(distance)
    cnt += 1 if distance == distance.to_i
  end
end

print cnt


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

using namespace std;

int main(){
int n; cin >> n; vector<int> p(n+1,0);
  for(int i = 1; i <= n; i++){
    cin >> p[i];}
   // pの入力は1-indexedで行う
  
  int i = 1; int cnt = 0; int j = 1;
  
  while( i < n ){
    if(p[i] == i && p[i+1] == i + 1)
    {p[i+1] = i; p[i] = i+1; cnt++;}
    i++;}
  
  while( j <= n){
    if(p[j] == j){ cnt++;}
    j++;}
  
  cout << cnt << endl; return 0;}

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

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

using namespace std;

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

bool chkmax(int &x,int y){return x<y?x=y,true:false;}
bool chkmin(int &x,int y){return x>y?x=y,true:false;}

int readint(){
	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,tot;
int col[205],v[40005],nxt[40005],h[205],q[205],lab[205];
bool vis[205];
char a[205][205];

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot;
}

bool dfs(int u){
	for(int p=h[u];p;p=nxt[p]){
		if(col[v[p]]>=0){
			if(col[v[p]]==col[u]) return false;
			continue;
		}
		col[v[p]]=col[u]^1;
		if(!dfs(v[p])) return false;
	}
	return true;
}

int main(){
	n=readint();
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<i;j++) if(a[i][j]=='1') addedge(i,j);
	memset(col,-1,sizeof(col));
	col[1]=0;
	if(!dfs(1)) return printf("-1\n"),0;
	int ans=0;
	for(int i=1;i<=n;i++){
		int front=0,rear=0;
		memset(lab,0,sizeof(lab));
		q[rear++]=i,lab[i]=1;
		while(front<rear){
			int t=q[front++];
			chkmax(ans,lab[t]);
			for(int p=h[t];p;p=nxt[p]){
				if(!lab[v[p]]){
					lab[v[p]]=lab[t]+1;
					q[rear++]=v[p];
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
R, G, B, N = map(int,input().split())
count = 0
for sr in range(N+1):
    for sg in range(N+1-sr):
        sb = N-sr-sg
        if sr%R == 0 and sg%G == 0 and sb %B == 0:
            count += 1
print(count)
                




Measured memory_bytes: 41308