akhauriyash/Code-Regression huggingface dataset:
#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cout << "\n\nTime elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
}
#else
#define endl '\n'
#define trace(...)
#define start_routine()
#define end_routine()
#endif

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }
const ll maxn = 200005;
ll n;
ll a[maxn];
ll height[maxn];
ll b[maxn];
set<ll> curr;

int main()
{ 
    start_routine();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        cin>>n;
        rep(i,n) cin>>height[i];
        rep(i,n) cin>>a[i];
        rep(i,n){
            curr.insert(height[i]);
            auto x = curr.lower_bound(height[i]);
            ll val;
            if(x == curr.begin()){
                val = a[i];
                x++;
            }
            else{
                x--;
                val = a[i] + b[(*x)];
                x++;
                x++;
            }
            b[height[i]] = val;
            while(x!=curr.end() && b[*x] <= val) {
                auto temp = x;
                x++;
                curr.erase(*temp);
            }
        }
        auto ans = curr.end();
        ans--;
        cout<<b[(*ans)];
    }
    end_routine();
}

Measured memory_bytes: 14336
#include <stdio.h>

int main(){
    int a,b,c,temp,i,j = 0;
    int array[3] = {0,0,0};
    scanf("%d %d %d",&a,&b,&c);
    array[0] = a;
    array[1] = b;
    array[2] = c;
    for(i = 0; i < 2; i++){
        for(j = 2; j > 0; j--){
            if(array[i] > array[j]){
                temp = array[j];
                array[j] = array[i];
                array[i] = temp;
            }
        }
    }
    printf("%d %d %d\n",array[0],array[1],array[2] );
    return 0;
}

Measured memory_bytes: 596
int main()
{
    int j,i,n,m,s,a[3];
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        m=0;
        for (j=0;j<3;j++)
        {
            scanf("%d",&a[j]);
            if (m<a[j])
                m=a[j];
        }
        s=a[0]*a[0]+a[1]*a[1]+a[2]*a[2];
        if (s==2*m*m)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a-b>0 && (4*a*b<(c-a-b)*(c-a-b)) )
    cout<<"Yes";
  else 
    cout<<"No";
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    int n, m, q;
    while (cin >> n >> m >> q, n || m || q)
    {
        string s, b;
        vector<char> state(n, '0');
        // check[i][j] := i 番目の switch と j 番目の buld が接続されているかも
        vector<vector<int>> check(n, vector<int>(m, 1));
        for (int k = 1; k <= q; k++)
        {
            cin >> s >> b;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == '1')
                {
                    if (state[i] == '0')
                        state[i] = '1';
                    else
                        state[i] = '0';
                }
                for (int j = 0; j < m; j++)
                {
                    if (state[i] != b[j])
                        check[i][j] = 0;
                }
            }
        }
        for (int j = 0; j < m; j++)
        {
            int res = -1;
            bool hatena = false;
            for (int i = 0; i < n; i++)
            {
                if (check[i][j] == 0)
                    continue;
                if (res != -1)
                    hatena = true;
                else
                    res = i;
            }
            if (hatena)
                cout << "?";
            else if (res <= 9)
                cout << res;
            else
            {
                cout << char('A' + (res - 10));
            }
        }
        cout << endl;
    }
}



