akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	v := make(vecs, n)
	for i := 0; i < n; i++ {
		x := scanFloat64()
		y := scanFloat64()
		r := math.Atan2(y, x)
		v[i] = vec{x, y, r}
	}
	sort.Sort(v)
	v = append(v, v...)
	ans := float64(0)
	for i := 0; i < n; i++ {
		for j := 1; j <= n; j++ {
			x, y := float64(0), float64(0)
			for k := 0; k < j; k++ {
				x += v[i+k].x
				y += v[i+k].y
			}
			z := math.Sqrt(x*x + y*y)
			if ans < z {
				ans = z
			}
		}
	}
	fmt.Fprintln(wr, ans)
}

type vec struct {
	x, y, r float64
}

type vecs []vec

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


Measured memory_bytes: 640
#入力
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
from sys import stdin
s=[stdin.readline() for i in range(h)]

#for i in range(h):
#  s_=list(input())
#  s.append(s_)
#幅優先探索
from collections import deque
q=deque([(ch-1,cw-1)])
used=[[float("INF")]*w for i in range(h)]
used[ch-1][cw-1]=0
X=((-1,0),(1,0),(0,1),(0,-1))
Y=((-2,-2),(-2,-1),(-2,0),(-2,1),(-2,2),(-1,-2),(-1,-1),(-1,1),(-1,2),(0,-2),(0,1),(0,2),(1,-2),(1,-1),(1,1),(1,2),(2,-2),(2,-1),(2,0),(2,1),(2,2))
while len(q)>0:
  y,x=q.popleft()
  for dy,dx in X:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
      if used[ny][nx]>used[y][x]:
        used[ny][nx]=used[y][x]
        q.appendleft((ny,nx))
  for dy,dx in Y:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]==".":
      if used[ny][nx]>used[y][x]:
        used[ny][nx]=used[y][x]+1
        q.append((ny,nx))

if used[dh-1][dw-1]==float("INF"):
  print(-1)
else:
  print(used[dh-1][dw-1])

      
      
      
    
  
  


Measured memory_bytes: 182124
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>


#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

namespace mp = boost::multiprecision;

int main(int argc, const char * argv[]) {
    // source code
    long n;
    cin >> n;
    mp::cpp_int ret = 0;
    if ( n% 2 == 1) cout << 0 << endl;
    else {
        mp::cpp_int mod = 10;
        for (int i = 1; i < 19; i++) {
            ret += (n / mod ) ;
            mod *= 10;
        }
        long t = 10;
        for (int j = 1 ; j < 19; j++) {
            mod = 5;
            for (int i = 1; i < 25; i++) {
                ret += (n / (mod * t) + 1) / 2;
                mod *= 5;
            }
            t *= 10;
        }
        cout << ret << endl;
    } 
    return 0;
}


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

using namespace std;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, x, y;
	cin >> n >> x >> y;

	vector<int> ans(n + 1);

	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			int _min = min(abs(j - i), abs(x - i) + abs(y - j) + 1);
			++ans[_min];
		}
	}

	for(int i = 1; i < n; i++)
		cout << ans[i] << '\n';

	return 0;
}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    a,b,c = map(int, input().split())


    print(max(0,c-(a-b)))



if __name__ == "__main__":
    main()

Measured memory_bytes: 77528
h, w, m = map(int, input().split())
l = [list(map(lambda x:int(x)-1, input().split())) for _ in range(m)]
A,B,ans = [0]*h,[0]*w,0
for i, j in l:
    A[i] += 1;    B[j] += 1 
ma,mb = max(A),max(B)
count = A.count(ma)*B.count(mb)
for i, j in l:
    if A[i] == ma and B[j] == mb:
        count -= 1
print(ma+mb-1 if count == 0 else ma+mb)

Measured memory_bytes: 68348
N = int(input())
w = [input() for _ in range(N)]

jdg = True

s_last = w[0][-1]
ss = [w[0]]

