akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main(){
  int n;
  cin>>n;
  int ans=1;
  rep(i,n){
    int a;
    cin>>a;
    ans=lcm(ans,a);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3096
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in a:
  heapq.heappush(q,-i)
for _ in range(m):
  heapq.heappush(q,-(heapq.heappop(q)//-2))
print(-sum(q))

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b;
    for(int i=0;i<3000;i++){
        cin>>a>>b;
        if(a==0&b==0)break;
        cout<<min(a,b)<<" "<<max(a,b)<<endl;
    }
}



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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ll N, K;
    cin >> N >> K;
    VI V(N);
    REP(i, N) cin >> V[i];
    ll ans = 0;
    // FOR(i, 0, min(N, K)) {
    //     FOR(left, 0, K - i) {
    //         ll sum = 0;
    //         vector<ll> A;
    //         REP(j, left) {
    //             if (j == N) break;
    //             sum += V[j];
    //             A.pb(V[j]);
    //         }
    //         int takeFromR = min({N - left, K - i - left, 0LL});
    //         FORD(j, N - 1, N - takeFromR) {
    //             sum += V[j];
    //             A.pb(V[j]);
    //         }
    //         sort(all(A));
    //         REP(j, i) {
    //             sum -= A[j];
    //         }
    //         ans = max(ans, sum);
    //     }
    // }
    FOR(l, 0, N) {
        FOR(r, 0, N) {
            if (l + r > N) break;
            FOR(i, 0, K) {
                if (l + r + i > K) break;
                if (i > l + r) break;
                vector<ll> A;
                ll sum = 0;
                REP(j, l) {
                    sum += V[j]; 
                    A.pb(V[j]);
                }
                FORD(j, N - 1, N - r) {
                    sum += V[j];
                    A.pb(V[j]);
                }
                sort(all(A));
                REP(j, i) {
                    sum -= A[j];
                }
                ans = max(ans, sum);
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m,c;
cin>>n>>m>>c;
vector<int> vec(m);
for(int i=0;i<m;i++){
  cin>>vec.at(i);
}
int sum=0;
for(int i=0;i<n;i++){
  int sum1=0;
  for(int j=0;j<m;j++){
    int d;
    cin>>d;
    sum1+=d*vec.at(j);
  }
  if(sum1+c>0){
    sum++;
  }

}
cout<<sum<<endl;
}



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

int32_t main() {
	int n, s, val = 1; cin >> n >> s;
	if(n == s) return cout << n+1<<endl, 0;
	for(int i = 2;i*i<=n;i++){
	    int sum = 0;
	    for(int t = n; t; t/=i) sum += t % i;
	    if(sum == s) return cout << i << endl, 0;
	    val = i;
	}
	for(int i = val + 1; i > 0;--i){
	    int r = s - i;
	    if(r < 0) continue;
	    int b = (n - r) / i;
	    if(i >= b || r >= b || i*b + r != n) continue;
	    if(r + i == s) return cout << b << endl, 0;
	}
	cout << -1 << endl;
	return 0;
}


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

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc069_a();
        }

        static void abc069_a()
        {
            // A - K-City
            int[] input = Console.ReadLine().Trim().Split(' ').Select(i => int.Parse(i)).ToArray();
            int n = input[0];
            int m = input[1];
            int ans = (n - 1) * (m - 1);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11348
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll D,p[11],c[11],G,res=999999999,pt,cnt,t[11],f;
  cin >> D >> G;
  REP(i,D)cin >> p[i] >> c[i];
  REP(i,D)t[i] = p[i];
  bool cmp[11];
  REP(i,11)cmp[i] = false;
  for(int i=0;i<pow(2,D);i++){
    pt = 0;
    cnt = 0;
    REP(k,11)cmp[k] = false;
    REP(k,D)t[k] = p[k];
    for(int j=0;j<D;j++){
      if(((i >> j) & 1) == 1){
        pt += c[j];
        pt += (j+1)*100*p[j];
        cnt += p[j];
        cmp[j] = true;
      }
    }
    while(1){
      if(pt >= G){
        f = 0;
        break;
      }
      f = 1;
      for(int i=D-1;i>=0;i--)
        if(cmp[i] == false && t[i] > 0){
          pt += 100*(i+1);
          cnt++;
          t[i]--;
          f = 0;
          break;
        }
      if(f)break;
    }
    if(!f)
      res = min(cnt,res);
  }
  
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 512
#!/usr/bin/python3
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    a = tuple(tuple(e for e in map(int, input().split())) for _ in range(2))
    dp = [[None] * n for _ in range(2)]
    dp[0][0] = dp[1][0] = 0
    for i in range(n):
        dp[0][i] = dp[0][max(0, i - 1)] + a[0][i]
        dp[1][i] = max(dp[0][i], dp[1][max(0, i - 1)]) + a[1][i]
    print(dp[1][n - 1])

if __name__ == '__main__':
    main()


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            const int RANGE = 14;

            int[,] map = new int[RANGE, RANGE];

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int[] temp = Array.ConvertAll(input.Split(','), int.Parse);
                int x = temp[0];
                int y = temp[1];
                int s = temp[2];

                Paint(map, x, y, s);
            }

            int count = 0, max = 0;

            for (int i = 2; i < 12; i++)
            {
                for (int j = 2; j < 12; j++)
                {
                    if (map[i, j] == 0) count++;

                    max = Math.Max(max, map[i, j]);
                }
            }
            Console.WriteLine(count + "\n" + max);
        }

        static void Paint(int[,] map, int x, int y, int size)
        {
            x += 2; y += 2;

            map[y, x]++;

            map[y, x - 1]++; map[y, x + 1]++;
            map[y - 1, x]++; map[y + 1, x]++;

            if (size == 1) return;

            map[y - 1, x - 1]++; map[y - 1, x + 1]++;
            map[y + 1, x - 1]++; map[y + 1, x + 1]++;

            if (size == 2) return;

            map[y, x - 2]++; map[y, x + 2]++;
            map[y - 2, x]++; map[y + 2, x]++;
        }
    }
}

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

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

int main()
{
    long long int n, sum = 0;
    cin >> n;
    vector<int> a(n);

    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    int min = *min_element(ALL(a)), max = *max_element(ALL(a));

    cout << min << " " << max << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3128
MAX = 21
N = int(input())
num = [int(x) for x in input().split()]
table = [[0 for _ in range(MAX)] for _ in range(N - 1)]

table[0][num[0]] = 1

for i in range(1, N-1):
	n = num[i]
	for j in range(MAX):
		if j + n < MAX:
			table[i][j+n] += table[i-1][j]
		if j - n > -1:
			table[i][j-n] += table[i-1][j]

print(table[-1][num[-1]])


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		int[] d = new int[n + 1];
		d[0] = 0;
		int cnt = 1;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			d[i + 1] = d[i] + a[i];
			if (d[i + 1] <= x) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


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

def f(x):
    z=[0]*40
    i=1
    while x>0:
        z[-i]=x%2
        x=x//2
        i+=1
    return z

for i in range(n):
    a[i]=f(a[i])

y=[0]*40
for i in range(40):
    y[i]=sum(a[j][i] for j in range(n))%2
ans=[]
for i in range(n):
    p=0
    for j in range(40):
        if y[-j-1]!=a[i][-j-1]:
            p+=2**j
    ans.append(p)
for i in range(n):
    print(ans[i], end=" ")


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,q,l,r,memo[100000];
string s;
queue<int> ans;

main() {
    cin >> n >> q;
    cin >> s;
    rep1(i,n-1) if (s[i-1] == 'A' && s[i] == 'C') memo[i]++;
    rep1(i,n-1) memo[i] += memo[i-1];
    rep(i,q) {
        int tmp;
        cin >> l >> r;
        l--;r--;
        tmp = memo[r]-memo[l];
        ans.push(tmp);
    }
    rep(i,q) {
        cout << ans.front() << endl;
        ans.pop();
    }
}



Measured memory_bytes: 2560
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

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

int main(){
    ll A[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    ll K;
    cin >> K;
    cout << A[K-1] << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    vector<ll> A(N), total_A(N + 1); total_A.at(0) = 0;
    rep(i, N){cin >> A.at(i); total_A.at(i + 1) += (A.at(i) + total_A.at(i));}
    ll L = total_A.at(N);
    if (L % 2 == 0 && find(total_A.begin(), total_A.end(), L / 2) != total_A.end()){
        cout << 0 << endl;
    } else {
        rep(i, N){
            if (total_A.at(i) < L / 2 && total_A.at(i + 1) > L / 2){
                // cout << total_A.at(i) << " " << total_A.at(i + 1) << " " << L << endl;
                // cout << abs(total_A.at(i) - (L - total_A.at(i))) << endl;
                // cout << abs(total_A.at(i + 1) - (L - total_A.at(i + 1))) << endl;
                cout << min(abs(total_A.at(i) - (L - total_A.at(i))), abs(total_A.at(i + 1) - (L - total_A.at(i + 1)))) << endl;
                exit(0);
            }
        }
    }
}

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


Measured memory_bytes: 6732
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int data[10];

int calc(const char *buff){
  if(*buff == '('){
    buff++;
    int l = calc(buff);
    if(*buff == '('){
      int depth = 1;
      buff++;
      while(depth != 0){
        if(*buff == '(') depth++;
        if(*buff == ')') depth--;
        buff++;
      }
    }else{
      buff++;
    }
    char op = *buff++;
    int r = calc(buff);
    if(op == '|'){
      return l | r;
    }else if(op == '&'){
      return l & r;
    }else{
      return l ^ r;
    }
  }else{
    return data[*buff - '1'];
  }
}

int main(){
  char buff[1000];
  while(fgets(buff,sizeof(buff),stdin),
        strncmp(buff, "END", 3)){
    int n;
    scanf("%d ",&n);
    REP(i,n){
      data[i] = 0;
      REP(j,4){
        int t;
        scanf("%d ",&t);
        if(t == 1) data[i] |= (1<<j);
      }
    }
    int spPos[8];
    int cnt = 0;
    int last = 1;
    for(int i=0; buff[i]; i++){
      if(buff[i] == ' '){
        spPos[cnt++] = i;
        last *= 3;
      }
    }
    const char *ops = "|&^";
    int ans = 0;
    REP(i,last){
      int tmp = i;
      REP(j,cnt){
        char op = ops[tmp%3];
        tmp/=3;
        buff[spPos[j]] = op;
      }
      if(calc(buff) == 15)
        ans++;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}
/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*ここから*/
int main() {
    int X,A;
    cin >> X >> A;
    if(A>X){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N, K;
    cin >> N >> K;
    int h[100010];
    for(int i = 1; i <= N; i++){
        cin >> h[i];
    }
    
    int dp[100010];
    dp[0] = 0;
    dp[1] = abs(h[2] - h[1]);
    
    for(int i = 2; i < N; i++){
        dp[i] = dp[i-1] + abs(h[i + 1] - h[i]);
        for(int j = 2; j <= K; j++){
            if(i >= j){
                dp[i] = min( dp[i], dp[i-j] + abs( h[i + 1] - h[i - (j - 1)] ));
            }
        }
    }

    
    cout << dp[N-1] << endl;
    


}


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

using namespace std;

bool isprime(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int q, l, r;
    cin >> q;

    vector<int> s(100001, 0);

    int sum = 0;
    for (int i = 3; i <= 100000; i++) {
        if (isprime(i) && isprime((i + 1) / 2)) {
            sum++;
        }
        s.at(i) = sum;
    }

    for (int i = 0; i < q; i++) {
        cin >> l >> r;
        cout << s.at(r) - s.at(l - 1) << endl;
    }
}

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

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

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  string s; cin>>s;
  string ans = "TBD";
  if(s <= "2019/04/30") ans = "Heisei";
  cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

a.sort()

cnt = 0
for i in range(1,len(a)):
    if a[i-1] == a[i]:
        cnt += 1

if cnt % 2 == 0:
    print(n - cnt)
else:
    print(n - cnt - 1)


Measured memory_bytes: 14388
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=1000010;
const int INF=1e9;
int dp[N][3];
int b[N],cb,c[N],cc;
int a[N];
char s[N];
int ans;
int n;

int work(int st){
	int i;
	cb=0,cc=0;
	while(st<=n&&a[st]!=0){
		i=st;
		for(;i<=n&&a[i]==1;i++);
		b[++cb]=i-st;
		st=i+1;
	}
	if(cb==0)	return st+1;
/*	c[++cc]=b[1];
	rep(i,2,cb){
		if(b[i]>1&&c[cc]>1){
			c[cc]-=1;
			c[++cc]=1;
			c[++cc]=b[i]-1;
			ans++;
		}
		else	c[++cc]=b[i];
	}*/
	//rep(i,1,cc)	printf("%d ",c[i]);printf("\n");
	rep(i,0,cb)	dp[i][0]=dp[i][1]=dp[i][2]=-INF;
	dp[0][0]=0;
	rep(i,1,cb){
		/*if(c[i]==1){
			dp[i][1]=max(dp[i-1][1],dp[i-1][0]);
			dp[i][0]=max(dp[i][0],dp[i-1][1]+1);
			dp[i][0]=max(dp[i][0],dp[i-1][0]);
		}
		else{
			dp[i][0]=max(dp[i][0],dp[i-1][1]+c[i]);
			dp[i][0]=max(dp[i][0],dp[i-1][0]);
			if(i+1<=cc&&c[i+1]==1){
				dp[i+1][0]=max(dp[i+1][0],dp[i-1][0]+c[i]);
			}
		}*/
		dp[i][0]=max(dp[i-1][1],dp[i-1][0]);
		dp[i][0]=max(dp[i][0],dp[i-1][2]);
		dp[i][0]=max(dp[i][0],dp[i-1][1]+b[i]);
		//dp[i][0]=max(dp[i][0],dp[i-1][1]);
		dp[i][1]=max(dp[i-1][0],dp[i-1][1]);	
		dp[i][1]=max(dp[i][1],dp[i-1][1]+b[i]-1);
		if(b[i]>1)	dp[i][1]=max(dp[i][1],dp[i-1][2]);
		dp[i][2]=max(dp[i][2],dp[i-1][0]+b[i]);
		if(b[i]>1)	dp[i][2]=max(dp[i][2],dp[i-1][2]+b[i]-1);
	}
	ans+=max(dp[cb][0],dp[cb][1]);
	return st+1;
}		
		


int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i;
	scanf("%d",&n);
	scanf("%s",s+1);
	rep(i,1,n)	a[i]=s[i]-'0';
	for(i=1;i<=n;){
		//if(a[i]==0)	continue;
		i=work(i);
	}
	printf("%d\n",ans);
}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

Measured memory_bytes: 9856
#include <iostream>
#include <map>
#include <queue>
using namespace std;





long long n, m, l, l1, l2;

string s, t;



long long gcd(long long a, long long b){
	if(b == 0) return a;
	return gcd(b, a % b);
}


long long lcm(long long a, long long b){
	return (a * b) / gcd(a, b);
}



map<long long, char> mmm;


int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m >> s >> t;
	l = lcm(n, m);


	l1 = l / n, l2 = l / m;
	for(long long i = 0; i < n; ++i){
		mmm[i * l1] = s[i];
	}

	for(long long i = 0; i < m; ++i){
		if(mmm.find(i * l2) != mmm.end() && mmm[i * l2] != t[i]){
			cout << -1 << endl;
			return 0;			
		}
	}

	cout << l << endl;

	return 0;
}

Measured memory_bytes: 6144
import sys
input = sys.stdin.readline
from collections import *

N, K = map(int, input().split())
td = [tuple(map(int, input().split())) for _ in range(N)]
td.sort(key=lambda t: t[1], reverse=True)
d = defaultdict(list)
now = 0

for ti, di in td[:K]:
    d[ti].append(di)
    now += di

rem = []

for k in d.keys():
    d[k].sort(reverse=True)
    
    for i in range(1, len(d[k])):
        rem.append(d[k][i])

add = []
s = set()

for ti, di in td[K:]:
    if ti not in d and ti not in s:
        add.append(di)
        s.add(ti)

rem.sort()
add.sort(reverse=True)
var = len(list(d.keys()))
ans = now+var**2

for i in range(min(len(rem), len(add))):
    now -= rem[i]
    now += add[i]
    ans = max(ans, now+(var+i+1)**2)

print(ans)

Measured memory_bytes: 72028
import sys
def input():
    return sys.stdin.readline()[:-1]
n,k=map(int,input().split())
tmp=0
ans=0
# if k==0:
#     print(n*n)
#     quit()
for i in range(k,n):
    tmp=n//(i+1)
    ans+=(i+1-k)*tmp
    tmp=max(1,k)
    if n%(i+1)-tmp+1>0:
        ans+=n%(i+1)-tmp+1
print(ans)

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
string S;
long long K;
int main() {
    cin >> S;
    cin >> K;

    for(int i = 0; i < K; ++i) {
        if(S.at(i) != '1') {
            cout << S.at(i) << endl;
            return 0;
        }
    }

    cout << 1 << endl;
}

Measured memory_bytes: 256
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            long N = long.Parse(line);
            line = Console.ReadLine();
            string[] strs = line.Split(' ');

            int[] A = new int[N];
            for(int i = 0; i < N-1; i++)
            {
                A[int.Parse(strs[i]) - 1]++;
            }
            for(int i = 0; i < N; i++)
            {
                Console.WriteLine(A[i]);
            }
        }
    }
}


Measured memory_bytes: 42100
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	long long sum = 0;
	vector<long long> a(1000001, 0);
	while (n --)
	{
		long long num;
		cin >> num;
		a[num] ++;
		sum += num;
	}
	int q;
	cin >> q;
	while (q --)
	{
		long long b, c;
		cin >> b >> c;
		sum -= b * a[b];
		long long temp = a[b];
		a[b] = 0;
		sum += c * temp;
		a[c] += temp;
		cout << sum << '\n';
	}
	return 0;
}

