akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

int main() {
    cin.tie();
    ios::sync_with_stdio(false);
    
    // input
    int X, A, B;
    cin >> X >> A >> B;
    
    if (B <= A) {
        cout << "delicious" << "\n";
    } else if (A < B && B <= A + X) {
        cout << "safe" << "\n";
    } else {
        cout << "dangerous" << "\n";
    }
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
        long k = sc.nextLong();
		long mod = 1000000007;
        long ans = 0;
        for(long i=k;i<=n+1;i++){ans+=((i*(2*n-i+1))/2-(i*(i-1))/2)+1;
                               ans%=mod;}       
		System.out.println(ans);
	}
}

Measured memory_bytes: 35724
#include <bits/stdc++.h>
using namespace std;
#define INF 1e16
long long n,dp[2007][2007],a[2007],ans=0;
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        dp[i][n-1]=a[(i+n-1)%n];
    }
    int turn=1;
    for(int j=n-2;j>=1;j--){
        if(turn==0){
            for(int i=0;i<n;i++){
                dp[i][j]=max(dp[i][j+1]+a[(i+j)%n],dp[(i+n-1)%n][j+1]+a[(i+n-1)%n]);
            }
        }
        else{
            long long cal;
            for(int i=0;i<n;i++){
                cal=-INF;
                if(a[(i+j)%n]>a[i]) cal=dp[i][j+1];
                if(a[(i+n-1)%n]>a[(i+j-1)%n]) cal=max(cal,dp[(i+n-1)%n][j+1]);
                dp[i][j]=cal;
            }
        }
        turn=(turn+1)%2;
    }
    if(turn==0){
        for(int i=0;i<n;i++){
            ans=max(ans,dp[i][1]+a[i]);
        }
    }
    else{
        for(int i=0;i<n;i++){
            ans=max(ans,dp[i][1]);
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main(){
	int nagasa;
  	string s;
  
  cin>>nagasa>>s;
  
  if(s.size()<=nagasa){
  	cout<<s<<endl;
  }
  else{
  	cout<<s.erase(nagasa)<<"..."<<endl;
  }
	
}

Measured memory_bytes: 3596
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long ll;

int main(){
  int K, X;
  cin >> K >> X;
  
  int a = K * 2 - 1;
  for (int i = 0 ; i < a; i++){
    cout << X - K + 1 + i << " ";
  }
  
  return 0;
}

Measured memory_bytes: 256
def solve(string):
    n = int(string)
    base = [(-2)**i for i in range(40)]
    ans = ""
    for b in base:
        if n % abs(2 * b) >= abs(b):
            n -= b
            ans += "1"
        else:
            ans += "0"
        if n == 0:
            break
    return ans[::-1]


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int ans = 0;

int dfs(int depth, int sum, int before) {
    int ret = 0;
    if(depth == 0) {
        if(sum == ans) return(1);
        else           return(0);
    }
    if(sum > ans) return(0);
    if(before > 9) return(0);
    for(int r = before; r <= 9; r++) {
        ret += dfs(depth - 1, sum + r, r + 1);
    }
    return(ret);
}

int main(void) {
    cin.tie();
    ios::sync_with_stdio(false);
    while(true) {
        int depth = -1;
        cin >> depth >> ans;
        if(depth + ans == 0) break;
        cout << dfs(depth, 0, 0) << endl;
    }
    
    return(0);
}

Measured memory_bytes: 1192
# -*- coding: utf-8 -*-
"""
Created on Mon Jun  1 13:59:38 2020

@author: NEC-PCuser
"""

N = int(input())
A = list(map(int, input().split()))
minusCount = 0
ans = 0
miniumAbs = 10 ** 9
for i in range(0, len(A)):
    if (A[i] < 0):
        minusCount += 1
    if (miniumAbs > abs(A[i])):
        miniumAbs = abs(A[i])
    ans += abs(A[i])
if minusCount %2 == 0:
    print(ans)
else:
    print(ans - 2 * miniumAbs)

Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
	int A, P;
	cin >> A >> P;
	
	print((A * 3 + P)/2);
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    int q; cin >> q;
    ll ttl = 0;
    cin >> skipws;
    rep(i, 0, q) {
        int p, n; char c; cin >> p >> c >> n;
        if (c == '(') ttl -= n; else ttl += n;
        if (!ttl) cout << "Yes" << endl; else cout << "No" << endl;
    }
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=1000000000;
	for(int i=0;i<s.size()-2;i++){
		int num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		ans=min(abs(num-753),ans);
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int memo[100100];

int rec(int n){
    if(n == 0) return 0;
    if(memo[n] != -1) return memo[n];

    int res = n;

    for(int i = 1; i <= n; i *= 6){
        res = min(res,rec(n-i) + 1);
    }
    for(int i = 1; i <= n; i *= 9){
        res = min(res,rec(n-i) + 1);
    }
    memo[n] = res;
    return memo[n];
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i <= n; i++){
        memo[i] = -1;
    }
    cout << rec(n) << endl;
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int a, b;
	cin >> a >> b;
	int ans;
	ans = (b - 1) /(a - 1);
  if((b-1)%(a-1)!=0) ans++;
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3620
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  S = readline()
  A = S[1:2] |> parseInt
  B = S[3:4] |> parseInt
  result = if A >= 1 && A <= 12 && B >= 1 && B <= 12
    "AMBIGUOUS"
  elseif A >= 1 && A <= 12
    "MMYY"
  elseif B >= 1 && B <= 12
    "YYMM"
  else
    "NA"
  end
  println(result)
end

main()


Measured memory_bytes: 165576
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
int main() {
	ll a, b;
  	cin >> a >> b;
  	if(a <= 0 && b >= 0){
      cout << "Zero" << endl;
      return 0;
    }
  	else if(a > 0 && b > 0){
      cout << "Positive" << endl;
      return 0;
    }
  	else{
      if((b-a+1) % 2 == 0) cout << "Positive" << endl;
      else cout << "Negative" << endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

def main():
  n,k=map(int,input().split())
  p=list(map(lambda x:(1+int(x))/2,input().split()))
  sumk=sum(p[:k])
  ans=sumk
  for i in range(n-k):
    sumk-=p[i]
    sumk+=p[i+k]
    ans=max(ans,sumk)
  print(ans)
if __name__=='__main__':
  #import datetime
  #print(datetime.datetime.now())
  main()
  #print(datetime.datetime.now())



Measured memory_bytes: 23524
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    ll a[n+1];
    memset(a,0,sizeof(a));
    for(int i=1;i<n;i++){
    	if(s[i]=='C'&&s[i-1]=='A')a[i+1]++;
    }
    for(int i=1;i<=n;i++){
    	a[i]+=a[i-1];
    }

    vector<ll> v;

    while(q--){
    	ll x,y;
    	cin>>x>>y;
    	v.pb(a[y]-a[x]);
    }
    for(auto& i:v)cout << i<<endl;
    return 0;
}


Measured memory_bytes: 2628
#include<iostream>

using namespace std;


int main(void){
	
	int n;
	while(cin>>n){
		
		int ans = 0;
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int p=0;p<=9;p++){
						if(i+j+k+p == n)ans++;
					}
				}
			}
		}
		
		cout<<ans<<endl;
	}
}

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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for(int i=0; i<=25; i++){
        for(int j=0; j<=14; j++){
            ans = i*4 + j*7;
            if(ans == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 3592
n = int(input())
a = list(map(int,input().split()))
a.sort()
from collections import Counter
dic = Counter(a)
ans = 0
for k in range(len(a)-1,-1,-1):
    if dic[a[k]]==0:
        continue
    dic[a[k]] -= 1
    t = 2**a[k].bit_length()-a[k]
    if dic[t]:
        dic[t] -= 1
        ans += 1
print(ans)

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;
  return x;
  #undef nc
}

const int maxn = 4e5 + 10;
bool mat[maxn];
int n, A[maxn], B[maxn], dataA[maxn], dataB[maxn];

void kmp(int *A, int *B) {
  static int nxt[maxn];
  for (int i = 2, j = 0; i <= n; i++) {
    while (j && B[i] != B[j + 1]) j = nxt[j];
    j += B[i] == B[j + 1], nxt[i] = j;
  }
  for (int i = 1, j = 0; i <= n * 2; i++) {
    while (j && A[i] != B[j + 1]) j = nxt[j];
    j += A[i] == B[j + 1];
    if (j == n) {
      mat[i - n + 1] = 1, j = nxt[j];
    }
  }
}

int main() {
  n = read();
  rep(i, 1, n) A[i] = read();
  rep(i, 1, n) B[i] = read();
  rep(i, 1, n) dataA[i] = A[i] ^ A[i % n + 1];
  rep(i, 1, n) dataB[i] = B[i] ^ B[i % n + 1];
  rep(i, 1, n) dataA[n + i] = dataA[i];
  kmp(dataA, dataB);
  rep(i, 1, n) if (mat[i]) {
    printf("%d %d\n", i - 1, A[i] ^ B[1]);
  }
  return 0;
}

Measured memory_bytes: 10880
#include<cstdio>

using namespace std;

int N;
int A[100];

void input(){
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d", A + i);
}

int solve(){
	int bestId = -1;
	int dis = -1;
	int sum = 0;
	for(int i = 0; i < N; ++i) sum += A[i];
	for(int i = 0; i < N; ++i){
		int curDis = A[i] * N - sum;
		if(curDis < 0) curDis *= (-1);
		if(dis == -1 || curDis < dis){
			dis = curDis;
			bestId = i;
		}
	}
	return bestId;
}

int main(){
	input();
	int ans = solve();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl d(N);
  rep(i, N) cin >> d[i];

  stable_sort(d.begin(), d.end());

  ll cnt = 1;

  rep2(i, 1, N){
    if(d[i] > d[i - 1]) cnt++;
  }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;

int main(){
    int n,k,a,b;
    scanf("%d%d%d",&k,&a,&b);
    int q=1;
    while(q*k<=b){
    	if(q*k>=a&q*k<=b){
    		printf("OK");
    		return 0;
    	}
    	q++;
    	
    }
    printf("NG");

    
 	return 0;
}




Measured memory_bytes: 3752
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int M;
    cin >> M;
    vector<ll> d(M), c(M);
    rep(i, M) { cin >> d[i] >> c[i]; }
    ll digsum = 0;
    ll dig = 0;
    rep(i, M) {
        digsum += d[i] * c[i];
        dig += c[i];
    }
    cout << (digsum - 1) / 9 + dig - 1 << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int par[100001],D[100001],sum[100001];
int find(int x){
if(par[x]!=x){
  int px=par[x];
  par[x]=find(par[x]);
  D[x]+=D[px];
  return par[x];
}
return x;
}

void Union(int x,int y,int c){
int rx=find(x);
int ry=find(y);
if(rx==ry)return;
par[rx]=ry;
D[rx]=c+D[y]-D[x];
}

void IN(){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
sum[a]+=c;
sum[b]+=c;
Union(a,b,c-sum[b]+sum[a]);
}

void COMP(){
int a,b;
scanf("%d%d",&a,&b);
if(find(a)!=find(b))printf("WARNING\n");
else printf("%d\n",D[a]-D[b]+sum[b]-sum[a]);
}
int main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++)par[i]=i;
while(q--){
  char s[10];
  scanf("%s",s);
  if(s[0]=='I')IN();
  else COMP();
}
return 0;
}

Measured memory_bytes: 2408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

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


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VL a_sum(n + 1, 0);
    FOR(i, 1, n) {
        ll a;
        cin >> a;
        a_sum[i] = a + a_sum[i - 1];
    }
    VL a_sub;
    FOR(i, 0, n - 1)FOR(j, i + 1, n)
        a_sub.push_back(a_sum[j] - a_sum[i]);
    sort(ALL(a_sub), greater<ll>());
    
    // REP(i, a_sub.size())
    //     cerr << bitset<8>(a_sub[i]) << endl;

    FORR(d, 45, 0) {
        int cnt = 0;
        VL candidate;
        REP(i, a_sub.size()) {
            if((a_sub[i] >> d & 1) == 1) {
                candidate.push_back(a_sub[i]);
                cnt++;
            }
        }
        if(cnt >= k) a_sub = candidate; 
    }

    ll ans = 0;
    ans = ~ans;
    REP(i, k) ans &= a_sub[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6512
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto N = readInt();
    auto x = readInts();
    foreach(ref xi; x) {
        --xi;
    }
    auto a = new int[](N*N);
    auto b = new bool[](N*N);
    auto m = iota(1, N+1).array;
    int idx;
    zip(x, m).sort();
    foreach(i; iota(N)) {
        if(b[x[i]]) {
            writeln("No");
            return;
        }
        b[x[i]] = true;
        a[x[i]] = m[i];
        foreach(j; iota(m[i]-1)) {
            while(idx < x[i] && b[idx]) {
                ++idx;
            }
            if(idx >= x[i]) {
                writeln("No");
                return;
            }
            b[idx] = true;
            a[idx] = m[i];
        }
    }
    zip(x, m).sort!((a, b) => a > b);
    idx = N*N-1;
    foreach(i; iota(N)) {
        foreach(j; iota(N - m[i])) {
            while(idx > x[i] && b[idx]) {
                --idx;
            }
            if(idx <= x[i]) {
                writeln("No");
                return;
            }
            b[idx] = true;
            a[idx] = m[i];
        }
    }
    writeln("Yes");
    writeln(a.map!(to!string).join(" "));
}



Measured memory_bytes: 4348
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  // エラトステネスの篩の入力配列でふるいをしていくバージョンをやればOK
  vector<int> cnt(1000005);
  vector<bool> p(1000005, true);
  rep(i, n) {
    int v = a[i];
    cnt[v]++;
    if (cnt[v] >= 2) continue;
    for (int j = v + v; j <= 1000005; j += v) p[j] = false;
  }

  int ans = 0;
  rep(i, n) {
    int v = a[i];
    if (cnt[v] == 1 && p[v]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8008
#include <stdio.h>
#define MAX 500000
#define Large 2000000000
int cnt;
int L[250000+2];
int R[250000+2];
int A[MAX];
void merge1(int l,int m,int r){
  int n1,n2,i;
  n1=m-l;     //?????´???????????¨
  n2=r-m;     //?????´???????????¨
  for(i=0;i<n1;i++){
    L[i]=A[l+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[m+i];
  }
  L[n1]=Large;
  R[n2]=Large;
  int i1=0,i2=0,j;
  for(j=l;j<r;j++){
    if(L[i1]<=R[i2]){
      A[j]=L[i1];
      i1++;
    }else{
      A[j]=R[i2];
      i2++;
    }
    cnt++;
  }
}

void mergesort(int l, int r){
  int m;
  if(l+1<r){
      m=(r+l)/2;
      mergesort(l,m);
      mergesort(m,r);
      merge1(l,m,r);
  }
}



int main(int argc, char const *argv[]) {
  int n,i;
  scanf("%d\n",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  mergesort(0,n);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",cnt);
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

// DP[i][j]:i番目までの数値をチェックした時、i番目の数値が左からj番目に小さい時のパターン数
ll dp[3001][3001];
ll dps[3001][3001];

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

  dp[0][0]=1;
  rep(i, n-1){

    dps[i][0] = dp[i][0];
    rep1(j, i+1){
      dps[i][j] += dps[i][j-1]+dp[i][j];
    }

    rep(j, i+1+1){
      if(s[i]=='<'){

        if(j)dp[i+1][j] += dps[i][j-1];

//        rep(k, i+1)if(k<j)dp[i+1][j] += dp[i][k];
      }else{

        dp[i+1][j] += dps[i][i];
        if(j)dp[i+1][j] -= dps[i][j-1];

//        rep(k, i+1)if(k>=j)dp[i+1][j] += dp[i][k];
      }
      dp[i+1][j] %= MOD;
    }
  }

  ll result = 0;
  rep(j, n)result = (result + dp[n-1][j])%MOD;

  cout<<result<<endl;

  return 0;

rep(i, n+1){
  rep(j, n+1)cout<<dp[i][j]<<' ';
  cout<<endl;
}cout<<"---"<<endl;

  return 0;
}

Measured memory_bytes: 95828
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>

int main(){
    double a, b;
    std::cin >> a >> b;

    std::cout << (int)(a / b) << " " << std::fmod(a, b) << " " << std::to_string(a / b) << std::endl;
    
    return 0;
}


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

// i+ a[i]== j- a[j] なるペアを数える。
// 上が成り立つ場合,制約より
// i- a[i]= j- 2*a[j]≠ j+ a[j]
// なので、各ペアの重複度は1.
int main(){
  int N;
  cin >> N;

  vector<int> data(N);
  unordered_map<int, int64_t> idx_val;
  for(int i=0; i<N; i++){
    cin >> data.at(i);

    if(idx_val.count(i-data.at(i))){ idx_val.at(i-data.at(i))++; }
    else                           { idx_val[i-data.at(i)]= 1; }
  }

  int64_t ans= 0;
  for(int i=0; i<N; i++){
    if(idx_val.count(i+data.at(i))){
      ans+= idx_val.at(i+data.at(i));
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 11932
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    REP(i,3) ans += (s[i] == t[i]);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ll long long int

int main()
{
    int n;
    vector<pair<ll, ll>> job;
    long long int nowt = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        long long int a, b;
        cin >> a >> b;
        job.push_back(make_pair(b, a));
    }

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

    for (auto x: job) {
        nowt += x.second;
        if (nowt > x.first) {
            cout << "No" << endl;
            return (0);
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int z=12800;
bitset<25601> dp[81][81];
int n,m;
int a[81][81],b[81][81];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)scanf("%d",&b[i][j]);
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)a[i][j]=abs(a[i][j]-b[i][j]);
    }
    dp[0][1][z]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j]|=dp[i-1][j];
            dp[i][j]|=dp[i][j-1];
            dp[i][j]=(dp[i][j]<<a[i][j])|(dp[i][j]>>a[i][j]);
        }
    }
    int ans=1000000000;
    for(int i=0;i<=25600;i++)if(dp[n][m][i])ans=min(ans,abs(i-z));
    printf("%d\n",ans);
    return 0;
}

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

int main()
{
    int K, X;
    cin >> K >> X;

    

    int min_b = X - K + 1;
    int max_b = X + K - 1;

    for (int i = min_b; i <= max_b; i++) {
        cout << i << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#0のときのことを考えなきゃいけない
import sys
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
rule = {}

if N==1:
    for i in range(M):
        if sc[i][1] != 0:
            break
    else:
        print(0)
        sys.exit()

for i in range(M):
    s = sc[i][0]
    c = sc[i][1]
    if s == 1 and c == 0:
        print('-1')
        sys.exit()
    elif s in rule:
        if rule[s] != c:
            print('-1')
            sys.exit()
        else:
            rule[s] = c
    else:
        rule[s] = c
        
if 1 not in rule:
    rule[1] = 1
    
for i in range(N):
    if i + 1 not in rule:
        rule[i + 1] = 0

ans = 0
for i in range(N):
    ans += rule[i+1] * (10 ** (N-i-1))
    
print(ans)           

Measured memory_bytes: 3064
n, x, y = map(int,input().split())
cnt = [0 for _ in range(n)]
for i in range(1, n):
    for j in range(i+1, n+1):
        if i <= x and j >= y:
            cnt[(x-i)+1+(j-y)] += 1
        else:
            c = min(j-i, abs(x-i)+1+abs(y-j))
            cnt[c] += 1
for i in cnt[1:]:
    print(i)

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

int main(){
  int n;
  cin>>n;
  int C,A,N;
  for(int i=0;i<n;i++){
    int count=0;
    cin>>C>>A>>N;
    while(N>0&&A>0&&C>0){
      C--;
      A--;
      N--;
      count++;
    }
    while(A>0&&C>1&&N==0){
      C--;
      C--;
      A--;
      count++;
    }
    count+=C/3;
    cout<<count<<endl;
  }
}


Measured memory_bytes: 3092
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = []
count= 0

for i in range(n):
    a = list(map(int,input().split()))
    sum = c

    for j in range(m):
        sum += b[j]*a[j]

    if sum > 0:
        count += 1
    else:
        pass

print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
 
const int  N = 102;
 
#define int long long
 
using namespace std;
 
int f[N][N][N * 3],n;
int w[N],v[N],ans,W;
main() {
	memset(f,0,sizeof(f));
	scanf("%lld%lld",&n,&W);
	for (int i = 1;i <= n; ++i)
		scanf("%lld %lld",&w[i],&v[i]);
	for (int i = 1;i <= n; ++i)
		for (int k = 0;k <= i; ++k)
			for (int o = 0;o <= i * 3; ++o) {
					f[i][k][o] = f[i - 1][k][o];
					if (k > 0&&o >= w[i] - w[1])
						f[i][k][o] = max(f[i][k][o],f[i - 1][k - 1][o - (w[i] - w[1])] + v[i]);
			}
	ans = 0;
	for (int i = 0;i <= n; ++i)
		for (int j = 0;j <= 3 * n; ++j)
			if (i * w[1] + j <= W) ans = max(ans,f[n][i][j]);
	cout <<ans << endl;
	return 0;
}

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

using namespace std;

typedef long long llint;

llint n, sol;
string s;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    n = s.size();
    for (int mask = 0; mask < (1 << (n - 1)); mask++) {
        llint sum = 0, curr = 0;
        for (int i = 0; i < n; i++) {
            curr = curr * 10 + s[i] - '0';
            if ((mask & (1 << i)) || i == n-1) {
                sum += curr;
                curr = 0;
            }
        }
        sol += sum;
    }
    cout << sol;
    return 0;
}


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

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

using namespace std;

int memo[50000][2];
int cpy[50000][2];
int cnt;

void func(int x, int y){
	//3分割して、copyに入れなおす。
	int flg = 0;
	int total = 0;
	int cn = 0;
	rep(i,cnt){
		int n = memo[i][1]-memo[i][0]+1;
		if(total + n > y && flg == 0){
			cpy[cn][0] = memo[i][0] + y - total;
			cpy[cn][1] = memo[i][1];
			memo[i][1] = memo[i][0] + y - total - 1;
			cn++;
			flg = 1;
		}else if(flg && n >= 1){
			cpy[cn][0] = memo[i][0];
			cpy[cn][1] = memo[i][1];
			memo[i][0] = 0;
			memo[i][1] = -1;
			cn++;
		}else{
			total += n;
		}
	}
	flg = 0;
	total = 0;
	rep(i,cnt){
		int n = memo[i][1]-memo[i][0]+1;
		if(total + n > x && flg == 0){
			cpy[cn][0] = memo[i][0] + x - total;
			cpy[cn][1] = memo[i][1];
			memo[i][1] = memo[i][0] + x - total - 1;
			cn++;
			flg = 1;
		}else if(flg && n >= 1){
			cpy[cn][0] = memo[i][0];
			cpy[cn][1] = memo[i][1];
			memo[i][0] = 0;
			memo[i][1] = -1;
			cn++;
		}else{
			total += n;
		}
	}
	rep(i,cnt){
		int n = memo[i][1]-memo[i][0]+1;
		if(n >= 1){
			cpy[cn][0] = memo[i][0];
			cpy[cn][1] = memo[i][1];
			memo[i][0] = -1;
			memo[i][1] = -1;
			cn++;
		}
	}
	cnt = cn;
	rep(i,cnt){
		memo[i][0] = cpy[i][0];
		memo[i][1] = cpy[i][1];
	}
}

int solve(int p, int q, int r){
	int ans = 0;
	int total = 0;
	int flg = 0;
	rep(i,cnt){
		int n = memo[i][1] - memo[i][0] + 1;
		if(total + n >= p && flg == 0){
			memo[i][0] = memo[i][0] + p-total-1;
			flg = 1;
		}
		if(total + n > q && flg == 1){
			memo[i][1] = memo[i][0] + q-total-1;
			flg = 2;
		}
		if(flg){
			if(memo[i][0] <= r){
				if(memo[i][1] <= r){
					ans += memo[i][1]-memo[i][0]+1;
				}else{
					ans += r-memo[i][0]+1;
				}
			}
		}
		//cout << "ans:" << ans << endl;
		if(flg==2)break;
		total += n;
	}
	return ans;
}

int main(void){
	int n;
	int ans;
	while(scanf("%d", &n), n){
		int m;
		int p, q, r;
		int flg = 0;
		cnt = 0;
		
		scanf("%d", &m);
		scanf("%d %d %d", &p, &q, &r);
		
		rep(i,50000)rep(j,2)memo[i][j] = 0;
		
		memo[cnt][0] = 1;
		memo[cnt][1] = n;
		cnt++;
		rep(i,m){
			int x,y;
			scanf("%d %d", &x, &y);
			int total = 0;
			
			func(x,y);
			/*
			rep(j,cnt){
				cout << memo[j][0] << "," << memo[j][1] << endl;
			}
			*/
		}
		
		ans  = solve(p,q,r);
		printf("%d\n", ans);
		
	}
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<K;i++){
    vector<int>B(N,0);
    for(int j=0;j<N;j++){
      int l=max(0,j-A[j]);
      int r=min(N,j+A[j]+1);
      B[l]++;
      if(r<N)B[r]--;
    }
    for(int i=0;i<N-1;i++)B[i+1]+=B[i];
    A=B;
    bool ok=true;
    for(auto it:A)if(it!=N)ok=false;
    if(ok)break;
  }
  for(auto it:A)cout<<it<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 4888
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,k=gsmi
pp=gsmi

#rui=rui(pp)
prev=sum(pp[0,k-1]).to_i
max=0
(k-1).upto(n-1) do |l_i|
  #puts "i:"+l_i.to_s
  sum=prev+pp[l_i]
  if sum>max
    max=sum
  end
  prev=prev+pp[l_i]-pp[l_i-k+1]
end

puts 0.5*k+0.5*max

Measured memory_bytes: 16020
def ketanowa(p):
    ans = 0
    p = str(p)
    for i in p:
        ans += int(i)
    return ans


def main():
    temp1 = input()
    temp1 = input()

    temp1 = temp1.split(" ")
    
    temp1 = list(map(int,temp1))
    temp1.sort()
    
    print(abs(temp1[0]-temp1[-1]))

if __name__ == '__main__':
    main()


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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define endl "\n"
#define all(V) V.begin( ), V.end( )
#define Unique(V) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
#define Check( N , p ) ( !( ( N & ( 1LL << p ) ) == 0 ) )
#define ON( N , p ) ( N = N | ( 1LL << p ) )
#define OFF( N , p ) ( N = N & ~( 1LL << p ) )
std::mt19937 rng( chrono::steady_clock::now().time_since_epoch().count() );
#define rnd(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))
#define ran(a, b) rng() % ( (b) - (a) + 1 ) + (a)
#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template < typename Arg1 >
void __f( const char* name , Arg1&& arg1 ) { cerr << name << " : " << arg1 << "\n"; }
template < typename Arg1 , typename... Args >
void __f( const char* names , Arg1&& arg1 , Args&&... args ) {
const char* comma = strchr( names + 1 , ',' );
cerr.write( names , comma - names ) << " : " << arg1 << " , " ; __f( comma + 1 , args... ); }
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int n , k;
int a[ N ];
int dp[ N ];

int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        cin >> n >> k;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        for( int i = 1; i <= n; i++ ) dp[i] = inf;
        dp[1] = 0;
        ///dp[i] = min total cost to reach to i'th stone from 1st stone.
        for( int i = 1; i <= n; i++ ) {
                for( int j = 1; j <= k; j++ ) {
                        if( (i - j) >= 1 ) dp[i] = min( dp[i] , dp[i-j] + abs( a[i] - a[i-j] ) );
                }
        }
        cout << dp[n] << endl;
        return 0;
}














Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//C++ as C#
#define var auto
#define Max std::max
#define Min std::min
template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline uint32_t read()
{
	uint32_t x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
	return x;
}

void writeline(uint32_t x) {
	int s = 0;
	char f[8];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int main()
{
	int h = read(), w = read();
	int columnAccum[2000] = {};
	int rowMax[2000] = {};
	int max = 0;
	for (size_t i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (size_t j = 0; j < w; j++)
		{
			var c = getchar_unlocked() & 1;
			if (c) 
			{
				max = Max(max, columnAccum[j] + rowMax[j]);
				for (size_t k = j - currentChain; k < j; k++)
					rowMax[k] = Max(rowMax[k], currentChain);
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else 
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		for (size_t j = w - currentChain; j < w; j++)
			rowMax[j] = Max(rowMax[j], currentChain);
		getchar_unlocked();
	}
	for (size_t i = 0; i < w; i++)
		max = Max(max, columnAccum[i] + rowMax[i]);
	writeline(max - 1);
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
N=int(input())
T=[int(input()) for _ in range(N)]
ans=1
for i in T:
    ans=lcm(i,ans)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}



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

  int N;
  while(cin >> N){
    vector<char> c(2*N);
    vector<int> a(2*N);

    map<pair<char,int>, int> m;
    
    REP(i,2*N){
      cin >> c[i] >> a[i];
      m[{c[i],a[i]}] = i;
    }

    vector<vector<int>> count_white(N+1, vector<int>(2*N+1, 0));
    vector<vector<int>> count_black(N+1, vector<int>(2*N+1, 0));

    FORE(i,0,N){
      FOR(j,0,2*N){
	count_white[i][j+1] += count_white[i][j];
	if(c[j] == 'W' and a[j] > i) count_white[i][j+1] += 1;

	count_black[i][j+1] += count_black[i][j];
	if(c[j] == 'B' and a[j] > i) count_black[i][j+1] += 1;
      }
    }
    dump(count_white);
    dump(count_black);
    
    vector<vector<int>> dp(N+1, vector<int>(N+1, INT_MAX/2));

    dp[0][0] = 0;
    
    FORE(w,0,N){
      FORE(b,0,N){
	if(w+1<=N){
	  int k = m[{'W',w+1}];
	  chmin(dp[w+1][b], dp[w][b] + count_white[w+1][k] + count_black[b][k]);
	}
	
	if(b+1<=N){
	  int k = m[{'B',b+1}];
	  chmin(dp[w][b+1], dp[w][b] + count_white[w][k] + count_black[b+1][k]);
	}
      }
    }
    dump(dp);

    int ans = dp[N][N];
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 78976
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s; cin >> s;
    cout << "0 0 " 
    << (s - 1LL) / 1000000000LL + 1LL << " 1 " 
    << (1000000000LL - (s % 1000000000LL)) % 1000000000LL << " 1000000000\n";
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc177/tasks/abc177_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const int SZ = 1e6;

// エラトステネスの篩
template <int N> struct Prime {
    bitset<N + 1> b;
    Prime() : b() {
        // trueで初期化
        b.flip();
        b[0] = b[1] = false;
        for (int i = 2; i <= N; ++i) {
            if (b[i]) {
                for (int j = i * i; j <= N; j += i) {
                    b[j] = false;
                }
            }
        }
    }
};
// SZ = 1e6 だと10ms
Prime<SZ> prime;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N), D(SZ + 1);
    for (auto &x : A) {
        cin >> x;
        D[x]++;
    }
    // trueなら "pairwise coprime"
    bool pc = true;
    REP(i, SZ) {
        // 素数の場合
        if (prime.b[i]) {
            int cnt = 0;
            // 素数の倍数に対して2つ以上存在するなら、gcd != 1になる
            for (int now = i; now <= SZ; now += i) {
                cnt += D[now];
            }
            if (cnt >= 2) {
                pc = false;
                break;
            }
        }
    }
    if (pc) {
        cout << "pairwise coprime\n";
    } else {
        int g = A[0];
        for (auto &x : A) {
            g = gcd(g, x);
        }
        if (g == 1) {
            cout << "setwise coprime\n";
        } else {
            cout << "not coprime\n";
        }
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 18996
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n;
	string s;
	cin>>n;
	cin>>s;
	int a=0,b=0;
	REP(i,s.length()){
		if(s[i]=='R'){
			a++;
		}else if(s[i]=='B'){
			b++;
		}
	}
	if(a>b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



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

int main()
{
    string str;
    stack<double> s;

    while( cin >> str )
    {
        if( str == "EOF" )
            break;
        int size = str.size();
        if( size != 1 )
        {
            double sum = 0, dig = 1;
            if( str[0] == '-' )         //マイナスの値の処理
            {
                for( int i = size - 1; i >= 1; i-- )
                {
                    sum += dig * ( str[i] - '0' );
                    dig *= 10;
                }
                s.push( -1 * sum );
            }
            else                        //通常の2ケタ以上の数字の処理
            {
                for( int i = size - 1; i >= 0; i-- )
                {
                    sum += dig * ( str[i] - '0' );
                    dig *= 10;
                }
                s.push(sum);
            }
        }
        else                            //計算処理
        {                               //48-57はASCII文字の0から9
            if( 48 <= str[0] && str[0] <= 57 )
                s.push(str[0]-'0');
            else
            {
                double a = s.top();
                s.pop();
                double b = s.top();
                s.pop();
                if( str[0] == '+' )
                    s.push( b + a );
                else if( str[0] == '-' )
                    s.push( b - a );
                else if( str[0] == '*' )
                    s.push( b * a );
                else if( str[0] == '/' )
                    s.push( b / a );
                else;
            }
        }
    }
    //計算結果をそのまま出すと、新しい結果から先に出力されるので、調整
    stack<double> res;
    while( s.empty() == false )
    {
        res.push(s.top());
        s.pop();
    }
    while( res.empty() == false )
    {
        cout << fixed << setprecision(8) << res.top() << endl;
        res.pop();
    }
    return 0;
}


Measured memory_bytes: 3228
N = int(input())
 
def dfs(s):
  if int(s) > N: 
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in '753':
    ret += dfs(s+c)
  return ret
 
print(dfs('0'))

Measured memory_bytes: 3060