akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>

int main() {
   
   long long int A;
   long double B;
   
   std::cin >> A >> B;
   
   B = B + 0.000001;
   
   long long int B_new = B*100;
   
   long long int ans = (A*B_new)/100;
   
   std::cout << ans << std::endl;
   
   return 0;
   
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define X first
#define Y second
#define sz(v) (int)v.size()

void solve();

main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ONPC
	freopen("in.txt", "r", stdin);
#endif
	int t = 1;
	//cin >> t;
	while (t--) solve();
	return 0;
}

const int N = 2005;
int n, k, q, a[N], ans = 1e9 + 7;

void solve() {
	cin >> n >> k >> q;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) {
		int tek = a[i];
		vector<int> cur, get;
		for (int j = 1; j <= n + 1; ++j) {
			if (j == n + 1 || a[j] < tek) {
				if (sz(cur) == 0) continue;
				sort(cur.begin(), cur.end());
				for (int z = 0; z < sz(cur) - k + 1; ++z) get.pb(cur[z]);
				cur.clear();
			} else cur.pb(a[j]);
		}
		sort(get.begin(), get.end());
		if (sz(get) < q) continue;
		ans = min(ans, get[q - 1] - tek);
	}
	cout << ans;
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
su = sum(a)-a[0]
ans = abs(a[0]-su)
curr=a[0]
for i in range(1,n-1):
    su-=a[i]
    curr+=a[i]
    ans = min(ans,abs(su-curr))
print(ans)


Measured memory_bytes: 3060
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
	line := nextLine()

	spl := intSprit(line)

	A, B, K := spl[0], spl[1], spl[2]

	top := 0
	if A >= B {
		top = B
	} else {
		top = A
	}

	t := []int{}

	for i := 1; i <= top; i++ {
		if A%i == 0 && B%i == 0 {
			t = append(t, i)
		}
	}

	if len(t)-K >= 0 {
		fmt.Println(t[len(t)-K])
	}

}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(N: int, W: "List[int]"):
    _sum = sum(W)
    __s = 0
    for i in range(N):
        __s += W[i]
        if __s >= _sum / 2:
            diff_l = sum(W[i:]) - sum(W[:i])
            diff_r = sum(W[:i + 1]) - sum(W[i + 1:])
            break
    if diff_l < diff_r:
        print(diff_l)
    else:
        print(diff_r)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)
    if ac[p-1] == 1:
        continue
    if s=='AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 1
AC=0
WA=0
for i in range(n):
    AC += ac[i]
    if ac[i] == 1:
        WA += wa[i]
print("{} {}".format(AC,WA))


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