Measured memory_bytes: 11180
import numpy as np
n, k, q = map(int, input().split())

A = [k for _ in range(n)]

for i in range(q):
    t = int(input())
    A[t-1] +=1

for i in range(n):
    if A[i]-q > 0:
        print('Yes')
    else :
        print('No')


Measured memory_bytes: 29316
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
const ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

const int MAX_N = 10000000;

int prime[MAX_N];           // i番目の素数
bool is_prime[MAX_N + 1];   // is_prime[i]がtrueならiは素数

// is_primeを構築した後、n以下の素数の数を返す O(n log log n)
int sieve(int n){
    int p = 0;
    for(int i = 0; i <= n; i++){
        is_prime[i] = true;
    }
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j = 2 * i; j <= n; j += i){
                is_prime[j] = false;
            }
        }
    }
    return p;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll x;
  cin >> x;
  sieve(300000);
  for(int i = x; ; i++){
    if(is_prime[i]){
      print(i);
      return 0;
    }
  }
}


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

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

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

int main(){

  string S;
  cin >> S;
  
  if(S=="SUN"){
   cout << "7" << endl; 
  }
  
  else if(S=="MON"){
   cout << "6" << endl; 
  }
  
  else if(S=="TUE"){
    cout << "5" << endl;
  }
  
  else if(S=="WED"){
    cout << "4" << endl;
  }
  
  else if(S=="THU"){
    cout << "3" << endl;
  }
  
  else if(S=="FRI"){
    cout << "2" << endl;
  }
  
  else{
    cout << "1" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int d=0;
    int b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
        d+=b[i];
        b[i]=d/(i+1);
    }
    sort(b,b+a);
    cout<<b[0]<<endl;
}
//私はすだぽんを愛している


