akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int r0, w0, c, r;
    while(1){
        cin >> r0 >> w0 >> c >> r;
        if(r0 + w0 + c + r == 0) break;
        int ans = 0;
        ans = max(ans, (c * w0 - r0 + r - 1) / r);
        cout << ans << endl;
    }
}

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

int main(){
    string s, res;
    cin >> s;
    int ans = 0;

    rep(bits, (1<<3)) {
        ans = s[0]-'0';
        res = s[0];
        rep(i, 3) {
            if(bits & (1<<i)) {
                ans += s[i+1]-'0';
                res = res + "+" + s[i+1];
            } else {
                ans -= s[i+1]-'0';
                res = res + "-" + s[i+1];
            }
        }

        if(ans == 7) {
            cout << res + "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
			Scanner scanner = new Scanner(System.in);

            // 空白で分割してaとb,cを定義

            int a = scanner.nextInt();

            int b = scanner.nextInt();

            int c = scanner.nextInt();

            if (a <= b && b <= c) {
            	System.out.println(a + " " + b + " " + c);
            } else if (a <= c && c <= b) {
            	System.out.println(a + " " + c + " " + b);
            } else if (b <= a && a <= c) {
            	System.out.println(b + " " + a + " " + c);
            } else if (b <= c && c <= a) {
            	System.out.println(b + " " + c + " " + a);
            } else if (c <= a && a <= b) {
            	System.out.println(c + " " + a + " " + b);
            } else if (c <= b && b <= a) {
            	System.out.println(c + " " + b + " " + a);
            }
	}
}


Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

const ll MODULO = 998244353L;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

ll mod_pow(ll x, ll n, ll modval) {
    if (n == 0) {
        return 1;
    }
    ll res = mod_pow(x * x % modval, n / 2, modval);
    if (n & 1) {
        res = res * x % modval;
    }
    return res;
}
ll pow(ll x, ll n) {
    return mod_pow(x, n, MODULO);
}
ll mod(ll n) {
    return n % MODULO;
}

const ll COMBMAX = 200000;
ll factorial[COMBMAX+1], invfactor[COMBMAX+1];
void combination_init() {
    factorial[0] = 1;
    factorial[1] = 1;
    invfactor[0] = 1;
    invfactor[1] = 1;
    for (ll i = 2; i <= 1 + COMBMAX; i++) {
      factorial[i] = (i * factorial[i-1]) % MODULO;
      invfactor[i] = pow(factorial[i], MODULO-2);
    }
}
ll combination(ll n, ll k) {
    return mod(mod(factorial[n]*invfactor[k])*invfactor[n-k]);
}

int main() {
    ll N, M, K;
    cin >> N >> M >> K;

    combination_init();
    ll result = 0;
    for (ll j = 0; j <= K; j++) {
        result = mod(result + mod(combination(N - 1, j) * mod(M * pow(M - 1, N - j - 1))));
    }
    print(result);
}


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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sps << ' '
#define sp << ' ' << 
# define M_PI   3.14159265358979323846
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
ll u, r, l, d;

bool check(ll x, ll y){
  if(x >= l and x <= r and y >= u and y <= d) return false;
  else return true;
}

int main()
{
  boost;
  ll tt = 1, n, m, i, a;

  // cin >> tt;

  for(int _ = 1; _ <= tt; _++){
    // cout << "Case #" << _ << ": ";
    cin >> n >> m;
    ll sum = 0;

    for(i = 0; i < m; i++){
      cin >> a;
      sum += a;
    }

    ll diff = n - sum;
    cout << max(-1LL, diff) << nl;
  }

  return 0;
}

Measured memory_bytes: 3612
N,M = [int(it) for it in input().split()]
pli=[int(it)-1 for it in input().split()]
sli=[ [int(it)-1 for it in input().split()] for i in range(M)]
ue = [-1]*N
dw = [[] for i in range(N)]

for a,b in sli:
  if ( b == ue[a] or a == ue[b] ):
    continue
  else:
    _a = ue[a] if ue[a]!=-1 else a 
    _b = ue[b] if ue[b]!=-1 else b
    if (_a == _b and _a != -1):
      continue
    if (len(dw[_a]) < len(dw[_b])):
      _a,_b=_b,_a
    if len(dw[_b])>0:
      dw[_a].extend(dw[_b])
      for _p in dw[_b]:
        ue[_p]=_a
      dw[_b]=[]
    dw[_a].append(_b)
    ue[_b]=_a

s = 0
for i in range(N):
  if ue[i]==-1:
    ue[i]=i 
for i in range(N):
  if (ue[i]==ue[pli[i]]):
    s+=1
print (s)


Measured memory_bytes: 93676
#include<stdio.h>
int main()
{
    int K,A,B,i,c=0;
     scanf("%d%d%d",&K,&A,&B);
      for(i=A;i<=B;i++)
      {
          if(i%K==0)
            c++;

      }
      if(c>0)
        printf("OK\n");
      else
        printf("NG\n");


    return 0;
}




Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define pb push_back
#define mp make_pair
#define ull unsigned long long int
#define ll long long int
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define eps 1e-10
#define dbs long double

ll i,j,k,sum=0,ans=0,n;

void fastio(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void solve()
{
	cin>>n;
	int a[n+1];
	int dp[n+1];
	for(i=1;i<=n;i++)
		cin>>a[i];
	dp[0]=INT_MAX;
	dp[1]=0;
	dp[2] = abs(a[2]-a[1]);
	for(i=3;i<=n;i++)
	{
		/*int mini = INT_MAX;
		j = i-1;
		while(j>0 && (i-j)<=k)
		{
			mini = min(mini,dp[j]+abs(a[i]-a[j]));
			j--;
		}
		dp[i] = mini;*/

		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n];
}

int main(){
	fastio();
	int t=1;
	//cin>>t;
	 while(t--)
	 	solve();
	return 0;
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs32 a(n), b(n);
    rep (i, n) cin >> a[i];
    rep (i, n) cin >> b[i];
    // sort(b.begin(), b.end());

    int ans = 0;
    rep (i, 29)
    {
        int mod = 1 << (i + 1);
        vs32 B(n);
        rep (j, n) B[j] = b[j] % mod;
        sort(B.begin(), B.end());

        s64 num = 0;
        int t = 1 << i;
        rep (j, n)
        {
            int A = a[j] % mod;
            num += lower_bound(B.begin(), B.end(), 2 * t - A) - lower_bound(B.begin(), B.end(), t - A);
            num += lower_bound(B.begin(), B.end(), 4 * t - A) - lower_bound(B.begin(), B.end(), 3 * t - A);
        }
        if (num & 1) ans |= 1 << i;
    }

    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 2672
#include <stdio.h>
#include <stdlib.h>
 
int main(){
  int n;
  long int ans;
  scanf("%d", &n);
  int i;
  long int m=0,a=0,r=0,c=0,h=0;
  
  char s[n+1][12];
  
  for(i=0;i<=n;i++)	gets(s[i]);
  
  for(i=0;i<=n;i++){
    switch(s[i][0]){
      case 'M':m++;break;
      case 'A':a++;break;
      case 'R':r++;break;
      case 'C':c++;break;
      case 'H':h++;break;
      
    }
  }
  ans = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
  
  printf("%lld", ans);
  
  return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 305;







int n, m;
ll dp[maxn][maxn][maxn];
//num ways to color rest of sequence if colored first i squares, first 2 different colors appeared at index j and k.
//values of j and k will uniquely determine the 3rd color

vector<pair<int,int>> a[maxn];



ll *mem(int a, int b, int c, int d) {
    vector<int> v={b,c,d};
    sort(v.begin(), v.end());

    b = v[0];
    c = v[1];

    return &dp[a][b][c];
}

ll go(int pos, int lr, int lg, int lb) {
    ll *res = mem(pos, lr, lg, lb);
    if (*res != -1) return *res;

    *res = 0;

    vector<int> v = {lr,lg,lb};
    sort(v.begin(), v.end());
    
    for (auto p: a[pos]) {
	if (p.first <= v[0]) {
	    if (p.second != 3) {
		return *res = 0;
	    }
	} else if (p.first <= v[1]) {
	    if (p.second != 2) {
		return *res = 0;
	    }
	} else if (p.first <= v[2]) {
	    if (p.second != 1) {
		return *res = 0;
	    }
	}
    }

    if (pos == n) {
	return *res = 1;
    }

    *res += go(pos+1, pos+1, lg, lb);
    *res %= mod;
    *res += go(pos+1, lr, pos+1, lb);
    *res %= mod;
    *res += go(pos+1, lr, lg, pos+1);
    *res %= mod;
    return *res;
}


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

    memset(dp,-1,sizeof(dp));
    cin>>n>>m;


    for (int i=1; i<=m; i++) {
	int l, r, x; cin>>l>>r>>x;
	a[r].push_back({l,x});
    }


    ll ans = go(0,0,0,0);
    ans %= mod;
    ans += mod;
    ans %= mod;
    out(ans);
  

    return 0;
}


Measured memory_bytes: 221952
#include <iostream>
    #include <string>
    #include <algorithm>
    #include <cassert>
    #include <set>
    #include <vector>
    #include <cmath>
    #include <bitset>
    #include <functional>
    #include <limits>
    #include <map>
    using namespace std;

    typedef long long ll;
    #define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
    #define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

    ll pow(ll a, ll n) { //compute a^n with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a;
            a = a * a;
            n >>= 1;
        }
        return res;
    }

    ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    int main(){
        ll n,m,k,cnt;
        cnt = 0;
        cin >> n >> m >> k;
        ll a[n+1],b[m+1];
        ll suma[n+1]; suma[0] = 0;
        ll sumb[m+1]; sumb[0] = 0;
        ll tmp_sum = 0;
        rep1(i,n){
            cin >> a[i];
            tmp_sum += a[i];
            suma[i] = tmp_sum;
        }
        tmp_sum = 0;
        rep1(i,m){
            cin >> b[i];
            tmp_sum += b[i];
            sumb[i] = tmp_sum;
        }
        int a_idx = n;
        int b_idx = 0;
        ll max_books = -1;
        while(a_idx >=  0){
            ll tmp_books;
            if(suma[a_idx] > k){
                a_idx--;
            }else{
                while(suma[a_idx] + sumb[b_idx] <= k && b_idx <= m) b_idx++;
                b_idx--;
                tmp_books = a_idx + b_idx;
                max_books = max(max_books, tmp_books);
                a_idx--;
            }
        }
        cout << max_books <<endl;
        return 0;
    }

Measured memory_bytes: 9404
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>

std::string IntToString(long long a){
  char x[100];
  sprintf(x,"%lld",a);
  std::string s = x;
  return s;
}
long long StringToInt(std::string a){
  char x[100]; long long res;
  strcpy(x,a.c_str());
  sscanf(x,"%lld",&res);
  return res;
}
inline void printIntVal(long long a) {
  std::cout << "The Value is: "<< IntToString(a) << std::endl;
}
inline void printStringVal(std::string a) {
  std::cout << "The Value of is: "<< a << std::endl;
}
inline std::string GetString(){
  char x[1000005];
  scanf("%s",x);
  std::string s = x;
  return s;
}
inline std::string uppercase(std::string s){
  int n = (int)s.size();
  for(int i = 0; i < n; i++) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
inline std::string lowercase(std::string s){
  int n = (int)s.size();;
  for(int i = 0; i < n; i++) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
inline void OPEN (std::string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}
inline long long CharToInt(char c) {
    return (c - '0');
}

// ---------------------------------------------------------



int main() {

  long long a,b,c;

  scanf("%lld %lld %lld",&a,&b,&c);

  if(c >= a && c <= b) {
    printf("Yes\n");
  }else {
    printf("No\n");
  }

  return 0;
}


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

d=0
a = [0] + a + [0]
for j in range(len(a)-1):
    d += abs(a[j]-a[j+1])

for i in range(1, len(a)-1):
    if a[i-1] <= a[i] <= a[i+1] or a[i-1] >= a[i] >= a[i+1]:
        print(d)
    else:
        print(d - abs(a[i-1]-a[i]) - abs(a[i+1]-a[i]) + abs(a[i-1]-a[i+1]))

Measured memory_bytes: 20564
import java.util.*;
class Main{
  public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int N = stdIn.nextInt();
    int D = stdIn.nextInt();
    int a =D*2+1;
    int ans=N/a;
    if(N%a!=0){
      ans+=1;
    }
    System.out.println(ans);
  }
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int i=0;
  //vector<int> c;
  //int ans=0;
  while(n>0){
    //c.push_back(n%k);
    //cout<<n%k<<endl;
    //ans+=ans*k+n%k;
    n /= k;
    i++;
  }
  cout<<i<<endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

vector<ll> Prime_fac(ll n){
    vector<ll> res;
    for(ll i=2; i*i<=n; i++){
        ll tmp=0;
        while(n%i == 0){
            tmp++;
            n/=i;
        }
        if(tmp) res.push_back(tmp);
    }
    if(n != 1) res.push_back(1);
    return res;
}

int main(){
    ll N; cin >> N;
    vector<ll> val=Prime_fac(N);
    ll res=0;
    for(int i=0; i<(int)val.size(); i++){
        int j=0;
        while(val[i] > j){
            res++;
            j++;
            val[i]-=j;
        }
    }
    cout << res << endl;
    return 0;
}

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

int euclid(int a, int b) {
	int temp;

	if (a < b) { temp = a; a = b; b = temp; }

	if (a % b == 0) return b;
	return euclid(b, a % b);
}

int main() {
	int N;
	cin >> N;
	int A[1000000];
	int B;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	B = A[0];

	for (int i = 1; i < N; i++) {
		B = euclid(B, A[i]);
	}

	cout << B << endl;
}

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

int H,W,N;
int a[201][201];
int A[201][201];


int calc(int h,int w,int H,int W){
  return A[H][W]-A[H][w]-A[h][W]+A[h][w];
}


int solve(int h,int w,int H,int W,int N){
  int res=0,total=calc(h,w,H,W);
  if(N==1)return total;
  
  for(int i=h;i<H;i++){
    for(int divi=1;divi<N;divi++){
      int v=solve(h,w,i,W,divi);
      int k=solve(i,w,H,W,N-divi);
      res=max(res, min(v,k) );
    }
  }
  for(int j=w;j<W;j++){
    for(int divi=1;divi<N;divi++){
      int v=solve(h,w,H,j,divi);
      int k=solve(h,j,H,W,N-divi);
      res=max(res, min(v,k) );
    }
  }
  return res;
}

int compute(){
  if(N!=4)return 0;
  int res=0;
  for(int ah=1;ah+1<H;ah++){
    for(int bh=ah+1;bh<H;bh++){
      for(int aw=1;aw+1<W;aw++){
        for(int bw=aw+1;bw<W;bw++){
          int sum0=calc(0,0,ah,bw);
          int sum1=calc(0,bw,bh,W);
          int sum2=calc(bh,aw,H,W);
          int sum3=calc(ah,0,H,aw);
          res=max(res,min(min(sum0,sum1),min(sum2,sum3)));
          
          sum0=calc(0,0,bh,aw);
          sum1=calc(bh,0,H,bw);
          sum2=calc(ah,bw,H,W);
          sum3=calc(0,aw,ah,W);
          res=max(res,min(min(sum0,sum1),min(sum2,sum3)));
        }
      }
    }
  }
  return res;
}

int main(){
  scanf("%d %d %d",&H,&W,&N);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      scanf("%d",&a[i][j]);
      A[i+1][j+1]=a[i][j]+A[i+1][j]+A[i][j+1]-A[i][j];
    }
  }

  int ans=max(solve(0,0,H,W,N),compute());
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  string sMin;
  sMin="z";
  for(int i=0;i<s.size();i++){
    if(s.substr(i,1) < sMin)sMin=s[i];
  }
  string tMax;
  tMax="a";
  for(int i=0;i<t.size();i++){
    if(t.substr(i,1) > tMax)tMax=t[i];
  }
  if(sMin<tMax)cout<<"Yes"<<endl;
  else if(sMin==tMax&&s<t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

public class HowManyWays
{
    //???????????????????????????????????§?????°??????????????????????????????????????°????????????????????????????????????????????????*???????????????????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        List<string> numPairList = new List<string>();
        string[] numPairBuffer;
        int range;
        int sum;
        int totalPair;
        int count;
        int numPairIndex;
        /*---??£?¨???¨---*/

        /*??\????????????????????? ??±??????????????????*/
        for(count = 0; ; count++)
        {
            numPairList.Add(Console.ReadLine());
            if (numPairList[count] == "0 0")
                break;
        }

        /*???????????????????¨??????????????????°??????*/
        for (numPairIndex = 0; numPairIndex < count; numPairIndex++)
        {
            //?????????
            numPairBuffer = numPairList[numPairIndex].Split(' ');
            range = int.Parse(numPairBuffer[0]);
            sum = int.Parse(numPairBuffer[1]);
            totalPair = 0;

            //???????????????????¨??????????
            for (int smallInteger = 1; smallInteger <= range - 2; smallInteger++)
            {
                for (int middleInteger = (smallInteger + 1);  middleInteger <= range - 1; middleInteger++) 
                {
                    for (int bigInteger = (middleInteger + 1); bigInteger <= range; bigInteger++) 
                    {
                        if (smallInteger + middleInteger + bigInteger == sum)
                            totalPair++;
                    }
                }
            }
            /*??????*/
            Console.WriteLine(totalPair);
        }
    }
}

Measured memory_bytes: 9144
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
    faster

    ll r;
    cin>>r;

    ll a=3*(r*r);

    cout<<a<<endl;




    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[8];
    int count = 0;
    for(int i = 0; i < 8; i++) a[i] = 0;
    for(int i = 0; i < n; i++){
        
        int rate;
        cin >> rate;
        if(rate <= 399){
            a[0]++;
        }
        else if(rate <= 799){
            a[1]++;
        }
        else if(rate <= 1199){
            a[2]++;
        }
        else if(rate <= 1599){
            a[3]++;
        }
        else if(rate <= 1999){
            a[4]++;
        }
        else if(rate <= 2399){
            a[5]++;
        }
        else if(rate <= 2799){
            a[6]++;
        }
        else if(rate <= 3199){
            a[7]++;
        }
        else {
            count++;
        }
    }
    
    int empty = 0;
    int full = 0;
    for(int i = 0; i < 8; i++){
        if(a[i] == 0){
            empty++;
        }
        else {
            full++;
        }
    }

    if(full == 0){
        cout << 1 << " " << full + count << endl;
    }
    else {
        cout << full << " " << full + count << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef priority_queue<P> PQ;

int main(void) {
    ll n, i;
    ll t[1001]={0}, a[1001]={0};
    cin >> n;
    for(i=0; i<n; i++) {
        cin >> t[i] >> a[i];
    }
    ll ta=t[0], ao=a[0];
    for(i=0; i<n; i++) {
        if(ta*a[i]==t[i]*ao);
        else {
            ll k=max(ta/t[i]+(ta%t[i]==0 ? 0 : 1), ao/a[i]+(ao%a[i]==0 ? 0 : 1));
            ta=t[i]*k;
            ao=a[i]*k;
        }
    }
    
    prin(ta+ao)
}


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

int main(){
  int h, w, i, j;
  string s;
  cin >> h >> w;
  for(i=0; i<h; i++){
    for(j=0; j<w; j++){
      cin >> s;
      if(s == "snuke"){
        cout << (char)('A'+j) << (i+1) << "\n";
        return 0;
      }
    }  
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    int a[n];
    rep(i, n) {
        a[i] = -1;  //変更されたかどうかのフラグ
    }
    rep(i, m) {
        int enta, entb;
        cin >> enta >> entb;
        if(a[enta - 1] == -1) {  //変更されていない場合
            a[enta - 1] = entb;
        } else if(a[enta - 1] != entb) {  //変更されているが同じ場合
            cout << -1 << endl;
            return 0;
        }
        if(n != 1 && enta == 1 && entb == 0) {  //一桁ではなく、先頭が0の場合
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i, n) {
        if((a[i] == -1 && i != 0) || (a[i] == -1 && i == 0 && n == 1))  //変更されていなく、1桁目の話ではない　または　1桁目の話だが一桁しかない
            a[i] = 0;
        else if(a[i] == -1 && i == 0)  //変更されていないが1桁目の話である
            a[i] = 1;
        cout << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# ABC 129: A – Airplane
flight_times = [int(s) for s in input().split()]

min_flight_time = 999999999

for i in range(3):
    for j in range(3):
        if i != j:
            min_flight_time = min(min_flight_time, flight_times[i] + flight_times[j])

print(min_flight_time)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <string>
#include <set>
#define MOD 1000000007

using namespace std;

int grid[100][100];
int main() {
	int A, B; cin >> A >> B;
	for (int i = 0; i < 50; i++) for (int j = 0; j < 100; j++) grid[i][j] = 1;
	A -= 1; B -= 1;
	for (int x = 0; x < 50 && A > 0; x += 2) for (int y = 0; y < 100 && A > 0; y += 2,A--) grid[x][y] = 0;
	for (int x = 99; x >=50 && B > 0; x -= 2) for (int y = 0; y < 100 && B > 0; y += 2,B--) grid[x][y] = 1;
	cout << 100 << " " << 100 << endl;
	for (int i = 0; i < 100; i++, cout << endl) for (int j = 0; j < 100; j++) cout << (grid[i][j] == 1 ? '#' : '.');
	cout << endl;
}

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

char find_last_word(std::string A)
{
  char last_word;
  for(int i = 0; A[i] != NULL; i++)
  {
    last_word = A[i];
  }
  
  return last_word;
}

int main()
{
  std::string A, B, C, result = "YES";
  std::cin >> A >> B >> C;
  
  if(find_last_word(A) != B[0])
  {
    result = "NO"; 
  }
  else if(find_last_word(B) != C[0])
  {
    result = "NO";
  }
  
  std::cout << result;
  return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <cstring>
#include <cstdio>

#define maxn 1000005
#define ll long long
ll exgcd(ll a, ll b, ll &x, ll &y){
    if (b == 0) return x = 1,y = 0,a;
    ll d = exgcd(b,a% b,x,y);
    ll xt = x,yt = y;
    x = yt;
    y = xt - (a / b) * yt;
    return d;
}

int main(){
    long long a,b;
    std::cin >> a >> b;
    long long x,y;
    exgcd(a,b,x,y);
    std::cout << x <<" " << y << std::endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	int a[100001]={};
	int mo=1000000007;
	int b[100001]={};
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	for(int i=1;i<=m;++i)
	{
		cin>>b[i];
	}
	int ans[n+1][m+1]={};
	ans[0][0]=1;
	for(int i=0;i<=n;++i)
	{
		ans[i][0]=1;
	}
	for(int i=0;i<=m;++i)
	{
		ans[0][i]=1;
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			ans[i][j]=ans[i-1][j]+ans[i][j-1]-ans[i-1][j-1];
			if(a[i]==b[j])
				ans[i][j]+=ans[i-1][j-1];
			ans[i][j]+=mo*2;
			ans[i][j]%=mo;
		}
	}
	cout<<ans[n][m];
}

Measured memory_bytes: 33152
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int n, x, a[N], b[N];
int main() {
    scanf("%d%d", &n, &x);
    if (x == n) {
        puts("Yes");
        for (int i = 1; i < 2 * n; i++) printf("%d\n", i);
    } else if (x == 1 || x == 2 * n - 1)
        puts("No");
    else {
        puts("Yes");
        for (int i = 1; i < 2 * n; i++) b[i] = 1;
        if (x == 2 * n - 2) {
            a[n] = 2 * n - 1;
            b[2 * n - 1] = 0;
            a[n + 1] = x;
            b[x] = 0;
            a[n + 2] = 1;
            b[1] = 0;
            a[n - 1] = 2;
            b[2] = 0;
        } else {
            a[n] = 1;
            b[1] = 0;
            a[n + 1] = x;
            b[x] = 0;
            a[n + 2] = 2 * n - 1;
            b[2 * n - 1] = 0;
            a[n - 1] = 2 * n - 2;
            b[2 * n - 2] = 0;
        }
        int j = 1;
        for (int i = 1; i < 2 * n; i++) {
            if (!b[i]) continue;
            while (a[j]) j++;
            a[j] = i;
        }
        for (int i = 1; i < 2 * n; i++) printf("%d\n", a[i]);
    }
    return 0;
}


Measured memory_bytes: 3072
"use strict"
const Main = (input) =>{
let xs = input.trim().split(' ').map(v=>parseInt(v,10));
    let a = xs[0];
    let b = xs[1];
    let ans = 1;
  if (b==1){
    console.log(0)
  }else{
    for(let i = 0; (a-1)*i+a < b; i++){
    ans += 1;
    }
    console.log(ans);
    }}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std ;

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0)
		return 1;
	if(e%2)
		return b*power(b*b%m,(e-1)/2,m)%m;
	else
		return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0)
		return 1;
	if(e%2)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int m,n;
	cin>>n>>m;
	if(m==n)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
using namespace std;
vector<pair<int,bool>>a[N];
vector<int>nods;
int c[N], sol[N];
bool v[N], f[N];
void dfs(int i){
    v[i]=f[i]=1;
    nods.push_back(i);
    for(auto it:a[i]){
        if(!v[it.first] && it.second){
            dfs(it.first);
        }
    }
}
int main(){
    int n,m,k,x,y;
    cin>>n>>m>>k;
    for(int i=1; i<=m; ++i){
        cin>>x>>y;
        a[x].push_back({y,1});
        a[y].push_back({x,1});
        c[x]++;
        c[y]++;
    }
    for(int i=1; i<=k; ++i){
        cin>>x>>y;
        a[x].push_back({y,0});
        a[y].push_back({x,0});
    }
    for(int i=1; i<=n; ++i){
        if(!v[i]){
            dfs(i);
            for(auto it:nods){
                for(auto itt:a[it]){
                    if(!itt.second && f[itt.first]){
                        c[it]++;
                    }
                }
                sol[it]=nods.size()-1-c[it];
            }
            for(auto it:nods){
                f[it]=0;
            }
            nods.clear();
        }
    }
    for(int i=1; i<=n; ++i){
        cout<<sol[i]<<" ";
    }
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	long long x, y;
	cin >> x >> y;
	int cnt = 0;
	while(x <= y) {
		x *= 2;
		cnt++;
	}
	cout << cnt << endl;
	return 0;	
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int maxn = 1E5 + 5E4 + 50;
typedef double DB;

int n,son[maxn];
DB f[maxn],g[maxn];

vector <int> v[maxn];

void Dfs1(int x,int from)
{
	DB sum = 0;
	for (int i = 0; i < v[x].size(); i++)
	{
		int to = v[x][i];
		if (to == from) continue;
		Dfs1(to,x); sum += f[to]; ++son[x];
	}
	if (!son[x]) return;
	f[x] = 1.00 + sum / (DB)(son[x]);
}

void Dfs2(int x,int from,DB now)
{
	if (x == 1) g[x] = f[x];
	else if (son[x])
	{
		DB t = son[x] + 1;
		g[x] = f[x] / t * (DB)(son[x]) + (1.00 + now) / t;
	}
	else g[x] = now + 1.00;
	for (int i = 0; i < v[x].size(); i++)
	{
		int to = v[x][i];
		if (to == from) continue; DB Nex = f[x];
		if (x == 1)
		{
			if (son[x] == 1) Nex = 0;
			else
			{
				Nex -= (1.00 + f[to]) / (DB)(son[x]);
				Nex = Nex / (DB)(son[x] - 1) * (DB)(son[x]);
			}
		}
		else
		{
			Nex += (1.00 + now) / (DB)(son[x]);
			Nex -= (1.00 + f[to]) / (DB)(son[x]);
		}
		Dfs2(to,x,Nex);
	}
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		v[x].push_back(y); v[y].push_back(x);
	}
	Dfs1(1,0); Dfs2(1,0,0);
	for (int i = 1; i <= n; i++) printf("%.10lf\n",g[i]);
	return 0;
}

Measured memory_bytes: 19072
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

bool vis[1005][1005];

inline void solve(){
    int  n, k, ans = 0 ; 
    string  s; 
    cin >> n >> k >> s ; 
    for (int i=1,k=1;i<n;i++ ){ 
        ans += (s[i] == s[i-1]);
    } 
    ans += k*2;
    cout << min(ans,n-1) << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}

/*

RRRLLRRR


*/

Measured memory_bytes: 3752
#include<iostream>
#include<cstdio>
#include<cstring>
bool ex[4];
char s[1050];
int n;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='E')ex[0]=1;
		else if(s[i]=='W')ex[1]=1;
		else if(s[i]=='N')ex[2]=1;
		else if(s[i]=='S')ex[3]=1;
	if((ex[0]^ex[1]) || (ex[2]^ex[3]))printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};



int main()
{
    string S;
    ll K;
    cin>>S>>K;
    ll N=S.size();

    REP(i,0,min(N,K)){
        if(S[i]!='1'){
            cout<<S[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;



int main()
{

    int N;
    cin >> N;
    map<string ,int> m;

    REP(i,N) {
        string s;
        cin >> s;
        sort(ALL(s));
        m[s]++;
    }

    ll ans = 0;
    for (auto x : m) {
        ll num = (ll)x.second;
        ans += num*(num-1)/2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11136
#include <iostream>

using namespace std;

int main()
{
    int n, x;
    scanf("%d\n%d", &n, &x);
    int mn = x, mx = -1e9;
    for (int i = 1; i < n; i++)
    {
        scanf("%d", &x);
        mx = max(mx, x - mn);
        mn = min(mn, x);
    }
    printf("%d\n", mx);
    return 0;
}



Measured memory_bytes: 3224
Printf.printf "%d\n" @@ Scanf.scanf "%d %d" @@ fun n p ->
  let m = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0))
    |> Array.fold_left (fun z x -> z + x mod 2) 0 in
  if m < p then 0 else 1 lsl (n - if m = 0 then 0 else 1)

Measured memory_bytes: 384
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int y = sc.nextInt();
      
    int tu = y-2*x;
    int ka = 4*x-y;

    if(tu>=0 && ka>=0 && tu%2==0 && ka%2==0) System.out.println("Yes");
    else System.out.println("No");

  }
}

Measured memory_bytes: 35688
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
 
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
 
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;
 #define mod 998244353
int modval[25];
int arr[10];
signed main() {
 
	
	fastio();
//	#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif	
	//https://www.coursera.org/learn/algorithms-on-strings/home/welcome
	//https://www.coursera.org/lecture/algorithms-on-strings/suffix-array-and-suffix-tree-TV4I6
	
	int n,d;
	cin>>n>>d;
	cout<<n/(2*d+1)+((n-(2*d+1)*(n/(2*d+1)))>0)?1:0;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int h, w;
struct lamp{
    char c;
    short int up, down, left, right;
};
lamp s[2000][2000] = {0};

int main()
{
    int ans = 0, k = 0;
    char t[2000];
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        scanf("%s", t);
        for(int j = 0; j < w; j++){
            s[i][j].c = t[j];
        }
    }

    /* --- 左右を照らす数 --- */
    for(int i = 0; i < h; i++){
        short int kl = 0, kr = 0;
        for(int j = 0; j < w; j++){
            if(s[i][j].c == '#') kr  = 0;
            else                 kr += 1;
            if(s[i][w-1-j].c == '#') kl  = 0;
            else                   kl += 1;
            s[i][j].right = kr;
            s[i][w-1-j].left  = kl;
        }
    }
    /* --- 上下を照らす数 --- */
    for(int j = 0; j < w; j++){
        short int ku = 0, kd = 0;
        for(int i = 0; i < h; i++){
            if(s[i][j].c == '#') kd = 0;
            else                 kd += 1;
            if(s[h-1-i][j].c == '#') ku  = 0;
            else                   ku += 1;
            s[i][j].down = kd;
            s[h-1-i][j].up  = ku;
        }
    }

    /* --- スキャン --- */
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            k = s[i][j].left + s[i][j].right + s[i][j].up + s[i][j].down - 3;
            ans = (ans < k ? k : ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAX = 200000;
const int MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int n,m,ans=1;
signed main(){
    COMinit();
    cin>>n>>m;
    for(int i=2;i<=sqrt(m);i++){
        int num=0;
        while(m%i==0){
            m/=i;
            num++;
        }
        (ans*=COM(num+n-1,num))%=MOD;
    }
    if(m!=1)ans*=COM(n,1);
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
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;}

signed main(){
  int q;
  cin>>q;
  int sumb=0,sumq1=0,sumq2=0;
  priority_queue<int> q1;
  priority_queue<int,vector<int>,greater<int> > q2;
  int k=1000000000;
  rep(i,q){
    int x;
    cin>>x;
    if(x==1){
	 int a,b;
	 cin>>a>>b;
	 a+=k;
	 sumb+=b;
	 if(i==0||a<=q1.top()){
	   q1.push(a);
	   sumq1+=a;
	 }else{
	   q2.push(a);
	   sumq2+=a;
	 }
	 if(sz(q1)>sz(q2)+1){
	   int top=q1.top();
	   q1.pop();
	   q2.push(top);
	   sumq1-=top;
	   sumq2+=top;
	 }
	 if(sz(q1)<sz(q2)){
	   int top=q2.top();
	   q2.pop();
	   q1.push(top);
	   sumq1+=top;
	   sumq2-=top;
	 }
    }else{
	 cout<<q1.top()-k<<" ";
	 cout<<q1.top()*sz(q1)-sumq1+sumq2-q1.top()*sz(q2)+sumb<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3828
N = int(input())
A = list(map(int, input().split()))

def Main(N, A):
    if 0 in A:
        return 0
    ans = 1
    for a in A:
        ans *= a
        if ans > 10**18:
            return -1
    return ans
    
res = Main(N, A)
print(res)

Measured memory_bytes: 21652
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int ans = (B / K) * K;
        System.out.println(A <= ans && ans <= B ? "OK" : "NG");
    }
}

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

int main()
{
    int N;
    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        int x, y, b, p;
        int val;
        int nval;
        cin >> x >> y >> b >> p;
        val = x * b + y * p;
        nval = (max(b, 5) * x + max(p, 2) * y) * 8 / 10;
        if ( val < nval ) {
            cout << val << endl;
        } else {
            cout << nval << endl;
        }
    }
    return ( 0 );
}



Measured memory_bytes: 3116
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var A = G();
		int N = A[0], K = A[1];
		A = G();
		var cnt = new Dictionary<int, int>();
		foreach (var a in A)
		{
			if (!cnt.ContainsKey(a)) cnt[a] = 1;
			else cnt[a]++;
		}
		var k = cnt.Values.ToList();
		k.Sort();
		var c = 0;
		for (var i = 0; i < k.Count - K; i++) c += k[i];
		Console.WriteLine(c);
	}
}


Measured memory_bytes: 38980
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  ll n = s.size();
  ll ans = 0;
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[n-1-i]) ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    int a, b; cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
}


Measured memory_bytes: 256