for s in w[1:]:
    if s in ss:
        jdg = False
        break
    if s[0] != s_last:
        jdg = False
        break
    s_last = s[-1]
    ss.append(s)
print('Yes' if jdg else 'No')

Measured memory_bytes: 3064
#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  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int N,K; cin >> N >> K;
    vector<LL> x(N);
    rep(i,N){
        cin >> x[i];
    }
    LL res = 1LL<<60;
    for(int i = 0;i + K - 1 < N;i++){
        LL left = x[i], right = x[i+K-1];
        res = min(res,min(abs(left),abs(right)) + right - left);
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
let ans sa sb sc =
  let na = String.length sa
  and nb = String.length sb
  and nc = String.length sc
  in
  let rec f ia ib ic = function
    'a' -> if ia = na then "A"  else f (ia+1) ib ic sa.[ia]
  | 'b' -> if ib = nb then "B" else f ia (ib+1) ic sb.[ib]
  | _ -> if ic = nc then "C" else f ia ib (ic+1) sc.[ic]
  in f 0 0 0 'a';;

Scanf.scanf "%s\n%s\n%s" (fun sa sb sc -> print_string (ans sa sb sc))


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct node {
    int key;
    struct node *prev, *next;
} Node;

Node *nil;

void init(void) {
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(void) {
    deleteNode(nil->next);
}

void deleteLast(void) {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList(void) {
    Node *cur = nil->next;
    while (cur != nil) {
        printf("%d", cur->key);
        cur = cur->next;
        if (cur != nil) printf(" ");
    }
    printf("\n");
}

int main(void) {
    int n, i, key;
    scanf("%d", &n);
    char command[13];
    init();

    for (i = 0; i < n; i++) {
        scanf("%s %d", &command, &key);

        if (!strcmp(command, "deleteFirst")) {
            deleteFirst();
        } else if (!strcmp(command, "deleteLast")) {
            deleteLast();
        } else if (command[0] == 'i') {
            insert(key);
        } else {
            deleteKey(key);
        }
    }

    printList();
    return 0;
}


Measured memory_bytes: 32968
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include<cmath>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int N;cin>>N;
    int T,A;cin>>T>>A;
    vector<int> H(N,0);
    REP(i,N){
        cin>>H[i];
    }
    vector<double>temp(N,0);
    REP(i,N){
        temp[i] = abs(T-H[i]*0.006-A);
    }
    vector<double>::iterator iter = min_element(temp.begin(), temp.end());
    int index = distance(temp.begin(), iter);
    cout<<index+1<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	static final long MOD = 1000000007;
	static int n;
	static StringBuilder sb;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		n = sc.nextInt();
		sb = new StringBuilder();
		create('a');
	}
	static void create(char now) {
		if (sb.length() == n) {
			System.out.println(sb);
			return;
		}

		for (int i = 'a'; i < now; i++) {
			sb.append((char)i);
			create(now);
			sb.deleteCharAt(sb.length() - 1);
		}
		sb.append(now);
		create((char)(now + 1));
		sb.deleteCharAt(sb.length() - 1);
	}
}

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 static 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 || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 47976
// abc.64.c   Colorful Leaderboard

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

int main( void ) {
    unsigned long long s, c;
    cin >> s >> c;
	//Sが余るとき
    if( s * 2 == c )
        cout << s << endl;
    else if(s*2>c){
        cout << c / 2 << endl;
    }
	//Sが足りない（Cで補う）とき
	else{
        c -= s * 2;
        unsigned long long cnt = c / 4;
        cout << s + cnt << endl;
    }
    return 0;
}


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

using namespace std;
map<int,int>mp;
int a[200010];
int main(){
	int n,ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		mp[a[i]]++;
	} 
	while(!mp.empty()){
		map<int,int>::iterator it=mp.end();
		it--;
		int x=it->first;
		if(mp[x]==0)throw;
		mp[x]--;
		if(mp[x]==0)mp.erase(x);
		int z=1;
		while(z<=x)z<<=1;
		if(mp.count(z-x)>0){
			mp[z-x]--;
			if(mp[z-x]==0)mp.erase(z-x);
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10368
import itertools

l = []
N = int(input())
*P, = map(int, input().split())
*Q, = map(int, input().split())
P = tuple(P)
Q = tuple(Q)
for i in range(N):
    l.append(i+1)
L = list(itertools.permutations(l))

a = L.index(P)
b = L.index(Q)

print(abs(a-b))


Measured memory_bytes: 8052
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
for i in range(N):

    if b[i] <= a[i]:
        cnt += b[i]
    else:
        cnt += a[i]
        # 倒せる数を減らす
        b[i] -= a[i]
        # print(cnt)

        if a[i + 1] >= b[i]:
            cnt += b[i]
            a[i + 1] -= b[i]
        else:
            cnt += a[i+1]
            a[i + 1] = 0
print(cnt)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n,cnt=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    if((1<=i&&i<=9)||(100<=i&&i<=999)||(10000<=i&&i<=99999)){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
a = str(input())
a = list(a)

XX = int(a[0]+a[1])
YY = int(a[2]+a[3])

x=0
y=0
if(XX<=12 and XX!=0):
    x=1
if(YY<=12 and YY!=0):
    y=1

if(x+y==2):
    print("AMBIGUOUS")
elif(x==1):
    print("MMYY")
elif(y==1):
    print("YYMM")
else:
    print("NA")    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll N,M,X;
  cin>>N>>M>>X;
  
  vector<ll>C(N);
ll A[N][M];
  vector<ll>date(M);
  rep(i,N){
    cin>>C[i];
    rep(j,M){
      cin>>A[i][j];
    }
  }
  ll ans=0;
  rep(i,power(2,N)){
  bitset<12>b(i);
  string K=b.to_string();
  
    
  
  
    
    ll sum=0;
  for(ll j=11;j>=12-N;j--){
    
if(K[j]=='1'){
  rep(k,M){
  date[k]+=A[11-j][k];
  }
sum+=C[11-j];
}
  }
    bool flag=true;
    
    rep(m,M){
      if(date[m]<X){
        flag=false;
      }
    }
if(flag){
  if(ans==0){
    ans=sum;
  }
  else{
    ans=min(sum,ans);
  }
}
    
    rep(l,M){
      date[l]=0;
    }
  }
if(ans!=0){
  cout<<ans<<endl;
}
  else{
    cout<<-1<<endl;
  }

}


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

int main() {
  int N;
  cin >> N;
  int a,b,c,d,e,n;
  a = floor(N/10);
  b = a%111;
  
  d = floor(N/1000);
  n = N-d*1000;
  e = n%111;
  
  if (b == 0 || e ==0){
    cout <<"Yes"<<endl;
  }
 
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int E,Y;
    cin >> E >> Y;
    if(E == 0){
        if(1868 <= Y && Y<= 1911){
            cout<<"M"<<Y-1867<<endl;
        }
        if(1912 <= Y && Y <= 1925){
            cout<<"T"<<Y-1911<<endl;
        }
        if(1926 <= Y && Y <= 1988){
            cout<<"S"<<Y-1925<<endl;
        }
        if(1989 <= Y && Y <= 2016){
            cout<<"H"<<Y-1988<<endl;
        }
    }
    if(E == 1){
        cout<<1867 + Y<<endl;
    }
    if(E == 2){
        cout<<1911 + Y<<endl;
    }
    if(E == 3){
        cout<<1925 + Y <<endl;
    }
    if(E == 4){
        cout<<1988 + Y <<endl;
    }
}



Measured memory_bytes: 3088
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")


N=int(input())

cost=10**15

import math
for _ in range(5):
  cost = min(cost, int(input()))

ans=5
ans+= max(0, math.ceil(N/cost)-1)

print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void){
  int R;
  cin >> R;

  if(R < 1200)
    cout << "ABC" << endl;
  else if(R < 2800)
    cout << "ARC" << endl;
  else 
    cout << "AGC" << endl;

  return 0;
}


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

int main()
{
	int a, b, c,A1,A2,A3,B1,B2,B3,C1,C2,C3;
	cin >> a >> b >> c;
	if (a > b)
	{
		A1 = b, B1 = a, C1 = c;
	}
	else
	{
		A1 = a, B1 = b, C1 = c;
	}
	if (B1 >C1 )
	{
		A2 = A1, B2 = C1, C2 = B1;
	}
	else
	{
		A2 = A1, B2 = B1, C2 = C1;
	}
	if (A2 > B2)
	{
		A3 = B2, B3 = A2, C3 = C2;
	}
	else
	{
		A3 = A2, B3 = B2, C3 = C2;
	}
	cout << A3 <<" "<< B3 <<" "<< C3 << endl;
    return 0;
}




Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
ll modular_pow(ll a,ll b){
	if(b == 0)
		return 1LL;
	ll x = modular_pow(a,b/2) % mod;
	x = (x * x) % mod;
	if(b & 1)
		return (a * x)%mod;
	return x;
}

int main(){
	ll n,k;
	cin>>n>>k;

	ll dp[k+1];

	ll sum = 0;
	for(ll i =1;i <= k;i++){
		dp[i] = modular_pow(k/i,n);

	}

	for(ll i = k;i>=1;i--){
		for(ll j = i * 2;j<=k ;j+=i){
			dp[i] = (dp[i] - dp[j] + mod)%mod;
			dp[i] = (dp[i] + mod);
		}
		sum = (sum + (dp[i] * i) %mod)%mod;
	}

	
	
	cout<<sum;
	cout<<"\n";

	return 0;




}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int power(int a, int b) {
	int ans = 1;
	while (b > 0) {
		ans = ans * a;
		b--;
	}
	return ans;
}
#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	while (t--) {
		int n, m, k, ans = 0;
		cin >> n >> m >> k;
		char crr[n][m];
		for (int i = 0; i < n; i++) {
			string s;
			cin >> s;
			for (int j = 0; j < m; j++)
				crr[i][j] = s[j];
		}
		for (int z = 0; z < power(2, n + m); z++) {
			int arr[n + m];
			char brr[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++)
					brr[i][j] = crr[i][j];
			}
			for (int l = 0; l < n + m; l++) {
				arr[l] = 0;
			}
			int p = z;
			for (int l = 0; l < n + m; l++) {
				arr[l] = p % 2;
				p = p / 2;
			}
			for (int i = 0; i < n; i++) {
				if (arr[i] == 1) {
					for (int x = 0; x < m; x++)
						brr[i][x] = '.';
				}
			}
			for (int i = n; i < n + m; i++) {
				if (arr[i] == 1) {
					for (int x = 0; x < n; x++)
						brr[x][i - n] = '.';
				}
			}
			int cnt = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (brr[i][j] == '#')
						cnt++;
				}
			}
			if (cnt == k) ans++;
		}
		cout << ans << endl;
		return 0;
	}
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k=1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u==p) continue;
        if (k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}