Measured memory_bytes: 3116
N, M = map(int,input().split())
X = sorted(list(map(int,input().split())))
if M > 1:
    l = [X[i+1]-X[i] for i in range(M-1)]
else:
    print(0)
    exit()
ll = sorted(l, reverse=True)
z = sum(ll[:N-1])
print(sum(l)-z)

Measured memory_bytes: 13968
// 120_D_Decayed_Bridges.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

typedef pair<int, int> bridge;

class UnionFind
{
	//par[i]：ノードiの親
	//count[i]：iが親の時、iが属するグループのノード数
	vector<int> par; 
	vector<int> count;
public:
	UnionFind(int N)
	{
		par.push_back(0);
		count.push_back(0);

		for (int i = 1; i <= N; i++)
		{
			//最初は全てが根であるとして初期化
			par.push_back(i);
			count.push_back(1);
		}
	}

	//データxが属する木の根を再帰で得る：root(x) = {xの木の根}
	int root(int x)
	{   
		if (par[x] == x) return x;

		//ついでに親を張り替え
		return par[x] = root(par[x]);
	}

	//xとyの木を併合
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		//xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		par[rx] = ry;

		//要素数の変更
		count[ry] += count[rx];
		count[rx] = 0;
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y)
	{ 
		return root(x) == root(y);
	}

	//指定したデータxが属するグループの要素数を返す
	int size(int x)
	{
		return count[root(x)];
	}
};

