akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int n;
    scanf("%d",&n);
    char s[10000],t[10000];
    int i;
    scanf("%s %s",s,t);
    for(i=0;i<n;i++){
        printf("%c%c",s[i],t[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

ll H, W, N;

int main(){
  string S;
  cin >> S;
  if(S[S.size()-2] == S[S.size()-1]){
    cout << S.size()-1 << " " << S.size() << endl;
    return 0;
  }
  S += 'A';
  rep(i, S.size()-2){
    int a = S[i], b = S[i+1], c = S[i+2];
    if(a == b || a == c || b == c){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
int main(void){
    int a,b,C;
    double S,L,h,R;
    
    scanf("%d %d %d",&a,&b,&C);
    R=C*PI/180;
    S=0.5*a*b*sin(R);
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(R));
    h=2*S/a;
    
    printf("%.8f\n%.8f\n%.8f\n",S,L,h);
    
    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
bool isACGT(char c){
    return (c == 'A' || c == 'C' || c == 'G' || c == 'T');
}

int main()
{
    string s;
    int maxlen = 0, len;
    int i, j;
    
    cin >> s;
    len = s.length();
    for (i = 0; i < len; i++, j=0){
        while (isACGT(s[i+j])){ j++; }
        if (j > maxlen){
            maxlen = j;
        }
    }
    cout << maxlen << endl;
}


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

import javax.swing.text.StyleContext.SmallAttributeSet;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int size = s.nextInt();
		int[] points  = new int[size];
		int sum =0;
		for (int i = 0; i < size; i++) {
			points[i] = s.nextInt();
			sum += points[i];
		}
		if (sum %10 != 0) {
			System.out.println(sum);
		}else{
			int SmallestNon10 = findSmallestNon10(points);
			if (SmallestNon10 == -1) {
				System.out.println(0);
			}else{
				System.out.println(sum - SmallestNon10);
			}
		}
	}
	

	public static int findSmallestNon10(int[] points){
		Arrays.sort(points);
		for (int i = 0; i < points.length; i++) {
			if (points[i]%10 != 0) {
				return points[i];
			}
		}
		return -1;
	}
}


Measured memory_bytes: 21972
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

int main()
{
    const long long MOD = 1000000007;
    long long m, n;
    int a;

    std::cin >> n >> m;

    std::vector<bool> b(n + 1, false);
    std::vector<long long> dp(n + 1);

    for (int i = 0; i < m; i++)
    {
        std::cin >> a;
        b[a] = true;
    }

    dp[0] = 1;
    if (b[1])
        dp[1] = 0;
    else
        dp[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        if (b[i])
            dp[i] = 0;
        else
            dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }

    std::cout << dp[n] << std::endl;

    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    
    int n, k, ans = INT_MAX;
    cin >> n >> k;
    vector<int> A(n);
    for (int i = 0; i < n; i++)cin >> A[i];
    
    for (int i = 0; i <=n-k; i++) {
        int a = A[i], b = A[i+k-1], result;
        
        if (b <= 0) {
            result = abs(a);
        } else if (a >= 0) {
            result = abs(b);
        } else {
            result = abs(a) + abs(b) + min(abs(a), abs(b));
        }
        ans = min(ans, result);
    }
    cout << ans << endl;
    
    return 0;
}



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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		char[] s = sc.next().toCharArray();
		Arrays.sort(s);

		System.out.println(new String(s).equals("abc") ? "Yes" : "No");
	}
}

Measured memory_bytes: 35640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    // 整数の入力
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    // W = 2;
    // H = 3;
    // x = 1;
    // y = 1;
    double S = W * H / 2;
    int num = 0;
    // 出力
    if(abs(x-W/2) <= 0.00001 && abs(y-H/2) <= 0.00001){
        num = 1;
    }
    else
        num = 0;

    cout << S << " " << num << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
a = deque(input())
b = deque(input())
c = deque(input())

i = 0
turn = 'a'
while True:
    if turn == 'a':
        if len(a) == 0:
            ans = 'A'
            break
        a0 = a.popleft()
        if a0 == 'a':
            turn = 'a'
        elif a0 == 'b':
            turn = 'b'
        elif a0 == 'c':
            turn = 'c'
    elif turn == 'b':
        if len(b) == 0:
            ans = 'B'
            break
        b0 = b.popleft()
        if b0 == 'a':
            turn = 'a'
        elif b0 == 'b':
            turn = 'b'
        elif b0 == 'c':
            turn = 'c'
    elif turn == 'c':
        if len(c) == 0:
            ans = 'C'
            break
        c0 = c.popleft()
        if c0 == 'a':
            turn = 'a'
        elif c0 == 'b':
            turn = 'b'
        elif c0 == 'c':
            turn = 'c'
print(ans)

Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int n,m,x,a[15][15],c[15];
ll call(int i,int mask)
{
//	cout<<i<<" "<<mask<<" ";
	int cost=0,p[n],j,k;
	for(j=0;j<n;j++) p[j]=0;
		for(k=0;k<m;k++)
		{
			if(1<<k & mask)
			{
				for(j=0;j<n;j++) 
					p[j]+=a[k][j];
				cost+=c[k];
			}
		}
		for(j=0;j<n;j++) 
		{
			
			if(p[j]<x) break;
		}
//		cout<<cost<<" "<<j<<" ";
		if(j==n)
		{
//		cout<<cost<<"\n";
		return cost;
		}
//		cout<<cost<<" ";
//cout<<endl;
	if(i==m) return -1;
	ll x=call(i+1,mask);
	ll y=call(i+1,mask|1<<i);
//	cout<<x<<" "<<y<<" \n";
	if(x==-1) return y;
	else if(y==-1) return x;
	else return min(x,y);
}
int main()
{
	int i,j;
	cin>>m>>n>>x;
	for(i=0;i<m;i++)
	{
		cin>>c[i];
		for(j=0;j<n;j++) cin>>a[i][j];
	}
	cout<<call(0,0);
	
	return 0;
}

Measured memory_bytes: 3596
// D - Dice in Line
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n >> k;
  vlli d(n);
  double tmp = 0, ans = 0, count = 0;
  vector<double> e, f(n + 1, 0);
  rep(i, 0, n)
  {
    cin >> d[i];
    if (d[i] % 2 == 1)
    {
      e.pb(d[i] / 2 + 1);
    }
    else
    {
      e.pb(d[i] / 2 + 0.5);
    }
  }
  rep(i, 0, n)
  {
    f[i + 1] = f[i] + e[i];
  }
  rep(i, k, f.size())
  {
    count = f[i] - f[i - k];
    ans = max(ans, count);
  }
  cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 8404
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer 降順ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int [] nk = inputval();
        int n = nk[0];
        int k = nk[1];
        int [] al = inputval();
        Map<Integer, Integer> map = new HashMap<>();
        int ans = 0;

        for (int i = 0; i<n; i++){
            int a = al[i];
            if (map.containsKey(a)){
                map.replace(a,map.get(a)+1);
            }else{
                map.put(a,1);
            }
        }
        List<Integer> list = new ArrayList<>(map.values());
        Collections.sort(list);
        int loopNum = list.size()-k;
        for (int j = 0; j < loopNum; j++){
            ans += list.get(j);
        }
        System.out.println(ans);

    }

}



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

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	vector<long long int> b(n);
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end());
	long long int aa = 0;
	long long int bb = 0;
	for (long long int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			vector<long long int>::iterator ite = lower_bound(b.begin(), b.end(), a[i]);
			long long int k = ite-b.begin();
			if (k % 2 == 1) {
				aa++;
			}
		} else {
			vector<long long int>::iterator ite = lower_bound(b.begin(), b.end(), a[i]);
			long long int k = ite-b.begin();
			if (k % 2 == 0) {
				bb++;
			}
		}
	}
	cout << aa << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner cin;
    static void Main()
    {
        
        cin = new Scanner();
        int[] nmc = cin.arrayInt(3);
        int[] bArray = cin.arrayInt(nmc[1]);
        int[][] aArray = new int[nmc[0]][];
        for(int a = 0; a < nmc[0]; a++)
        {
            aArray[a] = cin.arrayInt(nmc[1]);
        }
        int count = 0;
        
        for(int a = 0; a < nmc[0]; a++)
        {
            int total = 0;
            for(int b = 0; b < nmc[1]; b++)
            {
                total += bArray[b] * aArray[a][b];
            }
            total += nmc[2];
            if (total > 0) count++;
        }
        WriteLine(count);
        ReadLine();

    }
}