int main() {
  int N;
  cin >> N;
  if(N == 1)
    cout << "Hello World" << endl;
  else if(N == 2) {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
}

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

using namespace std;

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

	int size = S.size();


	if (S == T)
	{
		cout << "Yes" << endl;
		return 0;
	}

	for (int i = 1; i < size; i++)
	{
		char t = T.back();
		for (int j = size - 1; j >= 1; j--)
		{
			T[j] = T[j - 1];
		}
		T[0] = t;

		if (S == T)
		{
			cout << "Yes" << endl;
			return 0;
		}

	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100

int main(void)
{
    int i, j, k;

    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);

    int a_mat[MAX][MAX];
    for (i = 0; i < n; i++){
        for (j = 0; j < m; j++){
            scanf("%d", &a_mat[i][j]);
        }
    }

    int b_mat[MAX][MAX];
    for (i = 0; i < m; i++){
        for (j = 0; j < l; j++){
            scanf("%d", &b_mat[i][j]);
        }
    }

/*    for (i = 0; i < n; i++){
        for (j = 0; j < l; j++){
            int c = 0;
            for (k = 0; k < m; k++){
                c += a_mat[i][k] * b_mat[k][j];
            }
            if (j != 0){
                printf(" ");
            }
            printf("%d", c);
        }
        printf("\n");
    }*/

    long c_mat[MAX][MAX];
    for (i = 0; i < n; i++){
        for (j = 0; j < l; j++){
            c_mat[i][j] = 0;
            for (k = 0; k < m; k++){
                c_mat[i][j] += a_mat[i][k] * b_mat[k][j];
            }
        }
    }

    for (i = 0; i < n; i++){
        for (j = 0; j < l; j++){
            if (j != 0){
                printf(" ");
            }
            printf("%ld", c_mat[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
    ll h,a;
    cin>>h>>a;
    if(h%a==0)
        cout<<h/a<<endl;
    else
        cout<<(h/a)+1<<endl;
}

int main()
{

    //freopen("Input.txt","r",stdin);
    ios_base :: sync_with_stdio(false);
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}


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

int main()
{
    int n;
    std::cin >> n;
    std::string s;
    std::cin >> s;
    int cnt = 0;
    for(int i = 1; i < n ;i++){
        if(s[i] != s[i - 1])cnt++;
    }
    std::cout << cnt + 1 << std::endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

#define x first
#define y second

inline int getArea(int x1, int y1, int x2, int y2, int x3, int y3) {
    return abs((x1-x2)*(y3-y2)-(x3-x2)*(y1-y2));
}

int main() {
    int n;
    while (cin >> n, n) {
        map<int, bool> has;

        vector<pair<int,int> > co(n);
        for (int i=0; i<n; ++i) {
            cin >> co[i].x >> co[i].y;
            has[co[i].x+10000*co[i].y] = true;
        }
        sort(co.begin(), co.end());

        int area = 0;
        for (int i=0; i<(int)co.size(); ++i) {
            for (int j=i+1; j<(int)co.size(); ++j) {
                int dx, dy, x3, y3, x4, y4;
                dx = co[j].x - co[i].x;
                dy = co[j].y - co[i].y;
                x3 = co[j].x - dy;
                y3 = co[j].y + dx;
                x4 = co[i].x - dy;
                y4 = co[i].y + dx;
                if (has.count(x3+10000*y3) && has.count(x4+10000*y4)) {
                    area = max(area, getArea(co[i].x, co[i].y, co[j].x, co[j].y, x3, y3));
                }
            }
        }
        cout << area << endl;
    }
    return 0;
}

Measured memory_bytes: 1360
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

int s,n,t,p,m;
string w,ti;
int can[11000];
const int halfday = 720;
const int week = 10080;

int main(){
  while(cin >> s >> n >> t >> w >> ti >> p >> m,w!="None"){
    for(int i=0;i<week;i++)can[i] = false;

    int loop = (w == "All")?7:1;
    
    if(ti == "All"){
      for(int i=0;i<loop;i++){
	for(int j=0;j<2*halfday;j++)can[i*2*halfday+j] = true;
      }
    }else if(ti == "Day"){
      for(int i=0;i<loop;i++){
	for(int j=0;j<halfday;j++){
	  can[i*2*halfday + j + halfday/2] = true;
	}
      }
    }else{
      for(int i=0;i<loop;i++){
	for(int j=0;j<halfday/2;j++){
	  can[i*2*halfday + j] = true;
	  can[i*2*halfday + j + 3*halfday/2] = true;
	}
      }
    }

    int res = 0;
    int lim = (w=="All")?2*halfday:week;
    for(int start = 0;start < lim; start++){
      int now = start;
      int cnt = 0;
      for(int i=0;i<m;i++){
	if(can[now%week] && can[(now+s)%week])cnt++;
	now += t;
      }
      res = max(res,cnt);
    }
    printf("%.10lf\n",1-pow(1-1.0/p,n*res));
  }
}

Measured memory_bytes: 1308
import java.util.*;

public class Main {
    Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        new Main();
    }

    public Main(){
    	new AOJ().doIt();
    }
    
    class AOJ{
    	void doIt(){
    		while(in.hasNext()){
    			int a = in.nextInt();
        		int b = in.nextInt();
        		System.out.println(Integer.toString(a+b).length());
    		}
    	}
    }
    
}

Measured memory_bytes: 20452
#include <iostream>
#include <utility>
#include <stdint.h>
#include <set>

using namespace std;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;

  set<int> X;
  X.insert(A);
  X.insert(B);
  X.insert(C);

  cout << (X.size()==2 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrr
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ls = new List<int>();
            for (int i = 0; i < s[0]; i++)
            {
                ls.Add(int.Parse(ReadLine()));
            }
            ls.Sort();

            long ans = 1;
            int now = 1;int first = ls[0];
            for (int i = 1; i < s[0]; i++)
            {
                if (now == s[1])
                {
                    ans++;
                    now = 1;
                    first = ls[i];
                }
                else if (ls[i] - first <= s[2])
                {
                    now++;
                }
                else
                {
                    ans++;
                    now = 1;
                    first = ls[i];
                }
            }
            WriteLine(ans);
        }
    }
}


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

using namespace std;

using ll = long long;

constexpr ll MOD = 1e9 + 7;

constexpr inline ll Plus(const ll &x, const ll &y) {
    ll ret = x + y;
    ret %= MOD;
    return ret;
}

int main() {
    int H, W;
    cin >> H >> W;

    std::vector<std::vector<bool>> a(H, std::vector<bool>(W));
    {
        char c;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                cin >> c;
                a[i][j] = c == '#';
            }
        }
    }

    std::vector<std::vector<ll>> dp(H + 1, std::vector<ll>(W + 1, 0));
    dp[0][0] = 1;

    for (ll dph = 0; dph < H; ++dph) {
        for (ll dpw = 0; dpw < W; ++dpw) {
            if (dph + 1 < H && a[dph + 1][dpw] == false) {
                dp[dph + 1][dpw] = Plus(dp[dph + 1][dpw], dp[dph][dpw]);
            }
            if (dpw + 1 < W && a[dph][dpw + 1] == false) {
                dp[dph][dpw + 1] = Plus(dp[dph][dpw + 1], dp[dph][dpw]);
            }
        }
    }

    cout << dp[H - 1][W - 1] << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    int e;
    cin >> e;
    a[e - 1] = i;
  }
  int r = n;
  set<int> s;
  for (auto e : a) {
    if (!s.empty() && *s.begin() < e) r--;
    s.insert(e);
  }
  cout << r << endl;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll div_(ll x, ll y) {
    ll ret = x / y;
    return ret;
}

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

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = lcm(c, d);
    ll x = div_(b, c) - div_(a-1, c);
    ll y = div_(b, d) - div_(a-1, d);
    ll z = div_(b, e) - div_(a-1, e);
    cout << (b-a+1 - (x + y - z)) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NIL (2e9+1)
#define N 2000

typedef struct{
  int l,r,p;
  int key;
}E;

E A[N];

int left(int i,int H){
  if(2 * i > H){
    return NIL;
  }
  return A[2 * i].key;
}

int right(int i,int H){
  if(2 * i + 1 > H){
    return NIL;
  }
  return A[2 * i + 1].key;
}

int parent(int i){
  if(i == 1){
    return NIL;
  }
  return A[i/2].key;
}

int main(){
  int H,i;
  scanf("%d",&H);

  for(i=1;i<=H;i++){
    scanf("%d",&A[i].key);
  }
  for(i=1;i<=H;i++){
    A[i].l = left(i,H);
    A[i].r = right(i,H);
    A[i].p = parent(i);
  }
  // printf("%d",A[0].r);

  for(i=1;i<=H;i++){
    printf("node %d: key = %d,",i,A[i].key);
    if(A[i].p != NIL)printf(" parent key = %d,",A[i].p);
    if(A[i].l != NIL)printf(" left key = %d,",A[i].l);
    if(A[i].r != NIL)printf(" right key = %d, \n",A[i].r);
    else printf(" \n");
  }
  
  return 0;
}
  



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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 500005
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int32_t main(){
	IOS;
	int tt = 1; 
	//cin >> tt;
	while(tt--){
			char c; cin >> c;
			if(c >= 'A' and c <= 'Z') cout << 'A';
			else cout << 'a';
	
	}
	return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
using namespace std;
int n;
int a[1010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]&1) continue;
		if(a[i]%3!=0 && a[i]%5!=0)
		{
			printf("DENIED\n");
			return 0;
		}
	}
	printf("APPROVED\n");
	return 0;
}

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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造