int main()
{
    //解答方針
	//不便さを直接計算するのは面倒（橋を取り除いても、別ルートから島を行き来できるかもしれない）。
	//変わりに島に対して橋を一つずつ加えていって、行き来できるようになる島の個数（「便利さ」）を計算する。

	int n, m;
	cin >> n >> m;

	//橋を受け取る
	vector<bridge> bridges;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;

		bridges.push_back({ a, b });
	}

	//橋を逆順に処理
	reverse(bridges.begin(), bridges.end());

	vector<ll> usefulness;

	//UnionFind木で島のグループを管理
	auto uf = new UnionFind(n);
	for (auto b : bridges)
	{
		ll tmp = 0;

		//橋の始点と終点が異なるグループに属するときは、
		//1.橋を架けたときの便利さを計算
		//2.グループを併合
		if (!uf->same(b.first, b.second))
		{
			tmp = (ll)uf->size(b.first) * (ll)uf->size(b.second);

			uf->unite(b.first, b.second);
		}

		//橋を追加するたびに追加
		usefulness.push_back(tmp);
	}

	//便利さの累積値を逆順で表示
	reverse(usefulness.begin(), usefulness.end());

	ll accum = 0;
	for (ll u : usefulness)
	{
		accum += u;
		cout << accum << endl;
	}

}