class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string input()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return input();
        i = 0;
        return s[i++];
    }

    public int inputInt()
    {
        return int.Parse(input());
    }
    public int[] arrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputInt() + add;
        }
        return Array;
    }

    public long inputLong()
    {
        return long.Parse(input());
    }

    public long[] arrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputLong() + add;
        }
        return Array;
    }

    public double inputDouble()
    {
        return double.Parse(input());
    }


    public double[] arrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = inputDouble() + add;
        }
        return Array;
    }
}

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

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

			List<KeyValuePair<int, int>> list = new List<KeyValuePair<int, int>> (joinCount);

			for (int lp = 0; lp < joinCount; lp++)
			{
				int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
				list.Add (new KeyValuePair<int, int> (inputNum[0], inputNum[1]));
			}

			var result = list.OrderByDescending (item => item.Value).ThenBy (item => item.Key).First ();

			Console.WriteLine (result.Key + " " + result.Value);
		}
	}
}

Measured memory_bytes: 10136
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>
#include <ctime>
#include <complex>
#include <ext/rope>

#define F1(x,y,z) for(int x=y;x<z;x++)
#define F2(x,y,z) for(int x=y;x<=z;x++)
#define F3(x,y,z) for(int x=y;x>z;x--)
#define F4(x,y,z) for(int x=y;x>=z;x--)
#define mp make_pair
#define pb push_back
#define LL long long
#define co complex<double>
#define fi first
#define se second

