akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,mx=0,m;
    cin>>n;
    cin>>m;
    long long int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
    }
    
    long long int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
                else if(j<a[i-1])
                 dp[i][j]=dp[i-1][j];
                 else if(j>=a[i-1])
                   dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1]]+b[i-1]);
        }
    }
    
    cout<<dp[n][m]<<"\n";
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std; 
#define int int64_t
#define itn int
#define fi first
#define se second 
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,sum=0,ans=100;
  vector<int> ret;
  cin>>n;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  for(int i=0;i<ret.size();i++){
    int a=0,b=0,c=n/ret[i];
    while(true){
      if(c==0) break;
      a++;
      c/=10;
    }
    while(true){
      if(ret[i]==0) break;
      ret[i]/=10;
      b++;
    }
    ans=min(ans,max(a,b));
  }
  cout<<ans<<"\n";
}
  


Measured memory_bytes: 3600
from collections import deque

S = input().rstrip("\n")
# +の最大の数
max_plus = len(S) -1

answer = 0
for i in range(2 ** max_plus):
    state = i
    index = deque()
    for j in range(max_plus):
        # S[j]とS[j+1]の間に+がある
        if (state >> j) & 1:
            index.append(j+1)
    start = 0
    while index:
        idx = index.popleft()
        answer += int(S[start:idx])
        start = idx
    answer += int(S[start:])

print(answer)

Measured memory_bytes: 3316
{-# LANGUAGE ViewPatterns, OverloadedStrings #-}
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Debug.Trace

main :: IO ()
main = readLn >>= flip replicateM B.getLine >>= print . solve

solve :: [B.ByteString] -> Int
solve ss 
    | abn > 0 && an > 0 && bn > 0 = n + abn +  min an bn
    | abn > 0 && (an > 0 || bn > 0) = n + abn
    | abn > 0 = n + abn - 1
    | otherwise = n + min an bn
    where
        n = sum $ map (count 0) ss

        count acc s@(B.uncons -> Just (_, xs))
            |  "AB" `B.isPrefixOf` s = count (acc + 1) $ B.tail xs
            | otherwise = count acc xs
        count acc _ = acc

        bn = length $ filter (\s -> B.head s == 'B' && B.last s /= 'A') ss
        an = length $ filter (\s -> B.head s /= 'B' && B.last s == 'A') ss
        abn = length $ filter (\s -> B.head s == 'B' && B.last s == 'A') ss


readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

int main(){
	
	int H, W;
	string S[50];
	
	cin >> H >> W;
	for( int i = 0; i < H; i++ ) cin >> S[i];
	
	const int dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 };
	const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
	
	for( int i = 0; i < H; i++ ){
		for( int j = 0; j < W; j++ ){
			if( S[i][j] == '.' ){
				int sum = 0;
				for( int d = 0; d < 8; d++ ){
					const int nx = i + dx[d];
					const int ny = j + dy[d];
					if( nx >= H or nx < 0 ) continue;
					if( ny >= W or ny < 0 ) continue;				
					if( S[nx][ny] == '#' ) sum++;
				}
				S[i][j] = '0' + sum;
			}
		}
	}
	
	
	for( int i = 0; i < H; i++ ) cout << S[i] << endl;
	
	return 0;
	
}


Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬╬╬██╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<60
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef pair<int,int> P;
typedef vector<vector<P>> Graph;

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

  int n;
  cin >> n;

  int ans = 0;
  FOR(i,0,pow(4,9)+1){
    int x = 0, tmp = i;
    vector<int> flag(4,0);
    while(tmp){
      x *= 10;
      flag[tmp%4]++;

      x += ((tmp%4)*2+1);
      tmp/=4;
    }
    if(flag[0]) continue;
    //debug(x);
    if(x <= n && flag[3] && flag[1] && flag[2]) ans++;
  }


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
// AOJ ALDS1_2_D Shell Sort
// 2018.4.27 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cnt;

void insertion_sort(int n, int *a, int g)
{
	int i, j, key;

	for (i = g; i < n; i++) {
		key = a[i];
		j = i-g;
		while (j >= 0 && a[j] > key) {
			a[j+g] = a[j];
			j -= g;
cnt++;
		}
		a[j+g] = key;
	}
}

int m;
int g[102];

void shell_sort(int n, int *a)
{
	int i;

	g[0] = 1;
	for (m = 1; ; m++) {
		g[m] = 3*g[m-1]+1;
		if (g[m] >= n) break;
	}

	cnt = 0;
	for (i = m-1; i >= 0; i--) insertion_sort(n, a, g[i]);
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int a[1000002];

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	shell_sort(N, a);
	printf("%d\n", m);
	printf("%d", g[m-1]);
	for (i = m-2; i >= 0; i--) printf(" %d", g[i]);
	printf("\n%d\n", cnt);
	for (i = 0; i < N; i++) printf("%d\n", a[i]);
	return 0;
}


