akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct UnionFind {
	const int V;
	// par[x] := xのroot
	vector<int> par;
	// sz[x] := xを含む集合のサイズ
	vector<int> sz;
	UnionFind(const int V) :
		V(V),
		par(vector<int>(V)),
		sz(vector<int>(V, 1))
		{
			for(int i = 0; i < V; ++i) par[i] = i;
		}
	bool unite(int x, int y) {
		x = root(x), y = root(y);
		if(same(x, y)) return false;
		if(y < x) swap(x, y);
		par[y] = x;
		sz[x] += sz[y];
		return true;
	}
	int root(int x) {
		if(par[x] == x) return x;
		return (par[x] = root(par[x]));
	}
	bool same(int x, int y) {
		return (root(x) == root(y));
	}
	int size(int x) {
		return sz[root(x)];
	}
};

// https://atcoder.jp/contests/abc120/tasks/abc120_d
int main() {
	int64_t n, m; cin >> n >> m;
	UnionFind uf(n);
	int64_t a[m], b[m], ans[m];
	for(int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}
	ans[m - 1] = n * (n - 1) / 2;
	for(int q = m - 2; q >= 0; --q) {
		ans[q] = ans[q + 1];
		if(not uf.same(a[q+1], b[q+1])) ans[q] -= (int64_t)uf.size(a[q + 1]) * (int64_t)uf.size(b[q + 1]);
		uf.unite(a[q + 1], b[q + 1]);
	}
	for(int i = 0; i < m; ++i) cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 4480
n = int(input())
al = list(map(int, input().split()))
al_sum = sum(al)
q = int(input())

num = [0]*100001
for a in al:
    num[a] += 1


for _ in range(q):
    bi, ci = map(int, input().split())

    al_sum += num[bi]*(ci - bi)
    num[ci] += num[bi]
    num[bi] = 0

    print(al_sum)

Measured memory_bytes: 21104
#-*-coding:utf8;-*-
#qpy:console

n=int (input())
l= [ int(x) for x in input().split() ]

dmax=0
for v in l:
   if v > dmax :
      dmax=v

dmin = dmax
for v in l:
   ct=0
   tmp = v
   while tmp%2 == 0:
      tmp /=2
      ct += 1
   if ct < dmin:
      dmin=ct

print(dmin)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B, C := sc.nextInt(), sc.nextInt(), sc.nextInt()

	if A+B+C >= 22 {
		fmt.Fprintln(wtr, "bust")
	} else {
		fmt.Fprintln(wtr, "win")
	}
	wtr.Flush()
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    char arr[n][m];
    for(int i = 0;i <n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            cin >> arr[i][j];
        }
    }
    int dist[n][m];
    queue<pair<int, int> > q;
    for(int i=  0;i <n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            if(arr[i][j] == '#')
            {
                
                q.push(make_pair(i, j));
                dist[i][j] = 0;
            }
            else
            {
                dist[i][j] = INT_MAX;
            }
        }
    }
    while(!q.empty())
    {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        if(x > 0)
        {
            if(dist[x-1][y] > dist[x][y] + 1)
            {
                dist[x-1][y] = dist[x][y] + 1;
                q.push(make_pair(x-1, y));
            }
        }
        if(x < n-1)
        {
            if(dist[x+1][y] > dist[x][y] + 1)
            {
                dist[x+1][y] = dist[x][y] + 1;
                q.push(make_pair(x+1, y));
            }
        }
        if(y > 0)
        {
            if(dist[x][y-1] > dist[x][y] + 1)
            {
                dist[x][y-1] = dist[x][y] + 1;
                q.push(make_pair(x, y-1));
            }
        }
        if(y < m-1)
        {
            if(dist[x][y+1] > dist[x][y] + 1)
            {
                dist[x][y+1] = dist[x][y] + 1;
                q.push(make_pair(x, y + 1));
            }
        }
        
    }
    int sol = 0;
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            sol = max(sol, dist[i][j]);
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 13328
import sys
input = sys.stdin.readline

n = int(input())
color = list(map(lambda x: int(x)-1,input().split()))
out = [0] * n

total = n * ( n + 1)
total //= 2

stacks = [[[0,0]] for i in range(n)]
segs = [[] for i in range(n)]

adj = [[] for i in range(n)]
visited = [False] * n
dfs = []

for _ in range(n - 1):
    a, b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

visited[0] = True
dfs.append(0)
stacks[color[0]].append([1,0])
curr = 1

