akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int M[100010][4];
int dp[100010][4];
int g(int i , int sw){
    if(i == 0 ) return 0;
    if(dp[i][sw]!=-1) return dp[i][sw];
    if(sw == 0){
        dp[i][sw] = max(g(i-1,1)+M[i][1],g(i-1,2)+M[i][2]);
    }else{
        if(sw==1){
            dp[i][sw] = max(g(i-1,0)+M[i][0],g(i-1,2)+M[i][2]);
        }else{
            dp[i][sw] = max(g(i-1,0)+M[i][0],g(i-1,1)+M[i][1]);
        }
    }
    return dp[i][sw];
}
int main(){
    memset(dp,-1,sizeof dp);
    memset(M,0,sizeof M);
    int n;cin>>n;
    for(int i = 1 ; i <= n ; i++){
        cin>>M[i][0]>>M[i][1]>>M[i][2];
    }
    int res = max(g(n,1),g(n,0));
    res = max(res,g(n,2));
    cout<<res<<"\n";
    return 0;
}



Measured memory_bytes: 8064
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n):
    for j in range(i + 1, n):
        if j * 2 - i >= n:
            continue
        if s[i] == s[j] or s[j] == s[2 * j - i] or s[i] == s[2 * j - i]:
            continue
        ans -= 1

print(ans)


Measured memory_bytes: 68024
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = Is()
if abs(a-b)%2 == 1:
    print("IMPOSSIBLE")
