akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

double dist(vector<int> x, vector<int> y, int i, int j)
{
	return sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
}

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		ans += a - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	char n[1000];
	char a1[200];
	char b1[200];
	scanf("%s",&n);
	int s,a,b,i;
	s=strlen(n);
	a=(s-1)/2;
	b=(s+3)/2; 
	for(i=0;i<a;i++)
	a1[i]=n[i];
	for(i=b-1;i<s;i++)
	b1[i-b+1]=n[i];
	int p=1;
	for(i=0;i<a;i++)
	if(a1[i]!=a1[a-i-1])
	p=0;
	for(i=0;i<a;i++)
	{
		if(a1[i]!=b1[i])
		p=0;
	}
	if(p==1)
	printf("Yes");
	else
	printf("No");
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

	int a,b,c,x;
	cin >> a >> b >> c >> x;

	int ans=0;
	for(int i=0; i<=a; i++){
		for(int j=0; j<=b; j++){
			for(int k=0; k<=c; k++){
				if(500*i + 100*j + 50*k == x){
					ans++;
				}
			}
		}
	}

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

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

#define re(i, n) for(int i=1; i<=n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int n;
   cin>>n;
   int f[10001]={0};

   re(x, 100) re(y, 100) re(z, 100){
      int v=x*x+y*y+z*z+ x*y+y*z+z*x;
      if(v<=10000) f[v]++;
   }

   re(i, n) cout<<f[i]<<endl;
   return 0;
}


Measured memory_bytes: 3660
n,m,q = (int(x) for x in input().split())
field = [[0]*n for i in range(n)]
S = [[0]*(n+1) for i in range(n+1)]

for i in range(m):
  l,m = (int(x) for x in input().split())
  field[l-1][m-1] += 1

#累積和
for i in range(n):
  for j in range(n):
    S[i+1][j+1] = S[i][j+1] + S[i+1][j] - S[i][j] + field[i][j]
    
for i in range(q):
  begin,end = (int(x) for x in input().split())
  print(S[end][end] - S[begin - 1][end] - S[end][begin - 1] + S[begin - 1][begin - 1])
  


Measured memory_bytes: 15340
#include<iostream>
#include<cmath>
using namespace std;
int main( )
{
	int size,s,i;
	cin>>size;
	s=size/2;
    int* a=new int[size];
	if(size%2==0) 
	{
	for(i=0;i<size;i++)
	{
		s=s+(pow(-1,i))*i;
		cin>>a[s];
	}}
	else{
	
	for(i=0;i<size;i++)
	{
		s=s-(pow(-1,i))*i;
		cin>>a[s];
	}}
	for( i=0;i<size;i++)
	{
	cout<<a[i]<<" "; 
	}
	delete [] a;
	return 0;
	
}

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

int main(){
    int N;
    cin >> N;
    int d[N];
    for(int i=0; i<N; i++) cin >> d[i];
    sort(d,d+N);
    if (d[N/2-1]==d[N/2]){cout << 0; exit(0);}
    cout << d[N/2] - d[N/2-1];
}

Measured memory_bytes: 640
import numpy as np
N = int(input())
S = [input()[0] for _ in range(N)]

npS = np.array(S)
march = np.zeros(5,dtype = int)
tmp = 'MARCH'

for i in range(5):
    march[i] = np.sum(npS == tmp[i])

ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            tmp = march[i] * march[j] * march[k]
            ans += tmp


print(ans)