Measured memory_bytes: 4852
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int  numS = scanner.nextInt();//要素数
		int arrayS[] = new int[numS];
		
		for(int i = 0; i < numS; i ++ ){
			arrayS[i] = scanner.nextInt();
		}
		int  numT = scanner.nextInt();//要素数
		int arrayT[] = new int[numT];
		
		for(int i = 0; i < numT; i ++ ){
			arrayT[i] = scanner.nextInt();
		}
		
		LinearSearch(numS,arrayS,numT,arrayT);
		
		scanner.close();
	}
	
	public static void LinearSearch(int numS,int[] arrayS,int numT, int[] arrayT){ 
		int count = 0;
		int match = 0;
		int i;
		
		for(i = 0; i < numT; i ++ ){
			count = 0;
			while( count < numS ){
				if(arrayT[i] == arrayS[count]){
					match ++;
					break;
				}
				count ++;
			}
		}
		
		System.out.println(match);	
	}
}


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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    
    vector<ll> A(N), B(N), C(N);
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];
    
    if(B[N-1]==1 || A[N-1]%B[N-1]==0)
        C[N-1] = 0;
    else
        C[N-1] = B[N-1]-(A[N-1]%B[N-1]);
    
    for(int i=N-2; i>=0; i--){
        A[i] += C[i+1];
        if(B[i]==1 || A[i]%B[i]==0){
            C[i] = C[i+1];
        }
        else {
            C[i] = C[i+1] + B[i]-(A[i]%B[i]);
        }

    }
    
    cout << C[0] << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