Measured memory_bytes: 3260
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():
        H, W = map(int, input().split())
        if H % 3 == 0 or W % 3 == 0:
            return 0
        else:
            ans = 10**18

            for h in range(H):
                A = h*W
                B = ((H-h)//2)*W
                C = (H-h-(H-h)//2)*W
                ans = min(max(A, B, C) -
                          min(A, B, C), ans)

                B = (W//2)*(H-h)
                C = (W-(W//2))*(H-h)
                ans = min(max(A, B, C) -
                          min(A, B, C), ans)

            for w in range(W):
                A = w*H
                B = ((W-w)//2)*H
                C = (W-w-(W-w)//2)*H
                ans = min(max(A, B, C) -
                          min(A, B, C), ans)

                B = (H//2)*(W-w)
                C = (H-(H//2))*(W-w)
                ans = min(max(A, B, C) -
                          min(A, B, C), ans)
            return ans
    print(main())


resolve()

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            if(s[j] != t[j-i]) break;
            if(j == n-1){
                cout << i+n;
                return 0;
            }
        }
    }
    cout << 2*n;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
int D[110]={0};
void bfs(int src,int n,int g[110][110]){
queue<int> Q;
Q.push(src);
D[src]=0;
while (! Q.empty()){
    int cur =Q.front();
    Q.pop();
    for(int r=0;r<n;r++){
        if (g[cur][r]==1&&D[r]==0){
            D[r]=D[cur]+1;
            Q.push(r);
        }
    }
}
}
int main() {
int n,g[110][110]={0};
cin>>n;
int j,num,t;
for(int k=0;k<n;k++){
cin>>j>>num;
for(int kk=0;kk<num;kk++){
    cin>>t;
    g[k][t-1]=1;
}
}
bfs(0,n,g);

for(int a=0;a<n;a++){
    if (D[a]==0){
        D[a]=-1;
}
    D[0]=0;
    cout<<a+1<<" "<<D[a]<<endl;
}
    return 0;
}

Measured memory_bytes: 1252
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    h,w=list(map(int,input().split()))
    while (h,w)!=(0,0):
        top = "#" * w
        mid="#"+"."*(w-2)+"#"
        print(top)
        for _ in range(h-2):
            print(mid)
        print(top)
        print()
        h,w=list(map(int,input().split()))

main()



Measured memory_bytes: 5624
import math
def get_div_list(num):
    if num == 1:
        return [1]
    else:
        div_list = []
        div_list.append(1)
        div_list.append(num)
        for i in range(2, math.floor(math.sqrt(num))+ 1):
            if num % i == 0:
                div_list.append(i)
                div_list.append(num // i)
        list(set(div_list))
        div_list.sort(reverse = True)
        return div_list

n, m = [int(i) for i in input().split()]
d_list = get_div_list(m)

for i in d_list:
    if (n-1)*i < m:
        if (m - (n-1)*i) % i == 0:
            print(i)
            break


Measured memory_bytes: 3064
require 'prime'
n = STDIN.gets.to_i
divisors = [1]
primes = []
n.prime_division.each do |prime|
  prime[1].times { primes << prime[0] }
end

1.upto(primes.size) do |i|
  primes.combination(i) do |prime|
    divisors << prime.reduce(:*)
  end
end

divisors = divisors.uniq.sort
min = n.to_s.size
divisors.uniq.sort.each do |num|
  o = n / num
  m = [o.to_s.size, num.to_s.size].max
  if m < min
    min = m
  end
end
puts min


Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	ll n, m, x;
	ll ans = 0;
	cin>>n>>m;
	priority_queue <int> pq; 
	REP(i,n)
	{
		cin>>x;
		pq.push(x);
	}
	while(m>0)
	{
		x = pq.top();
		pq.pop();
		x/=2;
		pq.push(x);
		m--;	
	}
	while(!pq.empty())
	{
		ans+=pq.top();
		pq.pop();
	}
//	cout<<m<<" isleft\n";
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3844
from collections import deque


H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]


di = (1, 0, -1, 0)
dj = (0, 1, 0, -1)

def is_valid(i, j, d):
    ni = i + di[d]
    nj = j + dj[d]
    if not (0 <= ni < H and 0 <= nj < W):
        return False
    if S[i][j] == S[ni][nj]:
        return False
    return True


result = 0
visited = [[False] * W for _ in range(H)]
for i in range(H):
    for j in range(W):

        if visited[i][j]:
            continue
        visited[i][j] = True

        b = 0
        w = 0
        que = deque()
        que.append((i, j))
        while que:
            (ci, cj) = que.pop()
            if S[ci][cj] == '#':
                b += 1
            else:
                w += 1

            for d in range(4):
                if not is_valid(ci, cj, d):
                    continue
                ni = ci + di[d]
                nj = cj + dj[d]
                if visited[ni][nj]:
                    continue
                visited[ni][nj] = True
                que.append((ni, nj))

        result += b * w


print(result)



Measured memory_bytes: 12380
#include <stdio.h>

int main()
{
	int a,b,c;
	int d;
	scanf("%d %d %d",&a,&b,&c);//入力
	
	if(b<a)
	{
	d=a;
	a=b;
	b=d;
	}
	if(b>c)
	{
	d=b;
	b=c;
	c=d;
	}
	if(b<a)
	{
	d=a;
	a=b;
	b=d;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}


Measured memory_bytes: 2112
linha = input()
linha = linha.split()
menor = 101
segundoMenor = 101
for x in linha:
    if int(x) < menor:
        menor = int(x)
for x in linha:
    if int(x) <= segundoMenor and int(x) != menor:
        segundoMenor = int(x)
if linha[0] == linha[1] and linha[0] == linha[2]:
    print(int(linha[0]) + int(linha[1]))
else:
    print(menor + segundoMenor)


Measured memory_bytes: 3060
A=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
N=int(input())
S=list(input())
lenS=len(S)
for i in range(lenS):
    for j in range(len(A)):    
        if S[i]==A[j]:
            if j+N >=25:
                k=j-25+(N-1)
            else:
                k=j+N
    S[i]=A[k]
print(''.join(S))

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

int main(){
    int H,A;
    cin >> H >> A;
    int n = H/A;
    // cout << n << endl;
    if(H%A==0){
        cout << n << endl;
    }
    else{
        cout << n+1 << endl;
    }
    // for(int i=0;i<N;i++){
    //     cin >> p.at(i);
    // }
    // int max = 0;
    // int tmp;
    // int score;
    // for(int j=1;j<N;j++){
    //     tmp = 
    // }
}


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

int main(){
    long long n;
    cin >> n;
    long long sum = 0;
    int y = n;
    while (y > 0){
        sum += y % 10;
        y /= 10;
    }

    cout << (n % sum == 0 ? "Yes" : "No") << endl;
    
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
front = A[0]
back = sum(A)-A[0]
ans = abs(front-back)
for i in range(1,N-1):
    front += A[i]
    back -= A[i]
    ans = min(ans,abs(front-back))
print(ans)

Measured memory_bytes: 24832
while True:
    n=int(input())
    if n==0:
        break
    a=(1000-n)//500
    b=(1000-n-(500*a))//100
    c=(1000-n-(500*a)-(100*b))//50
    d=(1000-n-(500*a)-(100*b)-(50*c))//10
    e=(1000-n-(500*a)-(100*b)-(50*c)-(10*d))//5
    f=(1000-n-(500*a)-(100*b)-(50*c)-(10*d)-(5*e))//1
    print(a+b+c+d+e+f)


Measured memory_bytes: 5584
#include<stdio.h>
int main(void){
int A,B,C,D;
scanf("%d %d %d %d",&A,&B,&C,&D);

if(A<=C){
  if(D>=B&&B>C){
    printf("%d\n",B-C);
  }
  else if(B>=D){
    printf("%d\n",D-C);
  }
  else{
      printf("0\n");
  }
}

else{
  if(B<=D){
    printf("%d",B-A);
  }
  else if(B>=D&&A<D){
    printf("%d",D-A);
  }
  else{
      printf("0\n");
  }
}

return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetInput_long()[0];
            var input = GetInput_string()[0];
            int rcount = 0;
            for(int i = 0; i < N; i++)
            {
                if (input[i] == 'R') rcount++;
            }

            int kcount_lessr = 0;
            for(int i = 0; i < rcount; i++)
            {
                if (input[i] == 'W') kcount_lessr++;
            }
            Console.WriteLine(kcount_lessr);
        }

        #region input


        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
        
    }
}

Measured memory_bytes: 28276
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
class E { static void Main() { new J(); } }
class J
{
	int F() { return int.Parse(Console.ReadLine()); }
	int[] G() { return Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); }
	List<int>[] es;
	int[] d;
	public J()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		var N = F();
		es = new List<int>[N];
		for (var i = 0; i < N; i++) es[i] = new List<int>();
		for (var i = 1; i < N; i++) es[F() - 1].Add(i);
		d = new int[N];
		for (var i = 0; i < N; i++) d[i] = -1;
		Console.WriteLine(Calc(0));
		Console.Out.Flush();
	}
	int Calc(int u)
	{
		if (d[u] < 0)
		{
			d[u] = 0;
			var z = new int[es[u].Count];
			for (var i = 0; i < z.Length; i++) z[i] = -Calc(es[u][i]);
			Array.Sort(z);
			for (var i = 0; i < z.Length; i++) d[u] = Math.Max(d[u], -z[i] + i + 1);
		}
		return d[u];
	}
}

Measured memory_bytes: 21640
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        long n = sc.nextLong();
        long m = sc.nextLong();
        long k = sc.nextLong();
        long cn = n;
        n = Math.max(n-k, 0);
        if(n==0) {
            System.err.println(m-Math.abs(k-cn));
            m = Math.max(m-Math.abs(k-cn),0);
        }
        System.out.println(n+" "+m);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21460
#include <math.h>
#include <stdio.h>
int main(void){
    int n,i;
    int s[1001]={0};
    double ave,sum;
    double var,dev;
    
    do{
        sum=var=dev=0;
        scanf("%d",&n);
        if(n==0)break;
        
        for(i=1; i<=n; i++){
            scanf("%d",&s[i]);
            sum+=s[i];
        }
        
        ave=sum/n;
        
        for(i=1; i<=n; i++){
            var+=(double)(s[i]-ave)*(s[i]-ave)/n;
        }
        
        dev=sqrt(var);
        printf("%lf\n",dev);
        
    }while(1);
    
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	lli ans = 0;
	int pre=0;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		if(pre && a>0){
			a--;
			ans++;
		}
		ans+=a/2;
		pre=a%2;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>

using namespace std;

int main(){

	double r;
  	cin >> r;
  
  	double area = r*r*3.1415926535892;
  	double circle = 2*r*3.141592653589;
  
  	cout << fixed << setprecision(6) << area << " ";
   	cout << fixed << setprecision(6) << circle << endl;

  
    return 0;
}


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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 200001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

string maze[500];
string red[500];
string blue[500];

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_input.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; ++i) {
        cin >> maze[i - 1];
    }
    for (int i = 0; i < h; ++i) {
        red[i] = string(w, '.');
        red[i][0] = '#';
        if (i & 1) {
            red[i] = string(w, '#');
            red[i].back() = '.';
        }
    }
    for (int i = 0; i < h; ++i) {
        blue[i] = red[i];
        for (int j = 0; j < w; ++j) {
            blue[i][j] = '#' + '.' - red[i][j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (maze[i][j] == '#') {
                red[i][j] = '#';
                blue[i][j] = '#';
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        cout << red[i] << "\n";
    }
    cout << "\n";
    for (int i = 0; i < h; ++i) {
        cout << blue[i] << "\n";
    }
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int ans;
string t ,s ;
int main()
{

        cin >>s >>t;
        for (int i = 0 ; i< s.size() ; i++)
        {
            if (s[i] == t[i])ans++;
        }
        cout <<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n;
	int i,temp;
	char a[10];
	int men[6]={1,3,6,4,2,5};
	int sum;
	
	scanf("%d",&n);
	while(n!=0){
		sum=1;
		for(i=0;i<n;i++){
			scanf("%s",a);
			if(strcmp(a,"North")==0){
				temp=men[0];
				men[0]=men[4];
				men[4]=men[2];
				men[2]=men[5];
				men[5]=temp;
				sum=sum+men[0];
			}
			else if(strcmp(a,"East")==0){
				temp=men[0];
				men[0]=men[3];
				men[3]=men[2];
				men[2]=men[1];
				men[1]=temp;
				sum=sum+men[0];
			}
			else if(strcmp(a,"West")==0){
				temp=men[0];
				men[0]=men[1];
				men[1]=men[2];
				men[2]=men[3];
				men[3]=temp;
				sum=sum+men[0];
			}
			else if(strcmp(a,"South")==0){
				temp=men[0];
				men[0]=men[5];
				men[5]=men[2];
				men[2]=men[4];
				men[4]=temp;
				sum=sum+men[0];
			}
			else if(strcmp(a,"Right")==0){
				temp=men[1];
				men[1]=men[5];
				men[5]=men[3];
				men[3]=men[4];
				men[4]=temp;
				sum=sum+men[0];
			}
			else if(strcmp(a,"Left")==0){
				temp=men[1];
				men[1]=men[4];
				men[4]=men[3];
				men[3]=men[5];
				men[5]=temp;
				sum=sum+men[0];
			}
		}
		men[0]=1;
		men[1]=3;
 		men[2]=6;
		men[3]=4;
		men[4]=2;
		men[5]=5;
		printf("%d\n",sum);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1032
# AOJ 1067 Cutting a Chocolate
# Python3 2018.7.10 bal4u

from bisect import bisect_left

while True:
	n, m, w, h, S = map(int, input().split())
	if n == 0: break
	m, wh2 = m+1, 2*(w*h)
	S = wh2-2*S
	tbl, s = [[0,0,0,0]], [0]
	for i in range(1, m):
		l, r = map(int, input().split())
		tbl.append([l, r, 0, r-l])
		s.append((l+r)*w)
	p = []
	for i in range(n):
		x, y = map(float, input().split())
		p.append((x, y))
	p.sort(key=lambda x:(x[1],x[0]))
	j = 1
	for i in range(n):
		x, y = p[i]
		while True:
			y1 = tbl[j-1][3]*x/w + tbl[j-1][0]
			y2 = tbl[j  ][3]*x/w + tbl[j  ][0]
			if y1 < y:
				if y < y2: break
				j += 1
			else: j -= 1
		tbl[j][2] += 1
	for i in range(1, m): tbl[i][2] += tbl[i-1][2]
	if S == 0:
		print(n)
		continue
	elif S == wh2:
		print(0)
		continue
	j = bisect_left(s, S, 0, m)
	if s[j] != S: j -= 1
	ans, i = tbl[j][2], 1
	while j+1 < m:
		j += 1
		while s[j]-s[i] > S: i += 1
		ans = max(ans, tbl[j][2]-tbl[i][2])
	print(n - ans)


Measured memory_bytes: 19696
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>  
#define endl "\n"
using namespace std;
	typedef long long ll;
	const int maxn=100050;
	const int inf=0x3f3f3f3f;
	int dp[maxn];
	int a[105];
	int n,m;
	
	int main(){
		IOS
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>a[i];
		sort(a+1,a+1+n);
		for(int i=1;i<=m;i++){
			bool b=0;
			for(int j=1;j<=n;j++){
				if(i-a[j]>=0&&dp[i-a[j]]==0){
					b=1;
					dp[i]=1;
					break;
				}
			}
			if(!b)
				dp[i]=0;
		}
		map<int,string>mp;
		mp[1]="First";
		mp[0]="Second";
		cout<<mp[dp[m]];
		return 0;
	}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e5+100;
char ch[maxn];
int n,arr[27][maxn];
int lowbit(int n)
{
	return n&-n;
}
void update(int p,int t,int a[])
{
	for(int i=p;i<=n;i+=lowbit(i))
		a[i]+=t;
}
ll getsum(int p,int a[])
{
	ll ans=0;
	for(int i=p;i>0;i-=lowbit(i))
		ans+=a[i];
	return ans;
}
int main()
{
	int m;
	cin>>n;
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)
		update(i,1,arr[ch[i]-'a']);
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		int t;
		cin>>t;
		if(t==1)
		{
			char c;
			int p;
			cin>>p>>c;
			update(p,-1,arr[ch[p]-'a']);
			ch[p]=c;
			update(p,1,arr[c-'a']);
		}
		if(t==2)
		{
			ll sum=0,x,y;
			cin>>x>>y;
			for(int i=0;i<26;i++)
				sum+=getsum(y,arr[i])-getsum(x-1,arr[i])>0;
			cout<<sum<<endl;
		}
	}
    return 0;
} 


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

int main()
{
    int k;
    cin >> k;
    vector<long long> a(k);
    a.at(0) = 7 % k;
    for (int i = 1; i < k; i++)
    {
        a.at(i) = (a.at(i - 1) * 10 + 7) % k;
    }

    int s = -1;
    for (int i = 0; i < k; i++)
    {
        if (a.at(i) == 0)
        {
            s = i + 1;
            break;
        }
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 11120
#include <stdio.h>

int main() {
    long x;

    long A, B;
    scanf("%ld %ld", &A, &B);

    long i = 1, j = 1;
    while (1) {
        while (B * j <= A * i) {
            if (A * i == B * j) {
                x = A * i;
                goto OUT;
            }
            j++;
        }
        i++;
    }
    OUT:

    printf("%ld\n", x);
    return 0;
}

Measured memory_bytes: 128
s=' '+input()+' '
for _ in range(int(input())):
    l=input().split()
    o=l[0]
    a=int(l[1])+1; b=int(l[2])+2
    if o=='print': print(s[a:b])
    if o=='reverse': s=s[:a]+s[b-1:a-1:-1]+s[b:]
    if o=='replace': s=s[:a]+l[3]+s[b:]

Measured memory_bytes: 7728
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    const ll V = 100000;
    ll N, W; cin >> N >> W;
    vl w(N), v(N); REP(i, N) cin >> w[i] >> v[i];
    vvl dp(N+1, vl(V+1, 2*INF));
    dp[0][0] = 0;
    REP(i, N)
    {
        REP(j, V+1)
        {
            if(j >= v[i]) chmin(dp[i+1][j], dp[i][j-v[i]]+w[i]);
            chmin(dp[i+1][j], dp[i][j]);
        }
    }
    ll ans = 0;
    REP(i, V+1) if(dp[N][i] <= W) ans = i;
    cout << ans << endl;
}

Measured memory_bytes: 80384
#include<cstdio>
int main()
{
	long long n,m,ans=0;
	scanf("%lld%lld",&n,&m);
	ans=m-n*2;
	if(ans<0)
	{
		printf("%lld\n",m/2);
	} 
	else
	printf("%lld\n",n+ans/4);
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int inf = 1e5;

int n, m;
int c[20];
int dp[21][50001];

int main(){
	scanf("%d%d", &n, &m);
	rep(i, m){
		scanf("%d", &c[i]);
	}
	dp[0][0] = 0;
	fill_n(dp[0] + 1, n, inf);
	for(int i = 1; i <= m; ++i){
		rep(j, n + 1){
			dp[i][j] = dp[i - 1][j];
			if(j >= c[i - 1]){
				dp[i][j] = min(dp[i][j - c[i - 1]] + 1, dp[i][j]);
			}
		}
	}
	printf("%d\n", dp[m][n]);
	return 0;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {return(b?gcd(b,a%b):a);}

int main() {
    int n; cin >> n;
    if (n == 3) {cout << 2 << " " << 5 << " " << 63 << endl; return 0;}
    if (n == 4) {cout << 2 << " " << 5 << " " << 20 << " " << 63 << endl; return 0;}
    if (n == 5) {cout << 2 << " " << 5 << " " << 20 << " " << 30 << " " << 63 << endl; return 0;}
    int sum = 0;
    vint ans;
    for (int i = 2; i <= 30000; i++) {
        if (n == 0) break;
        if (i % 2 != 0 && i % 3 != 0) continue;
        ans.push_back(i);
        sum += i;
        n--;
    }
    int rem = sum % 6;
    if (rem == 2) {
        rep(i,ans.size()) {
            if (ans[i] == 8) {ans.erase(ans.begin()+i); break;}
        }
        int x = ans.back() + 6 - (ans.back()%6);
        ans.push_back(x);
    }
    if (rem == 3) {
        rep(i,ans.size()) {
            if (ans[i] == 9) {ans.erase(ans.begin()+i); break;}
        }
        int x = ans.back() + 6 - (ans.back()%6);
        ans.push_back(x);
    }
    if (rem == 5) {
        rep(i,ans.size()) {
            if (ans[i] == 9) {ans.erase(ans.begin()+i); break;}
        }
        for (int i = ans.back()+1;;i++) {
            if (i % 6 == 4) {
                ans.push_back(i);
                break;
            }
        }
    }
    rep(i,ans.size()) cout << ans[i] << " ";
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
#define vi vector<int>
#define vvi vector<vector<int> > 
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define ll long long 
#define all(x) x.begin(),x.end()
#define vpl vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
// #define mod 998244353
#define mod 1000000007
#define MAXN  1000001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)



void solve()
{  
    int x;
    for(int i = 1 ; i <= 5 ;i++)
    {
        cin>>x;
        if(x == 0)
        {
            cout<<i<<endl;
            return;
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3648
N = int(input())
A = [int(i) for i in input().split()]

next = 1
ans = 0
found = False
for i in range(N):
    if A[i] == next:
        next += 1
        found = True
    else:
        ans += 1

if found:
    print(ans)
else:
    print(-1)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
const ll INF = 1LL << 50;

// Problem Specific Parameter:
// a + b + c - ( d + e + f - (e + (f - g - e))
// + の直後に括弧を開いても嬉しくない
// - の直後に括弧を開くか考える
// 括弧を閉じるタイミングは自由
// -(expa -(expb -(expc))) = -(expa - expb) - expc

// A1) op (A2 

ll a[100010];
char op[100010];
ll dp[100010][3];

inline ll sgn(ll n){
	if(n&1)
		return -1LL;
	else
		return 1LL;
}

int main(void){
	ll n;
	cin >> n;
	
	rep(i,n){
		cin >> a[i];
		if(i==n-1) break;
		cin >> op[i];
	}

	rep(i,n)rep(j,3) dp[i][j]=-INF;
	dp[0][0]=a[0];
	
	rep(i,n-1)rep(j,3){
		if(dp[i][j]==-INF) continue;
		rep(k,3){
			int nj = j - k;
			if(nj < 0) continue;

			if(op[i]=='+') chmax(dp[i+1][nj],dp[i][j] + sgn(nj)*a[i+1]);
			if(op[i]=='-') chmax(dp[i+1][nj],dp[i][j] + sgn(nj+1)*a[i+1]);
			if(op[i]=='-' and nj+1 < 3) chmax(dp[i+1][nj+1],dp[i][j] + sgn(nj+1)*a[i+1]);
		}
	}

	ll ans = - INF;
	rep(j,3) chmax(ans,dp[n-1][j]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  for(int i=N-1; i>=0; i--){
    cout << a[i];
    if(i){
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[1000000];
int tree[2000005]={0};
void update(int k,int l,int r,int wei,int val)
{
	if(l==wei&&wei==r)
	{
		tree[k]=1<<val;
	}
	else if(!(r<wei||l>wei))
	{
		int m=(l+r)/2;
		update(k*2+1,l,m,wei,val);
		update(k*2+2,m+1,r,wei,val);
		tree[k]=tree[k*2+1]|tree[k*2+2];
	}
}
int suan(int k,int l,int r,int l1,int r1)
{
//	printf("%d %d %d %d %d\n",k,l,r,l1,r1);
	if(l1<=l&&r<=r1)
	{
		return tree[k];
	}
	else if(r<l1||l>r1)
	{
		return 0;
	}
	else
	{
		int m=(l+r)/2;
		return suan(k*2+1,l,m,l1,r1)|suan(k*2+2,m+1,r,l1,r1);
	}
}
int main()
{
	int n,q;
	scanf("%d",&n);
	scanf(" %s",s);
	for(int i=0;i<n;i++)
	{
		update(0,0,n-1,i,s[i]-'a');
	}
	scanf("%d",&q);
	while(q--)
	{
		int a,l,r,i;
		char c;
		scanf("%d",&a);
		if(a==1)
		{
			scanf("%d %c",&i,&c);
			update(0,0,n-1,i-1,c-'a');
		}
		else
		{
			scanf("%d %d",&l,&r);
			int d=suan(0,0,n-1,l-1,r-1);
			int ans=0;
			while(d>0)
			{
				if(d&1) ans++;
				d>>=1;
			}
			printf("%d\n",ans);
		}
	}
} 

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> demand(m);

  for (int i = 0; i < m; i++){
    cin >> demand[i].first >> demand[i].second;
  }

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

  int id = n, ret = 0;
  for (int i = m - 1; i >= 0; i--){
    if (demand[i].second <= id){
      ret++;
      id = demand[i].first;
    }
    else {
      ;
    }
  }

  cout << ret << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
    long long a,b,c;
    while(scanf("%lld%lld",&a,&b)==2)
    {
        c=a+b;
        int coun=0;
        while(c>0)
        {

            coun++;
            c/=10;
        }
        printf("%lld\n",coun);
    }
    return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long N, long long K){
    cout<<1+N-K<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.IO;
using System.Linq;

namespace CompetitiveProgramming
{
  
  class Solve
  {
    const int INF = (int)(1e9) + 10;

    private void Main()
    {
      int a = int.Parse(Console.ReadLine());
      int b = int.Parse(Console.ReadLine());
      int h = int.Parse(Console.ReadLine());
      Console.WriteLine((a + b) * h / 2);
    }

    public Solve()
    {
      Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
      Main();
      Console.Out.Flush();
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
      new Solve();
    }
  }
}

Measured memory_bytes: 2776
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007

struct Corr {
    int x;
    int y;
    long cost;
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long idx=0;
    long H, W;
    cin >> H >> W;
    std::vector<std::vector<string>> mat(H, vector<string>(W, ""));
    string line;
    for(size_t i=0;i<H; i++)
    {
        cin >> line;
        for(size_t j=0;j<W; j++)
        {
            mat[i][j] = line[j];
        }
    }
    long init_cost = 0;
    if(mat[0][0] == "#") init_cost++;
    vector<vector<int>> dp(H, vector<int>(W, H*W));

    dp[0][0] = init_cost;
    int dx[8] = {1, 0, -1, 0};
    int dy[8] = {0, 1, 0, -1};
    for(size_t i=0;i<H; i++)
    {
        for(size_t j=0;j<W; j++)
        {
            for(int k = 0; k < 2; k++) {
                int nextx = j + dx[k];
                int nexty = i + dy[k];
                // 探索する場所が配列外の場合
                if(nextx < 0 || nextx >= W || nexty < 0 || nexty >= H) continue;
                dp[nexty][nextx] = min(dp[nexty][nextx], dp[i][j] + (mat[i][j] == "." && mat[nexty][nextx] == "#" ? 1 : 0));
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
    return 0;
}



Measured memory_bytes: 896
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b;
string s;
signed main()
{
	cin>>a>>b;
	if(a-b*2<0){
		cout<<0;
	}else{
		cout<<a-b*2;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define LOWB(x) (x & (-x))
#define UNIQUE(a) sort(ALL(a)), (a).erase(unique(ALL(a)), (a).end())
#define INF 1e9
#define INF_LL 4e18
#define rep(i,a,b) for(__typeof(b) i=a; i<(b); ++i)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
/*-----------------------------------*/
int r, g, b, n;

int main() {
  cin >> r >> g >> b >> n;
  int res = 0;
  for (int i=0; i*r<=n; i++) {
    for (int j=0; j*g+i*r<=n; j++) {
      if ((n - j*g - i*r) % b == 0)  res++;
    }
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

s64 gcd(s64 x, s64 y)
{
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(y, x % y);
}

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

    int N;
    cin >> N;

    vs64 A(N);
    rep (i, N) cin >> A[i];

    s64 ans = 0;
    rep (i, N)
    {
        ans = gcd(A[i], ans);
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A[3];

    for (int i = 0; i < 3; i++) {
        cin >> A[i];
    }

    sort(A, A + 3);

    if (A[0] == A[1]) {
        cout << A[2] << endl;
    } else if (A[1] == A[2]) {
        cout << A[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
    return f?res:-res;
}
template<class tp>inline void chemx(tp &a,tp b){a<b?a=b:0;}
template<class tp>inline void chemn(tp &a,tp b){a>b?a=b:0;}
cs int mod=1e9+7;
inline int add(int a,int b){return (a+=b)>=mod?(a-mod):a;}
inline int dec(int a,int b){a-=b;return a+(a>>31&mod);}
inline int mul(int a,int b){static ll r;r=1ll*a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){(a+=b)>=mod?(a-=mod):0;}
inline void Dec(int &a,int b){a-=b,a+=a>>31&mod;}
inline void Mul(int &a,int b){static ll r;r=1ll*a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(int x){return (x<0)?x+mod:x;}
cs int N=1000005; 
int iv[N];
int n;
int main(){
	#ifdef Memoria
	freopen("lx.in","r",stdin);
	#endif
	n=read();
	iv[0]=iv[1]=1;
	for(int i=2;i<=N-5;i++)iv[i]=mul(mod-mod/i,iv[mod%i]);
	int res=0;
	for(int i=1,pw=iv[3];i<=n;i++,Mul(pw,iv[3]))
		Add(res,mul(pw,iv[n-i+1]));
	cout<<mul(res,iv[n])<<'\n';
}

Measured memory_bytes: 4352
#!/usr/bin/env python3
n, *h = map(int, open(0).read().split())
r = [0] * n
for i in range(1, n):
    if h[i - 1] >= h[i]:
        r[i] = r[i - 1] + 1
    else:
        r[i] = 0
print(max(r))


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

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		string s;
		cin >> n >> s;
		long long r = 0, g = 0, b = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == 'R') r++;
			if (s[i] == 'G') g++;
			if (s[i] == 'B') b++;
		}
		long long ans = r * g * b;
		for (int i = 0; i < n; i++) {
			for (int d = 1; i >= d && i + d < n; d++) {
				if (s[i] != s[i - d] && s[i] != s[i + d] && s[i - d] != s[i + d]) {
					ans--;
				}
			}
		}
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 3652