Measured memory_bytes: 22696
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        k: usize,
        n: usize
    }
    if k % 2 == 0 {
        print!("{}", k / 2);
        for _ in 0..n - 1 {
            print!(" {}", k);
        }
        println!("");
        return;
    }
    let mut a = vec![k / 2 + 1; n];
    for _ in 0..n / 2 {
        if a.last() == Some(&1) {
            a.pop();
        } else {
            *a.last_mut().unwrap() -= 1;
            while a.len() < n {
                a.push(k);
            }
        }
    }
    for i in 0..a.len() - 1 {
        print!("{} ", a[i]);
    }
    println!("{}", a.last().unwrap());
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() 
{
    int N; cin >> N;
    vector<Int> A(N); for (auto &a : A) cin >> a;
    int count = 0;
    for (int i = 0; i < N; i++) count += (A[i] < 0);
    Int abssum = 0, absmin = 1e9;
    for (int i = 0; i < N; i++) {
        abssum += abs(A[i]);
        absmin = min(absmin, abs(A[i]));
    }
    if (count % 2) {
        cout << abssum - absmin*2 << endl;
    } else {
        cout << abssum << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;


int main(){
    int n,m;
    cin >> n >> m;
    bool flag=false;
    int from1[200000+1];
    for(int i=0;i<n;i++){
        from1[i]=0;
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        if (a==1){
            if (from1[b]==-1){
                flag=true;
                break;
            }else{
                from1[b]=-1;
            }
        }
        if (b==n){
            if (from1[a]==-1){
                flag=true;
                break;
            }else{
                from1[a]=-1;
            }

        }
    }
    if (flag){
        cout <<"POSSIBLE"<<endl;
    }else{  
        cout <<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
num = gets.chomp.split(" ").map(&:to_i)

small = num[0]
large = num[1]
k = num[2]
ans = []

for i in small..(small + k - 1) do
    ans.push(i)
end

for i in (large - k + 1)..large do
    ans.push(i)
end

ans.uniq.each do |i|
    if small <= i and i <= large
        puts i
    end
end


Measured memory_bytes: 1788
n = int(input())
x = input()

num_of_1 = x.count("1")

x_num = int(x, 2)

def f(x):
    if x == 0:
        return 0
    return 1 + f(x % bin(x).count('1'))

if num_of_1 == 1:
    for i in range(n):
        if x[i] == '1':
            print(0)
        elif i == n-1:
            print(2)
        else:
            print(1)
    exit()

a = x_num % (num_of_1 + 1)
b = x_num % (num_of_1 - 1)

for i in range(n):
    if x[i] == "0":
        print(1 + f((a + pow(2, n-i-1, num_of_1 + 1)) % (num_of_1 + 1)))
    else:
        print(1 + f((b - pow(2, n-i-1, num_of_1 - 1)) % (num_of_1 - 1)))

Measured memory_bytes: 79416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
int INF = 100000000;

int main() {
  int N, A, B; cin >> N >> A >> B;
  if ((B - A) % 2 == 0) {
    cout << "Alice" << endl;
  }
  else {
    cout << "Borys" << endl;
  }
}

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

int main()
{
	int n;
	cin>>n;
	
	int x=n%10;
	
	if(x==2||x==4||x==5||x==7||x==9)
	  cout<<"hon";
	else if(x==3) cout<<"bon";
	else cout<<"pon";

  return 0;
}

Measured memory_bytes: 3568
t = int(input())
for _ in range(t):
  n = int(input())
  lst = list(map(int, input().split()))
  M = m = 0
  for i in range(n - 1):
    M = max(lst[i + 1] - lst[i], M)
    m = min(lst[i + 1] - lst[i], m)
  print(M, -m)


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

using ll = long long;

int n, m;
ll x[1111], y[1111], z[1111];
ll val[1111];

int main() {
   cin >> n >> m;
   for (int i = 0; i < n; i++) {
      cin >> x[i] >> y[i] >> z[i];
   }

   ll ans = -1e18;
   for (int mask = 0; mask < 8; mask++) {
      int a = (mask & 1) ? -1 : 1;
      int b = (mask & 2) ? -1 : 1;
      int c = (mask & 4) ? -1 : 1;
      for (int i = 0; i < n; i++) {
         val[i] = a * x[i] + b * y[i] + c * z[i];
      }
      sort(val, val+n, greater<ll>());
      ll cur = 0;
      for (int i = 0; i < m; i++) {
         cur += val[i];
      }
      ans = max(ans, cur);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
N=int(input())
AB=[list(map(int,input().split())) for i in range(N)]
from collections import defaultdict
d=defaultdict(int)
d2=defaultdict(int)
a0=0
b0=0
c0=0
from math import gcd
for a,b in AB:
    if a==b==0:
        c0+=1
    elif a==0:
        a0+=1
    elif b==0:
        b0+=1
    else:
        if a<0:
            a,b=-a,-b
        g=gcd(a,b)
        a,b=a//g,b//g
        if b>0:
            d[(a,b)]+=1
        else:
            d2[(-b,a)]+=1
m=10**9+7
a=1
for k,v in d.items():
    if k in d2:
        a=a*(pow(2,v,m)+pow(2,d2[k],m)-1)%m
    else:
        a=a*pow(2,v,m)%m
for k,v in d2.items():
    if k not in d:
        a=a*pow(2,v,m)%m
print((a*(pow(2,a0,m)+pow(2,b0,m)-1)-1+c0)%m)

Measured memory_bytes: 81100
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] ans = new int[20000];
		int cnt = 0;
		
		while(true){
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			
			if(op.equals("?"))
				break;
			
			if(op.equals("+"))
				ans[cnt] = a + b;
			else if(op.equals("-"))
				ans[cnt] = a - b;
			else if(op.equals("*"))
				ans[cnt] = a * b;
			else
				ans[cnt] = a / b;
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++){
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 26352
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

ll n, m, a, b, c, t, s[55];

struct Mat {
    ll v[55][55];
};

void show(Mat A) {
    cout << "[";
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        for (int j = 0; j < n; j++) {
            if (j) cout << " ";
            cout << A.v[i][j];
        }
        if (i != n - 1) cout << endl;
    }
    cout << "]" << endl;
}

void ans(Mat A) {
    for (int i = 0; i < n; i++) {
        if (i) cout << " ";
        ll val = 0;
        for (int j = 0; j < n; j++) {
            val += A.v[i][j] * s[j];
            val %= m;
        }
        cout << val;
    }
    cout << endl;
}

Mat mult(Mat A, Mat B) {
    Mat C;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ll val = 0;
            for (int p = 0; p < n; p++) {
                val += A.v[i][p] * B.v[p][j];
                val %= m;
            }
            C.v[i][j] = val;
        }
    }
    return C;
}

Mat expt(Mat A, ll p) {
    if (p == 0) return {};
    else if (p == 1) return A;
    else if (p % 2 == 1) return mult(A, expt(A, p - 1));
    else {
        Mat T = expt(A, p / 2);
        return mult(T, T);
    }
}


int main(void){
    while (1) {
        cin >> n >> m >> a >> b >> c >> t;
        if (n == 0) return 0;
    
        for (int i = 0; i < n; i++) cin >> s[i];
        
        Mat M;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (j - i == -1) M.v[i][j] = a;
                else if (j == i) M.v[i][j] = b;
                else if (j - i == 1) M.v[i][j] = c;
                else M.v[i][j] = 0;
            }
        }
        
        if (t == 0) {
            for (int i = 0; i < n; i++) {
                if (i) cout << " ";
                cout << s[i];
            }
            cout << endl;
        }
        else ans(expt(M, t));
        //show(expt(M, t));
    }
}



Measured memory_bytes: 10004
import java.util.*;

public class Main {
	void solve() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		Map<Integer, Integer> d = new HashMap<>();
		int cd = 1;
		for(int i = 0; i < n; i++) {
			int din = scan.nextInt();
			if(d.containsKey(din)) {
				cd = d.get(din) + 1;
			} else {
				cd = 1;
			}
			d.put(din, cd);
		}
		int m = scan.nextInt();
		
		Map<Integer, Integer> t = new HashMap<>();
		int ct = 1;
		for(int i = 0; i < m; i++) {
			int tin = scan.nextInt();
			if(t.containsKey(tin)) {
				ct = t.get(tin) + 1;
			} else {
				ct = 1;
			}
			t.put(tin, ct);
		}
		if(n < m) {
			System.out.println("NO");
			return;
		}
		for(var i : t.entrySet()) {
			if(!d.containsKey(i.getKey())) {
				System.out.println("NO");
				return;
			}
			if(d.get(i.getKey()) < i.getValue()) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
		scan.close();
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


Measured memory_bytes: 83212
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define ZERO(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair



int main() {
    int a,b,h; cin>>a>>b>>h;
    cout << (a+b)*h / 2 << "\n";


    return 0;
}


Measured memory_bytes: 764
import heapq
def dijkstra_heap(s):
  d=[float("inf")]*n
  used=[True]*n 
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while len(edgelist):
    minedge=heapq.heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v=minedge[1]
    d[v]=minedge[0]
    used[v]=False
    for e in edge[v]:
      if used[e[1]]:
        heapq.heappush(edgelist,[e[0]+d[v],e[1]])
  return d

N,m,s=map(int,input().split())
L=[list(map(int,input().split())) for i in range(m)]
L2=[list(map(int,input().split())) for i in range(N)]
n=N*(50*(N-1)+1)
edge=[[] for i in range(n)]
for i in range(m):
  for j in range(50*(N-1)+1):
    if j>=L[i][2]:
      edge[L[i][0]-1+N*j].append([L[i][3],L[i][1]-1+N*(j-L[i][2])])
      edge[L[i][1]-1+N*j].append([L[i][3],L[i][0]-1+N*(j-L[i][2])])
for i in range(N):
  for j in range(50*(N-1)):
    edge[i+N*j].append([L2[i][1],i+N*min(50*(N-1),j+L2[i][0])])
ans=[[] for i in range(N)]
D=dijkstra_heap(min(50*(N-1),s)*N)
for i in range(len(D)):
  ans[i%N].append(D[i])
for i in range(1,N):
  print(min(ans[i]))

Measured memory_bytes: 173512
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s;
  cin >> s;

  int n = s.size();
  bool f = true;
  if(s[0] != 'A') f = false;

  bool f2 = false;
  FOR(i,2,n-1){
    if(s[i] == 'C') f2 = true;
  }

  int cnt = 0;
  REP(i,n) if(range(s[i],'A','Z'+1)) cnt++;

  if(cnt == 2 && f && f2) cout <<  "AC" << endl;
  else cout << "WA" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  u64 s, c;
  cin >> s >> c;
  if (s*2 > c) {
    cout << c/2 << endl;
    return 0;
  }
  cout << s + (c-s*2)/4 << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
            char C = (char)Read();
            int i = Array.BinarySearch(abc, C);
            WriteLine(C =='z' ? 'a' : abc[i + 1]);
        }
    }
}

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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll x,steps,dis,ans = 0l; cin >> x >> steps >> dis;
    if(x<0) x = x*(-1L);
    ll tmp = x/dis;
    if(tmp >= steps) ans = x - (steps * dis);
    else {
        ans = x - (dis * tmp);
        steps -= tmp;
        if(steps % 2L == 1L) ans -= dis;
    }
    if(ans < 0) ans = ans * (-1L);
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

int main(void)
{
    string str;
    char c;
    int counter = 0;

    cin>>str;
    c = str[0];
    for(int i = 1;i < str.size();i++)
    {
	if(c != str[i])
	{
	    counter++;
	    c = str[i];
	}
    }

    cout<<counter<<endl;


    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

void solve(){
  int n; cin >> n;
  int a[n], b[n], c[n];
  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 - 1; i++) cin >> c[i];

  int x = -1, sum = 0;
  for(int i = 0; i < n; i++){
    if(a[i] == x + 1) sum += c[x - 1];
    sum += b[a[i] - 1];
    x = a[i];
  }
  cout << sum << endl;
  return;
}

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


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

int main() {
  int x;
  cin >> x;
  long long int aa,bb;
  for(long long int a = -1000; a < 1000; a++){
    for(long long int b = -1001; b < 999; b++){
      aa = a*a*a*a*a;
      bb = b*b*b*b*b;
		if(aa-bb==x){
          cout << a << " " << b << endl;
          return 0;
        }
      else continue;
    }
  }
}


Measured memory_bytes: 3540
s = input()

if (s[0] == s[2]) and (s[0] != s[1]):
    print('Yes')
elif (s[1] == s[2]) and (s[0] != s[2]):
    print('Yes')
elif (s[0] == s[1]) and (s[0] != s[2]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2e3+5;
int dp[N];
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x;
	cin>>n>>x;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++) dp[i]=1e17;
	int ans1=1e18;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			int k=(j-i);
			k=(k+n)%n;
			dp[j]=min(dp[j],a[k]);
		}
		int ans=i*x;
		for(int j=0;j<n;j++)
		{
			ans+=dp[j];
		}
		ans1=min(ans1,ans);
	}
	cout<<ans1;
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

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