bool mat[1005][1005];
bool vis[1005][1005];

ll dr[4] = {0, 0, -1, 1};
ll dc[4] = {1, -1, 0, 0};
    ll H,W;
bool valid(ll r, ll c) {
	return r >= 0 && r < H && c >= 0 && c < W;
}
int main()
{
    fast_cin;
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif


    cin>>H>>W;

    ll sx,sy,dx,dy;
    cin>>sx>>sy;
    cin>>dx>>dy;

    --sx,--sy,--dx,--dy;
    for(ll i=0;i<H;i++){
        for(ll j=0;j<W;j++){
         char c;
         cin>>c;
         mat[i][j]=(c=='.');
        }
    }

    deque<pair<pair<ll,ll>,ll> > q;
    q.push_front(make_pair(make_pair(sx,sy),0));

    ll ind=0;
    while(!q.empty()){
        pair<pair<ll,ll>,ll > p=q.front();
        q.pop_front();

        pair<ll,ll> pos=p.first;

        if(vis[pos.first][pos.second]) continue;
        vis[pos.first][pos.second]=1;
        
        if (pos.first == dx && pos.second == dy) {
			cout << p.second << '\n';
            ind=1;
			break;
		}

        for (ll d = 0; d < 4; d++) {
			ll nr = pos.first + dr[d];
			ll nc = pos.second + dc[d];
			
			if (valid(nr, nc) && mat[nr][nc] && !vis[nr][nc]) {
				q.push_front(make_pair(make_pair(nr, nc), p.second));
			}
		}
        for (ll dr = -2; dr <= 2; dr++) {
			for (ll dc = -2; dc <= 2; dc++) {
				ll nr = pos.first + dr;
				ll nc = pos.second + dc;
				
				if (valid(nr, nc) && mat[nr][nc] && !vis[nr][nc]) {
					q.push_back(make_pair(make_pair(nr, nc), p.second + 1));
				}
			}
		}

    }

    if(!ind)
        cout<<-1<<"\n";

}