Measured memory_bytes: 5572
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

bool ng[305];

signed main() {
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;

	return 0;
}

Measured memory_bytes: 256
def solve(N, X):
    res = 0
    for i in range(1, N - 1):
        for j in range(i + 1, N):
            k = X - i - j
            if k > j and k <= N:
                res += 1
    return res


if __name__ == "__main__":
    ans = []
    while True:
        N, X = map(int, input().split())
        if N == 0 and X == 0:
            break
        ans.append(solve(N, X))
    print(*ans, sep="\n")


Measured memory_bytes: 5600
#include <bits/stdc++.h> 
using namespace std; 
int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int pos = 0;
    int count = 0;
    vector<int> vect;
    for (int i = 1; i < 101; i++) {
        if (A%i == 0 && B%i == 0) {
            pos = i;
            count++;
            vect.push_back(i);
        }
    }
    cout << vect[vect.size()-K];
} 

Measured memory_bytes: 256
# AOJ 0544: Sugoroku
# Python3 2018.7.1 bal4u

import sys
from sys import stdin
input = stdin.readline

while True:
	n, m = map(int, input().split())
	if n == 0: break
	s = [0] + [int(input()) for i in range(n)]
	x = [0] + [int(input()) for i in range(m)]
	p = i = 1
	while p < n:
		p += x[i]
		i += 1
		if p < n: p += s[p]
	print(i-1)


Measured memory_bytes: 5640
n = int(input())
a = list(map(int, input().split()))
# tobitobi[i] -> distance [i - 1] to [i + 1]
tobitobi = [0] * n
for i in range(1, n - 1):
    tobitobi[i] = abs(a[i - 1] - a[i + 1])
sum_of_dis = abs(a[0]) + abs(a[n - 1])
for i in range(1, n):
    sum_of_dis += abs(a[i] - a[i - 1])
ans = [0] * (n)
for i in range(n):
    if i == 0:
        ans[i] = sum_of_dis - abs(a[i]) - abs(a[i] - a[i + 1]) + abs(a[i + 1])
    elif i == n - 1:
        ans[i] = sum_of_dis - abs(a[i]) - abs(a[i] - a[i - 1]) + abs(a[i - 1])
    else:
        ans[i] = sum_of_dis - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) + tobitobi[i]
for ANS in ans:
    print(ANS)


Measured memory_bytes: 83768
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	#s = input()
	vl = [lin() for _ in range(3)]
	for f, t in [(0,1), (1,2), (2,0)]:
		is_same = set()
		for i in range(3):
			is_same.add(vl[f][i] - vl[t][i])
		if len(is_same) != 1:
			return 'No'
		
	for f, t in [(0,1), (1,2), (2,0)]:
		is_same = set()
		for i in range(3):
			is_same.add(vl[i][f] - vl[i][t])
		if len(is_same) != 1:
			return 'No'
	return 'Yes'
	
			
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 61420
m,a[9][2],S[2499];D(d,s){int i=0;if(d==m)S[s]++;else for(;i<=a[d][1];i++)D(d+1,s+i**a[d]);}main(i){for(;scanf("%d",&m),m;){for(i=0;i<m;i++)scanf("%d%d",a[i],a[i]+1);memset(S,0,9996);D(0,0);for(scanf("%d",&i);i;i--)scanf("%d",&m),printf("%d\n",S[m]);}exit(0);}

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

int main()
{
    double a,b,x,y;
    cin>>a>>b>>x>>y;
    printf("%f ",a*b/2.0);
    if(x==a/2.0&&y==b/2.0)
        cout<<1;
    else cout<<0;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int mondai = scan.nextInt();
		int kaisu = scan.nextInt();

		int countAC = 0;
		int[] countWA = new int [mondai];
		int pena = 0;

		TreeMap<Integer,String> takahashi = new TreeMap<Integer,String>();

		for(int i=0;i<kaisu;i++) {

			Integer toi = scan.nextInt();
			String check = scan.next();


			if(takahashi.containsKey(toi)) {
				if(takahashi.get(toi).equals("AC")) {

					continue;
				}else {
					takahashi.put(toi,check);
						if(check.contentEquals("AC")) {
							countAC++;
							continue;
						}else if(check.contentEquals("WA")){
							countWA[toi-1]++;
							continue;
						}
				}
			}

				takahashi.put(toi,check);
				if(check.equals("AC")) {
					countAC++;
				}else if(check.equals("WA")) {
					countWA[toi-1]++;
				}
		}

				for(Integer key:takahashi.keySet()) {
					if(takahashi.get(key).equals("AC")) {
						pena += countWA[key-1];
					}
				}

		System.out.println(countAC+ " " +pena);
		scan.close();

	}

}


Measured memory_bytes: 73600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl
#define all(s) (s).begin(), (s).end()

bool odd_keta(int n) { //桁数が奇数か判定して true falseを返す
    int keta=1, ketasu=0;
    while (n/keta) {
        keta *= 10;
        ketasu++;
    }
    return (ketasu%2 == 1 ? true : false);
}