//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false; // 1や0,-1は素数ではない
  }
  if (x == 2) {
    return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false; // 割れたら素数じゃない
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<char>> A(N, vector<char>(N));
  vector<vector<char>> B(M, vector<char>(M));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> B.at(i).at(j);
    }
  }
  bool ans = false;
  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      bool ok = true;
      for (int k = i; k < i + M; k++) {
        for (int l = j; l < j + M; l++) {
          if (A.at(k).at(l) != B.at(k - i).at(l - j)) {
            ok = false;
          }
        }
      }
      if (ok) {
        ans = true;
      }
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

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

ll dp[110][100010];


int main(){
  int N,W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  rep(i,N){
    cin >> w[i] >> v[i];
  }
  rep(i,110){
    rep(j,100010){
      dp[i][j]=INF;
    }
  }
  dp[0][0]=0;
  rep(j,100010){
    rep(i,N){
      chmin(dp[i+1][j],dp[i][j]);
      chmin(dp[i+1][j+v[i]],dp[i][j]+w[i]);
    }
  }
  ll ans;
  rep(j,100010){
    if(dp[N][j]<=W)
      ans=j;//ans=dp[N][j]ではない
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 86144
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = ll(1e9 + 7);

vector<vector<ll>> dp1;
vector<vector<ll>> dp2;

int main(void) {
    string S;
    cin >> S;
    int slen = (int) S.size();
    S = " " + S;

    int K;
    cin >> K;

    dp1.resize(slen + 1, vector<ll>(105, 0));
    dp2.resize(slen + 1, vector<ll>(105, 0));
    dp1[0][0] = 1;

    for (int i = 0; i < slen; i++) {
        int d = S[i + 1] - '0';

        for (int j = 0; j <= K; j++) {
            // dp1
            if (d == 0) {
                dp1[i + 1][j] = (dp1[i + 1][j] + dp1[i][j]) % MOD;
            } else {
                dp1[i + 1][j + 1] = (dp1[i + 1][j + 1] + dp1[i][j]) % MOD;
            }

            // dp2
            dp2[i + 1][j] = (dp2[i + 1][j] + dp2[i][j]) % MOD; // when use 0

            dp2[i + 1][j + 1] = (dp2[i + 1][j + 1] + 9 * dp2[i][j]) % MOD; // when use other than 0
            // printf("i: %d, j: %d, dp2[i][j]: %lld, dp2[i + 1][j + 1]: %lld\n", i, j, dp2[i][j], dp2[i + 1][j + 1]);

            if (d != 0) {
                dp2[i + 1][j] = (dp2[i + 1][j] + dp1[i][j]) % MOD; // when use 0.
            }

            for (int k = 1; k < d; k++) {
                dp2[i + 1][j + 1] = (dp2[i + 1][j + 1] + dp1[i][j]) % MOD; // when use other than 0
            }
        }
    }

    cout << dp1[slen][K] + dp2[slen][K] << endl;

    // printf("dp1: \n");
    // for (int i = 0; i <= slen; i++) {
    //     for (int j = 0; j <= K; j++) {
    //         cout << dp1[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    // printf("dp2: \n");
    // for (int i = 0; i <= slen; i++) {
    //     for (int j = 0; j <= K; j++) {
    //         cout << dp2[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,m;
  cin>>n>>m;
  priority_queue<int> q;
  for(int i : irange(0, n)) {
    int a;
    cin>>a;
    q.push(a);
  }
  for (int i : irange(0, m)) {
    int v = q.top();
    q.pop();
    q.push(v/2);
  }
  ll sum = 0;
  while (!q.empty()) {
    int v = q.top();
    q.pop();
    sum += v;
  }
  cout<<sum<<endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ref = a[0];
    for (int i = 1; i < n; ++i)
        ref ^= a[i];

    rep(i, n) cout << (a[i] ^ ref) << " ";
    cout << endl;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;

int main(void) {

	int seito;
	cin >> seito;

	std::map<int, int> zaishitusu;

	for (int i = 0; i < seito; i++) {
		int temp;
		cin >> temp;
		zaishitusu[temp-1] = i;
	}

	for (int i = 0; i < seito; i++) {
		cout << zaishitusu.at(i) + 1 << " ";
	}
}




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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	int ind[n + 1];
	for1(i, n)
		scanf("%d", &ind[i]);
	int ans[n + 1];
	for(int i = n; i > 0; i--) {
		int total = 0;
		for(int j = i * 2; j <=n; j+=i) {
			total += ans[j];
		}
		if((total + 1) % 2 == ind[i])
			ans[i] = 1;
		else
			ans[i] = 0;
	}
	int max = 0;
	for1(i, n) {
		if(ans[i])
			max++;
	}
	printf("%d\n", max);
	for1(i, n) {
		if(ans[i])
			printf("%d ", i);
	}







	return 0;
}

Measured memory_bytes: 2432
import sys
import math

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, H, M = map(int, input().split())

AX = 30.0 * H + M / 2.0
BX = M * 6.0

D = AX - BX

ANS = A ** 2 + B ** 2 - 2 * B * A * math.cos(math.radians(D))

print(math.sqrt(ANS))


Measured memory_bytes: 9484
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 300000;

int d, t, s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> d >> t >> s;
    
    if (s * t >= d)
        cout << "Yes";
    else
        cout << "No";
    
    return 0;
}


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

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    for (size_t i = 1; i < s.size(); i++) {
        if (s[i] == s[i - 1]) {
            cout << i << " " << i + 1 << endl;
            return 0;
        }
    }
    
    for (size_t i = 2; i < s.size(); i++) {
        if (s[i] == s[i - 2]) {
            cout << i - 1 << " " << i + 1 << endl;
            return 0;
        }
    }
    
    cout << "-1 -1" << endl;
    return 0;
}



