akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int x; cin>>x;
	ll lcm=360*x/__gcd(360,x);
	cout<<lcm/x<<'\n';
	
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 998244353;


// 01ベクトルのランクを求める
int binary_matrix_rank(vector<vector<int>> A) {
  const int N = A.size();
  const int M = A[0].size();

  auto at = [](const vector<int> Ai, int j) -> int {
    return Ai[j];
  };

  int s = 0;
  REP(j, M) {
    int p = -1;
    for (int i = s; i < N; i++) if (at(A[i], j)) { p = i; break; }
    if (p >= 0) {
      swap(A[s], A[p]);
      for (int i = s+1; i < N; i++) if (at(A[i], j)) {
        REP(k, M)
        A[i][k] ^= A[s][k];
      }
      s++;
    }
  }
  return s;
}


int main2() {
  int N = nextLong();
  int M = nextLong();

  vector< vector<int> > A(N, vector<int>(M, 0));
  REP(i, N) REP(j, M) A[i][j] = nextLong();

  int R = binary_matrix_rank(A);

  ll ans = 1;
  REP(i, R) ans = (ans * 2) % MOD;
  ans = (ans - 1 + MOD) % MOD;

  REP(i, N-R) ans = (ans * 2) % MOD;
  REP(i, M-1) ans = (ans * 2) % MOD;

  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

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

int w, h;
struct xydata {
    int x, y;
};

int main() {
    while(1) {
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        int sx, sy;
        vector< vector<char> > tile(h, vector<char>(w, '.'));
        for(int i = 0; i < h; ++i) {
            for(int j = 0; j < w; ++j) {
                cin >> tile[i][j];
                if(tile[i][j] == '@') {
                    sx = j; sy = i;
                }
            }
        }
        vector< vector<char> > ntile = tile;
        queue<xydata> que;
        xydata first; first.x = sx; first.y = sy;
        que.push(first);
        ntile[sy][sx] = '#';
        while(!que.empty()) {
            xydata now = que.front();
            que.pop();
            for(int i = 0; i < 4; ++i) {
                int nx = now.x+dx[i], ny = now.y+dy[i];
                if(nx >= 0 && nx < w && ny >= 0 && ny < h) {
                    if(ntile[ny][nx] == '.') {
                        xydata next;
                        next.x = nx, next.y = ny;
                        que.push(next);
                        ntile[ny][nx] = '#';
                    }
                }
            }
        }

        int cnt = 0;
        for(int i = 0; i < h; ++i) {
            for(int j = 0; j < w; ++j) {
                if(tile[i][j] == '.' || tile[i][j] == '@') {
                    if(ntile[i][j] == '#') cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int i,j,k,ans,n,a,b,c,aa,bb,cc,amax,bmax,cmax;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>a>>b>>c;
    if(i==0){amax=a;bmax=b;cmax=c;}
    else
    {
      aa=a+max(bmax,cmax);
      bb=b+max(amax,cmax);
      cc=c+max(amax,bmax);
      amax=aa;
      bmax=bb;
      cmax=cc;
    }
    
  }
  ans=max(max(amax,bmax),cmax);
  cout<<ans<<endl;
  
  
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int x = Integer.parseInt(str);

		if(x < 1200){
			System.out.println("ABC");
		}else{
			System.out.println("ARC");
		}

	}

}


Measured memory_bytes: 20564
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string s; cin >> s;
	int right = s.size();
	vector<ll> aNum(right, 0), bcNum(right, 0);
	int i = 0;
	ll aCnt = 0;
	while (i < right)
	{
		while (i < right&&s[i] == 'A')
		{
			++aCnt;
			aNum[i] = aCnt;
			++i;
		}
		aCnt = 0;
		++i;
	}
	i = right - 1;
	ll bcCnt = 0;
	while (0 < i)
	{
		while (0 < i && s[i] == 'C' && s[i - 1] == 'B')
		{
			++bcCnt;
			bcNum[i - 1] = bcCnt;
			i -= 2;
		}
		bcCnt = 0;
		--i;
	}
	if (s.find("ABC") == string::npos)
	{
		cout << 0 << endl;
		return 0;
	}

	ll ans = 0;
	rep(i, 0, right - 3)
	{
		int tempANum = 0;
		while ((i <= right - 3 && s.substr(i, 3) == "ABC") || (i <= right - 3 && s[i] == 'A'))
		{
			if (s[i] == 'A'&&s[i + 1] == 'A')
			{
				++i;
				continue;
			}
			tempANum += aNum[i];
			ans += tempANum * bcNum[i + 1];
			i = i + 1 + bcNum[i + 1] * 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;	cin >> n;
  queue<int>	h;
  for(int i=0;i<n;i++){
    int x;	cin >> x;
    h.push(x);
  }
  
  int ans=0;
  int height=h.front();	h.pop();
  int now=height;
  int count=0;
  while(!h.empty()){
    int x=h.front();	h.pop();
    if(x<=now)	count++;
    if(now<x)	count=0;
    now=x;
    ans=max(ans,count);
  }
  cout << ans;
}

Measured memory_bytes: 3788
x,n,*l = map(int,open(0).read().split())

import sys
if not x in l:
    print(x)
    sys.exit()
for i in range(1, 100):
    if  not x -i in l:
        print(x -i)
        sys.exit()
    if  not x +i in l:
        print(x +i)
        sys.exit()

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int H,preH=0,max=0,cnt=0;
  for(int i=0;i<N;i++){
    cin >> H;
    if(preH >= H) cnt++;
    else{
      if(max < cnt) max = cnt;
      cnt = 0;
    }
    preH = H;
  }
  if(max < cnt) max = cnt;
  cout << max <<endl;
  return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3

import sys

def dfs(i, p, add):
    add += add_node[i]
    counter[i] += add
    for j in adj[i]:
        if j != p:
            dfs(j, i, add)

sys.setrecursionlimit(10 ** 6)
n, q = map(int, input().split())
adj = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, sys.stdin.readline().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)
add_node = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, sys.stdin.readline().split())
    add_node[p - 1] += x
counter = [0 for i in range(n)]
dfs(0, -1, 0)
print(" ".join(str(x) for x in counter))



Measured memory_bytes: 244108
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = INF;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> H >> W >> K;
	if (W == 1) cout << 1;
	else {
		vll sub_dp(W + 1, vl(2, 0));
		sub_dp[0][1] = 1;
		for (i = 0; i < W; i++) {
			sub_dp[i + 1][0] = sub_dp[i][0] + sub_dp[i][1];
			sub_dp[i + 1][1] = sub_dp[i][0];
		}
		vl sub(W + 1);
		for (i = 0; i < W + 1; i++) {
			sub[i] = (sub_dp[i][0] + sub_dp[i][1]) % MOD;
			//cout << sub[i] << endl;
		}
		vll dp(H + 1, vl(W, 0));
		dp[0][0] = 1;
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if (j == 0) {
					dp[i + 1][j] = (dp[i][j + 1] * sub[W - 2] + dp[i][j] * sub[W - 1]) % MOD;
				}
				else if (j == W - 1) {
					dp[i + 1][j] = (dp[i][j - 1] * sub[W - 2] + dp[i][j] * sub[W - 1]) % MOD;
				}
				else {
					dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - 1] * sub[j - 1] * sub[W - j - 1]) % MOD;
					dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * sub[j] * sub[W - j - 1]) % MOD;
					dp[i + 1][j] = (dp[i + 1][j] + dp[i][j + 1] * sub[j] * sub[W - j - 2]) % MOD;
				}
			}
		}
		cout << dp[H][K - 1];
	}
}

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


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