int main() {
    int n, count=0;
    cin >> n;
    rep(i, n) {
        count += odd_keta(i+1);
    }
    ct(count);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
ll score[3];
char str[MAXN];
ll dp[MAXN];

int main()
{
	int i, j;
	scanf("%d%d%lld%lld%lld", &N, &K, &score[0], &score[2], &score[1]);
	scanf("%s", str);
	for (i = 0; i < N; ++i) {
		if (str[i] == 'r') str[i] = 'a';
		else if (str[i] == 'p') str[i] = 'b';
		else if (str[i] == 's') str[i] = 'c';
	}

	dp[0] = score[(str[0] - 'a' + 1) % 3];
	ll maxi = dp[0];
	for (i = 1; i < N; ++i) {
		if (i < K) {
			dp[i] = dp[i - 1] + score[(str[i] - 'a' + 1) % 3];
		}
		else {
			if (str[i] == str[i - K]) {
				str[i] = 'd';
				dp[i] = dp[i - 1];
			}
			else {
				dp[i] = dp[i - 1] + score[(str[i] - 'a' + 1) % 3];
			}
		}
		maxi = MAX(maxi, dp[i]);
	}
	printf("%lld", maxi);
	return 0;
}

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

const double PI = acos(-1);

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double arad, brad;
    arad = (h+m/60)*2*PI/360*30;
    brad = (h+m/60)*2*PI/360*360;

    double difrad;
    if (abs(arad-brad) <= PI) {
        difrad = abs(arad-brad);
    } else {
        difrad = 2*PI - abs(arad-brad);
    }
    
    double clen;
    clen = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(difrad));
    cout << fixed << setprecision(20) << clen << endl;

    int keep;
    cin >> keep;

    return 0;
}

Measured memory_bytes: 4228
n = int(input())
a = [int(i) for i in input().split()]
score_Alice = 0
score_Bob   = 0
turnA = True
a.sort(reverse = True)
for i in range(n):
  if turnA == True:
    score_Alice += a[i]
  else:
    score_Bob   += a[i]
  turnA = not turnA
print(score_Alice - score_Bob)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    ll a;
    double b;
    cin>>a>>b;
    ll ib=b*100+0.5;
    a*=ib;
    a/=100;
    cout<<a;
}


Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int main(){
  int N;
  cin >> N;
  ll m = 10000000000000;
  ll ans = 0;
  ll sig = 0;
  rep(i,N){
    ll a;
    cin >> a;
    if(a < 0) sig++;
    ans += abs(a);
    m = min(m,abs(a));
  }
  if(sig % 2 == 0) cout << ans << endl;
  else cout << (ans - 2*m) << endl;
}




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

using namespace std;

int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20);


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

ll dist(pll a,pll b){return max(abs(a.F-b.F),abs(a.S-b.S));}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,p,q;
  cin>>N>>p>>q;
  p--; q--;
  vector<pll> A(N);
  cin>>A;
  map<ll,set<ll>> X,Y;
  map<ll,vector<ll>> cntX,cntY;
  for(auto &I:A){
    pll a=I;
    I.F=a.F-a.S;
    I.S=a.F+a.S;
    cntX[I.F].push_back(I.S);
    cntY[I.S].push_back(I.F);
    if(I==A[p]){continue;}
    X[I.F].insert(I.S);
    Y[I.S].insert(I.F);
  }
  
  for(auto &I:cntX){sort(I.S.begin(),I.S.end());}
  for(auto &I:cntY){sort(I.S.begin(),I.S.end());}
  queue<pll> Q;
  ll dis=dist(A[p],A[q]);
  Q.push(A[p]);
  ll ans=0;
  
  auto diffr=
    [](map<ll,vector<ll>> &M,ll x,ll mi,ll mx)->ll{
      if(M.count(x)==0){return 0;}
      auto &vec=M[x];
      return lower_bound(vec.begin(),vec.end(),mx)
        -lower_bound(vec.begin(),vec.end(),mi);
    };
  
  
  auto counter=
    [&](pll a){
      ll ret=0;
      ret+=diffr(cntX,a.F-dis,a.S-dis,a.S+dis);
      ret+=diffr(cntY,a.S+dis,a.F-dis,a.F+dis);
      ret+=diffr(cntX,a.F+dis,a.S-dis+1,a.S+dis+1);
      ret+=diffr(cntY,a.S-dis,a.F-dis+1,a.F+dis+1);
      return ret;
    };

  

  auto update2=
    [&](map<ll,set<ll>> &M,ll x,ll mi,ll mx,bool xp){
      if(M.count(x)==0){return;}
      auto &vec=M[x];
      auto I=vec.lower_bound(mi);
      while(I!=vec.end() && *I<=mx){
        if(xp){Q.push({x,*I});}
        else{Q.push({*I,x});}
        I=vec.erase(I);
      }
    };

  auto update1=
    [&](pll a){
      update2(X,a.F-dis,a.S-dis,a.S+dis,true);
      update2(Y,a.S-dis,a.F-dis,a.F+dis,false);
      update2(X,a.F+dis,a.S-dis,a.S+dis,true);
      update2(Y,a.S+dis,a.F-dis,a.F+dis,false);
    };
  
  while(!Q.empty()){
    pll u=Q.front();
    Q.pop();
    update1(u);
  }

  //cout<<A<<endl;
  
  for(auto &I:A){
    //cout<<I<<" "<<counter(I)<<endl;
    if(X[I.F].count(I.S)==0 ||  Y[I.S].count(I.F)==0){
      ans+=counter(I);
    }
  }
  assert(ans%2==0);
  ans/=2;
  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 46464