Measured memory_bytes: 6988
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

void dfs (int x, const vvi &g, vi &color, vi &comp)
{
    comp.pb(x);
    for (int dest : g[x]) if (color[dest] == -1)
    {
        color[dest] = (color[x] ^ 1);
        dfs(dest, g, color, comp);
    }
}

void solve (int n)
{
    vvi g(n);
    int m;
    cin >> m;
    forn (i, m)
    {
        int u, v;
        cin >> u >> v;
        --u, --v;
        g[u].pb(v);
        g[v].pb(u);
    }

    int cnt1 = 0, cntodd = 0, cntev = 0;
    vi color(n, -1);
    forn (i, n) if (color[i] == -1)
    {
        vi comp;
        color[i] = 0;
        dfs(i, g, color, comp);

        if (sz(comp) == 1)
            cnt1++;
        else
        {
            bool ok = true;
            for (int x : comp) for (int dest : g[x])
                ok &= (color[x] != color[dest]);
            if (ok)
                cntev++;
            else
                cntodd++;
        }
    }

    ll ans = (ll)cnt1 * (ll)cnt1 + 2 * (ll)(n - cnt1) * cnt1;
    ans += 2 * (ll)cntev * (ll)cntev;
    ans += (ll)cntodd * (ll)cntodd + 2 * (ll)cntev * (ll)cntodd;
    cout << ans << endl;
}

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

    int n;
    while (cin >> n)
        solve(n);
}


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

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

  int sum = 0;
  rep(i, N) {
    int begin,end;
    cin >> begin >> end;
    sum += end - begin + 1;
  }
  cout << sum << endl;
}


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

int main() {

  long long int n;
  cin >> n;

  if ( n == 0 || n == 2 ) {
    cout << 1 << endl;
  }else if ( n == 1 ) {
    cout << 2 << endl;
  }else {
    cout << 0 << endl;
  }

  return 0;

}

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

using namespace std;

// 321654987 234567891 13245
// 249999999 250000000 999999998

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	long double a,b,c;
 	long double eps = 1.0E-14;

	cin >> a >> b >> c;
	
	if(sqrt(a) + sqrt(b) + eps < sqrt(c))
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}
 
	return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		string[] a = new string[n];
		string[] b = new string[m];
		for(int i = 0; i < n; i++)
		{
			a[i] = Console.ReadLine();
		}
		for(int i = 0; i < m; i++)
		{
			b[i] = Console.ReadLine();
		}
		for(int i = 0; i < n; i++)
		{
			for(int k = 0; k < n; k++)
			{
				if(i + m - 1 >= n || k + m - 1 >= n)
					continue;
				bool match = true;
				for(int j = 0; j < m; j++)
				{
					for(int l = 0; l < m; l++)
					{
						if(a[i + j][k + l] != b[j][l]) 
						{
							match = false;
							break;
						}
					}
					if(!match) break;
				}
				if(match)
				{
					Console.WriteLine("Yes");
					return;
				}
			}
		}
		Console.WriteLine("No");
	}

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

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