while dfs:
    node = dfs[-1]
    prev, rem = stacks[color[node]][-1]
    diff = (curr - prev - rem)
    out[color[node]] += (diff * (diff + 1))//2
    stacks[color[node]][-1][1] += (diff) 
    
    if adj[node]:
        nex = adj[node].pop()
        if not visited[nex]:
            visited[nex] = True
            dfs.append(nex)
            curr += 1
            stacks[color[nex]].append([curr,0])
    else:
        dfs.pop()
        prev, rem = stacks[color[node]].pop()
        stacks[color[node]][-1][1] += rem + 1
for i in range(n):
    diff = (curr - stacks[i][0][1])
    out[i] += (diff * (diff + 1))//2
    out[i] = total - out[i]

print('\n'.join(map(str,out)))
        
        


Measured memory_bytes: 189536
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline


def main():
    n = input()
    if n[-1] == "3":
        print("bon")
    elif n[-1] in ["0", "1", "6", "8"]:
        print("pon")
    else:
        print("hon")


if __name__ == '__main__':
    main()

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

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  if ((r * 100 + g * 10 + b) % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (s[k-1] == 'A') s[k-1] = 'a';
    if (s[k-1] == 'B') s[k-1] = 'b';
    if (s[k-1] == 'C') s[k-1] = 'c';
    cout << s << endl;
}

Measured memory_bytes: 256
/**
 * @brief AtCoder Beginner Contest 116<br>
 * C - Grand Garden
 *
 * @see https://atcoder.jp/contests/abc116/tasks/abc116_c
 */
#include <iostream>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int h[N];
  for (int i{}; i < N; ++i)
    scanf("%d", &h[i]);

  int count{};
  int largest;
  do {
    largest = 0;
    bool on{false};
    for (int i{}; i < N; ++i) {
      if (h[i] == 0) {
        if (on) {
          ++count;
        }
        on = false;
      } else {
        on = true;
        --h[i];
        if (largest < h[i]) {
          largest = h[i];
        }
      }
    }
    if (on) {
      ++count;
    }
  } while (largest > 0);

  printf("%d\n", count);
  return 0;
}


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

int n, sumt = 0;
vector<int> t, v;
vector<double> lim;

double solve();

int main() {
  cout << fixed << setprecision(10);
  cin >> n;
  t.assign(n + 2, 0);
  for(int i = 1; i <= n; ++i) cin >> t[i];
  v.assign(n + 2, 0);
  for(int i = 1; i <= n; ++i) cin >> v[i];
  n += 2;
  cout << solve() << endl;
  return 0;
}

double solve() {
  for(int i = 0; i < n; ++i) sumt += t[i] * 2;
  lim.assign(sumt + 1, 1000000);
  int nowt = 0;
  for(int i = 0; i < n; ++i) {
    double nowv = v[i];
    for(int j = 0; j <= nowt; ++j) {
      lim[nowt - j] = min(lim[nowt - j], nowv);
      nowv += 0.5;
    }
    for(int j = nowt; j <= nowt + t[i] * 2; ++j)
      lim[j] = min(lim[j], (double)v[i]);
    nowt += t[i] * 2;
    nowv = v[i];
    for(int j = nowt; j < lim.size(); ++j) {
      lim[j] = min(lim[j], nowv);
      nowv += 0.5;
    }
  }
  double ans = 0;
  for(int i = 1; i < lim.size(); ++i)
    ans += (lim[i] + lim[i - 1]) * 0.25;

  return ans;
}

Measured memory_bytes: 512
nums = list(map(int, input().split()))
if nums[0] < nums[1] and nums[0]+nums[2] == nums[1]:
	print('Yes')
elif nums[0] < nums[2] and nums[0]+nums[1] == nums[2]:
	print('Yes')
elif nums[1] < nums[0] and nums[2]+nums[1] == nums[0]:
	print('Yes')
else:
	print('No')
	

Measured memory_bytes: 3060
# N:駅の数
# Ci:i駅から i+1 駅への移動にかかる時間(cost)
# Si:i駅の最初の発車時間(start)
# Fi:i駅の発車スパン(frequency)
# Si % Fi = 0

N = int(input())
C = [0 for i in range(N)]
S = [0 for i in range(N)]
F = [0 for i in range(N)]
C[0], S[0], F[0] = 0, 0, 0


for i in range(N-1):
    C[i+1], S[i+1], F[i+1] = (int(i) for i in input().split())