int N;
const long long INF = 1LL << 60;
vector<int> A;
vector<long long> S;
vector<vector<long long>> dp;

// [A_left, A_right) を合体させる最小コストを返す
long long func(int left, int right) {
  if (right - left == 1) return dp.at(left).at(right) = 0;  // 1 体のみなので 0
  if (dp.at(left).at(right) != INF) return dp.at(left).at(right);
  long long res = INF;
  long long cost = S.at(right) - S.at(left);  // 区間 [left, right)
  for (int i = 1; i < right - left; i++) {
    // [A_left ... A_left+i) と [A_left+i ... A_right) に分割
    long long tmp = func(left, left + i) + func(left + i, right);
    res = min(res, cost + tmp);
  }
  return dp.at(left).at(right) = res;
}

int main() {
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  S.assign(N+1, 0);
  for (int i = 0; i < N; i++) S.at(i+1) = S.at(i) + A.at(i);
  dp = vector<vector<long long>>(N+1, vector<long long>(N+1, INF));
  cout << func(0, N) << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    vector<ll> zz(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
        zz[i] = z[i];
    }
    vector<ll> x(1000001);
    for (int i = 0; i < n; i++) {
        for (int j = 2; j < 1001; j++) {
            ll c = 0;
            while (z[i] % j == 0) {
                c++;
                z[i] /= j;
            }
            x[j] = max(x[j], c);
        }
        if (z[i] != 1)x[z[i]] = 1;
    }
    ll zans = 1;
    for (int i = 0; i < 1000001; i++) {
        for (int j = 0; j < x[i]; j++) {
            zans *= i;
            zans %= 1000000007;
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += zans * modinv(zz[i], 1000000007) % 1000000007;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8192
import sys
def solve():
    readline = sys.stdin.readline

    N, M, K = map(int, readline().split())
    *A, = map(int, readline().split())

    S = A[:]
    T = [0]*N
    Q0 = [0]*N; Q1 = [0]*N
    for k in range(2, K+1):
        s = t = 0

        for i in range(k-1, N):
            a = S[i-1]
            while s < t and Q1[t-1] <= a:
                t -= 1
            Q0[t] = i-1; Q1[t] = a
            t += 1

            T[i] = Q1[s] + A[i]*k

            if s < t and Q0[s] <= i-M:
                s += 1
        S, T = T, S
    print(max(S))
solve()

Measured memory_bytes: 61992
#include<bits/stdc++.h>
using namespace std; 
int main() {
  int n, x, t; cin >> n >> x >> t;
  if(n % x == 0) {
    cout << n /x *t << endl;
  }
  else {
    cout << (n /x +1) *t << endl;
  }
}

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

int main() {
  double d,t,s=0;
  cin>>d>>t>>s;
  if(d/s>t){
    cout<<"No";
  }else{
    cout<<"Yes";
  }
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define sqrt sqrtl
#define fill(x,y) memset(x,y,sizeof(x))
#define debug(x) cout << #x << ":" << x << endl
const intl INF = 1e9;
const intl MOD = 1e9+7;
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a;
    cin >> a;
    intl b;
    cin >> b;
    intl c;
    cin >> c;
    ld e =  1.0e-14;
    fp((sqrt(a) + sqrt(b) + e < sqrt(c)));
    return 0;
}

Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

n = I()
a = LI()
ans = 0
for i, elem in enumerate(a):
    if (i + 1) % 2 != 0 and elem % 2 != 0:
        ans += 1
print(ans)


Measured memory_bytes: 9196
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int main(){
  int N, i, k, res=1073709056, tmp;
  rd(N);
  for(i=0;i<=N;i+=9){
    tmp = 0;
    k = i;
    while(k){
      tmp += k % 9;
      k /= 9;
    }
    k = N - i;
    while(k){
      tmp += k % 6;
      k /= 6;
    }
    chmin(res, tmp);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// {
//   int N;
//   int i, k, res = int_inf, tmp;
//   rd(N);
//   for(i=0;i<=N;i+=9){
//     tmp = 0;
//     k = i;
//     while(k) tmp += k % 9, k /= 9;
//     k = N - i;
//     while(k) tmp += k % 6, k /= 6;
//     res <?= tmp;
//   }
//   wt(res);
// }


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}
long long a[200004], b[200004];
int main()
{
	fast;
	int n, m, k, ans = 0;
	cin >> n >> m >> k;
	ll tot = 0;
	for (int i = 1; i <= n; i++)
	{
		ll t;
		cin >> t;
		tot += t;
		a[i] = a[i - 1] + t;
	}
	for (int i = 1; i <= m; i++)
	{
		ll t;
		cin >> t;
		tot += t;
		b[i] = b[i - 1] + t;
	}
	if (tot <= k)
	{
		cout << n + m << en;
		return 0;
	}
	for (int i = 0; i <= n; i++)
		if (k >= a[i])
		{
			int res = upper_bound(b + 1, b + 1 + m, k - a[i]) - b - 1;
			ans = max(ans, res + i);
		}
	cout << ans << en;
}

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


bool Compare(pii a, pii b)
{
	return a.ff > b.ff;
}
priority_queue<pii, vector<pii>, function<bool(pii, pii)>> pq(Compare);

void solve(){
	string s,t; cin>>s>>t;
	int mn=LLONG_MAX;
	f(i,0,sz(s)-sz(t)+1){
		int m=0;
		f(j,0,sz(t)) m+=s[i+j]!=t[j];
		mn=min(mn,m);
	}
	cout<<mn;
}

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

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,a[15][15],cnt,ans[105];

int main()
{
		scanf("%d %d",&n,&m);
	while(n||m)
	{
		++cnt;
		for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		scanf("%d",&a[i][j]);
		for(int i=2;i<=n-1;i++)
		for(int j=2;j<=m-1;j++)
		for(int k=i;k<=n-1;k++)
		for(int h=j;h<=m-1;h++){
			int miny=2e9,maxy=-1,sum=0;
			for(int ii=i;ii<=k;ii++)
			for(int jj=j;jj<=h;jj++){
				maxy=max(maxy,a[ii][jj]);
				sum+=9-a[ii][jj];
			}
			for(int ii=i-1;ii<=k+1;ii++)miny=min(miny,min(a[ii][j-1],a[ii][h+1]));
			for(int jj=j;jj<=h;jj++)miny=min(miny,min(a[i-1][jj],a[k+1][jj]));
			if(maxy<miny)ans[cnt]=max(ans[cnt],sum-(9-miny)*(k-i+1)*(h-j+1));
		}
		scanf("%d %d",&n,&m);
	}
	for(int i=1;i<=cnt;i++)printf("%d\n",ans[i]);
 } 


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;
#define N 2000005
int fact[N],invfact[N];

void fun()
{
	fact[0]=1;
	for(int i=1;i<N;i++)
		fact[i]=mul(fact[i-1],i);
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
		invfact[i]=mul(invfact[i+1],i+1);
}

int ncr(int n,int r)
{
	int ans=fact[n];
	ans=mul(ans,invfact[n-r]);
	ans=mul(ans,invfact[r]);
	return ans;
}

void solve()
{
	fun();
	int k,ans=0;
	string s;
	cin>>k>>s;
	int n=s.length(),i;
	int m=n+k;
	for(i=n;i<=m;i++)
	{
		int x=power(26,m-i);
		int y=power(25,i-n);
		int z=ncr(i-1,n-1);
		int val=mul(x,mul(y,z));
		ans=add(ans,val);
	}
	cout<<ans<<endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}

Measured memory_bytes: 35512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());

int a[3];

int main(){
    rep(i, 3)cin >> a[i];
    sort(a, a + 3);
    cout << abs(a[0] - a[1]) + abs(a[1] - a[2]) << endl;
}

Measured memory_bytes: 256
n = int(input())
c,s,f = [],[],[]
ans = []
for i in range(n-1):
    ls = list(map(int, input().split()))
    c.append(ls[0])
    s.append(ls[1])
    f.append(ls[2])

for i in range(n-1):
    ans.append(s[i])
    ans[i] += c[i]
    for j in range(i+1,n-1):
        if ans[i]-s[j] >= 0:
            if (ans[i]-s[j])%f[j] == 0:
                ans[i] += c[j]
            else:
                ans[i] +=f[j]-((ans[i]-s[j])%f[j])+c[j]
        else:
            ans[i] += (s[j]-ans[i])+c[j]
ans.append(0)
for i in range(n):
    print(ans[i])


Measured memory_bytes: 3188
#include <iostream>

using namespace std;
int n,x,a[100010];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		a[x]=i;
	}
	cout<<a[1];
	for(int i=2;i<=n;i++) cout<<" "<<a[i];
	return 0;
} 

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>

using namespace std;

// https://atcoder.jp/contests/cf16-tournament-round3-open/tasks/asaporo_b

void func_M(const vector<int>& a, vector<int>& b) {
    int n = int(a.size());
    b.resize(n - 1);
    for (int i = 0; i < n - 1; i++) {
        b[i] = max(a[i], a[i + 1]);
    }
}

void func_m(const vector<int>& a, vector<int>& b) {
    int n = int(a.size());
    b.resize(n - 1);
    for (int i = 0; i < n - 1; i++) {
        b[i] = min(a[i], a[i + 1]);
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cin.tie(nullptr);
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    string s;
    cin >> s;
    vector<int> b;
    for (char c: s) {
        if (c == 'M') func_M(a, b);
        else func_m(a, b);
        swap(a, b);
    }
    cout << a[0] << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int n, a[200], cnt;

int main(void) {
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", a+i);
    while (1) {
        int i;
        for(i=0; i<n; i++) {
            if(a[i]%2) break;
            a[i]/=2;
        }
        if(i<n) break;
        cnt++;
    }
    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int dp[110][MAXN];
vector<plii> A;
int pos[MAXN];

int main()
{
    int n,m,k,a,b,x,y;
    ll sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    ll cur = 0, idx = -1;

    cin>>n>>k;

    for(int i=1;i*i<=n;i++){
        A.push_back(plii(i,i));
        if(i!=n/(i+1)+1)A.push_back(plii(n/(i+1)+1,n/i));
    }

    sort(A.begin(),A.end());

    int sz = A.size();
    int en = sz-1;

    for(int i=0;i<sz;i++){
        while(A[i].s*A[en].s>n)en--;
        pos[i] = en;
    }
    /*
    for(int i=0;i<sz;i++)
        cout<<A[i].f<<" "<<A[i].s<<"\n";

    for(int i=0;i<sz;i++)
        cout<<pos[i]<<"\n";
    */

    for(int i=0;i<sz;i++)dp[1][i] = 1;

    for(int i=2;i<=k;i++){

        sum = 0;
        for(int j=0;j<sz;j++){
            cur = (ll)dp[i-1][j]*(A[j].s-A[j].f+1);
            cur %= MOD;
            sum+=cur;
            sum%=MOD;
        }
        //cout<<sum<<"\n";
        en = sz-1;
        for(int j=0;j<sz;j++){

            while(en>pos[j]){
                cur = (ll)dp[i-1][en]*(A[en].s-A[en].f+1);
                cur %= MOD;
                sum += (MOD-cur);
                sum %= MOD;
                en--;
            }
            dp[i][j] = sum;
        }
    }

    ll res = 0;
    /*
    for(int i=1;i<=k;i++,cout<<"\n")
        for(int j=0;j<sz;j++)
            cout<<dp[i][j]<<" ";
    */
    for(int i=0;i<sz;i++)
    {
        cur = (ll)dp[k][i]*(A[i].s-A[i].f+1);
        cur %= MOD;
        res+=cur;
        res%=MOD;
    }

    cout<<res;

    return 0;
}


Measured memory_bytes: 79732
# from math import gcd
from fractions import gcd


def solve(k, aa):
    if k in aa:
        return True
    if k > max(aa):
        return False
    g = aa.pop()
    for a in aa:
        g = gcd(g, a)
        if g == 1:
            return True
    return k % g == 0


n, k = map(int, input().split())
aa = set(map(int, input().split()))
print('POSSIBLE' if solve(k, aa) else 'IMPOSSIBLE')


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

#ifdef _MSC_VER
#define strcasecmp stricmp
#define strtok_r strtok_s
#endif

int main(void)
{
    char buf[1024], word[64];
    fgets(buf, sizeof(buf), stdin);
    sscanf(buf, "%s", word);

    int count = 0;

    while(1){
        char *p, *cont;
        fgets(buf, sizeof(buf), stdin);
        while(buf[strlen(buf)-1] == '\r' || buf[strlen(buf)-1] == '\n'){
            buf[strlen(buf)-1] = 0;
        }
        if(strcmp(buf, "END_OF_TEXT") == 0) break;

        p = strtok_r(buf, " ", &cont);
        while(p != NULL){
            //printf("[%s]", p);
            if(strcasecmp(p, word) == 0){
                count++;
            }
            p = strtok_r(NULL, " ", &cont);
        }
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1008
#include "bits/stdc++.h"
#include <fstream>

typedef long long int ll;
using namespace std;

int main()
{

    //freopen("14","r",stdin);
    //freopen("sparse.out","w",stdout);
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    sort(a,a+n);
    ll area=0;
    bool t=false;
    int pre = 0;
    for(int i=n-1;i>=0;i--){
        if(a[i]==pre){
            if(area==0){
                    area=pre;
            }
            else {
                    area*=pre;
                    t=true;
                    break;
            }
            pre=0;
        }else pre=a[i];
    }
    printf("%lld",t?area:0);
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int count1 = 0;
    int count2 = 0;
    // int count3 = 0;

    boolean[] isAC = new boolean[N];
    int[] penaCount = new int[N];
    Arrays.fill(isAC,false);
    Arrays.fill(penaCount,0);

    for(int i=0; i<M; i++){
        int index = sc.nextInt()-1;
        String s = sc.next();
        if(s.equals("AC")&&isAC[index]==false){
            isAC[index]=true;
            count1++;
            count2+=penaCount[index];
        }else if(s.equals("WA")&&isAC[index]==false){
            penaCount[index]++;
        }
    }
    System.out.print(count1 + " ");  
    System.out.print(count2);  
    return;
  }
}





Measured memory_bytes: 63232
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set set = new HashSet<Integer>();
        for(int i = 0; i < n; i++) {
            int tmp = sc.nextInt();
            set.add(tmp);
        }
        System.out.println(set.size());
    }
}

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

int main() {
    
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	int alice = 0;
	int bob = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) alice += a[i];
		else bob += a[i];
	}
	cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
#define INF 1000000
int m[100][100]; //adjacency matrix
int n; //vertexes
void dijkstra();
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            m[i][j] = INF;
        }
    }
    for (int i = 0; i < n; i++) {
        int u; //number
        int k; //output orders
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v; //vertex
            int c; //weight
            cin >> v >> c;
            m[u][v] = c;
        }
    }
    dijkstra();
    return 0;
}
void dijkstra() {
    int d[100]; //minimum cost
    int p[100]; //top parent
    d[0] = 0;
    p[0] = 1;
    for (int i = 1; i < n; i++) {
        p[i] = 0;
        d[i] = INF;
    }
    while (1) {
        int minv = INF;
        int u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && p[i] != 2) { //firstly only d[0]
                u = i; //tmp parent
                minv = d[i]; //min cost of 0 to i
            }
        }
        if (u == -1) {
            break;
        }
        p[u] = 2; //決まったら
        for (int v = 0; v < n; v++) {
            if (m[u][v] != INF && p[v] != 2) { //u and v are connected
                if (d[v] > d[u] + m[u][v]) {
                    d[v] = d[u] + m[u][v]; //get smaller cost
                    //ここでd[v]がINFから解放され、次の親になれる
                    p[v] = 1;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i << " ";
        if (d[i] == INF) {
            cout << -1 << endl;
        } else {
            cout << d[i] << endl;
        }
    }
}



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

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        long N = cin.Long();
        long K = cin.Long();

        var dic = new Dictionary<long, long>();
        for(int i = 0; i < N; i++)
        {
            var a = cin.Long();
            var b = cin.Long();
            if (dic.ContainsKey(a)) dic[a] += b;
            else dic.Add(a, b);
        }

        int index = 0;
        var list = new List<long>(dic.Keys);
        list.Sort();
        while(K > dic[list[index]])
        {
            K -= dic[list[index]];
            index++;
        }

        Console.WriteLine(list[index]);
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 19676
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
	string str;
	while(getline(cin,str)){
		if(str==".") break;
		stack<char> stk;
		string res = "yes";
		for(int i=0;i<str.size();i++){
			if(str[i]=='(') stk.push('(');
			if(str[i]=='[') stk.push('[');

			if(str[i]==')'){
				if(!stk.empty() && stk.top() != '(') res = "no";
				else if(stk.empty()) res = "no";
				else stk.pop();
			}

			if(str[i]==']'){
				if(!stk.empty() && stk.top() != '[') res = "no";
				else if(stk.empty()) res = "no";
				else stk.pop();
			}

		}

		if(!stk.empty()) res = "no";
		cout << res << endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A;
  int n;
  for (int i = 0; i < N; i++) {
    cin >> n;
    A.push_back(n);
  }
  set<int> S;
  for (int n : A) {
    if (S.count(n)) {
      cout << "NO" << endl;
      return 0;
    }
    S.insert(n);
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 10356
import itertools
n = int(input())
a = list(map(int, input().split()))
suma = sum(a)-a[0]
ans = 0
p = 10 ** 9+7
for i in range(len(a)-1):
    ans += a[i]*suma
    suma -= a[i+1]
    ans = ans%p
print(ans)

Measured memory_bytes: 94004
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  ll ans=n*(n+1);
    ans/=2;
  ll  p=n/3;
  ll q=n/5;
  ll r=n/15;
  ll a=p*(6+(p-1)*3);
    a/=2;
  ll b=q*(10+(q-1)*5);
    b/=2;
  ll c=r*(30+(r-1)*15);
  c/=2;
  ans=ans-a-b+c;
  cout<<ans<<"\n";
  return 0;
}
  


Measured memory_bytes: 3536
def main():
    L, R = map(int, input().split())
    # 60 の相異なる素因数は 3, 673 の 2つ
    if L + 672 <= R:
        print(0)
        return
    print(min(i * j % 2019 for i in range(L, R + 1)
              for j in range(i + 1, R + 1)))
    return


main()


Measured memory_bytes: 3316
s = input()
if ((int(s[2]) == 1 and int(s[3]) <= 2) or (int(s[2]) == 0 and int(s[3]) != 0)) and((int(s[0]) == 1 and int(s[1]) <= 2) or (int(s[0]) == 0 and int(s[1]) != 0)):
    print("AMBIGUOUS")
elif (int(s[0]) == int(s[1]) == int(s[2]) == int(s[3]) == 0) or (int(s[0]) >= 1 and int(s[1])>=3 and int(s[2])>=1 and int(s[3])>=3) or (int(s[0])==int(s[1])==0 and int(s[2])>=1 and int(s[3])>=3) or (int(s[2])==int(s[3])==0 and int(s[0]) >= 1 and int(s[1])>=3):
    print("NA")
elif (int(s[2]) == 1 and int(s[3]) <= 2) or (int(s[2]) == 0 and int(s[3]) != 0):
    print("YYMM")
elif (int(s[0]) == 1 and int(s[1]) <= 2) or (int(s[0]) == 0 and int(s[1]) != 0):
    print("MMYY")

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  set<int> s;
  for(int i=A;i<=B;i++){
    s.insert(i);
  }
  int ans=0;
  for(int i=C;i<=D;i++){
    if(s.count(i)){
      ans++;
    }
  }
  if(ans>0){
    ans--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int result = c;
        if (b/a < c) result = b / a;
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35820
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

template<class X> X gcd(X a, X b) {return b ? gcd(b,a%b):a;}

int main(){
    int N;
    cin >> N;
    ll X;
    cin >> X;
    vector<ll> city(N);
    for(int i = 0; i < N; i++) cin >> city[i];
    ll ans = abs(X - city[0]);
    for(int i = 1; i < N; i++){
        ans = gcd(ans, abs(X - city[i]));
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define int long long
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (ll i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((ll)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <ll, ll> pii ;
typedef vector <ll> vi ;
typedef vector <pii> vii ;
typedef queue <ll> qi ;
typedef queue <pii> qii ;
typedef set <ll> si ;
typedef map <ll, ll> mii ;
typedef map <string, ll> msi ;
const ll maxn = 2e6 + 100 ;
const ll inf = 0x3f3f3f3f ;
const ll iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T = ll> T chmin(T &a, T b) { return a = min(a, b);}
template <class T = ll> T chmax(T &a, T b) { return a = max(a, b);}
template <class T = ll> T read()
{
	T f = 1, a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	return a * f ;
}

ll n, lim;

ll p[maxn], q;

ll s[maxn];

ll power(ll a, ll b)
{
	ll ret = 1;
	for(; b; b >>= 1, (a *= a) %= mod) if(b & 1) (ret *= a) %= mod;
	return ret;
}

void fwt_xor(ll *a, ll lim, ll opt)
{
	for(ll i = 1; i < lim; i <<= 1)
	{
		for(ll j = 0; j < lim; j += (i << 1))
		{
			rep(k, 0, i - 1)
			{
				ll x = a[j + k], y = a[i + j + k];
				if(opt) a[j + k] = (x + y) % mod, a[i + j + k] = (x + mod - y) % mod;
				else a[j + k] = (x + y) % mod * ((mod + 1) / 2) % mod, a[i + j + k] = (x + mod - y) % mod * ((mod + 1) / 2) % mod;
			}
		}
	}
}

signed main()
{
	n = read();
	lim = 1 << n;
	rep(i, 0, lim - 1) q += (p[i] = read());
	q = power(q, mod - 2);
	rep(i, 0, lim - 1) (p[i] *= q) %= mod;
	(p[0] += mod - 1) %= mod;
	s[0] = lim;
	rep(i, 0, lim - 1) (s[i] += mod - 1) %= mod;
	fwt_xor(s, lim, 1), fwt_xor(p, lim, 1);
	s[0] = 0;
	rep(i, 1, lim - 1) (s[i] *= power(p[i], mod - 2)) %= mod;
	fwt_xor(s, lim, 0);
	ll d = mod - s[0];
	rep(i, 0, lim - 1) (s[i] += d) %= mod;
	rep(i, 0, lim - 1) printf("%lld\n", s[i]);
	return 0;
}

Measured memory_bytes: 7736
#include <iostream>
#include <map>
#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h> 
using namespace std;
#define ll long long int
int main()
{
	ll n;
	cin>>n;
	int ans=0;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			int cnt=0;
			while(n%i==0)
			{
				++cnt;
				n=n/i;
			}
			int x=1;
			while(x*(x+1)/2<=cnt)++x;
			ans=ans+x-1;
		}
	}
	if(n!=1)
	++ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int n;
string s;
ll ans = 0;

void DFS(string str){
    if(str.size() == n){
        ll tmp = 0;
        for (int i = 0; i < n; i++) {
            if(str[i] == '+'){
                ans += tmp;
                tmp = s[i] - '0';
            }
            else{
                tmp = tmp * 10 + (s[i] - '0');
            }
        }
        ans += tmp;
        return;
    }
    DFS(str+"0");
    DFS(str+"+");
}

int main(){
    cin >> s;
    n = s.size();
    DFS("0");
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <stdio.h>
using namespace std;
#define maxx 110000
typedef long long ll;
string a;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((c>=a&&c<=b)||(c>=b&&c<=a)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
}

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,h,w;
 
ll x[500005],y[500005],z[500005];
ll u[500005],v[500005];
char s[500005],t[500005];
bool ok=false;
bool check[100005];
 
int main(){
    cin>>s>>a;
	n=strlen(s);
	for(i=0;i<n;i++){
		//p(a);
		if((26-(s[i]-'a'))%26<=a){
			a -= (26-(s[i]-'a'))%26;
			s[i]='a';
		}
	}
	if(a>0){
		a %= 26;
		s[n-1] += a;
	}
	p(s);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a,b,c,d;
  a=n/1000;
  b=n/100%10;
  c=n/10%10;
  d=n%10;
  
  for(int i=0;i<8;i++){
    int x=a;
    
    if(i/4==0)
      x+=b;
    else
      x-=b;
    
    if(i/2%2==0)
      x+=c;
    else
      x-=c;
    
    if(i%2==0)
      x+=d;
    else
      x-=d;
    
    if(x==7){
      cout << a;
      if(i/4==0)
        cout << '+';
      else
        cout << '-';
      
      cout << b;
    
      if(i/2%2==0)
        cout << '+';
      else
        cout << '-';
      
      cout << c;
    
      if(i%2==0)
        cout << '+';
      else
        cout << '-';
      
      cout << d << "=7" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256