Measured memory_bytes: 512
/* https://img.atcoder.jp/arc077/editorial.pdf */
#include <stdio.h>
#include <string.h>

#define N	200000
#define A	26
#define K	100

int max(int a, int b) { return a > b ? a : b; }

int period(char *cc, int n) {
	static int zz[N];
	int i, l, r;

	for (i = 1, l = r = 0; i < n; i++)
		if (zz[i - l] < r - i)
			zz[i] = zz[i - l];
		else {
			l = i, r = max(r, l);
			while (r < n && cc[r] == cc[r - l])
				r++;
			zz[i] = r - l;
		}
	for (i = 1; i < n; i++)
		if (zz[i] == n - i)
			break;
	return i;
}

long long ans[A];

void solve(char *cc, int n, int m, long long r, int sign) {
	static long long len[K], cnt[K][A];
	int h, i, a, k;

	len[0] = m, memset(cnt[0], 0, sizeof cnt[0]);
	for (i = 0; i < m; i++)
		cnt[0][cc[i] - 'a']++;
	len[1] = n, memset(cnt[1], 0, sizeof cnt[1]);
	for (i = 0; i < n; i++)
		cnt[1][cc[i] - 'a']++;
	k = 2;
	while (len[k - 1] < r) {
		len[k] = len[k - 1] + len[k - 2];
		for (a = 0; a < A; a++)
			cnt[k][a] = cnt[k - 1][a] + cnt[k - 2][a];
		k++;
	}
	for (h = k - 1; h >= 0; h--)
		if (r >= len[h]) {
			for (a = 0; a < A; a++)
				ans[a] += cnt[h][a] * sign;
			r -= len[h];
		}
	for (i = 0; i < r; i++)
		ans[cc[i] - 'a'] += sign;
}