n=input()
m=input()
L=range(1,2*n+1)
for i in range(m):
    k=input()
    if k==0:
        T1,T2=L[:n],L[n:]
        for j in range(n):
            L[2*j]=T1[j]
            L[2*j+1]=T2[j]
    else:
        L=L[k:]+L[:k]
for i in range(2*n):
    print L[i]

Measured memory_bytes: 4276
import sys
f=lambda:list(map(int,sys.stdin.readline().split()))
n,m=f();l=f();t=n
for b,c in sorted([f() for _ in range(m)],key=lambda k:-k[1]):
  l+=[c]*b;t+=b 
  if t>n*2:break
l.sort()
print(sum(l[-n:]))

Measured memory_bytes: 36856
n,k,q=map(int,input().split())
a=[int(input())for i in range(q)]
x=[]
for i in range(n):
    x.append([i,k-q])
for i in range(q):
    x[a[i]-1][1]+=1
for i in range(n):
    if x[i][1]<1:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 24448
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

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

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

int main()
{
    string S,T;
    cin >> S >> T;

    ll counter = 0;
    ll N = S.size();

    for(ll i=0;i<N;i++)
    {
        if(S[i]!=T[i]) counter++;
    }

    OUT0(counter);

    return 0;
}

Measured memory_bytes: 3920
import scala.io.{StdIn => in}

object Main extends App {
  val Array(hh, ww) = in.readLine.split(" ").map(_.toInt)
  val table = Array.ofDim[Boolean](hh,ww)
  val Array(h, w) = in.readLine.split(" ").map(_.toInt)
  (0 until h).foreach(i => (0 until ww).foreach(j => table(i)(j) = true))
  (0 until w).foreach(i => (0 until hh).foreach(j => table(j)(i) = true))
  val ans = (hh * ww) - table.map(e => e.count(_ == true)).sum
  println(ans)
}