int main() {
    int m1,d1,m2,d2; cin >> m1 >> d1 >> m2 >> d2;
    int ans = 0;
    if (m1 != m2) ans = 1;
    else ans = 0;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvl;
const int mod = 1000000007;
const int N = 3e5;
typedef long long int lli;

int main()
{

ll n,i,x;
   sl(n);
    vll a;
    unordered_map<ll,ll> mp;

    fo(i,n)
    {
       sl(x);
       a.pb(x);
       mp[x]++;
    }

    ll ans=0;

    fo(i,n)
    {
       if(mp[a[i]]!=0)
       {
           if (a[i]<mp[a[i]])  {  ans += mp[a[i]]-a[i];  mp.erase(a[i]); }
           else if(mp[a[i]]<a[i]) { ans += mp[a[i]]; mp.erase(a[i]);}
    }

    }


   cout<<ans;
return 0;

}





Measured memory_bytes: 5020
#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;
int 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 || 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: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n), c(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> c[i];
  rep(i,n) p[i]--;
  ll ans = -1e18;
  rep(si,n) {
    int x = si;
    vector<int> s;
    ll tot = 0;
    while (1) {
      x = p[x];
      s.push_back(c[x]);
      tot += c[x];
      if (x == si) break;
    }
    int l = s.size();
    ll t = 0;
    rep(i,l) {
      t += s[i];
      if (i+1 > k) break;
      ll now = t;
      if (tot > 0) {
        ll e = (k-(i+1))/l;
        now += tot*e;
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int k,x;
    cin >> k >> x;
    for(int i=x-k+1;i<x+k-1;i++){
        cout << i << " ";
    }
    cout << x+k-1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct f {
	int no;
	int f;
};
f t[110];
double tot = 0;
int ans;
double mini = 1e7;
double doabs(double a) {
	if(a>0) return a;
	else return -a;
}
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&t[i].f);
		t[i].no = i;
		tot+=(double)t[i].f;
//		cout<<tot<<endl;
	}
//	tot+=0.0000001;
//	cout<<"tot = "<<tot<<endl;
	tot/=(double)n;
//	cout<<"tot = "<<tot<<endl;
//	sort(t,t+n,cmp);
	for(int i=0;i<n;i++)
		if(doabs(((double)t[i].f)-tot)<mini) {
			mini = doabs(((double)t[i].f)-tot);
			ans = t[i].no;
		}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <numeric>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::accumulate;
using std::vector;

static int
solve(int N, vector<int> const &A1, vector<int> const &A2)
{
  int count = accumulate(A2.begin(), A2.end(), A1[0]);
  int ret = count;
  for (int n = 1; n < N; n++)
  {
    count = count + A1[n] - A2[n - 1];
    if (ret < count)
    {
      ret = count;
    }
  }
  return ret;
}

int
main()
{
  int N;
  cin >> N;
  vector<int> A1(N), A2(N);
  for (int n = 0; n < N; n++)
  {
    cin >> A1[n];
  }
  for (int n = 0; n < N; n++)
  {
    cin >> A2[n];
  }
  cout << solve(N, A1, A2) << endl;
  return 0;
}


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

int n, pre[50], in[50], post[50], p = 0, cnt = 0;

void reconstruction(int left, int right){

  if(left >= right) return ;

  int c = pre[p++]; //next node in preorder                                                                                                                                                                 
  int m; //the position of variable c in inorder                                                                                                                                                            
  for(int i = 0;;i++){
    if(c == in[i]){
      m = i;
      break;
    }
  }

  reconstruction(left, m); //reconstruction left part tree                                                                                                                                                  
  reconstruction(m + 1, right); //resonstruction right part tree                                                                                                                                            

  post[cnt++] = c; //store c as postorder                                                                                                                                                                   
}

int main(){

  //input                                                                                                                                                                                                   
  cin >> n;
  for(int i = 0;i < n;i++) cin >> pre[i];
  for(int i = 0;i < n;i++) cin >> in[i];

  //reconstruction                                                                                                                                                                                          
  reconstruction(0, n);

  //output                                                                                                                                                                                                  
  for(int i = 0;i < n;i++){
    cout << (i?" ":"");
    cout << post[i];
  }
  cout << endl;

  return 0;
}


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

int main() {
    char inp;
    cin >> inp;

    if(inp == 'a' || inp == 'i' || inp == 'u' || inp == 'e' || inp == 'o') {
        cout << "vowel" << endl;
    }
    else {
    cout << "consonant" << endl;
    }
}
    


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
	int k;
	char s[105];

	scanf("%d", &k);
	scanf("%s", s);

	if(k < strlen(s)) {
		for(int i = 0; i < k; i++) {
			printf("%c", s[i]);
		}
		puts("...");
	}
	else {
		puts(s);
	}
}

Measured memory_bytes: 1616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> l(n);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ll x = llabs(l[i] - l[j]), y = l[i] + l[j];
      ll c = lower_bound(l.begin(), l.end(), y) - upper_bound(l.begin(), l.end(), x);
      if (l[i] > x && l[i] < y) {
        c--;
      }
      if (l[j] > x && l[j] < y) {
        c--;
      }
      if (c > 0) {
        ans += c;
      }
    }
  }
  cout << ans/3 << endl;
  return 0;
}

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

