akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
int main()
{
    std::string nums;
    std::cin >> nums;
    std::vector<char> op(3);

    for (int bit = 0; bit < (1 << 3); bit++)
    {
        int sum = nums[0] - '0';
        for (int i = 0; i < 3; i++)
        {
            if (bit & (1 << i))
            {
                sum += nums[i + 1] - '0';
                op[i] = '+';
            }
            else
            {
                sum -= nums[i + 1] - '0';
                op[i] = '-';
            }
        }
        if (sum == 7) { break; }
    }

    std::cout << nums[0] << op[0] << nums[1] << op[1] << nums[2] << op[2] << nums[3] << "=7" << std::endl;

    return 0;
}

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

namespace Practice
{
    class Program
    {
        public class Node
        {
            public int id;
            public int _parent;
            public List<int> _children = new List<int>();
            public int _depth;
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Node[] nodes = new Node[n];
            for (int i = 0; i < n; ++i)
            {
                int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var node = new Node();
                node.id = arr[0];
                node._parent = -1;
                //int m = arr[1];
                for(int j=2;j<arr.Length;++j)
                {
                    node._children.Add(arr[j]);
                }
                nodes[arr[0]] = node;
            }
            // parentの設定
            foreach (var node in nodes)
            {
                Setparent(nodes, node);
            }
            Node rootnode = nodes.First(p => p._parent == -1);
            SetDepth(nodes, rootnode);
           
            foreach(Node node in nodes)
            {
                string type = null;
                if( node._depth == 0)
                {
                    type = "root";
                }else if( node._children.Count >= 1)
                {
                    type = "internal node";
                }else
                {
                    type = "leaf";
                }
                string szChildren = string.Join(", ", node._children.ConvertAll(p => p.ToString()).ToArray());
                string sz = string.Format("node {0}: parent = {1}, depth = {2}, {3}, [{4}]", node.id, node._parent, node._depth, type, szChildren);
                Console.WriteLine(sz);

            }
        }
        private static void Setparent(Node[] nodes, Node parent)
        {
            if(parent == null) { return; }
            if( parent._children.Count == 0) { return; }
            foreach(var id in parent._children)
            {
                var child = nodes[id];
                child._parent = parent.id;
                Setparent(nodes, child);
            }
        }
        private static void SetDepth(Node[] nodes, Node parent)
        {
            foreach(var childid in parent._children)
            {
                nodes[childid]._depth = parent._depth + 1;
                SetDepth(nodes, nodes[childid]);
            }
        }
    }

}



Measured memory_bytes: 30916
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

int main() {
	int n,a;
	cin >> n;
	map<int, ll> mp;
	rep(i, n) {
		cin >> a;
		mp[a]++;
	}

	vector<ll> ar,ar4;
	for(auto i = mp.rbegin(); i != mp.rend(); ++i) {
		if (i->second >= 2) {
			ll num = i->first;
			ar.emplace_back(num);
		}
		if (i->second >= 4) {
			ll num = i->first;
			ar4.emplace_back(num);
		}
	}
	sort(all(ar));
	sort(all(ar4));
	ll ans;
	int size = ar.size();
	int size4 = ar4.size();
	if (size < 2 && size4 < 1) {
		ans = 0;
	} else if (size >= 2 && size4 > 0) {
		ans = ar[size - 1] * ar[size - 2];
		ans = max(ans, ar4[size4 - 1] * ar4[size4 - 1]);
	} else if(size < 2 && size4 >= 0){
		ans = ar4[size4 - 1] * ar4[size4 - 1];
	} else {
		ans = ar[size - 1] * ar[size - 2];
	}
	cout << ans << endl;
}



Measured memory_bytes: 6528
# coding:utf-8

rl_list = input()

num_list = []

# rightフラグ 最初はrightなので初期値True
r_f = True
# leftフラグ
l_f = False

count = 0
temp = []
for i, rl in enumerate(rl_list):
    if r_f:
        if rl == 'R':
            count += 1
        else:
            temp = [count]
            r_f = False
            l_f = True
            count = 1
    elif l_f:
        if rl == 'R':
            temp.append(count)
            num_list.append(temp)
            r_f = True
            l_f = False
            count = 1
        else:
            count += 1
temp.append(count)
num_list.append(temp)