int main() {
	static char cc[N + 1];
	int n, m, a;
	long long l, r;

	scanf("%s%lld%lld", cc, &l, &r), n = strlen(cc) / 2, l--;
	m = period(cc, n);
	solve(cc, n, m, r, 1), solve(cc, n, m, l, -1);
	for (a = 0; a < A; a++)
		printf("%lld ", ans[a]);
	printf("\n");
	return 0;
}


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

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

	int sum = 0;
	for (int i = 0; i < S.size(); i++) {
		char s1 = S[i];
		char t1 = T[i];

		if (S[i] != T[i]) {
			sum++;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

bool check(char c){
  string s = "S123456789";
  FOR(i,0,10)if(s[i] == c)return 1;
  return 0;
}

int ctoi(char c){
  string s = "S123456789";
  FOR(i,0,10)if(c == s[i])return i;
  return 0;
}

int main(){
  int H,W,N,ans=0;
  int dx[] = {1,-1,0,0};
  int dy[] = {0,0,1,-1};
  cin >> H >> W >> N;
  vector<int> perm(N);
  char c[H+2][W+2];
  FOR(i,0,H+2)FOR(j,0,W+2)c[i][j] = '#';
  FOR(i,0,N)perm[i] = i+1;
  vector<pair<int,int>> factory(N+1);
  FOR(i,1,H+1)FOR(j,1,W+1){
    cin >> c[i][j];
    if(check(c[i][j])){
      factory[ctoi(c[i][j])] = make_pair(i,j);
      c[i][j] = '.';
    }
  }
  FOR(i,0,N){
    int bfs[H+2][W+2];
    FOR(j,0,H+2)FOR(k,0,W+2)bfs[j][k] = -1;
    queue<pair<int,int>> que;
    que.push(factory[i]);
    bfs[factory[i].first][factory[i].second] = 0;
    while(que.size()){
      FOR(j,0,4){
        int x = que.front().first + dx[j];
        int y = que.front().second + dy[j];
        if(c[x][y] == '.' && bfs[x][y] == -1){
          que.push(make_pair(x,y));
          bfs[x][y] = 1+bfs[que.front().first][que.front().second];
        }
      }
      que.pop();
    }
    ans += bfs[factory[i+1].first][factory[i+1].second];
  }
  cout << ans << endl;
}



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

int main() {
	int n;
	string s;
	cin >> n >> s;
	rep(i, s.size()) {
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int k;
int is_palindrome(int ini,int fim){
    while(ini<fim){
        if(s[ini]!=s[fim])return 0;
        ini++;
        fim--;
    }
    return 1;
}


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

    cin>>s;
    k=(int)s.size();
    if(is_palindrome(0,k-1) && is_palindrome(0,(k-1)/2-1) && is_palindrome((k+3)/2-1,k-1)){
       cout<<"Yes";
       }

    else cout<<"No";


}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    vector<int> v(3);
    REP(i,3)cin>>v[i];
    sort(v.begin(),v.end());
    cout<<v[0]+v[1]<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            //
            var cin = GetIntArray();
            var ans = YesNo(cin[0] + cin[1] >= cin[2]);

            Console.WriteLine(ans);

            //
            Console.Out.Flush();
            Console.ReadKey();
        }

        static void Solve()
        {

        }

        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 13396
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, x ] <- readInts
	xs <- sort . ( x : ) <$> readInts
	print $ ( \l -> if length l == 1 then head l else foldl1 gcd l ) $ differences xs

differences [_] = []
differences ( a : rest@( b : xs ) ) = ( b - a ) : differences rest

Measured memory_bytes: 21884
#include <stdio.h>
#include<string.h>
int main(void) {
	// your code goes here
int a,b,i,flag,k;
scanf("%d%d",&a,&b);
flag=0;
i=(a>b)?b:a;
k=(a>b)?a:b;
for(i;i<=k;i++)
{
if((i*a*b)%2!=0)
{
flag=1;
}
}
if(flag==1)
{
printf("Yes");

}else{
printf("No");
}
return 0;
}



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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define full_auto(x) for(auto it=x.begin();it!=x.end();it++)
#define pdd pair<double,double>
#define pii pair<int,int>
#define PQ priority_queue
#define setp setprecision
#define sqr(a) ((a)*(a))
#define el cout<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define ins insert
#define re return
#define se second
#define fi first
const int INF=(int)INFINITY;

ll a,b,c,x,y;
ll ans=INF;

int main(){
	cin>>a>>b>>c>>x>>y;
	for (ll i=0;i<=max(x,y)*2;i+=2){
		ans=min(ans,c*i+max(0ll,x-i/2)*a+max(0ll,y-i/2)*b);
	}
	cout<<ans;
	re 0;
}

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

int main() {
  string s;
  cin >> s;

  int i = 0;
  while(s[i] != 'A') {
    i++;
  }

  int j = s.length() - 1;
  while(s[j] != 'Z') {
    j--;
  }

  cout << j - i + 1 << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll g1(ll n,ll p){
    if(n==0)return 0;
    ll res =n/p;
    res+=g1(n/p,p);
    return res;
}
ll g2(ll n,ll p){
    if(n%2)return 0;
    ll res =0;
    if(p==2)res+=n/2;
    res = g1(n/2,p);
    return res;
}
int main(){
    ll n;
    cin >> n;
    ll ans = min(g2(n,5),g2(n,2));
    cout << ans << endl;
    


}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll n;
	cin>>n;
	vs v(n);
	scan(v, 0, n);
	map< vlli, ll > m;
	forn(i, 0, n){
		vlli vv(26, 0);
		forn(j, 0, v[i].size()){
			vv[(int)(v[i][j] - 'a')]++;
		}
		m[vv]++;
	}
	map<vlli, ll>::iterator it;
	ll ans = 0;
	for(it = m.begin(); it!=m.end(); it++){
		ll x = it->S;
		ans += (x*(x-1))/2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 35812
// AC

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

#define INF 1000000001
typedef long long int ll;

int main()
{
  // INPUT
  int n,w; cin >> n >> w;
  int wt[n+1];
  ll  val[n+1];
  for(int i=0;  i<n; i++) cin >> wt[i+1] >> val[i+1];

  // INIT
  ll dp[n+1][w+1]={};

  // Base case already done: dp[0][j]=0;
  // i.e. in this q, base case is processed directly in the loop using dp[0][j]

  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=w;j++)
    {
      // dp[i][j+1] is the max val
      // at ith element (cumulative from the 1st element)
      // with j weight used
      ll a = dp[i-1][j];
      ll b = 0;
      if(wt[i]<=j) b = val[i] + dp[i-1][j - wt[i]];
      dp[i][j] = max(a,b);
    }
  }

  // OUTPUT
  cout << dp[n][w] << endl;
}


Measured memory_bytes: 82496
#include<iostream>
using namespace std;
int main(){
  int money;
  int change;
  while(cin >> money,money){
  money=1000-money;
  change=0;
  while(money){
    if(money>=500){
      change++;
      money-=500;
    }
    else if(money>=100){
      change++;
      money-=100;
    }
    else if(money>=50){
      change++;
      money-=50;
    }
    else if(money>=10){
      change++;
      money-=10;
    }
    else if(money>=5){
      change++;
      money-=5;
    }else{
      change++;
      money-=1;
    }
  }
  cout << change << endl;
}
}

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

int sum(vector<vector<int>> &C) {
  int s = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) s += C.at(i).at(j);
  }
  return s;
}