#define MAX 100005
#define AMAX 1500
#define MOD 1000000007

#define f(c,d) ((1<<(c))*(d))

using namespace std;
using namespace __gnu_cxx;

int i;
char x[1005];
bool y[4];

int main(){
	scanf("%s",x);
	while(x[i]){
		if(x[i]=='N')y[0]=1;
		if(x[i]=='S')y[1]=1;
		if(x[i]=='E')y[2]=1;
		if(x[i]=='W')y[3]=1;
		i++;
	}
	printf(((y[0]^y[1])||(y[2]^y[3]))?"No\n":"Yes\n");
	#ifdef LOCAL_PROJECT
    system("pause");
    #endif
    return 0;
}


Measured memory_bytes: 128
import math

N = int(input())
xs = []
ys = []
for i in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)
ans = 0
for i in range(N):
    for j in range(i):
        ans += 2 * math.sqrt((xs[i] - xs[j]) ** 2 + (ys[i] - ys[j]) ** 2)
ans /= N
print(ans)

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

using namespace std;
using ll = long long;

int n, m;
vector<vector<int>> hen;
vector<int> dp; //0 := 未訪問 1 := 検査中 2 := 終了

void dfs(int v) {
    if(dp[v] == 1) {
        cout << 1 << endl;
        exit(0);
    }
    if(dp[v] == 2) {
        return;
    }
    dp[v] = 1;
    for(auto i : hen[v]) {
        dfs(i);
    }
    dp[v] = 2;
}


int main()
{
    cin >> n >> m;
    hen.resize(n), dp.resize(n);
    for(int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        hen[a].push_back(b);
    }
    for(int i = 0; i < n; i++)dfs(i);
    cout << 0 << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int R;
  cin >> R;
  if(R < 1200){
  	cout << "ABC" << endl;
  }else if(R < 2800){
  	cout << "ARC" << endl;
  }else{
  	cout << "AGC" << endl;
  }
  
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class SegTree():
    def __init__(self, ide_ele, segfunc):
        self.ide_ele = ide_ele
        self.segfunc = segfunc
        self.seg = []
        self.num = 0

    def init(self, A):
        n = len(A)
        self.num = 2**(n-1).bit_length()
        self.seg = [self.ide_ele]*(2*self.num)
        for i in range(n):
            self.seg[i+self.num-1] = A[i]
        for i in range(self.num-2, -1, -1):
            self.seg[i] = self.segfunc(self.seg[2*i+1], self.seg[2*i+2])

    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])

    def query(self, p, q):
        if q <= p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p > 1:
            if p & 1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q & 1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res


import fractions
def main():
    s = SegTree(0, fractions.gcd)
    N = int(input())
    A = list(map(int, input().split()))
    s.init(A)
    ans = 0
    for i in range(N):
        ans = max(ans, fractions.gcd(s.query(0, i), s.query(i+1, N)))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86240