result = ''
for num in num_list:
    result += '0 ' * (num[0] - 1) + str(-(-num[0] // 2) + num[1] // 2) + ' ' + str(num[0] // 2 + -(-num[1] // 2)) + ' ' + '0 ' * (num[1] - 1)

print(result[:-1])


Measured memory_bytes: 9824
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=1e5+10;
int d[maxn],vis[maxn];
int main(){
    int n=read(),m=read();
    vis[1]=1;
    REP(i,1,n) d[i]=1;
    while(m--){
    	int x=read(),y=read();
    	d[x]--,d[y]++;
    	vis[y]|=vis[x];
    	if(!d[x]) vis[x]=0;
	}
	int ans=0;
	REP(i,1,n) ans+=vis[i];
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    string s; cin >> s;
    ll k; cin >> k;
    int countDiff = 0;
    repp(i, 0, (int)s.size()) {
        int countSame = 1;
        while(i < (int)s.size() - 1 && s[i] == s[i+1]) {
            ++countSame;
            ++i;
        }
        countDiff += countSame / 2;
    }
    int last = 1;
    repm(i,(int)s.size()-2,-1) {
        if(s[i] == s[(int)s.size()-1]) ++last;
        else break;
    }
    int first = 1;
    repp(i, 1, (int)s.size()) {
        if(s[i] == s[0])  ++first;
        else break;
    }

    if (first == (int)s.size()) cout << (int)s.size() * k / 2  << endl;
    else if (s[0] == s[(int)s.size() - 1]) {
        if (first == 1 && last == 1) cout << countDiff * k + k - 1 << endl;
        else if ((first + last) %2 == 0) cout << countDiff * k + k - 1  << endl;
        else  cout << countDiff * k  << endl;
    } else cout << countDiff * k << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<utility>
using namespace std;
int main(){
    int N,W;
    int p,w;
    pair<int,int>m[101];
    cin>>N>>W;
    for(int i=1;i<=N;++i){
        cin>>p>>w;
        m[i]=make_pair(p,w);
    }
    int V[101][10001];
    for(int i=1;i<=N;++i){
        for(int c=1;c<=W;++c){
            if(c-m[i].second<0){
                V[i][c]=V[i-1][c];
            }
            else{
                int temp;
                temp=m[i].first+V[i-1][c-m[i].second];
                V[i][c]=max(temp,V[i-1][c]);
            }
        }
    }
    cout<<V[N][W]<<endl;
}

Measured memory_bytes: 7028
#include<stdio.h>
int main(void){
	int a,b;
	char op;
	
	while(1){
		scanf("%d %s %d",&a,&op,&b);
		if(op=='?'){
			break;
		}else if(op=='+'){
			printf("%d\n",a+b);
		}else if(op=='-'){
			printf("%d\n",a-b);
		}else if(op=='/'){
			printf("%d\n",a/b);
		}else{
			printf("%d\n",a*b);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define push_back pb
void test(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({max(a,b) * max(c,d), min(a,b) * min(c,d), min(a,b) * max(c,d), max(a,b) * min(c,d)})<<"\n";
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//~ cin>>t;
	while(t--){
		test();
	}
}


Measured memory_bytes: 3648
a, b, c = gets.chomp.split(" ").map(&:to_i)
if a > b
  a.downto(b) do |v|
    if v == c
      puts "Yes"
      exit
    end
  end
else
  a.upto(b) do |v|
    if v == c
      puts "Yes"
      exit
    end
  end
end
puts "No"


Measured memory_bytes: 1788
#include <stdio.h>
#include <math.h>
#include <string.h>
 
int main(void){
 
	int in[2]={0};
	
	char tmp;
	int i,j;
	int count=0;
	int rev=0,num=0;
	scanf("%d %d",&in[0],&in[1]);
	//printf("%d %d\n",in[0],in[1]);
	
	for(i=in[0];i<=in[1];i++){
		
		num=i;
		rev=0;
		while(num>0){
			rev=rev*10+num%10;
			num/=10;
		}
		
		if(i==rev){
			count++;
		}
	}
	
	printf("%d",count);	
	
	return 0;
}

Measured memory_bytes: 128
//gcc test.c -o test.out
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(void){
	int len = 0;
	char str[101];
	scanf("%d",&len);
	scanf("%s",str);
	if(len%2!=0){
		printf("No");
		return 0;
	}
	for(int i=0;i<len/2;i++){
		if(str[i]!=str[i+len/2]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

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

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



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define IOS                      \
    ios_base::sync_with_stdio(0);\
    cin.tie(0);                  \
    cout.tie(0);
#define eps 1e-6
#define ll long long
//#define int long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
const int mod=1000000007;
using namespace std;
int cmp(int a,int b)
{
    return a>b;
}
//typedef pair<int ,int> P;
int main()
{
    ll n,k;
    cin>>n>>k;
    if(n==k)
        cout<<"0";
    else if(n<k)
    {
        cout<<min(n,k-n);
    }
    else
    {
        ll t=min(n%k,k-n%k);
        cout<<t;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i,j,k,count1=0,count2=0;
int gcd(int,int);
void ABC153();
void ABC155();
void ABC156();
void ABC157();
void ABC158();
void ABC161();
void ABC162();
void ABC163();
void ABC164();

int main(){
    ABC153();
}

void ABC153(){
    int n,k,i;
    cin>>n>>k;
    vector<int> h(n);
    for(i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    reverse(h.begin(),h.end());
    long long int sum=0;
    for(i=k;i<n;i++){
        sum+=h[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1152
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 1, inf = 1011111111;

string s;

int get(string s, char c) {
    int n = s.length();
    for (int i = 0; i < n; ++i) {
        int f = 0;
        for (int j = 0; j < s.length(); ++j) {
            if (s[j] != c) {
                f = 1;
            }
        }
        if (f == 0) {
            return i;
        }
        string t = "";
        for (int j = 0; j + 1 < s.length(); ++j) {
            if (s[j] == c || s[j + 1] == c) {
                t += c;
            } else {
                t += s[j];
            }
        }
        s = t;
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> s;
    int ans = inf;
    for (int i = 0; i < 26; ++i) {
        ans = min(ans, get(s, i + 'a'));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

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


a = 0
for i in h:
    if i < a: break
    elif i > a:
        a = i-1
#    print(a)
else:
    print("Yes")
    exit()

print("No")











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

#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using vpii = vector<Pii>;
using vpll = vector<Pll>;

const ll mod=1e9+7;
const int intINF=INT_MAX;
const ll  longINF=LONG_LONG_MAX;

template<class T> T gcd(T a,T b) {
        if(a==0||b==0)return a+b;
        return b?gcd(b,a%b):a;
}

main()
{
        int n,x; cin>>n>>x;
        set<int> s;
        rep(i,n)
        {
                int a; cin>>a;
                s.insert(abs(x-a));
        }

        int ans=0;
        each(it,s)ans=gcd(ans,it);
        cout<<ans<<endl;
}

Measured memory_bytes: 4864
#h, w からチェック柄を決める
def chess(h,w):
    if (h+w) % 2 == 0:
        return '#'
    return '.'
    
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            print(chess(i,j), end='')
        print()
    print()


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

int main() {
  ll a, b, c, k; cin >> a >> b >> c >> k;
  ll ans = 0;
  if (k%2) ans = b - a;
  else ans = a - b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()

BB = [1, 1, 1, 1]
DD = [-1, 1, -1, 1]
B = [sc, sc, sr, sr]
UB = [W, W, H, H]
C = "LRUD"
ok = 0

def check(l, r, sz, ps):
    lb = 0; rb = sz+1
    for i in range(N-1, -1, -1):
        s = S[i]; t = T[i]
        if t == l:
            rb = min(rb+1, sz+1)
        elif t == r:
            lb = max(lb-1, 0)
        if s == l:
            lb += 1
        elif s == r:
            rb -= 1
        if rb <= lb+1:
            return 0
    if ps <= lb or rb <= ps:
        return 0
    return 1

if not check("L", "R", W, sc) or not check("U", "D", H, sr):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3788
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] lines = new int[w+1];
		for(int i =1; i<lines.length; i++){
			lines[i]=i;	//initialize lines[]
		}
		for(int i=0; i<n; i++){
			String s = sc.next();
			int a = Integer.parseInt(s.substring(0, s.indexOf(",")));
			int b = Integer.parseInt(s.substring(s.indexOf(",")+1,s.length()));
			lines = Swap(lines, a, b);
		}
		for(int i=1; i<lines.length; i++){
			System.out.println(lines[i]);
		}

	}
	static int[] Swap(int[] ints, int a, int b){
		int c = ints[a];
		ints[a]= ints[b];
		ints[b]= c;
		return ints;
	}

}

Measured memory_bytes: 17180
#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;

int main() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    //for (int i = 0; i < N; i++) cout << " " << a[i];
    //cout << endl;
    int l = a[N-1];
    //cout << l/2 << endl;
    int tmp = distance(a.begin(), lower_bound(a.begin(), a.end(), l/2));
    //cout << tmp << endl;
    if (l%2) {
        if (a[tmp] - l/2 > l/2 - a[tmp-1]) cout << l << " " << a[tmp-1] << endl;
        else cout << l << " " << a[tmp] << endl;
    }
    else {
        if (a[tmp] - l/2 >= l/2 - a[tmp-1]) cout << l << " " << a[tmp-1] << endl;
        else cout << l << " " << a[tmp] << endl;
    }
}


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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			while (n-- != 0)
			{
				var xy = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();
				double x1 = xy[0], y1 = xy[1], x2 = xy[2], y2 = xy[3], x3 = xy[4], y3 = xy[5];
				double a = 0, b = 0, c = 0, d = 0, p = 0, q = 0;
				if (y2 - y1 != 0)
				{
					a = (x1 - x2) / (y2 - y1);
					b = -1;
					p = -(x2 * x2 - x1 * x1 - y1 * y1 + y2 * y2) / (2 * (y2 - y1));
				}
				else
				{
					a = 1;
					p = (x1 + x2) / 2;
				}
				if (y3 - y2 != 0)
				{
					c = (x2 - x3) / (y3 - y2);
					d = -1;
					q = -(x3 * x3 - x2 * x2 - y2 * y2 + y3 * y3) / (2 * (y3 - y2));
				}
				else
				{
					b = 1;
					q = (x2 + x3) / 2;
				}
				double delta = a * d - b * c;
				double xp = (d * p - b * q) / delta;
				double yp = (a * q - c * p) / delta;
				double r = Math.Sqrt((x1 - xp) * (x1 - xp) + (y1 - yp) * (y1 - yp));

				Console.WriteLine("{0:F3} {1:F3} {2:F3}", xp, yp, r);
			}
		}
	}
}

Measured memory_bytes: 6052
//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first 
#define se second 
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end() 
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    LL n, k;
    cin >> n >> k;
    LL temp, x, p = 3;
    if(k % 2 == 1){
        temp = k;
        x = 0;
        while(temp <= n){
            temp += k;
            x += 1;
        }
        cout << (LL)pow(x, p) << endl;
    }
    else{
        temp = k/2;
        x = 0;
        while(temp <= n){
            // cout << temp << endl;
            temp += k/2;
            x += 1;
        }
        LL a = x / 2;
        LL b = x - a;
        cout << (LL)pow(a, p) + (LL)pow(b, p) << endl;
    }
    // cout << x;

    return 0;
}



/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
xyz = [list(map(int, input().split())) for _ in range(n)]

res = -1
for xi in [1,-1]:
    for yi in [1,-1]:
        for zi in [1,-1]:
            xyz.sort(reverse=True, key=lambda c:c[0]*xi+c[1]*yi+c[2]*zi)
            t = [0,0,0]
            for i in range(m):
                t[0] += xyz[i][0]
                t[1] += xyz[i][1]
                t[2] += xyz[i][2]

            res = max(res, abs(t[0])+abs(t[1])+abs(t[2]))

print(res)


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

int a, b;

int main() {
    scanf("%d %d", &a, &b);
    if (a <= 0 && 0 <= b) {
        printf("Zero\n");
    } else if (a > 0) {
        printf("Positive\n");
    } else {
        int nm = b-a+1;
        if (nm%2 == 1) {
            printf("Negative\n");
        } else {
            printf("Positive\n");
        }
    }
}



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

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


int main(){
  string s;
  cin >> s;
  int n = s.size();
  int x = (n-1)/2;
  int y = (n+3)/2;
  int count = 0;
  rep(i,n/2){
    if(s[i]!=s[n-1-i]){
      count++;
      break;
    }
  }
  rep(i,n/4){
    if(s[y-1+i]!=s[n-1-i]){
      count++;
      break;
    }
  }
  rep(i,n/4){
    if(s[i]!=s[x-1-i]){
      count++;
      break;
    }
  }
  if(count==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

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

int H, W;
string mas[505];
int main()
{
        cin >> H >> W;
        for ( int i = 0; i < H; i++ ) cin >> mas[i];

        for ( int i = 0; i < H; i++ ) {
                for ( int j = 0; j < W; j++ ) {
                        if ( mas[i][j] != '#' ) {
                                if ( i % 2 == 0 && j < W - 1 || i % 2 == 1 && j == 0 ) {
                                        mas[i][j] = 'R';
                                } else {
                                        mas[i][j] = 'B';
                                }
                        }
                }
        }
        for ( int i = 0; i < H; i++ ) {
                for ( int j = 0; j < W; j++ ) {
                        if ( mas[i][j] == '#' || mas[i][j] == 'R' ) cout << '#';
                        else cout << '.';
                }
                cout << '\n';
        }
        cout << '\n';                           
        for ( int i = 0; i < H; i++ ) {
                for ( int j = 0; j < W; j++ ) {
                        if ( mas[i][j] == '#' || mas[i][j] == 'B' ) cout << '#';
                        else cout << '.';
                }
                cout << '\n';
        }

        return ( 0 );
}


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

int main() {
    string s;
    cin >> s;
    int n=s.length();
    vector<int> d(n+1);
    int ten = 1;
    for (int i = n-1; i >= 0; --i) {
        int a = (s[i]-'0') * ten % 2019;
        d[i] = (d[i+1]+a) % 2019;
        ten *= 10; ten %= 2019;
    }
    vector<int> cnt(2019);
    ll ans = 0;
    for (int i = n; i >= 0; --i) {
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){

    string s; cin >> s;
    int k; cin >> k;

    set<string> ms;

    for(int i = 0; i < s.size(); i++){
        string res = "";
        for(int j = i; j < s.size(); j++){
            res += s[j];
            ms.insert(res);
            if(ms.size() > k){
                auto it = ms.end();
                it--;
                ms.erase(it);
            }
        }
    }

    int cnt = 1;
    for(auto it = ms.begin(); it != ms.end(); it++, cnt++)
        if(cnt == k){
            cout << *it << endl;
            break;
        }
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int result = calc(x);
		System.out.println(result);
		scanner.close();
	}
	
	public static int calc(int x){
		int result = (int) (Math.pow(x, 3));
		return result;
	}

}

Measured memory_bytes: 26120
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;++i)
typedef long long ll;
using namespace std;
double cal(ll x)
{
	ll y=10,len=1,sum=0,ret=x;
	while(y<=x)y=(y<<1)+(y<<3),++len;
	while(len--)
	{
		y/=10;
		sum+=x/y;
		x%=y;
	}
	return ret*1.0/sum;
}
bool judge(ll x)
{
	ll a=1;
	while(a<=x)
	{
		if(cal(x+a)<cal(x))return false;
		a=(a<<1)+(a<<3);
	}
	return true;
}
ll k,now;
int main()
{
	cin>>k;
	while(k--)
	{
		ll a=1;
		while(true)
		{
			if(judge(now+a))
			{
				now+=a;
				break;
			}
			a=(a<<1)+(a<<3);
		}
		cout<<now<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<double, double> pdd;
using namespace std;


#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull testcase;cin>>testcase;while(testcase--)
#define pb push_back
#define mp make_pair
#define nl cout<<"\n"
#define prime 1000000007
#define debug(x) cout<<(#x)<<" : "<<x,nl
#define debug2(x,y) cout<<(#x)<<" : "<<x<<" "<<(#y)<<" : "<<y,nl
#define debug3(x,y,z) cout<<(#x)<<" : "<<x<<" "<<(#y)<<" : "<<y<<" "<<(#z)<<" : "<<z,nl
#define f first
#define s second
#define oa(a,n) loop(i,0,n)cout<<a[i]<<" ";nl;
#define ov(a) loop(i,0,a.size()) cout<<a[i]<<" ";nl;
#define MOD(a) (((a%prime)+prime)%prime)

int main()
{


 

    ll n,m,i,j;
    ll x,y;
    cin >> n >>m;

    ll l=1,r=100001;

    loop(i,0,m)
    {
        cin >> x >> y;

        l = max(l,x);
        r = min(r,y); 
    }

    if(r-l+1<0)
        cout << 0;
    else
        cout << r-l+1;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll N,W;cin>>N>>W;
	ll DP[W+1];
	for(ll i=0;i<=W;i++) DP[i]=0;
	for(ll i=1;i<=N;i++){
		ll a,b;cin>>a>>b;
		for(ll x=W;x>=a;x--){
			DP[x]=max(DP[x],b+DP[x-a]);
		}
	}
	cout<<DP[W];
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1 >> S2;
    int i=0;
    bool prev;
    ll res = 1;
    while(i<N){
        if(i==0){
            if(S1[i]==S2[i]){
                res *= 3;
                i+=1;
                prev = true;
            }else{
                res *= 6;
                i+=2;
                prev = false;
            }
        }else{
            if(S1[i]==S2[i]){
                if(prev){
                    res *= 2;
                }else{
                    res *= 1;
                }
                prev = true;
                i += 1;
            }else{
                if(prev){
                    res *= 2;
                }else{
                    res *= 3;
                }
                prev = false;
                i += 2;
            }
        }
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  while(1){
  int num;
  cin >> num;if(num==0)return;
  int ar[num];
  for(int i=0;i<num;i++)
    cin >> ar[i];
  int sum=0;
  for(int i=0;i<num;i++)
    sum+=ar[i];
  sum/=num;
  int ct=0;
  for(int i=0;i<num;i++)
    ct+=ar[i]<=sum;
  cout << ct << endl;
}}

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



Measured memory_bytes: 3156
n = int(input())
ac =0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle +=1
    elif s == 'RE':
        re += 1
print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<ll, ll> p;
ll n, a, b, c;
vector<ll> v;
ll res = INT_MAX;

void v_init(){
  for (ll i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
}

void calc(vector<int> tmp){
  int tmpa = 0;
  int tmpb = 0;
  int tmpc = 0;
  ll mp = 0;
  for(int i = 0; i < int(tmp.size()); i++){
    if(tmp[i] == 1) {
      if(tmpa != 0) mp += 10;
      tmpa += v[i];
    }
    if(tmp[i] == 2) {
      if(tmpb != 0) mp += 10;
      tmpb += v[i];
    }
    if(tmp[i] == 3) {
      if(tmpc != 0) mp += 10;
      tmpc += v[i];
    }
  }
  if(tmpa == 0 || tmpb == 0 || tmpc == 0) return;
  mp += abs(tmpa - a);
  mp += abs(tmpb - b);
  mp += abs(tmpc - c);

  res = min(res, mp);
}

void dfs(int which, vector<int> tmp, int step){
  tmp.push_back(which);
  if(step == n-1) {
    calc(tmp);
    return;
  }
  dfs(0, tmp, step+1);
  dfs(1, tmp, step+1);
  dfs(2, tmp, step+1);
  dfs(3, tmp, step+1);

}


int main(){
  cin >> n >> a >> b >> c;
  v_init();
  vector<int> tmp;
  for (int i = 0; i < 4; i++) {
    dfs(i, tmp,  0);
  }


  cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;

    scanf("%d", &n);

    long long int sum = 0;

    for (int i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    printf("%lld", sum);
    return 0;
}

Measured memory_bytes: 1660
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################

#####ide_ele#####
ide_ele = -1
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

N, K = map(int,input().split())
Num_max = 3*10**5 + 1

A = [int(input()) for _ in range(N)]
st = SegTree([0 for _ in range(Num_max+4)], segfunc, ide_ele)

#DP = [1 for _ in range(N)]
st.update(A[0], 0)  
for i in range(N):
  l = st.query(max(A[i] - K, 0), min(A[i] + K+1, Num_max))
  st.update(A[i], 1 + l)  
  #print(i, A[i], l, st.tree)
#print(st.tree)

print(st.query(0, Num_max))

Measured memory_bytes: 128072
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val s = read()

    var output = ""
    s.forEach {
        when(it) {
            '0', '1' -> output += it
            else -> output = output.slice(0 until output.length-1)
        }
    }
    println(output)
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 34036
H,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
dp = [[10**18]*(N+1) for _ in range(H+1)]
dp[0][0] = 0
for h in range(H+1):
    for i in range(N):
        dp[h][i+1] = min(dp[h][i], dp[max(0,h-AB[i][0])][i+1] + AB[i][1])
print(dp[H][N])

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

int main() {
  int n, t;
  cin >> n >> t;
  int res = 10000;
  int cm = 10000;
  vector<pair<int, int>> root(n);
  for (int i = 0; i < n; i++) {
    cin >> root.at(i).first;
    cin >> root.at(i).second;
  }
  for (int i = 0; i < n; i++) {
    if (root.at(i).second > t) {
      continue;
    }
    else {
      if (root.at(i).first <= cm) {
        cm = root.at(i).first;
        res = root.at(i).second;
      }
    }
  }
  if (res == 10000) {
    cout << "TLE" << endl;
  }
  else {
    cout << cm << endl;
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int flag[100005];
int main()
{
    int n,i,maxi=0,a;
    scanf(" %d",&n);
    for(i=0;i<n;i++){
        scanf(" %d",&a);
        flag[a]++;
        flag[a+1]++;
        if(a>0){
            flag[a-1]++;
        }
        maxi=max(maxi,flag[a]);
        maxi=max(maxi,flag[a+1]);
        if(a>0){
            maxi=max(maxi,flag[a-1]);
        }
    }
    printf("%d\n",maxi);
    return 0;
}


Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    vint p = {100,101,102,103,104,105};
    vint dp(x+1,0);
    dp[0] = 1;
    for(int i=100;i<=x;i++){
        REP(j,6){
            if(i-p[j]>=0&&dp[i-p[j]]>0) dp[i]=1;
        }
    }
    cout << dp[x] << endl;

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y)
{
  x+=y;
  if (x>=mod)
    return x-mod;
  return x;
}
inline int sub(int x,int y)
{
  x-=y;
  if (x<0)
    return x+mod;
  return x;
}
inline int mul(int x,int y)
{
  return (x*1ll*y)%mod;
}
inline int power(int x,int y)
{
  int ans=1;
  while(y)
    {
      if (y&1) ans=mul(ans,x);
      x=mul(x,x);
      y>>=1;
    }
  return ans;
}
inline int inv(int x)
{
  return power(x,mod-2);
}
inline int gcd(int x, int y)
{
  return(y!=0)?gcd(y, x%y):x;
}

/*------------CODE-----------*/

int main()
{
  IOS;
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x=(a+d-1)/d;
  int y=(c+b-1)/b;
  if (x>=y)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
n= len(l)
cnt = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[k]<(l[i]+l[j]) and l[i]<(l[j]+l[k]) and l[j]<(l[i]+l[k]) and l[i]!=l[j]!=l[k]:
                cnt+=1
print(cnt)

Measured memory_bytes: 9164
import sys
lis = [list(map(int,input().split())) for _ in range(3)]
d1 = lis[0][0] - lis[0][1]
d2 = lis[0][1] - lis[0][2]
flag = 'No'
for l in lis:
    if l[0] - l[1] != d1 or l[1] - l[2] != d2:
        print('No')
        sys.exit()
else:
    flag = 'Yes'
print(flag)

Measured memory_bytes: 3188
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
using namespace std;
double cul(double a,double b,string e){
	double sum;
	if(e=="+")
		sum=a+b;
	else if(e=="-")
		sum=a-b;
	else if(e=="*")
		sum=a*b;
	else
		sum=a/b;
	
	return sum;
}
int main(){
	
	string s;
	
	while(getline(cin,s)){
		stack<double> 	st;
		string e="";
		for(int i=0;i<=s.size();i++){
			if(s[i]!=' '&&i!=s.size())
				e=e+s[i];
			else{
				if(e=="+"||e=="-"||e=="*"||e=="/"){
					double b=st.top();
					st.pop();
					double a=st.top();
					st.pop();
					st.push(cul(a,b,e));
				}
				else{
					st.push(stod(e));
				}
				e="";
				
			}
			
		}
			
		printf("%.6lf\n",st.top());

	}
	
}

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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------

int main(){
    int n;
    cin >> n;
    vec p(n);
    int cnt = 0;
    rep(i, n) {
        cin >> p[i];
        if(p[i] != i + 1) cnt++;
    }
    if(cnt == 2 || cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r,p,q ;
	cin >> W>> H>> x>> y>> r;
	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
  int x,y;
  while (true) {
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0) break;
    if (x > y) swap(x,y);
    cout << x << " " << y << endl;
  }
  return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

string S;

int main(){
	cin >> S;
	for (int i = 0; i <= S.size(); i++){
		if (i % 2 == 0){
			if (S[i] == 'L'){
				cout << "No" << endl;
				return 0;
			}
		}
		else{
			if (S[i] == 'R'){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}

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

#define rin(i,a,b) for(int i=(a);i<=(b);++i)
#define irin(i,a,b) for(int i=(a);i>=(b);--i)
#define trav(i,a) for(int i=head[a];i;i=e[i].nxt)
#define Size(a) (int)a.size()
#define pb push_back
#define mkpr std::make_pair
#define fi first
#define se second
#define lowbit(a) ((a)&(-(a)))
typedef long long LL;

using std::cerr;
using std::endl;

inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1005;

int n,s,t,ecnt=1,head[MAXN<<1];

struct Edge{
	int to,nxt,cap,cost;
}e[MAXN*20];

inline void add_edge(int bg,int ed,int ca,int co){
	++ecnt;
	e[ecnt].to=ed;
	e[ecnt].nxt=head[bg];
	e[ecnt].cap=ca;
	e[ecnt].cost=co;
	head[bg]=ecnt;
}

int maxflow,cur[MAXN<<1];
LL mincost,dis[MAXN<<1];
bool book[MAXN<<1],insta[MAXN<<1];
std::queue<int> q;

bool spfa(){
	memset(dis,0x3f,sizeof dis);
	rin(i,1,t)cur[i]=head[i];
	while(!q.empty())q.pop();
	dis[s]=0,book[s]=true;q.push(s);
	while(!q.empty()){
		int x=q.front();q.pop();
		trav(i,x){
			int ver=e[i].to;
			if(e[i].cap&&dis[ver]>dis[x]+e[i].cost){
				dis[ver]=dis[x]+e[i].cost;
				if(!book[ver]){
					book[ver]=true;
					q.push(ver);
				}
			}
		}
		book[x]=false;
	}
	return dis[t]<1e18;
}

int dfs(int x,int pref){
	if(x==t||!pref)return pref;
	int temp=0,flow=0;insta[x]=true;
	for(int &i=cur[x];i;i=e[i].nxt){
		int ver=e[i].to;if(insta[ver])continue;
		if(dis[ver]==dis[x]+e[i].cost&&(temp=dfs(ver,std::min(pref,e[i].cap)))){
			e[i].cap-=temp;
			e[i^1].cap+=temp;
			flow+=temp;
			pref-=temp;
			mincost+=1ll*temp*e[i].cost;
			if(!pref)break;
		}
	}
	insta[x]=false;
	return flow;
}

void ek(){
	while(spfa())maxflow+=dfs(s,1e9);
}

int main(){
	n=read();
	int x0=n*2+1,x1=x0+1,x2=x1+1,x3=x2+1;
	s=x3+1,t=s+1;
	rin(i,1,n){
		int rx=read(),ry=read(),rc=read();
		add_edge(s,i,rc,0);
		add_edge(i,s,0,0);
		add_edge(i,x0,1e9,rx+ry);
		add_edge(x0,i,0,-rx-ry);
		add_edge(i,x1,1e9,rx-ry);
		add_edge(x1,i,0,-rx+ry);
		add_edge(i,x2,1e9,-rx+ry);
		add_edge(x2,i,0,rx-ry);
		add_edge(i,x3,1e9,-rx-ry);
		add_edge(x3,i,0,rx+ry);
	}
	rin(i,1,n){
		int bx=read(),by=read(),bc=read();
		add_edge(n+i,t,bc,0);
		add_edge(t,n+i,0,0);
		add_edge(x0,n+i,1e9,-bx-by);
		add_edge(n+i,x0,0,bx+by);
		add_edge(x1,n+i,1e9,-bx+by);
		add_edge(n+i,x1,0,bx-by);
		add_edge(x2,n+i,1e9,bx-by);
		add_edge(n+i,x2,0,-bx+by);
		add_edge(x3,n+i,1e9,bx+by);
		add_edge(n+i,x3,0,-bx-by);
	}
	ek();
	printf("%lld\n",-mincost);
	return 0;
}

Measured memory_bytes: 640