else:
    print(min(a,b) + abs(a-b)//2)


Measured memory_bytes: 4720
mod input {
    use std;

    #[allow(dead_code)]
    pub fn read_line() -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn read_single<T: std::str::FromStr>() -> T {
        read_line()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    #[allow(dead_code)]
    pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line()
            .split(' ')
            .filter_map(|x| x.parse::<T>().ok())
            .collect::<Vec<T>>()
    }

    #[allow(dead_code)]
    pub fn read_chars() -> Vec<char> {
        read_line().chars().collect()
    }
}

type Graph = Vec<Vec<(usize, usize)>>;

fn dfs(g: &Graph, ans: &mut Vec<i32>, node: usize, parent: usize, pdist: usize) {
    if node != 1 {
        ans[node] = if pdist % 2 == 0 { ans[parent] } else { 1 - ans[parent] };
    }

    for &(child, dist) in g[node].iter().filter(|&&(x, _)| x != parent) {
        dfs(g, ans, child, node, dist);
    }
}

fn main() {
    let n: usize = input::read_single();
    let mut g: Graph = vec![vec![]; n + 1];

    for _ in 1..n {
        let (u, v, w) = {
            let tok = input::read_vec::<usize>();
            (tok[0], tok[1], tok[2])
        };

        g[u].push((v, w));
        g[v].push((u, w));
    }

    let mut ans = vec![0; n + 1];
    dfs(&g, &mut ans, 1, 0, 0);

    for i in 1..n+1 { println!("{}", ans[i]); }
}


Measured memory_bytes: 17788
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979

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 (b<a) { a=b; return 1; } return 0; }




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){
  size_t len = s.length();
  if(len == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}


 
int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  int j = 0;
  ll ans = 0;
  if(A*N < B){
    cout << 0 << endl;
  }

  while(true){
    j++;
    ll max = B * j - 1;
    if(max >= N) max = N;

    ll cal = (A*max)/B - A * (max/B);

    if(ans < cal){
      ans = cal;
    }

    if(max = N) break;

  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3604
import Data.List (sort)

func :: Int -> [Int] -> Int -> Int
func c [] r
  | r > 0 = c - 1
  | otherwise = c
func c (x:xs) r
  | r >= x = func (c+1) xs (r-x)
  | otherwise = c

main = do
  line1 <- getLine
  line2 <- getLine
  let
    [_,x] = map read $ words line1 :: [Int]
    dat = sort $ map read $ words line2 :: [Int]
    ans = func 0 dat x
  putStrLn $ show ans


Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main() {
	int n, k, p, ans[111], an;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> k >> p;
		while (k > p) {
			k = k - p;
		}
		if (k == 0) {
			ans[i] == p;
		}
		else {
			ans[i] = k;
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 3112
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


# https://atcoder.jp/contests/abc135/tasks/abc135_c
# 前から貪欲に倒していくのが最適
# ある勇者iについて, 街iをできる限り倒す。
# 余裕があったら街i+1を減らしておく

N = read_a_int()
A = read_ints()
B = read_ints()

ans = 0
for i in range(N):
    atk = B[i]
    if atk < A[i]:  # 倒しきれないとき
        ans += atk
        A[i] -= atk
    else:  # 倒し切れるとき
        ans += A[i]
        atk -= A[i]
        A[i] = 0
        ans += min(atk, A[i + 1])
        A[i + 1] = max(A[i + 1] - atk, 0)
print(ans)


Measured memory_bytes: 73572
def resolve():
    import sys
    import os
    input = sys.stdin.readline
    
    S = input().rstrip(os.linesep)
    pre = S[:2]
    suf = S[2:]

    def can_MM(string):
        if int(string) <= 12 and int(string) >= 1: # MM or YY
            return True
        else:
            return False

    pre_mm = can_MM(pre)
    suf_mm = can_MM(suf)

    if pre_mm:
        if suf_mm:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if suf_mm:
            print("YYMM")
        else:
            print("NA")
    

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 38256
#include <stdio.h>
  
int main(int argc, char *argv[]) {
    int h, w;
    char s[52][52] = {0};

    scanf("%d%d ", &h, &w);

    for (int i = 1; i <= h; i++) {
        scanf("%s", &s[i][1]);
    }

    for (int j = 1; j <= h; j++) {
        for (int i = 1; i <= w; i++) {
            if (s[j][i] == '#') {
                if (s[j - 1][i] == '#') continue;
                if (s[j + 1][i] == '#') continue;
                if (s[j][i - 1] == '#') continue;
                if (s[j][i + 1] == '#') continue;

                printf("No\n");
                return 0;
            }
        }
    }

    printf("Yes\n");

    return 0;
}

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

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

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

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

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// Problem Specific Parameter:

const int limit = 100010;
ll s[limit];

int a[limit], b[limit];
ll c[limit];

int asz[limit], bsz[limit];
vector<int> tree[limit];
int sz[limit], par[limit];

ll dist[limit];

int dfs(int v, int p) {
	par[v] = p;
	sz[v] = 1;
	for (auto &e : tree[v]) {
		const int v2 = v ^ a[e] ^ b[e];
		if (v2 == p) continue;
		sz[v] += dfs(v2, v);
	}
	return sz[v];
}

void calc(int v, int p, ll d) {
	dist[v] = d;
	for (auto &e : tree[v]) {
		const int v2 = v ^ a[e] ^ b[e];
		if (v2 == p) continue;
		calc(v2, v, d + c[e]);
	}
}

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

	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		tree[a[i]].push_back(i);
		tree[b[i]].push_back(i);
	}

	rep(i, n) cin >> s[i];
	dfs(0, -1);

	rep(i, n - 1) {
		if (par[a[i]] == b[i]) {
			asz[i] = sz[a[i]];
			bsz[i] = n - asz[i];
		} else {
			bsz[i] = sz[b[i]];
			asz[i] = n - bsz[i];
		}

		if (asz[i] != bsz[i]) {
			c[i] = abs(s[a[i]] - s[b[i]]) / abs(asz[i] - bsz[i]);
		}
	}

	rep(i, n - 1) {
		if (asz[i] == bsz[i]) {
			calc(a[i], b[i], 0LL);
			calc(b[i], a[i], 0LL);
			ll cur = s[a[i]];
			rep(j, n) cur -= dist[j];
			c[i] = cur / (n / 2);
		}
	}


	rep(i, n - 1) cout << c[i] << endl;

	return 0;
}

Measured memory_bytes: 15616
#103c
import fractions #math.gcdだとatcoderでは怒られる
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
a_list = [int(e) for e in input().split()]

n = lcm_list(a_list)-1
#print(n)
#print([n%i for i in a_list])
print(sum([n%i for i in a_list]))

Measured memory_bytes: 5332
#include <iostream>

using namespace std;

int n;
string s;
int cnt[30];
long long sol;
 
int main(){
    cin >> s;
    n = s.size();
    sol=(long long)n * (n-1) / 2 + 1;
    for(int i = 0;i < s.size();i++)
        cnt[s[i]-'a']++;
    for(int i = 0;i < 26;i++)
        sol-=(long long)cnt[i] * (cnt[i]-1) / 2;
    cout << sol << endl;
    return 0;
}

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

ll solve() {
    ll A, B, K;
    cin >> A >> B >> K;
    ll a ,b = B;
    ll k1 = min(A,K);
    A -= k1;
    K -= k1;
    ll k2 = min(B,K);
    B -= k2;
    cout << A << " " << B << "\n";
    return 0;
}

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main()
	{
		var s1 = Console.ReadLine().ToArray();
		var s2 = s1.Distinct();

		Console.WriteLine(s1.Length == s2.Count() ? "yes" : "no");

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


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

int main(){
  int cnt = 0;
  string s;
  cin >> s;
  for (int i = 1; i < s.size()-1; i++){
  	cnt++;
  }
  cout << s.at(0) << cnt << s.at(s.size()-1) << endl;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        while (true)
        {

            string zeta = null;
            string delta = null;
            string[] alpha = Console.ReadLine().Split(' ');
            int a = int.Parse(alpha[1]);
            int b = int.Parse(alpha[0]);
            if (a == 0 && b == 0)
            {

                break;
            }

            for (int j = 0; a > j; j++)
            {
                delta = delta + "#"; 
                if (j == 0 | j == a - 1) zeta = zeta + "#";
                else zeta = zeta + ".";

            }
            for (int q = 0; b > q; q++)
            {
                if (q == 0 | q == b - 1) Console.Write(delta);
                else Console.Write(zeta);
                Console.Write("\n");
            }
            Console.Write("\n");
           
        }

    }
}



Measured memory_bytes: 15908
#include <iostream>
using namespace std;
int main() {
  int a, b, x;
  cin >> a >> b;
  x = a + b;
  if (x % 2 == 0) {
    cout << x / 2 << endl;
  }
  else {
    cout << x / 2 + 1 << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>

#define MAX 2000000
#define SENTINEL 2000000000
int L[MAX / 2 + 2], R[MAX / 2 + 2];

long long superBubbleSort(int A[], int left, int mid, int right)
{
    int i, j;
    long long times = 0;

    //for (int i = left; i < right; i++) std::cout << A[i] << " ";
    //std::cout << std::endl;

    int ln = mid - left;
    int rn = right - mid;

    for (i = 0; i < ln; i++) L[i] = A[left + i];
    for (i = 0; i < rn; i++) R[i] = A[mid + i];

    L[ln] = R[rn] = SENTINEL;
    
    i = j = 0;

    for (int k = left; k < right; k++)
    {
        if (L[i] <= R[j]) A[k] = L[i++];
        else
        {
            A[k] = R[j++];
            times += ln - i;
        }
    }

    return times;
}

long long bubbleManager(int A[], int left, int right)
{
    int mid;
    long long v1, v2, v3;
    if (left + 1 < right)
    {
        mid = (left + right) / 2;
        v1 = bubbleManager(A, left,   mid);
        v2 = bubbleManager(A,  mid, right);
        v3 = superBubbleSort(A, left, mid, right);

        return v1 + v2 + v3;
    }
    else return 0;
}

int main()
{
    int N;
    std::cin >> N;

    int *A = new int[N];
    for (int i = 0; i < N; i++) std::cin >> A[i];

    int left  = 0;
    int right = N;
    long long times = bubbleManager(A, left, right);

    //for (int i = 0; i < N; i++) std::cout << A[i] << " ";
    //std::cout << std::endl;

    std::cout << times << std::endl;
}


Measured memory_bytes: 4660
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		for(int i = 0;i<m;i++){
			n-= sc.nextInt();
		}
		if(n<0){
			System.out.println(-1);
		}else{
			System.out.println(n);
		}
	}
	
}

Measured memory_bytes: 46484
#include <iostream>

using namespace std;

int A, B, C;

int main(void)
{
	cin >> A >> B >> C;
	
	int ans = 1000000000;
	for(int k = 0; k <= 55; k++){
		for(int x = 0; x <= 50; x++){
			for(int y = 0; y <= 50; y++){
				for(int z = 0; z <= 50; z++){
					int cnt = x + y + z;
					int a = A + x + z, b = B + x + y, c = C + y + z;
					if(a > k || b > k || c > k) continue;
					if( (k-a)%2 ||  (k-b)%2 || (k-c)%2 ) continue;
					cnt += (k-a)/2 + (k-b)/2 + (k-c)/2;
					ans = min(ans, cnt);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;



int main(){
    int n; cin>>n;
    int a[n+1], b[n];
    
    long long cnt = 0;
    
    for(int i = 0; i <= n; i++) cin>>a[i];
    for(int i = 0;i < n; i++) cin>>b[i];
    
    for(int i = 0; i < n; i++){
    	if(a[i] >= b[i]) cnt += b[i];
    	else{
    		cnt += a[i];
    		b[i] -= a[i];
    		
    		if(a[i+1] >= b[i]){
    			cnt += b[i];
    			a[i+1] -= b[i];
    		}
    		else{
    			cnt += a[i+1];
    			a[i+1] = 0;
    		}
    	}
    }
    cout<<cnt<<"\n";
	return 0;
}

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

int main() {
	// your code goes here
	
	int A,B=0;
	cin>>A>>B;
	
	if(A>=13)cout<<B;
	else if (A<=5)cout<<0;
	else cout<<B/2;
	
	
	return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;


int main()
{
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int dx = tx-sx;
    int dy = ty-sy;

    string ans = "";
    // 行き
    rep(i,dx)
    {
        ans += "R";
    }
    rep(i,dy)
    {
        ans += "U";
    }
    rep(i, dx)
    {
        ans += "L";
    }
    rep(i, dy)
    {
        ans += "D";
    }
    ans += "D";
    rep(i, dx+1)
    {
        ans += "R";
    }
    rep(i, dy+1)
    {
        ans += "U";
    }
    ans += "L";
    ans += "U";
    rep(i, dx + 1)
    {
        ans += "L";
    }
    rep(i, dy + 1)
    {
        ans += "D";
    }
    ans += "R";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool flag=true;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
        int n;
        cin >>n;
        int t[n]; int x[n];int y[n];
      int pt=0;int px=0;int py=0;
        for(int i=0; i<n; i++) {
           cin >> t[i] >>x[i] >> y[i];
        }
        for(int i=0; i<n; i++) {
          int d=abs(px-x[i])+abs(py-y[i]);
          int dt=t[i]-pt;
          if(dt<d||(dt-d)%2==1) {
                flag=false;
                break;
          }
          pt=t[i];
          px=x[i];
          py=y[i];
        }
        if(!flag) cout << "No"<< endl;
        else cout <<"Yes" << endl;
}


Measured memory_bytes: 1408
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var K = long.Parse(Console.ReadLine());
        int count = 0;
        var lastChar = S[0];
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == '1')
            {
                count = i + 1;
            }
            else
            {
                lastChar = S[i];
                break;
            }
        }

        if (0 < count && K <= count)
        {
            Console.WriteLine('1');
        }
        else
        {
            Console.WriteLine(lastChar);
        }

    }

}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

  vector<int> a;
  int sum = 0;
  for (int i = 1; i <= n; ++i)
  {
    if (sum >= n)
      break;
    sum += i;
    a.push_back(i);
  }
  for (int i = 0; i < a.size(); ++i)
  {
    if (sum - n == a[i])
      continue;
    cout << a[i] << endl;
  }

  return 0;
}

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

using ll=long long;
int main(){
    ll k,a,b;
    cin>>k>>a>>b;
    ll res=1;
    res+=min(a-1,k);
    k-=min(a-1,k);
    cout<<(res+(k/2)*max(b-a,2LL)+k%2)<<endl;
    return 0;
}

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

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

int n, m;

int main()
{
    n = read<int>();
    m = read<int>();
    if (n < 6) printf("0");
    else if (n <= 12) write(m / 2);
    else write(m);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const auto PI = std::acos(-1);
double calcAngle(double h, double m)  
{  
    if (h <0 || m < 0 || h >12 || m > 60)  
        printf("Wrong input");  
  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  
    double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  
    double angle = abs(hour_angle - minute_angle);  
  
    angle = min(360 - angle, angle);  
  
    return angle;  
}  
int main(int argc, const char** argv) {
    cout.precision(20);
    cout << fixed;
    double a,b,h,m,i;
    cin>>a>>b>>h>>m;
    cout<<sqrt(a*a + b*b - 2*a*b*cos(2*PI*calcAngle(h,m)/360))<<"\n";

    return 0;
}

Measured memory_bytes: 4220
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int r;

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

  int ans = 3 * r * r;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int h,w;
    cin>>w>>h;
    vector<vi> v(w,vi(h,0));
    rep(i,n){
      int x,y;
      cin>>x>>y;
      v[x-1][y-1]++;
    }
    int s,t,k,l;
    cin>>s>>t;
    int ans=0;
    rep(i,w-s+1)rep(j,h-t+1){
      int tmp=0;
      rep(k,s)rep(l,t)if(v[i+k][j+l])tmp++;
      ans=max(ans,tmp);
    }
    cout<<ans<<endl;
  }
}

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

using namespace std;

#define i64 int64_t
#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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 (b < a) { a = b; return 1;} return 0;}

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> B;
    rep(i, n) {
        int b;
        cin >> b;
        B.push_back(b);
    }

    rep(i, n) {
        if (B[i] > i + 1) {
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(all(B));
    vector<int> ans;
    rep(i, n) {
        int index = B.size();
        stl_rep(itr, B) {
        if (*itr == index) {
            ans.push_back(*itr);
            B.erase(itr);
            break;
        }

        --index;
        }
    }

    reverse(all(ans));
    stl_rep(i, ans) {
        cout << *i << endl;
    }

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	multiset<int> st;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		auto itr = st.lower_bound(a);
		if (itr == st.begin()) {
			st.insert(a);
		} else {
			itr--;
			st.erase(itr);
			st.insert(a);
		}

	}
	int ans = st.size();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8244
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		int A = 0;
		int B = 0;
		int C = 0;
		int D = 0;
		int E = 0;
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> ary = new ArrayList<Integer>();
		int i;
		for (i = 0; i < 5; i++) {
			int time = Integer.parseInt(sc.next());
			ary.add(i, time);
		}
		int max = 0;
		int dif=11;
		for (i = 0; i < 5; i++) {
			int remainder = ary.get(i) % 10;
			if (dif > remainder&&remainder!=0) {
				dif=remainder;
				max = i;
			}
		}
		double total=0;
		double temp=0;
		for (i = 0; i < 5; i++) {
			if(max!=i){
				temp=ary.get(i);
				temp=temp/10;
				total=total+(Math.ceil(temp)*10);
			}
			else{
				total=total+ary.get(i);
			}
		}
		System.out.println((int)total);
	}
}

Measured memory_bytes: 23764
package main

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

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func main() {
	A := readInt()
	B := readInt()

	N := gcd(A, B)
	if N == 1 {
		fmt.Println(1)
		return
	}

	result := 1
	r := int(math.Sqrt(float64(N)))
	for x := 2; x < r+1; x++ {
		if N%x == 0 {
			result++
			for N%x == 0 {
				N /= x
			}
			if N == 1 {
				break
			}
		}
	}
	if N != 1 {
		result++
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
 
class Main
{
  public static void main(String Args[])
  {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    int ans=(int)Math.ceil((b-a)*1.0/(a-1))+1;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a[200010],b[200010],d[200010],nxt[200010],ans[200010],pre[200010];
struct dian
{
    int x,y;
}c[200010];
int n;
bool cmp(const dian &x,const dian &y)
{
     return x.y>y.y;
}
int main()
{
    int i,t,now,u;
    srand((unsigned)time(NULL));
    cin>>n;
    for(i=1;i<=200000;i++) c[i].x=i;
    for(i=1;i<=n;i++) 
    {
        cin>>a[i];
        c[a[i]].y++;
    }
    for(i=1;i<=n;i++)
    {
        cin>>b[i];
        d[b[i]]++;
        c[b[i]].y++;
    }
    for(i=1;i<=200000;i++)
    {
        if(c[i].y>n)
        {
            cout<<"No";
            return 0;
        }
    }
    for(i=0;i<=200000;i++) 
    {
        nxt[i]=i+1;
        pre[i]=i-1;
    }
    sort(c+1,c+200001,cmp);
    for(i=1;i<=200000;i++)
    {
        if(c[i].y==0) break;
        t=d[c[i].x];
        u=c[i].x;
        now=0;
        while(t>0&&now<=n)
        {
            now=nxt[now];
            if(now>n) break;
            if(a[now]!=u)
            {
                ans[now]=u;
                pre[nxt[now]]=pre[now];
                nxt[pre[now]]=nxt[now];
                d[u]--;
                t--;
            }
        }
    }
    /*for(i=1;i<=n;i++) cout<<ans[i]<<" ";
    cout<<endl;
    for(i=0;i<=n;i++) cout<<nxt[i]<<" ";*/
    now=0;
    for(i=1;i<=200000;i++)
    {
         while(d[i]>0)
         {
             now=nxt[now];
             ans[now]=i;
             d[i]--;
         }
    }
    for(i=1;i<=n;i++)
    {
        if(ans[i]==a[i])
        {
             while(1)
             {
                 t=rand()%n+1;
                 if(ans[t]!=a[i]&&ans[i]!=a[t])
                 {
                     swap(ans[t],ans[i]);
                     break;
                 }
             }
        }
    }         
    cout<<"Yes"<<endl;
    for(i=1;i<=n;i++) cout<<ans[i]<<" ";
    cin>>i;
}
    
            
        


Measured memory_bytes: 9712
# https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d

def main():
    N = int(input())
    S = tuple(map(int,input()))

    ans = 0

    # Rnum: 000 ~ 999
    for Rnum in range(1000):
        R = list(map(int,str(Rnum).zfill(3)))

        for s in S:
            if s == R[-1]:
                R.pop()
            if not R:
                ans += 1
                break

    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x, y;
    cin>>x>>y;

    if(x<=8 && y<=8)
        cout<<"Yay!";
    else
        cout<<":(";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int v[N];
int dp[N];
int n, k = 2;
int f(int i){
    if(i == n - 1)return 0;
    int &ans = dp[i];
    if(ans == -1){
        ans = 1e9;
        for(int j = 1; j <= k; j++)
            if(i + j < n)
                ans = min(ans, f(i + j) + abs(v[i] - v[i + j]));
            else
                break;
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> n;
    fore(i, 0, n)cin >> v[i];
    cls(dp, -1);
    cout << f(0) << '\n';
    
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 10804
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  if (n == 0) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  

}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

struct Node {
    int key;
    Node *parent=nullptr;
    Node *left= nullptr;
    Node *right= nullptr;
};

Node *NIL = nullptr;
Node *root = nullptr;

void insert(int key) {
    Node *y = nullptr;
    Node *x = root;

    while (x != NIL) {
        y = x;
        if (key < x->key) {
            x = x->left;
        } else if (key > x->key) {
            x = x->right;
        }
    }
    Node *z = new Node;
    z->key=key;
    z->parent=y;


    if (y==NIL) {
        root = z;
    } else if (z->key < y->key) {
        y->left = z;
    } else if (z->key > y->key){
        y->right = z;
    }
}

string find(int k, Node* r) {
    if (r == NIL) {
        return "no";
    } else if (k == r->key) {
        return "yes";
    } else if (k > r->key) {
        return find(k, r->right);
    } else if (k < r->key) {
        return find(k, r->left);
    }
}

void print_pre_order(Node* r) {
    if (r==NIL) return;
    cout << " " << r->key;
    print_pre_order(r->left);
    print_pre_order(r->right);
}

void print_middle_order(Node* r) {
    if (r==NIL) return;
    print_middle_order(r->left);
    cout << " " << r->key;
    print_middle_order(r->right);
}

int main() {
    int n, key;
    string cmd;

    cin >> n;

    for (int j=0; j < n; j++) {
        cin >> cmd;
        if (cmd == "insert") {
            cin >> key;
            insert(key);
        } else if (cmd == "print") {
            print_middle_order(root);
            cout << endl;

            print_pre_order(root);
            cout << endl;
        } else if(cmd == "find") {
            cin >> key;
            cout << find(key, root) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 21888
R, G, B, N = (int(i) for i in input().split())
numofpattern = 0
for i in range(1+(N // R)):
    for j in range(1+((N - i * R) // G)):
        if (N-i*R-j*G) % B == 0:
            numofpattern += 1
print("{}".format(numofpattern))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T ll
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 10005;

int dp[N][100][2];
string s;
int d;

int solve(int pos, int sum, bool tight){
	if(pos==sz(s)){
		if(sum==0){
			return 1;
		}
		else{
			return 0;
		}
	}
	int &res = dp[pos][sum][tight];
	if(res!=-1 && tight==0){
		return res;
	}
	int lim=9;
	if(tight){
		lim=s[pos]-'0';
	}
	int ans=0;
	FOR(i,0,lim){
		bool next_tight=tight;
		if(s[pos]-'0'!=i){
			next_tight=0;
		}
		ans=(ans+solve(pos+1,(sum+i)%d,next_tight))%MOD;
	}
	return res=ans;
}

int main(){
    IOS
    memset(dp,-1,sizeof(dp));
    cin>>s>>d;
    cout<<(solve(0,0,1)-1+MOD)%MOD;
    
    return 0;
}

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

using namespace std;
typedef vector<int> vec;
typedef pair<int, int> P;

int n;
int pre[100001];
int v1, v2;
vec G[100001], G2[100001], path;

void getPre(int s, int t) {
  pre[t] = s;
  for (int i = 0; i < G[t].size(); i++) {
    int v = G[t][i];
    if (v == s) continue;
    getPre(t, v);
  }
}

int count(int s, int t) {
  int res = 1;
  for (int i = 0; i < G[t].size(); i++) {
    int v = G[t][i];
    if (v == s) continue;
    if ((t == v1 && v == v2) || (t == v2 && v == v1)) continue;
    res += count(t, v);
  }
  return res;
}

int main(void) {
  cin >> n;

  vector<int> a(n - 1), b(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i] >> b[i];
    G[a[i] - 1].push_back(b[i] - 1);
    G[b[i] - 1].push_back(a[i] - 1);
  }

  getPre(-1, 0);

  int p = n - 1;
  while (p != -1) {
    path.push_back(p);
    p = pre[p];
  }

  int cut = (path.size() - 2) / 2;
  v1 = path[cut], v2 = path[cut + 1];

  int sz1 = count(-1, 0), sz2 = count(-1, n - 1);
  cout << (sz1 > sz2 ? "Fennec" : "Snuke") << endl;
  
  return 0;
}

Measured memory_bytes: 14588
N = int(input())
S = [0] * N
P = [0] * N
restaurant= []
for i in range(N):
  S[i], P[i] = input().split()

for i in range(N):
  restaurant.append([i+1, S[i], int(P[i])])

restaurant = sorted(restaurant, key=lambda x: x[2], reverse=True)
restaurant = sorted(restaurant, key=lambda x: x[1])

for i in range(N):
  print(restaurant[i][0])

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <tuple>
using namespace std;
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int main() {
string s;
cin >>s;
long long margin=0;
char s_Mid;
long long N= s.length();
if ( N%2==0){
    s_Mid=s[N/2-1];
    while( margin<=N/2 && s_Mid==s[N/2-1-margin] && s_Mid==s[N/2+margin]){
        margin++;
    }
margin=2*margin;
}
else{
    s_Mid=s[(N-1)/2];
    margin++;
    while( margin<=(N+1)/2&& s_Mid==s[(N-1)/2-margin]&& s_Mid==s[(N-1)/2+margin]){
        margin++;
    }
margin=2*margin-1;
}
cout << (margin+N)/2;
return 0;
}


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

const int INF = 1e9+7;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int n;
	cin >> n;
	vector<long long> a(n);
	rep(i, n) cin >> a.at(i);
	sort(a.begin(), a.end());
	long long ans=0;
	rep(i, n) ans+= a.at(i);
	ans -= a.at(n-1)/2;
	cout << ans << endl;
}

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

int main()
{


        double n,m,a,b=2,c,d,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=0,y=-1,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        scanf("%lf",&n);

        double pi=acos(-1);

        d=b*n;  pi=pi*d;

        printf("%0.14lf\n",pi);












    return 0;
}





Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int, int> p;



int main() {
	int n;
	cin >> n;
	string s,t;
	cin >> s;
	map<string, bool> mp;
	bool a = true;
	mp[s]=true;
	for (int i = 0; i < n - 1; i++) {
		cin >> t;
	//	cout << endl<<i<<" "<<s[s.size() - 1] << " " << t[t.size() - 1] << endl;
		if (s[s.size() - 1] != t[0]) {
	//		cout << "s= " << s << "  t= " << t << endl;
		
			a = false;
		}
		if (mp[t] == true) {
			a = false;
		}
		mp[t] = true;
		s = t;
	}
	if (a == true) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define wi while
#define vl vector<ll>
#define vi vector<int>
#define map map<char,ll>
#define endl "\n"
const int mxN = 200001;
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    
    int n,k;
    cin>>n>>k;
    int a[n];
    int mn = INT_MAX;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        mn = min(mn,a[i]);
    }
    vector<bool> dp(k+1,0);
    for(int i=0;i<mn;++i)
    {
        dp[i] = false;
    }
    for(int i=mn;i<=k;++i)
    {
        int flag = false;
        for(int j=0;j<n;++j)
        {
            if(a[j]<=i)
            {
                if(dp[i-a[j]]==false)
                {
                    flag = true;
                    break;
                }
            }
        }
        if(flag)
        {
            dp[i] = true;
        }
        else
        {
            dp[i] = false;
        }
    }
    if(dp[k])
    {
        cout<<"First"<<endl;
    }
    else
    {
        cout<<"Second"<<endl;
    }

    
    return 0;

}


Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


int second_number(int a, int b, int c){
    vector<int> s;
    s.push_back(a);
    s.push_back(b);
    s.push_back(c);
    sort(s.begin(), s.end());
    
    return s[1];
}


int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    
    sort(p.begin(), p.end());
    
    int a = p[n/2] - p[n/2-1];

    int ans = a;
     
    cout << ans << endl;
    return 0;
    

}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	rep1(i, 9)rep1(j, 9)
	{
		if (i * j == n)
		{
			co("Yes");
			return 0;
		}
	}
	co("No");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    for (n in 1..10000) {
        if ((n * 0.08).toInt() == a && (n * 0.1).toInt() == b) {
            println(n)
            return
        }
    }
    println(-1)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> jun(n);
  vector<int> bonus(n-1);
  int point = 0;
  rep(i,n) cin>>jun.at(i);
  rep(i,n){
    int p;
    cin >> p;
    point+= p;
  }
  rep(i,n-1) cin >> bonus.at(i);
  rep(i,n-1){
    if(jun.at(i+1)==jun.at(i)+1) point += bonus.at(jun.at(i)-1);
  }
  cout << point << endl;
}

Measured memory_bytes: 256
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
template <class T>
using Graph = vector<vector<T>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

template <typename T>
inline T Gcd(T a, T b) {
    T c;
    while (b) {
        c = b;
        b = a % b;
        a = c;
    }
    return a;
}

Int Lcm(Int a, Int b) {
    if (a < b) {
        swap(a, b);
    }

    return a / Gcd(a, b) * b;
}

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

    int a, b;
    cin >> a >> b;

    cout << max(0, a - b * 2) << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n){
        int x;
        cin>>x;
        x--;
        a[x]=i+1;
    }
    vector<int> b(n);
    rep(i,n){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 4040
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
struct UnionFind{
    vector<int> par;
    UnionFind(int N){
        par.resize(N);
        for(int i=0;i<N;i++){
            par[i] = i;
        }
    }
    void Union(int x,int y){
        par[Get(x)] = Get(y); 
    }
    bool Same(int x,int y){
        return Get(x) == Get(y);
    }
    int Get(int x){
        if(x != par[x]){
            par[x] = Get(par[x]);
        }
        return par[x];
    }
};
int X[200000];
int Y[200000];
void Calc(){
	int N = rei();
	UnionFind U(200000);
	for(int i=0;i<N;i++){
		int x = rei()-1;
		int y = rei()-1;
		U.Union(x,y+100000);
	}
	for(int i=0;i<100000;i++){
		X[U.Get(i)]++;
		Y[U.Get(i+100000)]++;
	}
	long ans = -N;
	for(int i=0;i<200000;i++){
		ans += 1LL * X[i] * Y[i];
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int A[100], n, v, j;

void print()
{
    for (j = 0; j < n; j++)
    {
        cout << (j == 0 ? "" : " ") << A[j];
    }
    cout << endl;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    print();
    for (int i = 1; i < n; i++)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print();
    }
    return 0;
}


Measured memory_bytes: 3052
def get_longest_count(X, Y):
  offsets = [0]
  for y in Y:
    tmp = offsets[:]
    for i, o in enumerate(offsets):
      j = X.find(y, o)
      if j < 0: break
      if i < len(offsets) - 1:
        tmp[i + 1] = min(offsets[i + 1], j + 1)
      else:
        tmp.append(j + 1)
    offsets = tmp
  return len(offsets) - 1

for i in range(int(input())):
  X = input()
  Y = input()
  print(get_longest_count(X, Y))

Measured memory_bytes: 7668
#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> p(n);
	
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	
	sort(p.begin(),p.end());
	
	int sum=0;
	sum+=p[n-1]/2;
	for(int i=0;i<n-1;i++)
	{
		sum+=p[i];
	}
	cout<<sum<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import numpy as np


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

dp = n * [10**10]

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for j in range(2, n):
    dp[j] = min(dp[j-1] + np.abs(h[j] - h[j-1]), dp[j-2] + np.abs(h[j] - h[j-2]))
print(dp[-1])


Measured memory_bytes: 23092
y,x = [int(x) for x in input().split()]
even = "#." * 151
odd  = ".#" * 151
while(x > 0 or y > 0):
    for i in range(y):
        if(i % 2 == 0):
            print(even[:x])
        else:
            print(odd[:x])
    print()          
    y,x = [int(x) for x in input().split()]

Measured memory_bytes: 7748
N = int(input())
bs = list(map(int, input().split()))

a_list = [None for _ in range(N)]
a_list[0] = bs[0]

bs_size = len(bs)

for i in range(bs_size):
    if i == bs_size - 1:
        a_list[N-1] = bs[i]
    else:
        a_list[i+1] = min(bs[i],bs[i+1])

print(sum(a_list))


Measured memory_bytes: 3060