l = list(map(int,input().split()))
r = l[0]
c = l[1]

#各列毎の合計
lst = [0 for i in range(c)]

for i in range(r):
    temp = list(map(int,input().split()))
    for i in range(c):
        lst[i] += temp[i]

    print(*temp,sum(temp))

print(*lst,sum(lst))


Measured memory_bytes: 5632
N,A=map(int, input().split())
x=tuple(map(lambda i:int(i)-A,input().split()))
l=[0]*5001
l[0]=1
for i in x:
    f=l.copy()
    for j in range(-2500,2501):
        if l[j]:
            f[i+j]+=l[j]
    l=f.copy()
print(l[0]-1)

Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int a;
	int b;
	char mark;

	scanf("%d %c %d", &a, &mark, &b);

	if(mark == '+'){
		cout << a + b << "\n";
	}else{
		cout << a - b << "\n";
	}

	return 0;
}

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


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



int main() {

    string s; cin >> s;
    int c1=0,c2=0;
    rep(i, s.size()) {
        if(s[i] == '0') c1++;
        else c2++;
    }
    int ans = min(c1,c2) * 2;
    cout << ans << endl;

    return 0;

}

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

typedef long long ll;
typedef vector<int, int> vi;
typedef pair<int, int> pi;
#define F first;
#define S second;
#define PB push_back;
#define MP make_pair;
#define REP(i, a, b) for(int i = a; i <= b; i++)
ll itr(int *arr, int curr, int size, int value) {
	if(size==curr){
		return value%360;
	}
	ll add = itr(arr, curr+1, size, value + arr[curr]);
	ll sub = itr(arr,curr+1, size, value-arr[curr]);
	if(add == 0){
		return add;
	}
	return sub;
}
int main(){
	string as, bs;
	cin >> as >> bs;
	int a,b;
	cin >> a>>b;
	string u;
	cin >> u;
	if(as==u) a--;
	else if(bs==u) b--;
	cout << a << " " << b;
}


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

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

  long long int c[a], d[a];

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

  for(int i = 0; i < a; i++) {
    for(int j = 0; j < a - i - 1; j++) {
      if(c[j] < c[j + 1]) swap(c[j], c[j + 1]);
    }
  }

  for(int i = 0; i < a; i++) {
    vector<int> k;
    long long int gou = 0;
    for(int j = i; j < a; j++) {
      if(gou + c[j] >= b) {
        k.push_back(j);
        for(int v = 0; v < k.size(); v++) {
          d[k[v]] = 1;
        }
        k.resize(0);
      }else {
        k.push_back(j);
        gou += c[j];
      }
    }
  }

  int ans = 0;

  for(int i = 0; i < a; i++) {
    if(!d[i]) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author toshif
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, MyReader in, PrintWriter out) {
            int N = in.nextInt();
            long[] a = new long[N];
            long tot = 0;
            long[] s = new long[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextLong();
                tot += a[i];
                s[i] = tot;
            }

            long d = Long.MAX_VALUE;
            for (int i = 0; i < N - 1; i++) {
                d = Math.min(d, Math.abs(s[i] - (tot - s[i])));
            }

            out.println(d);

        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 48056
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main() {
  int n, x;
  cin >> n >> x;
  int S = 0;
  rep(i, n) {
    int L;
    cin >> L;
    S += L;
    if(S > x) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << n + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a + b >= c){
            System.out.println("Yes");
            return;
        }
            System.out.println("No");
    }
}


Measured memory_bytes: 21204
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    h = LI()
    h = [h[0]] + h
    dp = [0 for _ in range(n+1)]

    for i in range(2,n+1):
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]))
    ans = dp[n]
    print(ans)
main()            


Measured memory_bytes: 22084
menu = [int(input()) for i in range(5)]
mod = []
for i in menu:
    mod.append(i % 10)
last_index = 0
for i in range(5):
    if mod[last_index] > mod[i] and mod[i] >= 1:
        last_index = i
res = 0
for i, v in enumerate(menu):
    if i == last_index:
        continue
    res += v
    while res % 10 != 0:
        res += 1

res += menu[last_index]
print(res)