#define ll long long
#define REP(i, n) for(int i = 0;i < (int)(n);i++)
#define REPD(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, a, b) for(int i = a;i <= (int)(b);i++)
#define FORD(i, a, b) for(int i = a;i >= (int)(b);i--)
int main() {
  ll S = 1;
  bool c = false;
  int N;
  cin >> N;
  vector<ll> v(N);
  REP(i, N) {
    cin >> v[i];
    if (v[i] == 0) {
      c = true;
      break;
    }
  }
  if (c) {
    cout << 0 << endl;
  } else {
    REP(i, N) {
      if (S * v[i] > 0 && S * v[i] < 1000000000000000001) {
        S *= v[i];
      } else {
        cout << "-1" << endl;
        c = true;
        break;
      }
    }
    if (!c) cout << S << endl;
  }
}


Measured memory_bytes: 4052
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#define ll long long
using namespace std;

const int N = 1e5 + 2;

int n, a[N];

int main() {
    bool even = false, odd = false;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        even |= a[i] % 2 == 0;
        odd |= a[i] % 2;
    }
    puts(odd ? "first" : "second");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

vector<vector<int> > graph;
vector<int> signpost, visited;

void bfs(int u) {
	deque<int> vertices;
	vertices.push_back(u);
	visited[u] = 1;

	while (!vertices.empty()) {
		int v = vertices.front();
		vertices.pop_front();

		for (int i = 0; i < graph[v].size(); ++i) {
			if (!visited[graph[v][i]]) {
				visited[graph[v][i]] = 1;
				signpost[graph[v][i]] = v;
				vertices.push_back(graph[v][i]);
			}
		}
	}
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	graph = vector<vector<int> > (n + 1, vector<int> ());
	int u, v;
	for (int i = 0; i < m; ++i) {
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	signpost = vector<int> (n + 1);
	visited = vector<int> (n + 1);

	bfs(1);

	for (int i = 2; i <= n; ++i) {
		if (signpost[i] == 0) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	for (int i = 2; i <= n; ++i) {
		cout << signpost[i] << "\n";
	}

	return 0;

}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	vector<int> c(n);
	for (int i = 0; i < n; i++) cin >> c[i];

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] > c[i]) ans += v[i] - c[i];
	}
	cout << ans << endl;
}

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