int diagonal(vector<vector<int>> &C) {
  int d = 0;
  for (int i = 0; i < 3; i++) d += C.at(i).at(i);
  return d;
}

int main() {
  int i, j;
  vector<vector<int>> C(3, vector<int>(3));
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) cin >> C.at(i).at(j);
  }
  
  string s = "No";
  if (sum(C) == diagonal(C) * 3) s = "Yes";
  
  cout << s << endl;
}


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

template <typename T>
class avl_tree {
	struct node {
		T val;
		int dep;
		node *ch[2];
		node() : node(0) {}
		node(T v, node* l = nullptr, node* r = nullptr)
			: val(v), dep(1), ch{ l, r } {}
		void *operator new(size_t) {
			static const int pmax = 2e5; // number of nodes
			static int p = 0;
			static node pool[pmax];
			return pool + p++;
		}
	};
	int depth(node *t) { return !t ? 0 : t->dep; }
	node *update(node *t) {
		t->dep = max(depth(t->ch[0]), depth(t->ch[1])) + 1;
		return t;
	}
	node *rotate(node *t, int b) {
		node *s = t->ch[!b];
		t->ch[!b] = s->ch[b];
		s->ch[b] = t;
		update(t);
		return update(s);
	}
	node *fix(node *t) {
		if (!t) return t;
		int dd = depth(t->ch[0]) - depth(t->ch[1]);
		if (abs(dd) < 2) return t;
		int b = dd < 0;
		if (depth(t->ch[b]->ch[!b]) > depth(t->ch[b]->ch[b])) {
			t->ch[b] = rotate(t->ch[b], b);
		}
		return rotate(t, !b);
	}
	node *insert(node *t, T val) {
		if (!t) {
			++cnt;
			return new node(val);
		}
		if (val == t->val) return t;
		int b = val > t->val;
		t->ch[b] = insert(t->ch[b], val);
		return fix(update(t));
	}
	T minimum(node *t) {
		while (t->ch[0]) t = t->ch[0];
		return t->val;
	}
	node *erase(node *t) {
		if (!t) return t;
		if (!t->ch[0]) return t->ch[1];
		if (!t->ch[1]) return t->ch[0];
		T mini = minimum(t->ch[1]);
		++cnt;
		return fix(update(new node(mini, t->ch[0], erase(t->ch[1], mini))));
	}
	node *erase(node *t, T val) {
		if (!t) return t;
		if (val == t->val) {
			--cnt;
			return fix(erase(t));
		}
		int b = val > t->val;
		t->ch[b] = erase(t->ch[b], val);
		return fix(update(t));
	}
	node *root;
	int cnt;
public:
	avl_tree() : root(nullptr), cnt(0) {}
	int size() {
		return cnt;
	}
	void insert(T val) {
		root = insert(root, val);
	}
	void erase(T val) {
		root = erase(root, val);
	}
	bool count(T val) {
		node *t = root;
		while (t) {
			if (t->val == val) return true;
			t = t->ch[val > t->val];
		}
		return false;
	}
};