Measured memory_bytes: 3064
F =-> {gets.split.map &:to_i}
*,k = F[]
a,B = F[]<<k,F[]
m=i = a.index {0 > k-=_1}
A = a[0..i]
while a=A.pop
  k += a
  (k-=B.shift; i+=1) until B[0]>k rescue A.clear
  m = [m,1+i-=1].max
end
p m

Measured memory_bytes: 41752
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n=1;
	char a[5];
	for(i=1;i<5;i++)
	{
		cin>>a[i];
	}
	for(i=2;i<5;i++)
	{
		if(a[i]!=a[1])
		{
		a[1]=a[i];
		n=1;
		}
		else if(a[i]==a[1])
		{
		n++;
		}
		if(n==3)
			break;
	}
	if(n>2)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	vector<int> Nums;
	int now = 1; //今見ている数
	int cnt = 0; //nowがいくつ並んでいるか
	for (int i = 0; i < N; i++)
	{
		if (S[i] == (char)('0' + now)) cnt++;
		else {
			Nums.push_back(cnt);
			now = 1 - now; //0と1を切り替える時の計算 now ^= 1;
			cnt = 1; //新しいのをカウントし始める
		}
	}
	if (cnt != 0) Nums.push_back(cnt);

	//1-0-1-0-1-0-1って感じの配列が欲しい
	//1-0-1-0みたいに0で終わってたら、適当に１つ足す
	if (Nums.size() % 2 == 0) Nums.push_back(0);

	int Add = 2 * K + 1;

	//累積和を作る
	// 0 1 2 3 4 5 6
	//  0 1 2 3 4 5

	vector<int> sum(Nums.size() + 1);
	for (int i = 0; i < Nums.size(); i++)
	{
		sum[i + 1] = sum[i] + Nums[i];
	}


	int ans = 0;
	//1-0-1...の1から始めるので、偶数番目だけ見る
	for (int i = 0; i < Nums.size(); i += 2)
	{
		//次のleft, rightを計算する [left, right)
		int left = i;
		int right = min(i + Add, (int)Nums.size());
		int tmp = sum[right] - sum[left];

		ans = max(tmp, ans);
	}

	cout << ans << endl;
}



Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s=="Sunny"){
    cout << "Cloudy";
  }
  if(s=="Cloudy"){
    cout << "Rainy";
  }
  if(s=="Rainy"){
    cout << "Sunny";
  }
}

Measured memory_bytes: 256
#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 <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> C(H);
	rep(i, H) {
		cin >> C[i];
	}

	rep(i, 2 * H) {
		rep(j, W) {
			cout << C[i / 2][j];
			if (j == W - 1) {
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
//In The Name of ALLAH//

/*      ______     _    _______
       |  ___ \   | |  |  ____/   /\
       | |   \ \  | |  | |       /  \
       | |___/ /  | |  | |___   / /\ \
       |     _/   | |  |  __/  / /__\ \
       | |\ \     | |  | |    / ______ \
       | | \ \    | |  | |   / /      \ \
       |_|  \_\   |_|  |_|  /_/        \_\
*/

#include<bits/stdc++.h>

//#define FILEIO
#define ll long long

using namespace std;

const int SZ = 100005;
const int LIM = 1000000000;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
    return (a > b);
}

void solve()
{
    ll n, k, a[SZ], dp[SZ];
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++)
    {
        dp[i] = INT_MAX;
        for(int j = 1; j <= k; j++)
        {
            if(i > j) dp[i] = min(dp[i - j] + abs(a[i - j] - a[i]), dp[i]);
        }
    }
    cout << dp[n] << endl;
}

int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    //int tc;

    //cin >> tc;
    //while(tc--)
    {
        solve();
    }

    return 0;
}





Measured memory_bytes: 5172
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

stack<char> S;