int main() {
    int n,sum=0;
    int a;
    cin>>n;
    int* af = new int[n+1];
    for(int i=0; i<n; i++) {
        cin>>a;
        if(a>n) {
            sum++;
            continue;
        }
        af[a]++;
    }
    for(int i=0; i<n+1; i++) {
        if(!af[i]) continue;
        if(af[i] > i) {
            sum += af[i]-i;
        } else if(af[i] < i) {
            sum += af[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
// kyopro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<map>
#include<algorithm>
#include<set>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<string>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define For(i,N) for(ll i=0;i<N;i++)
int main()
{
	ll N;
	cin >> N;
	vector<ll>A(N + 1);
	rep(N) {
		cin >> A[i + 1];
	}
	ll c = 0;
	vector<ll>atai;
	vector<ll>DP(N + 1);
	DP[0] = 0;
	DP[1] = 1;
	atai.push_back(A[1]);
	
	rep(N-1) {
		if (A[i + 2] > *(--atai.end())) {
			*(--atai.end()) = A[i + 2];
			DP[i + 2] = DP[i + 1];
			
			
		}
		else if (A[i + 2] <= atai[0]) {
		
			DP[i + 2] = DP[i + 1] + 1;
			auto ita = atai.begin();
			atai.insert(ita, A[i + 2]);
			
			
		}
		else {
			DP[i + 2] = DP[i + 1];
			auto ita = lower_bound(atai.begin(),atai.end(),A[i + 2]);
			while (1) {
				if (*ita < A[i + 2]) {
					*ita = A[i + 2];
					break;
				}
				ita--;
			}
			
		}

	}
	cout << DP[N];
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================
// Template End =========================

constexpr int MOD=1e9+7;

int main(void){
  string s; cin>>s;
  deque<char> de;
  rep(i,s.size()){
      switch(s[i]){
          case 'B' : if(!de.empty()) de.pop_back(); break;
          default : de.push_back(s[i]);
      }
  }
  while(!de.empty()){cout<<de.front();de.pop_front();}
}












Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n, m;
  cin >> n >> m;
  int a[n];
  int b[m];
  for(int i = 0;i < n;i++)
    cin >> a[i];
  for(int i = 0;i < m;i++)
    cin >> b[i];
  long long x_sum = 0, y_sum = 0;
  for(int i = 0;i < n - 1;i++){
    x_sum += 1ll * (i + 1) * (n - i - 1) % MOD * (a[i + 1] - a[i]) % MOD;
    if(x_sum >= MOD)
      x_sum -= MOD;
  }
  for(int i = 0;i < m - 1;i++){
    y_sum += 1ll * (i + 1) * (m - i - 1) % MOD * (b[i + 1] - b[i]) % MOD;
    if(y_sum >= MOD)
      y_sum -= MOD;
  }
  cout << x_sum * y_sum % MOD;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
  
using namespace std;
  
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
  
int a,b;
cin>>a>>b;
  
if(a>b) cout<<"a > b"<<endl;
else if(a<b) cout<<"a < b"<<endl;
else cout<<"a == b"<<endl;
  
return 0;
  
}


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

int main() {
    while(true){
    double sum=0;
    double a[50000];
    double n;
    cin >> n;

    if(n==0)break;
    
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    double ave = sum/n;
    int cnt=0;
    for(int i=0;i<n;i++){
        if(ave>=a[i]){
            cnt++;
        }
    }

    cout << cnt<<endl;
    }

    return 0;
}


Measured memory_bytes: 3296
#include<cstdio>
char a[10101];
char s[99];
int tp = 0;
int main()
{
 scanf("%s", s);
  for(char* x=s;*x; ++x)
  {
   if(*x=='B') --tp;
   else a[tp++] = *x;
    if(tp<0) tp = 0;
  }
  a[tp] = 0; puts(a);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define ll long long

int main(){
    int a,b,tmp,res;
    cin >> a >> b;
    res = (b+a-3)/((tmp=a-1)==0?1:tmp);
    cout << res << endl;
}

Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<long long,long long> data_t;
int main()
{
	long long N, M, i, baikai, count, sum;
	cin >> N >> M;
	vector<data_t> data_array(N);
	for (i = 0; i < N; i++)
	{
		cin >> data_array[i].first >> data_array[i].second;
	}
	sort(data_array.begin(), data_array.end());
	sum = 0;
	for (i = 0; i<N; i++)
	{
		if (M - data_array[i].second>=0)
		{
			M = M - data_array[i].second;
			sum = sum + data_array[i].second*data_array[i].first;
		}
		else
		{
			sum = sum + M * data_array[i].first;
			break;
		}
	}
	cout << sum;

	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  string s;
  cin >> s;
  int n = s.size();
  vii dp(n + 1, vi(3, -inf));
  dp[0][0] = 0;
  rep (i, n) {
    rep (j, 3) {
      if (dp[i][j] == -inf) continue;
      if (i - j >= 0) {
        string pre = s.substr(i - j, j);
        if (i + 1 <= n) {
          string nex = s.substr(i, 1);
          if (pre != nex) {
            chmax(dp[i + 1][1], dp[i][j] + 1);
          }
        }
        if (i + 2 <= n) {
          string nex = s.substr(i, 2);
          if (pre != nex) {
            chmax(dp[i + 2][2], dp[i][j] + 1);
          }
        }
      }
    }
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 1005;
const int MAX_K = MAX_N;
int dp[MAX_N][MAX_K];

int main() {

  for (;;) {
    int N = nextInt();
    ll MOD = nextInt();
    if (N == 0) break;
    vector<int> a(N), b(N), c(N);
    REP(i, N) a[i] = nextInt();
    REP(i, N) b[i] = nextInt();
    REP(i, N) c[i] = (b[i] - a[i] + MOD) % MOD;

    const int INF = 1001001001;
    REP(i, MAX_N) REP(j, MAX_K) dp[i][j] = INF;

    dp[0][0] = c[0];
    for (int i = 1; i < N; i++) {
      for (int j1 = 0; j1 < MAX_K; j1++) {
        if (dp[i-1][j1] >= INF) continue;
        int ac1 = c[i-1] + j1 * MOD;
        for (int j2 : {j1-1, j1, j1+1}) if (0 <= j2 && j2 < MAX_K) {
          int ac2 = c[i] + j2 * MOD;
          int cost = max(0, ac2 - ac1);
          chmin(dp[i][j2], dp[i-1][j1] + cost);
        }
      }
    }
    int ans = dp[N-1][0];
    REP(j, MAX_K) chmin(ans, dp[N-1][j]);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 7104
n, m = map(int, input().split())
min_id = 0
max_id = 10**9
for _ in range(m):
    l, r = map(int, input().split())
    min_id = max(l, min_id)
    max_id = min(r, max_id)

ans = max_id - min_id + 1
if ans <= 0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 9200
import sys
I=input().split()
N=int(I[0])
M=int(I[1])
HYO=[0]*N

I=input().split()
SO=0
for _ in range(N):
    HYO[_]=int(I[_])
    SO+=int(I[_])

HYO.sort()
if (HYO[N-M]<SO/(4*M)):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int64_t MOD = 1e9 + 7;

class Matrix {
    vector<int64_t> m_container;
    size_t m_col;

public:
    Matrix(size_t r, size_t c)
        : m_container(r * c)
        , m_col(c)
    {
    }

    size_t row() const
    {
        return m_container.size() / m_col;
    }
    size_t col() const
    {
        return m_col;
    }
    int64_t& operator()(size_t i, size_t j)
    {
        return m_container[i * m_col + j];
    }
    const int64_t& operator()(size_t i, size_t j) const
    {
        return m_container[i * m_col + j];
    }
    friend Matrix operator*(const Matrix& lh, const Matrix& rh);
};
Matrix operator*(const Matrix& lh, const Matrix& rh)
{
    Matrix result(lh.row(), rh.col());
    for (size_t i = 0; i < result.row(); i++) {
        for (size_t j = 0; j < result.col(); j++) {
            result(i, j) = 0;
            for (size_t k = 0; k < lh.col(); k++) {
                result(i, j) += lh(i, k) * rh(k, j) % MOD;
                result(i, j) %= MOD;
            }
        }
    }
    return result;
}

Matrix mpow(const Matrix& x, int64_t y)
{
    if (y == 0) {
        Matrix result(x.row(), x.col());
        rep(i, result.row())
        {
            result(i, i) = 1;
        }
        return result;
    } else if (y % 2 == 0) {
        return mpow(x * x, y / 2);
    } else {
        return x * mpow(x, y - 1);
    }
}

int main()
{
    int n;
    int64_t k;
    cin >> n >> k;

    Matrix mat(n, n);
    rep(i, n) rep(j, n)
    {
        cin >> mat(i, j);
    }

    Matrix p = mpow(mat, k);
    int64_t result = 0;
    rep(i, n) rep(j, n)
    {
        result = (result + p(i, j)) % MOD;
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1408