int main()
{
	int q;
	scanf("%d", &q);
	avl_tree<int> st;
	while (q--) {
		int t, x;
		scanf("%d%d", &t, &x);
		switch (t) {
		case 0:
			st.insert(x);
			printf("%d\n", st.size());
			break;
		case 1:
			printf("%d\n", st.count(x));
			break;
		default:
			st.erase(x);
		}
	}
	return 0;
}



Measured memory_bytes: 7912
#include <bits/stdc++.h>  // ver2.2.5
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,i) upper_bound(ALL(a),i)-lower_bound(ALL(a),i)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(iY,0,a.size()){Verr(a[iY]);}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,k;
  cin >> n >> k;
  Vi a(n);
  Vin(a);
  int sum = 0,ct;
  int ans = 0;
  PQir my;
  
  repreq(i,k,1){
    PQir my;
    sum = 0;
    ct = k-i;
    if(i >= n){
      rep(j,0,n) {
        sum += a[j];
        my.push(a[j]);
      }
      rep(j,0,ct) {
        if(my.size()==0) break;
        if(my.top() >= 0) break;
        sum += abs(my.top());
        my.pop();
      }
      cerr << sum <<endl;
      ans = max(ans,sum);
    }
    else {
      rep(j,0,i+1){
        PQir my;
        sum = 0;
        ct = k-i;
        rep(K,0,j){
          my.push(a[K]);
          sum += a[K];
        }
        rep(K,0,i-j){
          my.push(a[n-1-K]);
          sum += a[n-1-K];
        }
        
        rep(K,0,ct) {
          if(my.size()==0) break;
          if(my.top() >= 0) break;
          else {
            sum += abs(my.top());
            my.pop();
          }
        }
        cerr << sum _ k-i _ j _ i-j <<endl;
        ans = max(ans,sum);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/********** TEMPLATE ENDS HERE ***********/

main()
{
	IOS
	
	int n, m;
	cin >> n >> m;
	
	if(n > m)
		swap(n, m);
	
	if(n == 1 && m == 1)
	{
		cout << 1;
	}
	else
		if(n == 1)
		{
			cout << m - 2;
		}
		else
		{
			cout << (n - 2LL) * (m - 2);
		}
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
hun = 6*M * math.pi/180
ji = (30*H + M/2)*math.pi/180
print((A**2 + B**2 -2*A*B*math.cos(max(hun, ji) - min(hun, ji)))**(1/2))


Measured memory_bytes: 9500
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{   
    class Template
    {
        static void Main(string[] args)
        {
            var data = IO.ReadStrArr();
            if (data[1] == "+") WriteLine(int.Parse(data[0]) + int.Parse(data[2]));
            else WriteLine(int.Parse(data[0]) - int.Parse(data[2]));
        }
    }

    public class IO
    {
        public static string ReadStr() => Console.ReadLine();
        public static string[] ReadStrArr() => ReadStr().Split(' ');
        public static int ReadInt() => int.Parse(ReadStr());
        public static int[] ReadIntArr() => Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        public static double ReadDouble() => double.Parse(ReadStr());
        public static double[] ReadDoubleArr() => Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
        public static long ReadLong() => long.Parse(ReadStr());
        public static long[] ReadLongArr() => Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
    }
}


Measured memory_bytes: 13140