string r;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	cin >> r;
	int  n = r.size();
	for(int i = 0; i < n; i++) {
		if(S.empty()) S.push(r[i]);
		else {
			if(S.top() != r[i]) { S.pop(); }
			else S.push(r[i]);
		}
	}
	cout << n - S.size();
	return 0;
}
/**/

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();

        long[] a = sc.LongArray();

        if (a.Contains(0))
        {
            Console.WriteLine(0);
            return;
        }

        decimal answer = 1;

        for (int i = 0; i < n; i++)
        {
            int digit1 = answer.ToString().Length;
            int digit2 = a[i].ToString().Length;

            if (digit1 + digit2 >= 21)
            {
                Console.Write(-1);
                return;
            }

            answer *= (decimal)a[i];

            if (answer < 0 || answer > 1000000000000000000)
            {
                Console.Write(-1);
                return;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 41432
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
int n;
int bit[100010];
void add(int v, int x) {

	while (v <= n)
	{
		bit[v] += x;
		v += v & -v;
	}
}

ll sum(int v) {
	ll r = 0;
	while (v > 0)
	{
		r += bit[v];
		v -= v & -v;
	}
	return r;
}

void solv() {
	int s;
	cin >> s;
	int se = s % 60;
	int ho = s / 3600;
	int mi = (s - (ho * 3600) - se) / 60;
	cout << ho << ":" << mi << ":" << se << endl;
}


int main() {
	//	COMinit();
	solv();

	return 0;
}



Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder170
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputList = input.Split(" ");
            int.TryParse(inputList[0], out var x);
            int.TryParse(inputList[1], out var y);

            if (y % 2 != 0 || 4 * x < y || 2 * x > y)
            {
                Console.WriteLine("No");
                return;
            }

            var a = 2 * x - y / 2;
            if (a <= x)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27476
def shuffle(cards, h):
    return cards[h:] + cards[:h]

def solve(cards, hs):
    for h in hs:
        cards = shuffle(cards, h)
    return cards

if __name__ == '__main__':
    while True:
        s = input()
        if s == '-':
            break
        m = int(input())
        hs = [int(input()) for i in range(m)]
        print(solve(s, hs))

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define forabr(i, a, b) for(int i = int(b)-1; i >= int(a); i--)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

ld ans, cnt;
int n;

ld dist(const pii &a, const pii &b) {
    return sqrt((a.fst - b.fst) * (a.fst - b.fst) + (a.snd - b.snd) * (a.snd - b.snd));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(20);
    cin >> n;
    vector<pii> a(n);
    forn(i, n) cin >> a[i].fst >> a[i].snd;
    sort(all(a));
    do {
        forn(i, n - 1) {
            ans += dist(a[i], a[i + 1]);
        }
        cnt++;
    } while (next_permutation(all(a)));
    cout << ans / cnt << "\n";
    return 0;
}

Measured memory_bytes: 256
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

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

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  lcm(x, y)   ((x) * (y) / __gcd(x, y))
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    
    ll mx = -INF;
    
    mx = max(a*c , mx);
    mx = max(a*d , mx);
    mx = max(b*c , mx);
    mx = max(b*d , mx);
    
    cout << mx;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 3652
import java.io.*;
import java.util.StringTokenizer;
     
class Main{
     
static final PrintWriter out=new PrintWriter(System.out);
  
static class binarySearchTree{
  
static class Node{
int id;
Node p;
Node l;
Node r;
Node(int id){
this.id=id; this.p=null; this.l=null; this.r=null;
}
}
  
private static Node root;
  
binarySearchTree(){
root=null;
}
  
public static void insert(int v){
if(root==null) root=new Node(v);
else __insert(new Node(v));
}
  
private static void __insert(Node z){
Node x=root;
Node y=null;
while(x!=null){
y=x;
if(z.id<x.id) x=x.l;
else x=x.r;
}
z.p=y;
if(z.id<y.id) y.l=z;
else y.r=z;
}
  
public static boolean find(int v){
Node x=root;
while(x!=null){
if(x.id==v) return true;
else if(x.id>v) x=x.l;
else x=x.r;
}
return false;
}

public static boolean delete(int v){
Node x=root;
Node y=null;
boolean isLeftChild=true;
while(true){
if(x==null) return false;
else if(x.id==v) break;
y=x;
if(v<x.id){
x=x.l;
isLeftChild=true;
}
else{
x=x.r;
isLeftChild=false;
}
}
if(x.l==null){
if(x==root) root=x.r;
else if(isLeftChild) y.l=x.r;
else y.r=x.r;
}
else if(x.r==null){
if(x==root) root=x.l;
else if(isLeftChild) y.l=x.l;
else y.r=x.l;
}
else{
y=x;
Node right=x.r;
isLeftChild=false;
while(right.l!=null){
y=right;
right=right.l;
isLeftChild=true;
}
x.id=right.id;
if(isLeftChild) y.l=right.r;
else y.r=right.r;
}
return true;
}

public static void print(){
inorder(root);
out.println();
preorder(root);
out.println();
}
  
private static void preorder(Node now){
if(now==null) return;
out.print(" "+now.id);
preorder(now.l);
preorder(now.r);
}
   
private static void inorder(Node now){
if(now==null) return;
inorder(now.l);
out.print(" "+now.id);
inorder(now.r);
}
   
private static void postorder(Node now){
if(now==null) return;
postorder(now.l);
postorder(now.r);
out.print(" "+now.id);
}
}
  
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
binarySearchTree tree=new binarySearchTree();
int num=Integer.parseInt(br.readLine());
while(num-->0){
st=new StringTokenizer(br.readLine());
String command=st.nextToken();
int n;
if("insert".equals(command)){
n=Integer.parseInt(st.nextToken());
tree.insert(n);
}
else if("find".equals(command)) {
n=Integer.parseInt(st.nextToken());
out.println((tree.find(n))?"yes":"no");
}
else if("delete".equals(command)) {
n=Integer.parseInt(st.nextToken());
tree.delete(n);
}
else tree.print();
}
out.flush();
}
}

Measured memory_bytes: 145996
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int dr[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n, m, k;
	cin >> n >> m >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1--, y1--, x2--, y2--;
	vector<string> mat(n);
	vector<vector<int>> shr(n, vector<int>(m, -1));
	for(auto& el: mat) cin >> el;
	auto ins = [&](int x, int y) {
		return x >= 0 && y >= 0 && x < n && y < m;
	};

	queue<ii> q;
	q.push(ii(x1, y1));
	shr[x1][y1] = 0;
	while(q.size()) {
		auto cr = q.front();
		q.pop();
		for(int i = 0; i < 4; i++) {
			for(int j = 1; j <= k; j++) {
				int x = cr.fi + j * dr[i][0], y = cr.se + j * dr[i][1];
				if(!ins(x, y) || mat[x][y] == '@') break;
				if(shr[x][y] == -1) { 
					shr[x][y] = shr[cr.fi][cr.se] + 1;
					q.push(ii(x, y));
				} else if(shr[x][y] <= shr[cr.fi][cr.se]) break;
			}
		}
	}
	int ky = shr[x2][y2];
	cout << ky << '\n';
}



Measured memory_bytes: 11160
#include <bits/stdc++.h>
using namespace std;
int main(){
        int x, n; cin >> x >> n;
        map<int, bool> b;
        for (int y = 1; y <= n; ++y){
            int q; cin >> q;
            b[q] = true;
        }
        for (int y = 0; ; ++y){
            int l = x - y;
            int r = x + y;
            if (!b[l]){
                cout << l << endl;
                break;
            }
            if (!b[r]){
                cout << r << endl;
                break;
            }
        }
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
int main(void){
 char s[3][11];
 int i;
 for(i=0;i<3;i++) scanf("%s",s[i]);
 if(s[0][strlen(s[0])-1]==s[1][0] && s[1][strlen(s[1])-1]==s[2][0]) printf("YES");
 else printf("NO");
 return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int n, a, b, c, d;
	int count;
	while (scanf("%d", &n) != EOF)
	{
		count = 0;
		for (a = 0; a < 10; a++)
			for (b = 0; b < 10; b++)
				for (c = 0; c < 10; c++)
					for (d = 0; d < 10; d++)
						if (a + b + c + d == n)count++;
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main()
{
    int a,b,c; cin >> a >> b >>c;
    if(a==5&&b==5){
        if(c==7) cout<<"YES";
        else cout<<"NO";
    }
    else if(b==5&&c==5){
        if(a==7) cout<<"YES";
        else cout<<"NO";
    }
    else if(a==5&&c==5){
        if(b==7) cout<<"YES";
        else cout<<"NO";
    }
    else cout<<"NO";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n,i,s=0;
	cin>>n;
	int a[n-1],b[n];
	for(i=0;i<n-1;i++)
	{
	    cin>>a[i];
	}
	for(i=n-2;i>=0;i--)
	{
	    if(i==n-2)
	    b[i+1]=a[i];
	    else
	    {
	        b[i+1]=min(a[i],a[i+1]);
	    }
	}
	 b[0]=a[0];
	 for(i=0;i<n;i++)
	 s+=b[i];
	cout<<s<<endl;
}

Measured memory_bytes: 256