Measured memory_bytes: 27284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int cnt[10] = {};
    rep(i,3){
        cnt[a[i]]++;
    }
    sort(cnt, cnt + 10);
    reverse(cnt, cnt + 10);
    if(cnt[0] == 2 && cnt[1] == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
h_list=[int(x) for x in input().split()]

flag=True

m=h_list[0]
for j in range(len(h_list)-1):
    if m<h_list[j]:
        m=h_list[j]
    if m-h_list[j+1]>=2:
        flag=False
        break        
    
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <iostream>

using namespace std;

int main()
{
	int a, b, c, d, ans;

	cin >> a >> b >> c >> d;

	if(a < b) ans = a;
	else ans = b;

	if(c < d) ans += c;
	else ans += d;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
//*******************************************************
// Tree
//*******************************************************

// status of edge
template <typename X>
struct Edge{
  int from;
  int to;
  X cost;
  int idx;
  
  Edge() = default;

  Edge(int from, int to, int idx, X cost) : from(from), to(to), idx(idx), cost(cost) {}
};

//status of node
template <typename X>
struct Node{
  int idx;
  int par;
  X depth;
  vector<Edge<X>> edge;
  
  Node() = default;

  explicit Node(int idx) : idx(idx) {
  }
  
};

// tree
template <typename X>
class Tree{
private:
  int n; // number of node
  vector<Node<X>> node;
  vector<int> res;
  
  void Init_Node() {
    rep(i,n) node.emplace_back(i);    
  }
  
public:
  Tree() = default;

  explicit Tree(int n) : n(n) {
    Init_Node();
  }

  // no-weight
  Tree(int n, vector<int> a, vector<int> b) : n(n) {
    Init_Node();
    rep(i,n-1) {
      add_edge(a[i], b[i], i);
      add_edge(b[i], a[i], i);  // indirected edge
    }
  }

  Tree(int n, vector<int> a, vector<int> b, vector<X> c) : n(n) {
    Init_Node();
    rep(i,n-1) {
      add_edge(a[i], b[i], i, c[i]);
      add_edge(b[i], a[i], i, c[i]);  // indirected edge
    }
  }  

  void add_edge(int from, int to, int idx, X cost = 1) {
    node[from].edge.emplace_back(from, to, idx, cost);
  }

  void DFS_Init(int v, int p, int d) {
    node[v].par = p;
    node[v].depth = d;
    for(auto next: node[v].edge) {
      int w = next.to;
      X cost = next.cost;
      if(w == p) continue;
      DFS_Init(w, v, d + cost);
    }
  }

  // make rooted tree
  void Make_root(int root) {
    DFS_Init(root, -1, 0);
  }

  void DFS(int v, int p, int num) {
    int cnt = 1;
    for(auto next: node[v].edge) {
      int w = next.to;
      int id = next.idx;
      if(w == p) continue;
      if(cnt == num) cnt++;
      res[id] = cnt;
      DFS(w, v, cnt);
      cnt++;
    }
  }

  void Solve() {
    res.resize(n-1);
    DFS(0, -1, 0);
    int maxi = 0;
    rep(i,n-1) chmax(maxi, res[i]);
    cout << maxi << "\n";
    rep(i,n-1) {
      cout << res[i] << "\n";
    }
  }
  
};

int main()
{
  int n; cin >> n;
  vector<int> a(n-1), b(n-1);
  rep(i,n-1) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  Tree<int> tr(n, a, b);
  tr.Solve();

  
  return 0;
}


Measured memory_bytes: 11628
#include<bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define mod 1000000007
#define bitcount __builtin_popcountll
#define ll long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define mp make_pair
int s[105];
int main()
{
	int i,j,k,sum=0;
	int n;
	sd(n);
	for(i=1;i<=n;i++){
		sd(s[i]);
		sum+=s[i];
	}
	if(sum%10!=0)
		printf("%d\n",sum );
	else
	{
		sort(s+1,s+n+1);
		i=1;
		while(s[i]%10==0&&i<=n)
			i++;
		if(i==n+1)
			printf("0\n");
		else
			printf("%d\n",sum-s[i] );
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int a, b;
  cin >> a >> b;
  if(b >= a) cout << "unsafe\n";
  else cout << "safe\n";
  return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();


		int count=0;
		while (true){
			if(x-z<0) {
				count--;
				break;
			}
			x=x-z;
			if(x-y<0) break;
			x=x-y;
			count++;
		}

		System.out.println(count);
	}

}


Measured memory_bytes: 22740
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    A=[]
    B=[]
    flg=0
    for i in range(n):
        A.append(STR())
    for i in range(m):
        B.append(STR())
    
    for i in range(n-m+1):
        for j in range(n-m+1):
            if A[i][j:j+m] == B[0]:
                temp=1
                for k in range(1,m):
                    if A[i+k][j:j+m] != B[k]:
                        temp=0
                if temp==1:
                    flg=1
    if flg==1:
        print('Yes')
    else:
        print('No')
    
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    long long x, y, i;
   
    long long a = 0;
   
      
    scanf("%lld %lld", &x, &y );
   

    for( i = 1 ; x * i <= y ; i *= 2 ){

         a += 1;

         }

    printf("%d\n", a );

    return 0;
                                                          
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#define _3_ true
using namespace std;

int main(){
  int n,k,index,ini;
  int in[100005];  

  bool ZeroE;
  while(_3_){
    scanf("%d %d",&n,&k);
    if(!(n|k))break;
    ZeroE = false;
    index = 0;

    for(int i=0;i<k;i++){
      scanf("%d",&ini);
      if(ini == 0)ZeroE=true;
      else {
	in[index] = ini; 
	index++;
      }
    }

    sort(in,in+index);
   
    int ans = 0;
    int count = 1;
    bool used = false; 
    for(int i=1;i<index;i++){
      // cout << "i = " << i << ", cout = " << count  << ", in[i] = " << in[i]<< endl;
      if(in[i] == in[i-1]+1)count++;
      else{
	if(ZeroE && !used && in[i] == in[i-1]+2){
	  count+=2;
	  used = true;
	}
	else if(ZeroE && used && in[i] == in[i-1]+2){
	  ans = max(ans,count);
	  count = 3;
	}
	else {
	ans = max(ans,count);
	count = 1;
	used = false;
	} 
     }
      if(in[i] == in[i-1]+1 && i == index-1 && !used && ZeroE)count++;
    }
    if(index == 1 && ZeroE)count = 2;

    ans = max(ans,count);
    
      cout << ans << endl;
  
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int aTotal = 0;
            int bTotal = 0;
            for (int i = 0; i < n; i++) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                if (a == b) {
                    aTotal += a;
                    bTotal += b;
                } else if (a > b) {
                    aTotal += a + b;
                } else {
                    bTotal += a + b;
                }
            }
            sb.append(aTotal).append(" ").append(bTotal).append("\n");
        }
        System.out.print(sb);
    }
}