Measured memory_bytes: 13140
using Kujikatsu002.Questions;
using Kujikatsu002.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Kujikatsu002.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/agc034/tasks/agc034_b
    /// </summary>
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine().Replace("BC", "*");

            var aStack = 0;
            long count = 0;

            foreach (var c in s)
            {
                if (c == 'A')
                {
                    aStack++;
                }
                else if (c == '*')
                {
                    count += aStack;
                }
                else
                {
                    aStack = 0;
                }
            }

            yield return count;
        }
    }
}

namespace Kujikatsu002
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Kujikatsu002.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Kujikatsu002.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 14560
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
        int max = 0;
        int count = 0;
        for(int i = 0; i < N; i++){
        	H[i] = sc.nextInt();
        }
      	for(int j = 0; j < N-1; j++){
        	if(H[j] >= H[j+1]){
            	count++;
            }else{
            	if(max < count){
                	max = count;
                }
                count = 0;
            }
          
        }
      	if(max < count){
                max = count;
        }
        System.out.println(max);
	}
 
}

Measured memory_bytes: 49952
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize, b: usize,
    }
    for i in 0..20 {
        let acc = a * i + 1 - i;
        if acc >= b {
            return println!("{}", i);
        }
    }
}


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

using namespace std;

typedef long long int ll;

struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main(){
    int64_t n, d, a;
    cin >> n >> d >> a;
    vector<array<int64_t, 2>> X(n);
    for (int i = 0; i < n; i++){
        cin >> X[i][0] >> X[i][1];
    }
    sort(X.begin(), X.end());
    LazySegmentTree seg(vector<ll>(n, 0));

    for (int i = 0; i < n; i++){
        seg.add(i, i + 1, X[i][1]);
    }

    int64_t ans = 0;
    int64_t r = 0;
    for (int i = 0; i < n; i++){
        if (seg.getsum(i, i + 1) <= 0)
            continue;
        while (r < n and X[r][0] <= X[i][0] + 2 * d)
            r++;
        int64_t m = (seg.getsum(i, i + 1) + a - 1) / a;
        seg.add(i, r, -a * m);
        ans += m;
    }

    cout << ans << endl;
}

Measured memory_bytes: 13184
a=[]
b=[]
while(True):
    x,y = map(int,input().split())
    if(x==0 and y==0):
        break
    a.append(x)
    b.append(y)
poi = True
for qq in range(len(a)):
    for qqq in range(a[qq]):
        for qqqq in range(b[qq]):
            if(poi):
                print("#",end="")
                poi = False
            else:
                print(".",end="")
                poi = True
        if(qqq%2==0):
            poi = False
        else:
            poi = True
        print("")
    poi = True
    print("")


Measured memory_bytes: 7016
import fractions
A,B,C,D=map(int,input().split())

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

BdivC=B//C
BdivD=B//D
BdivCD=B//(lcm(C,D))
AdivC=(A-1)//C
AdivD=(A-1)//D
AdivCD=(A-1)//(lcm(C,D))

ans=B-(A-1)-(BdivC-AdivC+BdivD-AdivD-BdivCD+AdivCD)

print(ans)

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N, A, B; cin >> N >> A >> B;
        vector<int> P(N); cin >> P;
        sort(all(P));
        vector<int> cnt(3);
        for(int p : P) cnt[p <= A ? 0 : p <= B ? 1: 2]++;
        cout << *min_element(all(cnt)) << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


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

int main()
{
  int k;
  scanf("%d",&k);
  vector<long long> a(k);
  for(int i=0;i<k;i++){
    scanf("%lld",&(a[i]));
  }
  long long A=2,B=2;
  bool F=0;
  for(int i=k-1;i>=0;i--){
    long long s=(A+a[i]-1)/a[i],t=B/a[i];
    if(s>t){
      F=1;
      break;
    }
    A=s*a[i];
    B=(t+1)*a[i]-1;
  }
  if(F){
    puts("-1");
  }
  else{
    printf("%lld %lld\n",A,B);
  }
  return 0;
}


Measured memory_bytes: 1024