const int maxn = 100009;
int cnt[maxn], a, n;

int power(int p) {
	int res = 1, x = 2;
	while (p) {
		if (p&1) res = 1LL * res * x % 1000000007;
		x = 1LL * x * x % 1000000007; p >>= 1;
	}
	return res;
}

int main() {
	scanf("%d", &n);
	for (int i=1; i<=n; i++) {
		scanf("%d", &a);
		cnt[a]++;
	}
	if (n&1) {
		for (int i=2; i<=n-1; i+=2)
			if (cnt[i] != 2) {
				puts("0"); return 0;
			}
		if (cnt[0] != 1) {
			puts("0"); return 0;
		}
		printf("%d\n", power(n/2));
	}
	else {
		for (int i=1; i<=n-1; i+=2)
			if (cnt[i] != 2) {
				puts("0"); return 0;
			}
		printf("%d\n", power(n/2));
	}
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>

typedef long long LL;
const int Mod = 1000000007;
const int Inv2 = 500000004;
const int MN = 200005;

int A, B, nA, nB, Pow2;
int Fac[MN], iFac[MN];

void Init(int N) {
	Fac[0] = iFac[0] = iFac[1] = 1;
	for (int i = 2; i <= N; ++i)
		iFac[i] = (LL)(Mod - Mod / i) * iFac[Mod % i] % Mod;
	for (int i = 1; i <= N; ++i) {
		Fac[i] = (LL)Fac[i - 1] * i % Mod;
		iFac[i] = (LL)iFac[i - 1] * iFac[i] % Mod;
	}
}
inline int Binom(int n, int m) {
	if (m < 0 || m > n) return 0;
	return (LL)Fac[n] * iFac[m] % Mod * iFac[n - m] % Mod;
}

int main() {
	scanf("%d%d", &A, &B);
	Init(A + B);
	for (int i = 1; i <= A + B; ++i) {
		if (i == 1) nA = nB = 0, Pow2 = 1;
		else {
			Pow2 = (LL)Pow2 * Inv2 % Mod;
			nA = (nA + (LL)Pow2 * Binom(i - 2, A - 1)) % Mod;
			nB = (nB + (LL)Pow2 * Binom(i - 2, B - 1)) % Mod;
		}
		printf("%lld\n", (LL)(1 + nB - nA + Mod) * Inv2 % Mod);
	}
	return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>

int main ()
{
double H,max,min;
max=0;min=0;
while(scanf("%lf",&H)!=EOF)
{
	
if(H>max)max=H;
else if(H<min)min=H;
if(min==0)min=H;
}
printf("%lf",max-min);
return 0;
}

Measured memory_bytes: 1076
using System;
class Program
{
	static void Main(string[] args)
	{
		int a = int.Parse(Console.ReadLine());
		string[] input2 = Console.ReadLine().Split(' ');
      	int[] input = new int[a];
      	int status = 0;
      	for(int j = 0; j < a; j++){
        	input[j] =int.Parse(input2[j]);
        }
      	
		for(int i = 0; i < a-2; i++){
          if(input[i] < input[i+1]){
            if(input[i+1] < input[i+2]){
              status++;
            }
          }
          
          if(input[i] > input[i+1]){
            if(input[i+1] > input[i+2]){
              status++;
            }
          }
        }
      	
      	Console.WriteLine(status);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

struct Node{
    string name;
    map<string,Node*> msn;
    Node *par;
    int num;
    Node(){
        par=NULL;
        num=0;
    }
};

int idx;

void parse(string s,Node *node){
    string name;
    string left;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='/'){
            name=s.substr(0,i);
            left=s.substr(i+1);
            break;
        }
        else if(i==s.size()-1){
            name=s;
            break;
        }
    }
    if(node->msn.find(name)==node->msn.end()){
        Node *nd = new Node();
        nd->name=name;
        nd->par=node;
        node->msn[name]=nd;
        // t@CÉÍidðÂ¯Ä¯Ê
        if(left=="")
            nd->num=idx++;
    }
    // Ü¾¶ªcÁÄ¢êÎAÄA
    if(left!="")
        parse(left,node->msn[name]);
}

// ßêéæ¤Éem[hÖÌQÆàÁÄ¨­
int search(Node *node,string path){
    if(node==NULL)return 0;
    // t@CÌêÜÅB
    if(node->num!=0)
        return node->num;
    // ±±ÅpXªóÉÈÁ½
    if(path==""){
        // indexªºÉ é©Å»f
        if(node->msn.find("index.html")==node->msn.end())
            return 0;
        return node->msn["index.html"]->num;
    }
    string name;
    string left;
    bool isFile=false;
    for(int i = 0; i < path.size(); i++){
        if(path[i]=='/'){
            name=path.substr(0,i);
            left=path.substr(i+1);
            break;
        }
        else if(i==path.size()-1){
            isFile=true;
            name=path;
            break;
        }
    }
    if(!isFile&&node->msn.find(name)!=node->msn.end()&&node->msn[name]->num!=0)
        return 0;
    // ÅºwÌfBNg é¢Ít@Cð¦·
    if(name=="..")
        return search(node->par,left);
    else if(name==".")
        return search(node,left);
    // ÄA
    if(node->msn.find(name)==node->msn.end())
        return 0;
    return search(node->msn[name],left);
}

void deleteTree(Node *node){
    if(node->msn.size()==0){
        delete node;
        return;
    }
    for(map<string,Node*>::iterator it=node->msn.begin();it!=node->msn.end();it++){
        deleteTree(node->msn[it->first]);
    }
}

int main(){

    int n,m;
    while(cin>>n>>m&&!(n==0&&m==0)){
        idx=1;
        Node *root = new Node();
        root->name+='/';
        root->par=NULL;
        for(int i = 0; i < n; i++){
            string s;
            cin>>s;
            parse(s.substr(1),root);
        }
        for(int i = 0; i < m; i++){
            string s1,s2;
            cin>>s1>>s2;
            int res1=search(root,s1.substr(1));
            int res2=search(root,s2.substr(1));
            if(res1==0||res2==0)cout<<"not found"<<endl;
            else if(res1==res2)cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
        deleteTree(root);
    }

    return 0;
}

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


int inf = 1000*16;
vector<vector<int>> dist(15, vector<int>(15, inf));  // グラフ構造
vector<vector<int>> dp(pow(2, 15), vector<int>(15, 0));

int rec(long long S, int v)
{
    if (S==0 && v==0) return 0;
    if (!(S & (1<<v))) return inf;

    if (dp[S][v]) return dp[S][v];
    int &ret = dp[S][v];
    ret = inf;
    for (int i=0; i<15; i++)
    {
        ret = min(ret, rec(S^(1<<v), i) + dist[i][v]);
    }
    return ret;
}

int main()
{
    int V, E;
    cin >> V >> E;

    // グラフの初期化
    for (int i=0; i<15; i++)
    {
        for (int j=0; j<15; j++) dist[i][j] = inf;
    }
    
    for (int i=0; i<E; i++)
    {
        int s,t,d;
        cin >> s >> t >> d;
        dist[s][t]=d;
    }

    int ans = rec((1<<V)-1, 0);
    if (ans >= inf) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 6144
// 153

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

int main() {
    ll h, n;
    cin >> h >> n;
    vector <ll> a(n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans = ans + a[i];
    }
    if (h > ans) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
function Main(input) {
    let k = input.split('\n')[0];
    let a = input.split('\n')[1].split(' ')[0];
    let b = input.split('\n')[1].split(' ')[1];

    let result = 'NG';

    for (let i = 1; k * i <= 1000; i++) {
        if (a <= (k * i) && (k * i) <= b) {
            result = 'OK';
            break;
        }
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29628
N = int(input())
D1 = [0] * N
D2 = [0] * N
for i in range(N):
    D1[i], D2[i] = input().split()

flg = False
for i in range(N -2):
    if D1[i] == D2[i] and D1[i + 1] == D2[i + 1] and D1[i + 2] == D2[i + 2]:
        flg = True
        # break
if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9184
#include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define int         long long
    #define pb          push_back
    #define vi          vector<int>
    #define pii         pair<int,int>
    #define all(a)      (a).begin(),(a).end()
    #define ff           first
    #define ss           second
    #define INF         1e10
    const int N = 2000 + 5, K = 21, mod = 1000000007, MOD = 1000000007;  
    
    void solve(){
        int n;
        cin>>n;
        vi v(n);
        for(int i=0; i<n; i++)
            cin>>v[i];
        int ans = 0;
        sort(all(v));
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                for(int k=j+1; k<n; k++){
                    if(v[i]==v[j] || v[i]==v[k] || v[j]==v[k])
                        continue;
                    if(v[i]+v[j] > v[k])
                        ans++;
                }
            }
        }
        cout<<ans<<endl;
    }      

    int32_t main()
    {
        IOS;
        int TESTS=1;
        // cin>>TESTS;
        while(TESTS--)
        {       
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

class Point
{
public:
    int y, x;
    bool operator==(const Point& p) const{
        return y == p.y && x == p.x;
    }
};

bool isAccess(Point& p1, Point& p2)
{
    return p1.y == p2.y || p1.x == p2.x || abs(p1.y - p2.y) == abs(p1.x - p2.x);
}

int solve(Point& p1, Point& p2, Point gp)
{
    if(p1 == gp || p2 == gp)
        return 0;
    if(isAccess(p1, gp) && isAccess(p2, gp))
        return 1;
    if(isAccess(p1, gp) || isAccess(p2, gp))
        return 2;
    if(isAccess(p1, p2))
        return 3;

    for(int i=0; i<4; ++i){
        for(int j=0; j<4; ++j){
            int a = dx[i];
            int b = -dx[j];
            int c = p2.x - p1.x;
            int d = dy[i];
            int e = -dy[j];
            int f = p2.y - p1.y;

            if(b * d - a * e == 0)
                continue;
            if((b * f - c * e) % (b * d - a * e) != 0)
                continue;

            int s = (b * f - c * e) / (b * d - a * e);
            Point q;
            q.y = p1.y + s * dy[i];
            q.x = p1.x + s * dx[i];

            if(isAccess(q, gp))
                return 3;
        }
    }

    return 4;
}

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

    while(--n >= 0){
        Point p1, p2, gp;
        cin >> p1.x >> p1.y >> p2.x >> p2.y >> gp.x >> gp.y;
        cout << solve(p1, p2, gp) << endl;
    }
}

Measured memory_bytes: 1156
#include <iostream>

using namespace std;

int main(void){

  int n;
  while( cin >> n , n ){

    int m = - 99999999;
    int s = 0;
    while(n--){

      int x;
      cin >> x;
      s += x;
      m = max( m , s );
      if( s < 0 ) s = 0;

    }
    cout << m << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ac,wa,tle,re;
    ac=wa=tle=re=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s=="WA")
            wa++;
        else if(s=="AC")
            ac++;
        else if(s=="TLE")
            tle++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
string s;
int main()
{
	cin>>s;
	int p=0;
	int n=s.size();
	for (int i=0;i<n;i++) p+=s[i]-'0';
	if (p%9) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 3392
#include <iostream>

int main(){
   int N, K;
   std::cin >> N >> K;
   int h;
   int ans = 0;
   for(int i=0; i<N; ++i) {
      std::cin >> h;
      if(h>=K) ++ans;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main(){ cin.tie(0); ios::sync_with_stdio(false);
    int N = in, D = in;
    vector<vector<int>> X( N, vector<int>(D) );
    rep( i, N ) rep( j, D ) X[i][j] = in;

    int ans = 0;
    rep( i, N ) rep( j, i ) {
        int temp = 0;
        rep( k, D ) temp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
        for( int k=1; k*k <= temp; k++ ) {
            if( k*k == temp ) {ans ++; break;}
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N,L;
    cin >> N >> L;
    vector<int> taste(N);
    int sum=0, m=10000000, flag;
    for(int i=0; i<N; i++){
        taste[i]=L+i;
        sum+=taste[i];
        int tmp=abs(taste[i]);
        if(tmp<m){
            m=tmp;
            flag=i;
        }
    }
    cout << sum-taste[flag] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int len,i,j;
	char s[9],t[9];
	scanf("%s",s);
	len = strlen(s);
	if(len == 2)
		printf("%s\n",s);
	else
	{
		for(i = 0,j = len - 1;i < len;i++,j--)
		{
			t[j] = s[i];
		}
		t[len] = '\0';
		printf("%s\n",t);
	}
	return 0;
}

	


Measured memory_bytes: 128
n, k = map(int, input().split())
l = [0 for _ in range(k)]
for i in range(k-1, -1, -1):
    j = pow(k//(i+1), n, 10**9+7)
    for m in range(2, k//(i+1) + 1):
        j -= l[(i+1)*(m)-1]
    l[i] = j

ans = 0
for i in range(k):
    ans += (i+1) * l[i]
print(ans % (10**9+7))

Measured memory_bytes: 11268
n = int(input())
a = input().split()
aa = [int(a[i]) for i in range(n)]
b = 1
for i in range(n):
  s = list(str(aa[i]))
  ss = int(s[-1])
  if ss == 0 or ss == 2 or ss == 4 or ss == 6 or ss == 8:
  	b = b * aa[i]

c = 0
cnt = 0
while c < 1:
  if b % 2 == 0:
    b = b // 2
    cnt = cnt + 1
  else:
    c = 1
print(cnt)



Measured memory_bytes: 52060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,m;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int s=sc.nextInt();
		int ss=sc.nextInt();
    if(s*500>=ss){
          System.out.print("Yes") ;
      }
     else{
      System.out.print("No") ;
     }
	}
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int K;
bool f[10];

bool ok(int x)
{
    while (x) {
	int t = x % 10;
	if (f[t]) return false;
	x /= 10;
    }
    return true;
}

int main() {
    cin >> N >> K;

    rep(i, K) {
	int x;
	cin >> x;
	f[x] = 1;
    }

    while (true) {
	if (ok(N)) {
	    cout << N << endl;
	    return 0;
	}
	N++;
    }
}

Measured memory_bytes: 256
L = int(input())
if L % 3 == 0:
  b = [i + 1 for i in range(L)]
  k = [(i * (L - i) * (L - i)) / 4 for i in b]
  print(max(k))
else: 
  import numpy as np
  b = np.arange(0.1, L+0.005, 0.005)
  k = [(i * (L - i) * (L - i)) / 4 for i in b]
  print(max(k))


Measured memory_bytes: 21744
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

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

    int L = 0;
    int pointer = 0;
    rep(i, s.size()){
        if(s[i] == '(') pointer++;
        else if(pointer - 1 < 0) L++;
        else pointer--;
    }
    int R = pointer;

    string ans = "";
    rep(i, L) ans += "(";
    ans += s;
    rep(i, R) ans += ")";

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean isNext(){return sc.hasNext();}
        static String[] mySplit(String str){return str.split("");}
        public static void main(String[] args){
          int N = getInt();
          long output = 0;
          HashMap<String,Long> hm = new HashMap<String,Long>();
          hm.put("M",new Long(0));
          hm.put("A",new Long(0));
          hm.put("R",new Long(0));
          hm.put("C",new Long(0));
          hm.put("H",new Long(0));
          for(int i = 0; i < N; i++){
            String tmp = getStr().substring(0,1);
            if(hm.containsKey(tmp)){
              hm.put(tmp,hm.get(tmp) + 1);
            }
          }
          myerr(hm);
          ArrayList<String> keys = new ArrayList<String>();
          keys.add("M");
          keys.add("A");
          keys.add("R");
          keys.add("C");
          keys.add("H");
          for(int i = 0; i < keys.size() - 2; i++){
            for(int j = i + 1; j < keys.size() - 1; j++){
              for(int k = j + 1; k < keys.size(); k++){
                output += hm.get(keys.get(i)) * hm.get(keys.get(j)) * hm.get(keys.get(k));
              }
            }
          }
          myout(output);
        }
        //Method addition frame start

        //Method addition frame end
}


Measured memory_bytes: 46016
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;

map<int,int> A;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>x;
		A[x]++;
	}
	cin>>M;
	FOR(i,M) {
		cin>>x;
		if(A[x]==0) return _P("NO\n");
		A[x]--;
	}
	_P("YES\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
char s[50],s2[20];

int main()
{
	int a,b;
	scanf("%d%d%s",&a,&b,s);
	int len=strlen(s);
	if(len==a+b+1){
		int f=0;
		for(int i=0;i<len;i++){
			if(i!=a){
				if(s[i]>='0'&&s[i]<='9') continue;
				else{
					f=1;
					break;
				}
			}else{
				if(s[i]!='-'){
					f=1;
					break;
				}
			}
		}
		if(!f)
		puts("Yes");
		else
		puts("No");
	}else
	    puts("No");
	    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef pair <int, int> ii;

const int Maxn = 100005;
const int Inf = 1000000000;

int K;
int dist[Maxn];
priority_queue <ii> Q;

int main()
{
	scanf("%d", &K);
	fill(dist, dist + K, Inf);
	for (int i = 1; i <= 9; i++) if (dist[i % K] >= Inf) {
		dist[i % K] = i; Q.push(ii(-i, i % K));
	}
	while (!Q.empty()) {
		int v = Q.top().second, d = -Q.top().first; Q.pop();
		if (dist[v] != d) continue;
		if (v == 0) { printf("%d\n", d); break; }
		for (int i = 0; i < 10; i++) {
			int u = (10 * v + i) % K;
			if (d + i < dist[u]) {
				dist[u] = d + i;
				Q.push(ii(-dist[u], u));
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2804
def inputlist():
    return [int(i) for i in input().split()]


def main():
    N, K = inputlist()
    aryNum = [0] * N

    aryInput = []
    for i in range(K):
        intNumType = int(input())
        aryInput = inputlist()
        for j in range(len(aryInput)):
            aryNum[aryInput[j] - 1] += 1

    sum = 0
    for i in range(N):
        if aryNum[i] == 0:
            sum += 1

    print(sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9132
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  unsigned int *key;
  struct node *next;
  struct node *prev;
};
 typedef struct node * NodePointer;

 NodePointer c;

NodePointer search(int key){
  NodePointer a=c->next;
  while(a!=c && a->key != key){
    a=a->next;
  }
  return a;
}
 void z(){
   c=malloc(sizeof(struct node));
   c->next=c;
   c->prev=c;
 }
 void list(){
   NodePointer a=c->next;
   int b = 1;
   while(1){
     if(a==c)break;
     if(b==0)printf(" ");
     printf("%d",a->key);
     a=a->next;
     b=0;
   }
   printf("\n");
 }
  void delete(NodePointer x){
    if(x==c)return;
    x->prev->next=x->next;
    x->next->prev=x->prev;
    free(x);
  }

void first(){
  NodePointer x=c->next;
  if(x==c) return;
  delete(x);
}

void last(){
  delete(c->prev);
}

void deletekey(int key){
delete(search(key)) ;
}
void insert(int key){
  NodePointer y;
  y=malloc(sizeof(struct node));
  y->key=key;
  y->next=c->next;
  c->next->prev=y;
  c->next=y;
  y->prev=c;
}
int main(){
  int key,kin,i;
  int size=0;
  char com[20];
  int mi=0,hi=0;
  scanf("%d",&kin);
  z();
  for(i=0;i<kin;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){insert(key);mi++;size;}
else if(com[0]=='d'){
  if(strlen(com)>6){
    if(com[6]=='F')first();
    if(com[6]=='L')last();
  }else{
    deletekey(key); hi++;
  }
  size--;
}
}
list();
return 0;
}



Measured memory_bytes: 32960
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            double d = n / 1.08;
            int i = (int)Math.Ceiling(d);
            if ((int)(i * 1.08) == n)
            {
                Console.WriteLine(i);
            }
            else {
                Console.WriteLine(":(");
            }
        }
    }
}

Measured memory_bytes: 27400
from collections import OrderedDict

d = OrderedDict((chr(i), 0) for i in range(ord('a'), ord('a')+26))

while True:
    try:
        s = input()
    except EOFError:
        break
    else:
        for c in s.lower():
            if c in d:
                d[c] += 1

for k, v in d.items():
    print("{} : {}".format(k, v))

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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    int a, b, c;
    cin >> a >> b >> c;
    cout << b + min(c, a + b + 1) << endl;
    return 0;
}


Measured memory_bytes: 892