Measured memory_bytes: 57908
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
int main()
{
	int n,a[200005],d[200005],s=0;
	scanf("%d",&n);
	memset(d,0,sizeof(d));
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
	{
		d[a[i]]=d[a[i]-1]+1;
		s=max(s,d[a[i]]);
	}
	printf("%d\n",n-s);
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
const ll MAX_N = 200000;
 
int main(void){
    ll N;
    ll A[MAX_N];
    ll L[MAX_N + 1], R[MAX_N + 1];
    ll answer = INF * INF;
 
    /*
    after sorting in ascending order...
    A[i] <= b <= A[i + 1]
    f = (A[i + 1] - A[i])
      + (A[i + 2] - A[i - 1])
      + (A[i + 3] - A[i - 2])
      ...
      + (A[N - 1] - A[k]) or (A[k] - A[0])
      - (A[k - 1] + ... + A[0]) + b * k or + (A[N - 1] + ... + A[k + 1]) - b * .
    f = 
    */
 
    cin >> N;
    rep(i, N){
        cin >> A[i];
        A[i] -= i + 1;
    }
 
    sort(A, A + N);
    
    L[0] = 0;
    R[0] = 0;
    rep(i, N){
        L[i + 1] = L[i] + A[i];
        R[i + 1] = R[i] + A[N - i - 1];
    }
 
    rep(i, N + 1){
        ll cnt = R[N - i] - L[i];
        ll c = 2 * i - N;
        if (i == 0) answer = min(answer, R[N] - N * A[0]);
        else if (i == N) answer = min(answer, - L[N] + N * A[N - 1]);
        else answer = min({answer, cnt + c * A[i], cnt + c * A[i - 1]});
    }
 
    cout << answer << endl;
 
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
using namespace std;

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

int N, M;
vector<int> a[10];
int p[10];

int main() {
  cin >> N >> M;
  rep(i, M) {
    int temp;
    cin >> temp;
    a[i].resize(temp);
    rep(j, a[i].size()) {
      cin >> a[i][j];
    }
  }

  rep(i, M) {
    cin >> p[i];
  }

  bool f = true;
  int ans = 0;

  for(int bit = 0; bit < (1<<N); bit++) {
    f = true;
    for(int j = 0; j < M; j++) {
      int count = 0;
      for(int i = 0; i < a[j].size(); i++) {
        int temp = a[j][i] - 1;
        if(bit & (1<<temp)) {
          count++;
          // cout << bit << " " << a[j][i]-1 << endl;
        }
      }
      // cout << count << endl;
      if(count % 2 != p[j]) f = false;
    }
    if(f) ans++;
    // if(bit == 3) cout << endl << f << endl;
  }

  cout << ans << endl;
  // cout << N << endl;
  // cout << endl;
  // cout << a[1][0] << endl;
  // cout << a[0].size() << endl;
  // cout << a[1].size() << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const int INF=1e9;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  if(a==b || b==c || c==a){
    if(a==b && b==c){
      cout<<"No"<<endl;
      return 0;
    }else{
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;
}

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

#define Int register int

const int MAXN = 1e5;
int n, a[MAXN + 5];

inline void Work () {
	scanf ( "%d", &n );
	for ( Int i = 1; i <= n; ++ i ) scanf ( "%d", &a[i] );
	std :: sort ( a + 1, a + n + 1, []( const int x, const int y ) { return x > y; } );
	for ( Int i = 1; i <= n; ++ i ) {
		if ( i + 1 > a[i + 1] ) {
			int du = a[i] - i, dr = 0;
			for ( ; a[i + dr + 1] == i; ++ dr );
			puts ( du & 1 || dr & 1 ? "First" : "Second" );
			break;
		}
	}
}

int main () {
	Work ();
	return 0;
}

Measured memory_bytes: 512
import sys


s = sys.stdin.readline().split('/')
if int(s[0]) < 2019:
    ans = 'Heisei'
if int(s[0]) == 2019 and int(s[1]) <= 4:
    ans = 'Heisei'
else:
    ans = 'TBD'
print(ans)


Measured memory_bytes: 8976
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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; }

typedef long long ll;
using namespace std;

int main() {
    
    ll k, a, b;
    cin >> k >> a >> b;

    if (b - a <= 2ll || k == 1ll) {
        cout << k + 1ll << endl;
        return 0;
    }
    
    ll tp = k - a + 1ll; // torihiki phase
    ll g = (tp / 2ll) * (b - a);
    cout << a + g + tp % 2ll << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 

 
int main(void){
    string s;
    cin>>s;
    string ans ="";
    for(int i=0;i<s.length();i++){
        if(s[i]=='B'){
            if(ans.length()>0)ans.pop_back();
        }
        else ans.push_back(s[i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
string s;
int main(){
	int i,n;
	long long ans = 0;
	cin >> s;
	s.push_back('X');
	n = s.size();
	bool flag = false;
	int las = 1;
	long long cnt1 = 0,cnt2 = 0;
	for(i=0;i<n;i++){
		if(flag){
			if(s[i-1]=='A' && s[i]=='A'){
				cnt1++;
			}else if((s[i-1]=='A' || s[i-1]=='C') && s[i]=='B'){
				continue;
			}else if(s[i-1]=='B' && s[i]=='C'){
				cnt2++;
			}else{
				ans += cnt1*cnt2;
				cnt2 = 0;
				if(s[i]=='A'){
					if(s[i-1]=='C') cnt1++;
					else cnt1 = 1;
				}else{
					flag = false;
					cnt1 = 0;
				}
			}
		}else if(s[i]=='A'){
			cnt1 = 1;
			flag = true;
		}
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    vector<int> d(n);

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

    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            sum += d[i] * d[j];
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,m,i,j,k,l,x,y,z;
x=0;y=0;z=0;
char a[3];
scanf("%s",a);
if(a[0]=='a'||a[1]=='a'||a[2]=='a'){
if(a[0]=='b'||a[1]=='b'||a[2]=='b'){
if(a[0]=='c'||a[1]=='c'||a[2]=='c'){
x=1;}}}
if(x){printf("Yes\n");}else{printf("No\n");}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int X, Y, Z; cin >> X >> Y >> Z; 
	int N = X + Y + Z; 
	long long int sum = 0; 
	pair<long long, pair<long long, long long>> A[100010];  
	for(int i = 0; i < N; i++){
		long long int a, b, c; 
		cin >> a >> b >> c; 
		sum += c; 
		/* 単なる平行移動なのでC[i]たちは全部0にする */
		A[i].second.first = a - c; 
		A[i].second.second = b - c; 
		A[i].first = b - a; 
	}
	sort(A, A + N); 
	/* B[i]-A[i]でソートしているので，切れ目を全探索できる．逆転は起きない．*/ 
	vector<long long> D = {}; // Aの上位X個の和をiが小さい方から
	vector<long long> E = {}; // Bの上位Y個の和をiが大きい方から
	priority_queue<long long, vector<long long>, greater<long long>> Q1, Q2; 
	long long int s1 = 0, s2 = 0; 
	for(int i = 0; i < X; i++){
		Q1.push(A[i].second.first); 
		s1 += A[i].second.first; 
	}
	D.push_back(s1); 
	for(int i = X; i < X + Z; i++){
		long long int t = Q1.top(); 
		if(A[i].second.first > t){
			Q1.pop(); Q1.push(A[i].second.first); 
			D.push_back(D[D.size() - 1] - t + A[i].second.first); 
		}
		else{
			D.push_back(D[D.size() - 1]); 
		}
	}
	for(int i = N - 1; i >= N - Y; i--){
		Q2.push(A[i].second.second); 
		s2 += A[i].second.second; 
	}
	E.push_back(s2); 
	for(int i = N - Y - 1; i >= X; i--){
		long long int t = Q2.top(); 
		if(A[i].second.second > t){
			Q2.pop(); Q2.push(A[i].second.second); 
			E.push_back(E[E.size() - 1] - t + A[i].second.second); 
		}
		else{
			E.push_back(E[E.size() - 1]); 
		}
	}
	reverse(E.begin(), E.end()); 
	long long int mx = -1e18; 
	for(int i = 0; i <= Z; i++){
		mx = max(mx, D[i] + E[i]); 
	}
	cout << sum + mx << endl; 
}

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

int main(){
    int h,w,m;
   cin>>h>>w>>m;
   ll row[h]={0};
   ll clm[w]={0};
   set<pair<int,int>>s;
   while(m--){
     ll x,y;
     cin>>x>>y;
     s.insert({x-1,y-1});
     row[x-1]++;
     clm[y-1]++;
   }
   ll rmax=INT_MIN;
   ll cmax=INT_MIN;
   vector<ll>r,c;
    for(ll i=0;i<h;i++)
    rmax=max(rmax,row[i]);
    for(ll i=0;i<w;i++)
    cmax=max(cmax,clm[i]);
    for(ll i=0;i<h;i++){
        if(rmax==row[i])
        r.push_back(i);
    }
    for(ll i=0;i<w;i++){
        if(cmax==clm[i])
        c.push_back(i);
    }
        ll p=0;
    for(ll i=0;i<r.size();i++){
        for(ll j=0;j<c.size();j++){
            if(s.find({r[i],c[j]})==s.end()){
                p=1; break;
            }
        }
        if(p==1) break;
    }
    if(p==1)cout<<rmax+cmax;
    else cout<<rmax+cmax-1; 
    return 0;
}

Measured memory_bytes: 30248
import sys
n=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
    print(0)
    sys.exit()
d.sort()
mx=d[-1]
count=[0]*(mx+1)
MOD=998244353
for i in range(n):
    count[d[i]]+=1
c=1
#print(d,count)
if count[0]!=1:
    print(0)
    sys.exit()
for i in range(1,mx+1):
    c*=pow(count[i-1],count[i],MOD)
    c%=MOD
print(c)

Measured memory_bytes: 52824
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    int n;
    string s;

    while (cin >> n){
        if (n == 0){
            break;
        }

        cin >> s;
        for (int i = 0; i < n; i++){
            ostringstream oss;

            int j = 0;
            while (j < s.length()){
                int r = 0;
                char c = s[j];

                while (s[j] == c){
                    r++;
                    j++;
                }
                oss << r << c;
            }
            s = oss.str();
        }
        cout << s << endl;
    }

    return (0);
}

Measured memory_bytes: 1376
import java.util.Scanner;

public class Main {
    
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		for(;;){
			int x = s.nextInt();
			int h = s.nextInt();
			if(x==0)
				break;
			System.out.println(x*x+x*Math.sqrt(4*h*h+x*x));
		}
    }
}

Measured memory_bytes: 12000
//Zory-2018
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
#ifdef DEBUG
const int LOCAL=1;
#else
const int LOCAL=0;
#endif

namespace mine
{
	typedef long long ll;
	const int INF=0x3f3f3f3f;
	int qread()
	{
		int ans=0;char c=getchar();
		while(c<'0' or c>'9') c=getchar();
		while(c>='0' and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans;
	}
	void qwrite(ll num)
	{
		if(num>=10) qwrite(num/10);
		putchar('0'+num%10);
	}
	void qwriteln(ll num) {qwrite(num);puts("");}

	int mi1,mi2;
	void putmi(int num)
	{
		if(num<=mi1) mi2=mi1,mi1=num;
		else if(num<mi2) mi2=num;
	}
	int mx1,mx2;
	void putmx(int num)
	{
		if(num>=mx1) mx2=mx1,mx1=num;
		else if(num>mx2) mx2=num;
	}
	int a[100010];
	void main()
	{
		int n;scanf("%d",&n);
		ll all=0;
		for(int i=1;i<=n;i++) scanf("%d",&a[i]),all+=a[i];
		sort(a+1,a+n+1);

		ll ans=0;

		if(n&1)
		{
			//more
			ll sum=0;for(int i=n/2+1;i<=n;i++) sum+=a[i];
			mi1=INF,mi2=INF;
			for(int i=n/2+1;i<=n;i++) putmi(a[i]);
			ans=max(ans,sum*2-mi1-mi2-(all-sum)*2);

			sum=0;for(int i=n/2+2;i<=n;i++) sum+=a[i];
			mx1=0,mx2=0;
			for(int i=1;i<=n/2+1;i++) putmx(a[i]);
			ans=max(ans,sum*2-(2ll*(all-sum)-mx1-mx2));
		}
		else
		{
			mi1=INF,mi2=INF;
			ll sum=0;for(int i=n/2+1;i<=n;i++) putmi(a[i]),sum+=a[i];
			int t=0;for(int i=1;i<=n/2;i++) t=max(t,a[i]);
			ans=max(ans,sum*2-mi1-(all-sum)*2+t);
			//printf("%lld\n",sum*2-mi1);
		}
		printf("%lld",ans);
	}
};
int main()
{
	mine::main();
}


Measured memory_bytes: 640
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(int(input()) for _ in range(n))

    LIS = [A[0]]
    for i in range(n):
        if A[i] > LIS[-1]:
            LIS.append(A[i])
        else:
            idx = bisect_left(LIS, A[i])
            LIS[idx] = A[i]
    print(len(LIS))


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 10408
import java.util.*;

public class Main{
	public static void main(String[]args){
		
		Scanner sc=new Scanner(System.in);
		
		String c1=sc.next();
		String c2=sc.next();
		String s1[]=c1.split("");
		String s2[]=c2.split("");
		boolean ans=true;
		
		for(int i=0;i<3;i++){
			
			if(s1[i].equals(s2[2-i])){
				
			}else{
				ans=false;
			}
		
		}
		
		
	if(ans==true){
		System.out.println("YES");
	}else{
		System.out.println("NO");
	}
	
	}
}

Measured memory_bytes: 23252
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long ac = 0;
        int[] hArray = new int[n];
        for(int i = 0; i < n; i++) hArray[i] = Integer.parseInt(sc.next());
        Arrays.sort(hArray);
        n -= k;
        for(int i = 0; i < n; i++) ac += hArray[i];
        System.out.println(ac);
    }
}

Measured memory_bytes: 62448
# -*- coding: utf-8 -*-
import math
import sys


N = int(sys.stdin.readline().rstrip())

def solve(n):
  for i in range((n//4)+1):
    if (n-i*4)%7 == 0:
      return True
  return False

if solve(N):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    if(abs(a-b)%2==0)
    	cout<<"Alice"<<endl;
    else
    	cout<<"Borys"<<endl;
    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100001

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}


int main(){
  int H,W,h,w,i,ans=0;
  scanf("%d%d%d%d",&H,&W,&h,&w);

  printf("%d\n",H*W-h*W-H*w+h*w);
	return 0;
}


Measured memory_bytes: 128