for s in range(1, N+1):
    # print("start=", s)
    if s == N:
        t = 0
        pass
    else:
        t = 0
        for i in range(s, N):
            # print("i =", i)
            # print("S[", i, "] =", S[i])
            if t < S[i]:
                t = S[i]
                t += C[i]
            else:
                for j in range(F[i]):
                    if (t + j) % F[i] == 0:
                        t = t + j
                        # print("notta zikan =", t)
                        t += C[i]
                        # print("tuita zikan =", t)
                        break
    print(t)


Measured memory_bytes: 3188
#include <iostream>
#include <assert.h>
#include <vector>

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

    int32_t b1,b2,b3;
    int32_t a2,a3;
    std::vector<int32_t> c(9);
    for(auto& i : c){
        std::cin >> i;
    }
    b1 = c[0];
    b2 = c[1];
    b3 = c[2];
    a2 = c[3] - b1;
    if(a2 + b2 != c[4] || a2 + b3 != c[5]){
        std::cout << "No" << std::endl;
        return 0;
    }
    a3 = c[6] - b1;
    if(a3 + b2 != c[7] || a3 + b3 != c[8]){
        std::cout << "No" << std::endl;
        return 0;
    }

    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <map>
#include <set>

using namespace std;
using ll = long long;

const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    map<map<char, ll>, ll> mp;
    vector<ll> cnt(n, 0);
    for(ll i = 0; i < n; i++)
    {
        string s; cin >> s;
        map<char, ll> tmp;
        for(ll j = 0; j < s.size(); j++)
        {
            tmp[s[j]]++;
        }
        mp[tmp]++;
    }
    ll ans = 0;
    for(auto itr : mp)
    {
        if(itr.second >= 2) ans += itr.second * (itr.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 63104
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e6;
int n,s[N+1],t[N+1];
int hea=1,tai,que[N+1];
int res;
void input(int x[])
{
	static char str[N+2];
	scanf("%s",str+1);
	for(int i=1;i<=n;++i) {
		x[i]=str[i]-'a';
	}
	return;
}
bool check0()
{
	for(int i=1;i<=n;++i) {
		if(s[i]!=t[i]) {
			return false;
		}
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	input(s);
	input(t);
	if(check0()) {
		puts("0");
		return 0;
	}
	for(int spos=n,tpos=n;tpos;--tpos) {
		while((tpos>1)&&(t[tpos-1]==t[tpos])) {
			--tpos;
		}
		while(spos&&((spos>tpos)||(s[spos]!=t[tpos]))) {
			--spos;
		}
		if(!spos) {
			puts("-1");
			return 0;
		}
		while((hea<=tai)&&(que[hea]-(tai-hea+1)+1>tpos)) {
			++hea;
		}
		que[++tai]=spos;
		if(tpos!=1) {
			res=max(res,tai-hea+1);
		}
	}
	++res;
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 14416
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
 

int main()
{
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll ans=0;
    if(p==2||p==5)
    {
        for(int i=0;i<n;i++)
        {
            if((s[i]-48)%p==0)
                ans+=i+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    vector <ll> rem(n+1);
    rem[0]=1;
    for(int i=1;i<=n;i++)
        rem[i]=(rem[i-1]*10)%p;
    map <ll,ll> m;
    ll temp=0;
    m[0]+=1;
    for(int i=0;i<n;i++)
    {
        temp*=10;
        temp+=(s[i]-48);
        temp%=p;
        ll t=(temp*rem[n-i-1])%p;
        m[t]+=1;
    }

    map <ll,ll>::iterator it;
    for(it=m.begin();it!=m.end();it++)
    {
        ll count=it->second;
        if(count>1)
        {
            ans+=((count*(count-1))/2);
        }
    }

    cout<<ans<<endl;




    return 0;   
}
 
 


Measured memory_bytes: 2564
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define ll long long

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

using namespace std;

void init()
{
}

void solve()
{
	int n;
	cin >> n;

	int val = n % 10;

	if (val == 2 || val == 4 || val == 5 || val == 7 || val == 9)
	{
		cout << "hon" << endl;
	}
	if (val == 0 || val == 1 || val == 6 || val == 8)
	{
		cout << "pon" << endl;
	}
	if (val == 3)
	{
		cout << "bon" << endl;
	}
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 3068
#include<stdio.h>
int main(){
	int i;
	int n,a,b;
	int as=0,bs=0;
	while(1){
		as=0;
		bs=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=0;i<n;i++){
			scanf("%d%d",&a,&b);
			if(a>b)as+=a+b;
			else if(a==b){
				as+=a;
				bs+=b;
			}else bs+=a+b;
		}
		printf("%d %d\n",as,bs);
	}
	return 0;
}

Measured memory_bytes: 600
/*
  donttttttt use vector 
  run n = 1 and n = MAXN before submit
  try to AC within one submission
*/
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;
 
template<typename tp> inline void read(tp &x) {
	x = 0; char c = getchar(); int f = 0;
	for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
	for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
	if (f) x = -x;
}

#define int long long

const int N = 555;
const int M = 5e6 + 233;
bool np[M], ban[M]; int p[M / 10], p_cnt;
int n, a[N][N], bad[N][N];

inline void prepare(int n) {
	for (int i = 2; i <= n; i++) {
		if (np[i]) continue;
		p[++p_cnt] = i;
		for (int j = i + i; j <= n; j += i) {
			np[j] = true;
		}
	}
}

inline int lcm(int x, int y) {
	return x / __gcd(x, y) * y;
}

signed main(void) {
	prepare(10000);
	read(n);
	if (n == 2) {
		cout << "4 7\n23 10\n";
		return 0;
	}
	rep (i, n) rep (j, n) bad[i][j] = ~(i + j) & 1;
	int tot = 0;
	rep (len, n + n) if (len % 2 == 0) {
		++tot;
		rep (i, n) rep (j, n)
			if (i + j == len && bad[i][j])
				a[i][j] = p[tot];
	}
	rep (len, n + n) {
		int cnt = 0;
		rep (i, n) rep (j, n)
			if ((n - i + 1 + j) == len && bad[i][j])
				++cnt;
		if (cnt) {
			++tot;
		}
		rep (i, n) rep (j, n)
			if ((n - i + 1 + j) == len && bad[i][j])
				a[i][j] *= p[tot];
	}
	// cerr << p[500] * p[1000] << "\n";
	// rep (i, n) rep (j, n) cout << a[i][j] << " \n"[j == n];
	rep (i, n) rep (j, n) if ((i + j) & 1) {
		a[i][j] = 1;
		auto add = [&](int x, int y) {
			if (x < 1 || x > n || y < 1 || y > n) return ;
			int t = lcm(a[i][j], a[x][y]), base = t;
			a[i][j] = t;
			return ;
		};
		add(i - 1, j);
		add(i + 1, j);
		add(i, j - 1);
		add(i, j + 1);
		++a[i][j];
	}
	rep (i, n) rep (j, n) cout << a[i][j] << " \n"[j == n];
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int N,K; cin >>N >>K;
  string s; cin >>s;
  vector<int> A;
  int buf = 1;
  for (int i=1; i<=N; i++){
    if (i < N && s[i] == s[i-1]) buf++;
    else{
      int coe = s[i-1] == '0' ? -1 : 1;
      A.push_back(coe * buf);
      buf = 1;
    }
  }
  // Aには'0'の数を負の数、'1'の数を正の数として並んでいる
  int n = A.size();
  int i = 0, j = 0; // [i, j)
  int tatsu = 0;
  int sum = 0;
  int res = 0;
  while (j < n){
    if (A[j] > 0){
      sum += A[j]; j++;
    }
    if (A[j] < 0){
      if (tatsu < K){
        tatsu++;
        sum += abs(A[j]); j++;
      }else{
        chmax(res, sum);
        if (A[i] > 0){ sum -= A[i]; i++; }
        sum -= abs(A[i]); i++;
        sum += abs(A[j]); j++;
      }
    }
    if (j == n){
      chmax(res, sum); break;
    }
  }
  cout <<res <<endl;
}

Measured memory_bytes: 1020
while true
    h,w = gets.chomp.split.map(&:to_i)
    
    if h==0 && w==0 then
        break
    end
    
    y_tgl_flg = true
    h.times do
        if y_tgl_flg then
            x_tgl_flg = true
            y_tgl_flg = false
        else
            x_tgl_flg = false
            y_tgl_flg = true
        end
        
        w.times do
            if x_tgl_flg then
                print("#")
                x_tgl_flg = false
            else
                print(".")
                x_tgl_flg = true
            end
        end
        print("\n")
    end
    print("\n")
end

Measured memory_bytes: 8860
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
#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()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

typedef struct{
  short x,y;
  int cost;
  short ch;
}mouse;


mouse t;
short cx,cy,nx,ny,ch,nch,h,w,n;
int cost;

main(){
  scanf("%d%d%d",&h,&w,&n);
  short maxch[h][w];
  char ku[h][w];
  
  rep(i,h)scanf("%s",ku[i]);


  rep(i,h)rep(j,w){
    if(ku[i][j]=='S')cx=i,cy=j;
    maxch[i][j]=-1;
  }

  queue<mouse> Q;

  Q.push((mouse){cx,cy,0,0});
  maxch[cx][cy]=0;

  while(!Q.empty()){
    //cout<<Q.size()<<endl;
    t=Q.front();Q.pop();
    cx=t.x,cy=t.y,cost=t.cost;
    ch=t.ch;

    rep(i,4){
      nx=cx+dx[i],ny=cy+dy[i];
      if(nx<0 || nx>=h || ny<0 || ny>=w)continue;
      if(ku[nx][ny]=='X')continue;
      nch=ch;
      if(ku[nx][ny]<='9' && ku[nx][ny]>='1' && ku[nx][ny]-'0'==t.ch+1){
        nch=ch+1;
      }

      if(maxch[nx][ny]>=nch)continue;
      if(nch==n){
        printf("%d\n",cost+1);
        return 0;
      }
      maxch[nx][ny]=nch;
      Q.push((mouse){nx,ny,cost+1,nch});
    }
  }
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int main()
{
int l,n;
cin>>l>>n;
int arr[n],sum(0);
for(int i=0; i<n; ++i)
{
cin>>arr[i];
sum+=arr[i];
}
if(sum>l)
cout<<-1;
else
cout<<l-sum;
}


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

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

  int number;
  int P[N];

  for (int i = 0; i < N; i++) {
    P[i] = 0;
  }

  string S;

  int sumP=0;
  int sumAC = 0;
  for (int i = 0; i < M; i++) {
    cin >> number;
    number--;
    cin >> S;

    if (P[number] == -1) {
      continue;
    }

    if (S == "AC") {
      sumP += P[number];
      sumAC++;
      P[number] = -1;
    }
    else {
        P[number]++;
    }
  }

  cout << sumAC << " " << sumP;
  return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  if(a % MOD < 0) return MOD + (a % MOD);
  return a % MOD;
}

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


int main(){
  string s; cin >> s;
  s[3] = '8';
  
  cout << s << endl;
  
  
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<vector>
using namespace std;
int n;
vector<int> g[233333];
int dist[2][233333],id;
void dfs(int idx,int par=-1){//树上dfs
    if(par!=-1){
        dist[id][idx]=dist[id][par]+1;
    }
    for(int i=0;i<g[idx].size();i++){
        if(g[idx][i]!=par){
            dfs(g[idx][i],idx);
        }
    }
    return;
}
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    id=0;
    dfs(0);//F距离每个点的距离
    id=1;
    dfs(n-1);//S距离每个点的距离
    int res=0;
    for(int i=0;i<n;i++){
        if(dist[0][i]<=dist[1][i]){//显而易见，比离谁进
            res++;
        }
    }
    if(res>=n/2+1){//F赢了
        puts("Fennec");
    }
    else{//不然就是S赢了
        puts("Snuke");
    }
    return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#define loop(i, N) for (i = 0; i < N; i++)
#define For(N) for (int i = 0; i < N; i++)
using namespace std;
using ll = long long int;
using vi = vector<int>;

void say(string);

int main() {
	string S;
	int K;
	cin >> S;
	int N = S.size();
	for (K = N / 2 + 1; K <= N; K++) {
		string s = S.substr(N - K, 2 * K - N);
		bool flag = false;
		char a = s[0];
		for (char b : s) 
			if (a != b)flag = true;
		if (flag)break;
	}
	say(to_string(K - 1));
	return 0;
}

void say(string s) {
	cout << s << endl;
}

Measured memory_bytes: 512
n=int(input())
s=input()
b=s.count("#")
w=s.count(".")
M=n
noww=0
for i in range(n-1):
    if s[i]==".":
        noww+=1
        if s[i+1]=="#":
            M=min(M,(i-noww+1)+w-noww)

print(min(b,w,M))

Measured memory_bytes: 3500
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        n:usize,c:usize,k:usize,
       mut t:[usize;n],
    }

    t.sort();
    let mut ans = 0i64;
    let mut left = 0usize;
    let mut right = 0usize;
    loop {
        let base = t[left];
        while right < n && right < c + left && base + k >= t[right] {
            right += 1;
        }
        ans += 1;
        if right == n {
            break;
        }
        left = right;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4264
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int N, M;
  cin >> N >> M;
  
  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  ll ans = 0;
  vector<int> kukan(M - 1);
  for (int i = 0; i < M - 1; i++) {
    kukan[i] = abs(vec[i+1] - vec[i]);
    ans += kukan[i];
  }

  sort(kukan.rbegin(), kukan.rend());
  
  for (int i = 0; i < N - 1; i++) {
    ans -= kukan[i];
  }
  cout << max(0LL, ans) << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
bool f[303030];
vector<pii>pat[303030];
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < num - 1; i++)pat[i + 1].push_back(make_pair(i, 0));
	for (int i = 0; i < way; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za--, zb--;
		pat[za].push_back(make_pair(zb, zc));
	}
	priority_queue<pii>que;
	que.push(make_pair(0, 0));
	for (;;)
	{
		if (que.empty())
		{
			printf("-1\n");
			return 0;
		}
		pii z = que.top();
		que.pop();
		int v = z.second;
		if (f[v])continue;
		if (v == num - 1)
		{
			printf("%lld\n", -z.first);
			return 0;
		}
		f[v] = true;
		for (int i = 0; i < pat[v].size(); i++)que.push(make_pair(z.first - pat[v][i].second, pat[v][i].first));
	}
}

Measured memory_bytes: 15096
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,arr[105],b[105],c[105],m,ans;
void f(int x){
    int y,i;
    if(x==n){
        for(i=0;i<m;i++)    c[i]=b[i];
        sort(c,c+m);
        y=(c[m-1]-c[0]);
        x=24-(c[m-1]-c[0]);
        y=y>x?x:y;
        for(i=1;i<m;i++){
            x=c[i]-c[i-1];
            y=y>x?x:y;
            x=24-x;
            y=y>x?x:y;
        }
        ans=ans<y?y:ans;
        return;
    }
    if(x+1<n && arr[x]==arr[x+1]){
        b[m++]=arr[x];
        b[m++]=24-arr[x];
        f(x+2);
        m-=2;
    }else{
        b[m++]=arr[x];
        f(x+1);
        m--;
        b[m++]=24-arr[x];
        f(x+1);
        m--;
    }
}
int main(){
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    arr[n++]=0;
    sort(arr,arr+n);
    if(n>1 && arr[0]==arr[1]){
        printf("0\n");
        return 0;
    }
    for(i=0;i<n-2;i++){
        if(arr[i]==arr[i+1] && arr[i+1]==arr[i+2]){
            printf("0\n");
            return 0;
        }
    }
    f(0);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n], b[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	bool ok = 0;
	for(int i = 0; i + 2 < n; i++) {
		if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]) {
			ok = 1;
			break;
		}
	}
	if(ok) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define lld I64d
using namespace std ;
template < class R > inline void Readin( R &K ) {
	K = 0 ; bool F = false ; char C = getchar() ; while( C < '0' or C > '9' ) { if( C == '-' ) F = true ; C = getchar() ; }
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ; if( F ) K = -K ;
}
const int MaxN = 2000000 + 10 ;
int N ;
char S[MaxN] ;
int Lb[MaxN] , Rw[MaxN] , Minans = 1 << 30 ;
int main() {
	scanf( "%d" , &N ) ;
	scanf( "%s" , S + 1 ) ;
	for(register int i = 0 ; ++i <= N ; Lb[i] = Lb[i-1] + ( S[i] == '#' ) ) ; Lb[N+1] = Lb[N] ;
	for(register int i = N ; i ; Rw[i] = Rw[i+1] + ( S[i] == '.' ) , --i ) ; Rw[0] = Rw[1] ;
	for(register int i = 0 ; i <= N ; ++i ) Minans = min( Minans , Lb[i] + Rw[i+1] ) ;
	return not printf( "%d\n" , Minans ) ;
}

Measured memory_bytes: 7168
#include <iostream>

using namespace std;

int main(){
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  long long x = min(A, min(B, min(C, (min(D, E)))));
  cout << (N + (x-1))/x + 4 << endl;
}


Measured memory_bytes: 256
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

s = readChar()
x = list(s)
a = [0,0]
for i in x:
	if i=="A":
		a[0]+=1
	else:
		a[1]+=1

if max(a)==3:
	print("No")
else:
	print("Yes")

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()
using namespace std;

typedef long long ll;

int main()
{
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<string> s(N);
    bool flagAB = false, flagAC = false, flagBC = false;
    REP(i, N) cin >> s[i];
    string ansS;
    REP(i, N){
        if (s[i] == "AB"){
            if (A == 0 && B == 0) break;
            if (A == 1 && B == 1 && C == 0){
                if (i + 1 < N){
                    if (s[i + 1] == "AC"){
                        A++;B--;
                        ansS.push_back('A');
                        continue;
                    }
                    else if (s[i + 1] == "BC")
                    {
                        A--;
                        B++;
                        ansS.push_back('B');
                        continue;
                    }
                }
            }
            if (A >= B)
            {
                A--;
                B++;
                ansS.push_back('B');

            }
            else
            {
                A++;
                B--;
                ansS.push_back('A');
            }
        }
        else if (s[i] == "AC")
        {
            if (A == 0 && C == 0) 
            {
                break;
            }
            if (A == 1 && B == 0 && C == 1)
            {
                if (i + 1 < N)
                {
                    if (s[i + 1] == "AB")
                    {
                        A++;
                        C--;
                        ansS.push_back('A');
                        continue;
                    }
                    else if (s[i + 1] == "BC")
                    {
                        A--;
                        C++;
                        ansS.push_back('C');
                        continue;
                    }
                }
            }
            if (A >= C){
                A--;C++;
                ansS.push_back('C');
            }
            else{
                A++;C--;
                ansS.push_back('A');
            }
        }
        else if (s[i] == "BC"){
            if (B == 0 && C == 0) break;
            if (A == 0 && B == 1 && C == 1){
                if (i + 1 < N){
                    if (s[i + 1] == "AB"){
                        B++;C--;
                        ansS.push_back('B');
                        continue;
                    }
                    else if (s[i + 1] == "AC"){
                        B--;C++;
                        ansS.push_back('C');
                        continue;
                    }
                }
            }
            if (B >= C){
                B--;C++;
                ansS.push_back('C');
            }
            else{
                B++;C--;
                ansS.push_back('B');
            }
        }
    }
    if (ansS.size() != N){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        REP(i, N) cout << ansS[i] << endl;
    }
    
}

Measured memory_bytes: 6632
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Integer a, b, c, d;
    a = sc.nextInt();
    b = sc.nextInt();
    c = (a+b)/2;
    d = (a+b)%2;
    if(d == 0){
      System.out.println(c);
    }else{
      System.out.println(c + 1);
    }
    
  }
}

Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	string s;
	int x=0;
	stack<int> st;
	while(true){
		cinl(s);
		if(s==".") return 0;
        while(st.size() !=0 ){
        	st.pop();
        }	
        x=0;
        for(int i=0;i<s.size();i++){
        	if(s[i]=='('){
        		st.push(1);
        	}
        	if(s[i]=='['){
        		st.push(2);
        	}
        	if(s[i]==')'){
        		if(st.size()==0){
        			x=1;
        			break;
        		}
        		if(st.top()==1){
        			st.pop();
        		}
        		else{
        			x=1;
        			break;
        		}
        	}
        	if(s[i]==']'){
        		if(st.size()==0){
        			x=1;
        			break;
        		}
        		if(st.top()==2){
        			st.pop();
        		}
        		else{
        			x=1;
        			break;
        		}
        	}
        }
        if(st.size()!=0) x=1;
        if(x==0) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
	}
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int D, G;
int P[11], C[11];
int dp[20][200010];

void solve() {
	cin >> D >> G; G /= 100;
	rep(i, 0, D) {
		cin >> P[i] >> C[i];
		C[i] /= 100;
	}
	rep(i, 0, D + 1) {
		rep(j, 0, 200000 + 1) {
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	rep(i, 0, D) {
		rep(j, 0, G + 1) {
			rep(k, 0, P[i]) {
				MIN(dp[i + 1][min(j + k * (i + 1), G)], dp[i][j] + k);
			}
			MIN(dp[i + 1][min(j + P[i] * (i + 1) + C[i], G)], dp[i][j] + P[i]);
		}
	}
	cout << dp[D][G] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 10496
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        long[] L = new long[N+1];
        for(int i=1;i<N+1;i++){
            L[i] = 1000000001;
        }
        for(int i=0;i<N;i++){
            int bf = 0;
            int bl = N-1;
            long A = int.Parse(Console.ReadLine());
            while(bf != bl){
                int bc = (bf+bl+1)/2;
                if(L[bc] < A){
                    bf = bc;
                }
                else{
                    bl = bc-1;
                }
            }
            L[bf+1] = Math.Min(L[bf+1],A);
        }
        for(int i=N;i>=0;i--){
            if(L[i] != 1000000001){
                sb.Append(i+"\n");
                break;
            }
        }
    }
}

Measured memory_bytes: 10836
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if x==500*i+100*j+50*k:
                ans+=1
print(ans)

Measured memory_bytes: 3060
N, K, C = map(int, input().split())
S = list(input())

R = []
tmp = 0
count = 0
while tmp < N:
    if S[tmp] == 'o':
        R.append(tmp)
        count += 1
        if count == K:
            break
        tmp += C + 1
    else:
        tmp += 1

L = []
tmp = N - 1
count = 0
while tmp >= 0:
    if S[tmp] == 'o':
        L.append(tmp)
        count += 1
        if count == K:
            break
        tmp -= C + 1
    else:
        tmp -= 1

for l, r in zip(R, L[::-1]):
    # print (l, r)
    if l == r:
        print (l + 1)

Measured memory_bytes: 23532
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	int ans=0;
	cin>>n;
	
	vi a(n);
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	}

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

	for(int i=n-1;i>=0;i--){
		if( (n-i)%2 != 0 ) ans+=a[i];
		else ans-=a[i];
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

int main()
{
    string S;
    cin >> S;
    if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;


int main(void) {
  int n;
  string s;
  int cntr = 0,cntb = 0;
  cin >> n;
  cin >> s;
  for(char c : s) {
    if(c == 'R') {
      ++cntr;
    } else {
      ++cntb;
    }
  }
  cout << (cntr > cntb ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vvi a(2,vi(n));
	REP(i,2)REP(j,n) cin>>a[i][j];
	
	REP(i,n-1) a[0][i+1]+=a[0][i];
	for(int i=n-1;i>0;--i) a[1][i-1]+=a[1][i];
	
	int ans=0;
	REP(i,n) ans=max(ans,a[0][i]+a[1][i]);
	
	cout<<ans<<endl;
}


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

int main(){
	int n;
	cin >> n;
	char alphabets[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
	int alphabets_have_least[26];
	for(int i = 0; i < 26; i++){
		alphabets_have_least[i] = 51;
	}
	for(int i = 0; i < n; i++){
		int alphabets_have[26];
		for(int i = 0; i < 26; i++){
			alphabets_have[i] = 0;
		}
		string text;
		cin >> text;
		for(int j = 0; j < text.size(); j++){
			for(int k = 0; k < 26; k++){
				if(text[j] == alphabets[k]){
					alphabets_have[k]++;
					break;
				}
			}
		}
		for(int j = 0; j < 26; j++){
			alphabets_have_least[j] = min(alphabets_have_least[j], alphabets_have[j]);
		}
	}
	for(int i = 0; i < 26; i++){
		if(alphabets_have_least[i] == 51){
			continue;
		}
		for(int j = 0; j < alphabets_have_least[i]; j++){
			cout << alphabets[i];
		}
	}
	cout << endl;
}

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

int main() {
  int x;
  cin >> x;
  if (x == 7 || x == 3 || x == 5)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

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

using namespace std;
int main() {
    long long H,W;
    cin >> H >>W;
    long long result = H * W;
    for(int yi = 0; yi < H; yi++){
        long long A = 0;
        long long B = 0;
        long long C = 0;
        A = yi * W;
        if(W % 2 == 1){
            B = (H - yi) * (W + 1) / 2;
            C = (H - yi) * (W - 1) / 2;
        }else{
            B = (H - yi) * W / 2;
            C = (H - yi) * W / 2;
        }
        long long m = min(A,min(B,C));
        long long M = max(A,max(B,C));
        result = min(result,M-m);
    }

    for(int yi = 0; yi < H; yi++){
        long long A = 0;
        long long B = 0;
        long long C = 0;
        A = yi * W;
        if((H - yi) % 2 == 1){
            B = (H - yi + 1) * W / 2;
            C = (H - yi - 1) * W / 2;
        }else{
            B = (H - yi) * W / 2;
            C = (H - yi) * W / 2;
        }
        long long m = min(A,min(B,C));
        long long M = max(A,max(B,C));
        result = min(result,M-m);
    }


    for(int xi = 0; xi < W; xi++){
        long long A = 0;
        long long B = 0;
        long long C = 0;
        A = xi * H;
        if(H % 2 == 1){
            B = (W - xi) * (H + 1) / 2;
            C = (W - xi) * (H - 1) / 2;
        }else{
            B = (W - xi) * H / 2;
            C = (W - xi) * H / 2;
        }
        long long m = min(A,min(B,C));
        long long M = max(A,max(B,C));
        result = min(result,M-m);
    }

    for(int xi = 0; xi < W; xi++){
        long long A = 0;
        long long B = 0;
        long long C = 0;
        A = xi * H;
        if((W - xi) % 2 == 1){
            B = (W - xi + 1) * H / 2;
            C = (W - xi - 1) * H / 2;
        }else{
            B = (W - xi) * H / 2;
            C = (W - xi) * H / 2;
        }
        long long m = min(A,min(B,C));
        long long M = max(A,max(B,C));
        result = min(result,M-m);
    }

    cout << result << endl;
}

Measured memory_bytes: 256