akhauriyash/Code-Regression huggingface dataset:
a, b, c, x, y = map(int, input().split())

ans = a * x + b * y
if a + b > 2 * c:
    if x > y:
        if a > 2 * c:
            ans = 2 * c * x
        else:
            ans = 2 * c * y + a * (x - y)
    else:
        if b > 2 * c:
            ans = 2 * c * y
        else:
            ans = 2 * c * x + b * (y - x)
print(ans)


Measured memory_bytes: 38384
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int N,M;
	int[] s,c;

	private boolean f(int n) {
		String a = String.valueOf(n);
		if(a.length() != N) {
			return false;
		}
		for(int i=0;i<M;i++) {
			if(a.charAt(s[i])-'0' != c[i]) {
				return false;
			}
		}
		return true;
	}
	
	public void _main(String[] args) {
		Scanner sc = new Scanner(in);
	
		N = sc.nextInt();
		M = sc.nextInt();
		
		s = new int[M];
		c = new int[M];
		for(int i=0;i<M;i++) {
			s[i] = sc.nextInt()-1;
			c[i] = sc.nextInt();
		}
		
		int n = (int)Math.pow(10, N-1);
		if(n==1)n--;
		for(; n<Math.pow(10, N);n++) {
			if(f(n)) {
				out.println(String.valueOf(n));
				return ;
			}
		}
		out.println("-1");
	}

//	public void _main(String[] args) {
//		Scanner sc = new Scanner(in);
//
//		int N = sc.nextInt();
//		int M = sc.nextInt();
//
//		int[] a = new int[N + 1];
//		Arrays.fill(a, -1);
//
//		for (int i = 0; i < M; i++) {
//			int s = sc.nextInt() - 1;
//			int c = sc.nextInt();
//
//			if (a[s] == -1 || a[s] == c) {
//				a[s] = c;
//			} else {
//				out.println("-1");
//				return;
//			}
//		}
//
//		sc.close();
//
//		for (int i = 0; i < N; i++) {
//			if (a[i] == -1) {
//				a[i] = 0;
//			}
//		}
//
//		String ans = "";
//		for (int i = 0; i < N; i++) {
//			ans += a[i];
//		}
//
//		int x = Integer.parseInt(ans);
//		if (N > 1 && ans.startsWith("0")) {
//			out.println("-1");
//			return;
//		}
//
//		out.println(ans);
//
//	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

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

Measured memory_bytes: 3624
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 1; i < b; ++i) {
    if (a * i % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}



Measured memory_bytes: 256
N = int(input())
s = []
for _ in range(N):
    ver = input()
    s.append(ver)

ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    if s[i] == 'AC':
        ac += 1
    elif s[i] == 'WA':
        wa += 1
    elif s[i] == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

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

int main()
{
    ll a[2], b[2];
    rep (i, 2)
        cin >> a[i];
    rep (i, 2)
        cin >> b[i];

    ll ans = a[0] * b[0];
    rep (i, 2)
        rep (j, 2)
            ans = max(a[i] * b[j], ans);

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


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	ll n,m,c;
	cin>>n>>m>>c;
	vll B(m);
	for(int i=0;i<m;i++) cin>>B[i];
	ll ans =0;
	for(int j=0;j<n;j++){
		ll temp=0;
		for(int i=0;i<m;i++){
			ll x;
			cin>>x;
			temp+=x*B[i];
		}
		if(temp+c>0) ans++;
	}
	cout<<ans<<'\n';


}


Measured memory_bytes: 256
//C
#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 <cstdalign>
#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

//Hang in there!

using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}
}



Measured memory_bytes: 384
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
	int n, i = 0;
	cin >> n;
	while (1) {
		if (n <= 1000 * i)break;
		i++;
	}
	cout << abs(n - 1000 * i);
	return 0;
}


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

typedef long long ll;
const int maxn = 10005, mod = 998244353;

char A[maxn], B[maxn];
int n, f[maxn][maxn], fac[maxn], ifac[maxn];

inline int fpow(int x, int k)
{
	int res = 1;
	while (k) {
		if (k & 1) res = (ll)res * x % mod;
		k >>= 1; x = (ll)x * x % mod;
	}
	return res;
}

inline int C(int m, int n) {return (ll)fac[m] * ifac[n] % mod * ifac[m - n] % mod;}

int main()
{
	scanf("%s\n%s", A + 1, B + 1);
	n = strlen(A + 1);
	
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = (ll)fac[i - 1] * i % mod;
	ifac[n] = fpow(fac[n], mod - 2);
	for (int i = n - 1; ~i; --i) ifac[i] = (ll)ifac[i + 1] * (i + 1) % mod;

	int s1 = 0, s2 = 0;
	for (int i = 1; i <= n; ++i)
		s1 += A[i] == '1' && B[i] == '1', s2 += A[i] == '1' && B[i] == '0';

	for (int i = 0; i <= s2; ++i) f[0][i] = (ll)fac[i] * fac[i] % mod;
	for (int i = 1; i <= s1; ++i)
		for (int j = 1; j <= s2; ++j)
			f[i][j] = ((ll)f[i - 1][j] * i % mod * j + (ll)f[i][j - 1] * j % mod * j) % mod;

	int ans = 0;
	for (int i = 0; i <= s1; ++i)
		ans = (ans + (ll)f[s1 - i][s2] * fac[i] % mod * fac[i] % mod * C(s1, i) % mod * C(s1 + s2, i)) % mod;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 387840
#include <bits/stdc++.h>
using namespace std;
bool DEBUG = false;

int main(){
    int N,M=0;
    cin >> N;

    
    int A[N+1],ans[N+1];
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    for(int i = N; i >= 1; i--) {
        int count = N / i;

        if(count <= 1){
            ans[i] = A[i];
            if(ans[i] == 1)M++;
            continue;
        }

        int sum=0;
        while(count > 1){
            int look = i*count;
            sum += ans[look];
            count--;
        }

        int now = sum%2;
        ans[i] = (A[i] ^ now);

        if(ans[i] == 1)M++;
    }

    cout << M << endl;
    for(int i = 1; i <= N; i++) {
        if(DEBUG)cout << ans[i] << endl;
        if(ans[i] == 1)cout << i << " ";
    }

    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll long long
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;

using namespace std;

bool compare(pair<int, int> x, pair<int, int> y) {
    if (x.second != y.second) {
        return x.second > y.second;
    } else {
        return x.first < y.first;
    }
}

void solve() {
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i, N) cin >> v[i];

    map<int, int> meven, modd;

    for (int i = 0; i < N; ++i) {
        if ((i+1) % 2 == 0) {
            if (meven.count(v[i])) meven[v[i]] += 1;
            else meven[v[i]] = 1;
        } else {
            if (modd.count(v[i])) modd[v[i]] += 1;
            else modd[v[i]] = 1;
        }
    }
    vector<pair<int, int> > even, odd;
    for (auto item : meven) {
        even.push_back(make_pair(item.first, item.second));
    }
    for (auto item : modd) {
        odd.push_back(make_pair(item.first, item.second));
    }
    sort(even.begin(), even.end(), compare);
    sort(odd.begin(), odd.end(), compare);

    if (even[0].first != odd[0].first) {
        print(N - even[0].second - odd[0].second);
    } else {
        if (even[0].second != odd[0].second) {
            if (even[0].second > odd[0].second) {
                print(N - even[0].second - odd[1].second);
            } else {
                print(N - even[1].second - odd[0].second);
            }
        } else {
            print(N - even[0].second - max(even[1].second, odd[1].second));
        }
    }
}

int main() {

    solve();
    return 0;
}


Measured memory_bytes: 6520
n,m=[int(x) for x in input().split()]
A=[[0 for i in range(m)] for i in range(n)]
vector=[0 for i in range(m)]
result=[0 for i in range(n)]
for i in range(n):
    A[i]=[int(x) for x in input().split()]
for i in range(m):
    vector[i]=int(input())
for i in range(n):
    for j in range(m):
        result[i] += A[i][j]*vector[j]
for _ in result:
    print(_)

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a;
    int ans = 1;
    Scd(n);
    int dp[200004] = {};
    Rep(i,n){
        Scd(a);
        dp[a] = max(1,dp[a-1]+1);
        ans = max(ans,dp[a]);
    }

    printf ("%d\n", n-ans);

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<int> l(n);
  for(int &a:l) cin >> a;
  sort(l.begin(), l.end());
  int sum = 0;
  for(int a:l) sum += a;
  cout << (sum > l[n-1] * 2 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#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>
#include <ctype.h>
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;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}
int search(int x) {

	int k = 0;
	int p = 1;
	while (p * 2 <= max_n)
	{
		p *= 2;
	}
	for (int i = p; i > 0; i /= 2)
	{
		if (i + k < max_n && bit[i + k] < x) {
			x -= bit[i + k];
			k += i;
		}
	}
	return k + 1;
}
void solv() {

	double a, b, c, d;
	cin >> a >> b >> c >> d;
	double r = (a - c) * (a - c);
	double l = (b - d) * (b - d);
	cout << fixed << setprecision(10) << sqrt(r + l) << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 3292
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
ll infi=1e18+100;

int N;
int X[200005];
int Y[200005];
 
int main(){
	cin>>N;
	Rep(i,N) cin>>X[i];
	Rep(i,N) Y[i]=X[i];
	sort(X,X+N);
	Rep(i,N){
		if(Y[i]>=X[(N+1)/2]) cout<<X[(N-1)/2]<<endl;
		else cout<<X[(N+1)/2]<<endl;
	}
	

	return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

long long dp[60][60][60*60];

int main(void){
	int i,j,k,x[50],X=0,n=in(),a=in();
	long long ans=0;
	rep(i,n){
		x[i+1]=in();
		X=max(X,x[i+1]);
	}
	X=max(X,a);
	rep(i,n+1){
		rep(j,n+1){
			rep(k,n*X+1){
				if(i==0&&j==0&&k==0)
					dp[i][j][k]=1;
				else if(i>=1&&k<x[i])
					dp[i][j][k]=dp[i-1][j][k];
				else if(i>=1&&j>=1&&k>=x[i])
					dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
				else
					dp[i][j][k]=0;
			}
		}
	}
	for(i=1;i<=n;i++)ans+=dp[n][i][i*a];
	llprint(ans);
	return 0;
}

Measured memory_bytes: 85632
#include <stdio.h>

int main()
{
  int A, B;
  //整数の入力
  scanf("%d %d", &A, &B);
  //出力
  if(A + B < 10)
  {
    printf("%d\n", A + B);
  }
  else
  {
    printf("error\n");
  }
  return 0;
}

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

int main() {
    int N,K;
    string S;
    cin >> N >> K >> S;
    S[K-1] = S[K-1] + 32;
    cout << S;
    return 0;
}

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

int gcd( int m, int num )
{
	if ( ( 0 == m ) || ( 0 == num ) )
		return 0;
	
	while( m != num )
	{
		if ( m > num ) m = m - num;
		else         num = num - m;
	}
	return m;
}

int main(){  
  int n;
  cin >> n;
  int x[n+1];
  for(int i=0;i<n+1;i++){
    cin >> x[i];
    }
  sort(x,x+n+1);
  int d=x[1]-x[0];
  for(int i=0;i<n;i++){
    d = gcd(max(d,x[i+1]-x[i]),min(d,x[i+1]-x[i]));
  }
  cout << d << endl;
  return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int n, m;
int as[301][301];

bool solve(int k){
    vector<int> idxs(n);
    unordered_set<int> us;

    while(1){
        unordered_map<int, int> um;
        for(int i = 0; i < n; i++){
            um[as[i][idxs[i]]]++;
        }
        bool ok = true;
        for(auto p : um){
            if(p.second > k){
                us.insert(p.first);
                ok = false;
            }
        }
        if(ok){ break; }
        for(int i = 0; i < n; i++){
            while(idxs[i] < m && us.count(as[i][idxs[i]])){ idxs[i]++; }
            if(idxs[i] == m){ return false; }
        }
    }
    return true;
}

int main(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> as[i][j];
        }
    }
    int l = 1, r = n;
    while(l < r){
        int piv = (l + r) / 2;
        if(solve(piv)){
            r = piv;
        }else{
            l = piv + 1;
        }
    }
    cout << l << '\n';
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define alles(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF=1 << 30;
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vit;
typedef map<string,int> mstit;
typedef priority_queue<int> pqit;
 
 
 
 
 
int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string str;
  int ner=INF;
  cin >>str;
  int len=str.length();
  FOR(i,len-2){
    int hoge=(str[i]-'0')*100+(str[i+1]-'0')*10+(str[i+2]-'0');
    
    ner=min(ner,abs(753-hoge));
  }
  cout <<ner fin;
  return 0;
}


Measured memory_bytes: 256
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
count = 0
for i in range(n):
    for j in range(i+1,n):
        dis = 0
        for k in range(d):
            dis += (x[i][k]-x[j][k])**2
        if (dis**0.5).is_integer() == True:
            count += 1
print(count)

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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)

int main(){
  int x,n;
  cin >> x >> n;
  int flag = 3;
  int x1 = x;
  int x2 = x;



  if(n!=0){
    int p[n];

  rep(i,0,n){
    cin >> p[i];
    if(p[i]==x){
      flag = 0;
    }
  }

  while(flag==0){
    x1 -= 1;
    x2 += 1;

    int c1=0;
    int c2=0;
    rep(i,0,n){
      if(p[i]==x1){
        c1 = 1;
      }
      else if(p[i]==x2){
        c2 = 1;
      }
    }
    if(c1==0&&c2==0){
      flag = 1;
    }
    else if(c1==1&&c2==0){
      flag = 2;
    }
    else if(c1==0&&c2==1){
      flag = 1;
    }
  }
}
  if(flag==1){
    cout << x1<< endl;
  }
  else if(flag == 2){
    cout << x2 << endl;
  }
  else if(flag == 3){
    cout << x << endl;
  }
}


Measured memory_bytes: 3628
#include <math.h>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int count[n] = {};
    for (int i = 0; i < n - 1; i++) {
        int m;
        cin >> m;
        count[m-1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4380
#include <iostream>

using namespace std;

int main(){
    int s,h,mm,mmm,m,ss;
    cin >> s;
    h = s/3600;
    m = s%3600;
    mm = m/60;
    mmm=m%60;
    ss=s-h*3600-m/60;
    cout <<h <<":"<< mm<<":"<<mmm<<endl;
    
    
    
}


Measured memory_bytes: 3092
n,m=map(int,input().split())
if n==1 and m==1:
    print(1)
elif n==1 or m==1:
    print(max(n,m)-2)
elif n==2 or m==2:
    print(0)
elif n>2 and m>2:
    print((n-2)*(m-2))


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        for (int i = 0; i < 6; i++) {
            if (s.charAt(i) == '1') {
                cnt++;
            }
        }
        System.out.println(cnt);
    }

}


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

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)

#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
const int maxn = 2e5 + 6;

int d , n , m;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> m >> d;
    cout << fixed << setprecision(10);
    if(d == 0){
        cout << (ld)1.0 * n / (1.0 * n * n) * (m - 1);
    }
    else{
        cout << (ld)1.0 * (n - d) * 2 / (1.0 * n * n) * (m - 1);
    }
}


Measured memory_bytes: 256
n = int(input())

ans = []
def dfs(x):
    if len(x) == n:
        ans.append(x)
        return
    for i in range(0, max(x)+1):
        y = x.copy()
        y.append(i+1)
        dfs(y)
dfs([1])
#print(ans)

r = ['a','b','c','d','e','f','g','h','i','j']
for ai in ans:
    print(''.join(map(lambda x: str(r[x-1]), ai)))




Measured memory_bytes: 28968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> T1 pow_(T1 a, T2 b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, m;
  cin >> n >> m;
  if (n % 2) {
    rep(l, m) {
      cout << l + 1 << " " << n - l << endl;
    }
  } else {
    rep(l, m - m / 2) {
      cout << l + 1 << " " << n - l << endl;
    }
    rep(l, m / 2) {
      cout << n / 2 - 1 - l << " " << n / 2 + 1 + l << endl;
    }
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

const LL INF = 0x7fffffffffffffff;

LL F(LL a, LL b, LL c) {
    if (!a || !b || !c) return INF;
    if (a > b) swap(a, b);
    if (a > c) swap(a, c);
    if (b > c) swap(b, c);
    return max(b - a, c - a);
}

LL Calc(LL h, LL w, LL k) {
    if (!h || !w) return INF;
    return min(F(h / 2 * w, (h - h / 2) * w, k), F(w / 2 * h, (w - w / 2) * h, k));
}

int main() {
    LL h, w;
    scanf("%lld%lld", &h, &w);
    LL Min = min(min(Calc(h - h / 3, w, h / 3 * w), Calc(h - h / 3 - 1, w, (h / 3 + 1) * w)), min(Calc(h, w - w / 3, w / 3 * h), Calc(h, w - w / 3 - 1, (w / 3 + 1) * h)));
    printf("%lld\n", Min);
    return 0;
}

Measured memory_bytes: 256
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, 0, N) cin >> X[i];

    int min_cost = 1000000000;
    rep(c, 0, 101)
    {
        int cost = 0;
        for (auto x: X)
            cost += (c-x)*(c-x);
        min_cost = min(min_cost, cost);
    }

    cout << min_cost << 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 K, A, B;

		K = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();

		int min, max, flg;

		min = A / K;
		max = B / K;
		flg = 0;

		for (int i = min; i <= max; i++) {
			if (K * i >= A && K * i <= B)
				flg = 1;
		}
		if(flg==1) System.out.println("OK");
		else System.out.println("NG");
	}
}


Measured memory_bytes: 35792
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,cnt=0,ans;
   cin >> n;
   for(int i=1;i<=n;i+=2){
     ans=0;
     for(int j=1;j<=i;j++){
        if(i%j==0)ans++;
     }
     if(ans==8){
        cnt++;
     }
   }
   cout << cnt << endl;
}


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

int main() {
    int a, b, k; cin >> a >> b >> k;
    for (int i = a; i <= b; i++) {
        if (a+k-1 >= i || b-k+1 <= i) cout << i << 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 N = sc.nextInt();
        int soeji = 1;
        int max = 0;
        for(int i=1;i<=N;i++){
            int x = i;
            int count=0;
            while(x % 2 == 0){
                count++;
                x = x / 2;
            }
            if(count > max){
                max = count;
                soeji = i;
            }
        }
        System.out.println(soeji);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

vector<ll> a;
vector<pll> answ;
vector<int> seq;

ll build(int l, int r, int s) {
	if(l == r) {
		return a[l];
	} else if(r == l + 1) {
		int val = seq[l] * s;

		if(val == 1) {
			answ.emplace_back(a[l], a[r]);

			return a[l] - a[r];
		} else {
			answ.emplace_back(a[r], a[l]);

			return a[r] - a[l];
		}
	} else {
		int val = seq[r] * s;

		if(val == 1) {
			ll lst = build(l, r - 1, -s);
			answ.emplace_back(a[r], lst);

			return a[r] - lst;
		} else {
			ll lst = build(l, r - 1, s);
			answ.emplace_back(lst, a[r]);

			return lst - a[r];
		}
	}
}

void solve() {
	int n = fetch<int>();
	a = fetch_vec<ll>(n);

	int cnt_pos = 0, cnt_neg = 0;
	ll sum = 0;
	int mn = 0;
	seq.resize(n, 1);

	for(int i = 0; i < n; ++i) {
		ll val = a[i];

		if(val < 0) {
			seq[i] = -1;
		}

		cnt_pos += val > 0;
		cnt_neg += val < 0;

		sum += abs(val);

		if(abs(val) < abs(a[mn])) {
			mn = i;
		}
	}

	DBG(seq);

	if(cnt_pos == 0 || cnt_neg == 0) {
		sum -= 2 * abs(a[mn]);
		seq[mn] = -seq[mn];
	} 

	DBG(seq);

	for(int i = 1; i < n; ++i) {
		if(seq[i] != seq[0]) {
			swap(seq[i], seq[1]);
			swap(a[i], a[1]);

			break;
		}
	}

	build(0, n - 1, 1);
	cout << sum << '\n';

	for(auto& pr: answ) {
		cout << pr.first << ' ' << pr.second << '\n';
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 9456
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

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

    int out = 0;
    for(auto itr = inp.begin(); itr != inp.end(); itr++){
        if(*itr == '+') out ++;
        else out --;
    }

    cout << out << endl;
}

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

class Program {
    static void Main() {
        var H = NextLong();
        var W = NextLong();
        var ans = new string[H * 2];
        for (var i = 0; i < H; i++) {
            var C = ReadLine();
            for (var j = 0; j < 2; j++) {
                ans[2 * i + j] = C;
            }
        }
        WriteLine(string.Join("\n", ans));
    }

    static long NextLong() {
        return long.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}


Measured memory_bytes: 13316
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class DTeleporter {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n,k;
        in>>n>>k;
        vector<ll> a(n);
        rep(i,n) in>>a.at(i);

        vector<ll> s;
        vector<ll> ord(n+1,-1);
        ll c=1;
        ll l=0;
        {
            ll v = 1;
            while(ord[v]==-1){
                ord[v] = s.size();
                s.push_back(v);
                v=a[v-1];
            }
            c = s.size() - ord[v];
            l =  ord[v];
        }

        if(k<l) out<<s[k]<<endl;
        else {
            k-=l;
            k%=c;
            out<<s[l+k]<<endl;
        }

	}
};


int main() {
	DTeleporter solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8056
n = int(input())
l = list(map(int, input().split()))
max_v = 0
curr = 0

for i in range(n-1):
    if l[i] < l[i+1]:
        max_v = max(max_v, curr)
        curr = 0
    else:
        curr += 1
max_v = max(curr, max_v)

print(max_v)

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


Measured memory_bytes: 2056
#include <stdio.h>
int main(void){
    int a,i=0,j=0,k=0,l=0,num,wei,v[4][100]={},w[100],tmp;
    long long int value=0,va[4]={},max=0,now=0,ws[4]={};
    scanf("%d %d",&num,&wei);
    for(a=0;a<num;a++){
        scanf("%d",&w[a]);
        scanf("%lld",&v[w[a]-w[0]][ws[w[a]-w[0]]]);
        ws[w[a]-w[0]]++;
    }
    for(i=0;i<4;i++){
        for(j=0;j<ws[i]-1;j++){
            for(k=ws[i]-1;k>j;k--){
                if(v[i][k-1]<v[i][k]){
                    tmp=v[i][k];
                    v[i][k]=v[i][k-1];
                    v[i][k-1]=tmp;
                }
            }
        }
        for(j=0;j<ws[i];j++){
            va[i]+=v[i][j];
        }
             
    }
   
    
    for(i=0;i<=ws[0];i++){
        if(i!=0){
            now+=w[0];
            value+=v[0][i-1];
        }
        
        for(j=0;j<=ws[1];j++){
            if(j!=0){
                now+=w[0]+1;
                value+=v[1][j-1];
            }
            
            for(k=0;k<=ws[2];k++){
                if(k!=0){
                now+=w[0]+2;
                value+=v[2][k-1];
                }
                for(l=0;l<=ws[3];l++){
                    if(l!=0){
                        now+=w[0]+3;
                        value+=v[3][l-1];
                    }
                
                    if(now<=wei){
                        if(max<value){
                           
                            max=value;
                        }
                    }
                    
                }
                now-=(w[0]+3)*ws[3];
                value-=va[3];
                
            }
            now-=(w[0]+2)*ws[2];
            value-=va[2];
        }
        now-=(w[0]+1)*ws[1];
        value-=va[1];
    }
    printf("%lld",max);
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <functional>
#include <cassert>
#define SIZE 1005
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll inv[SIZE],fac[SIZE],finv[SIZE];
ll dp[SIZE],way[SIZE];
ll nxt[SIZE];

void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll Cb(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}

int main()
{
	make();
	int n,A,B,C,D;
	scanf("%d %d %d %d %d",&n,&A,&B,&C,&D);
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	for(int i=A;i<=B;i++)
	{
		memset(nxt,0,sizeof(nxt));
		for(int j=0;j<=n;j++)
		{
			if(dp[j]==0) continue;
			ll way=1;
			for(int k=0;k<=n-j;k+=i)
			{
				if(k==0||(C<=k/i&&k/i<=D))
				{
					nxt[j+k]+=dp[j]*way%MOD;
					if(nxt[j+k]>=MOD) nxt[j+k]-=MOD;
				}
				if(n-j-k<i) break;
				way=way*Cb(n-j-k,i)%MOD*inv[k/i+1]%MOD;
			}
		}
		for(int j=0;j<=n;j++) dp[j]=nxt[j];
	}
	printf("%lld\n",dp[n]);
	return 0;
}


Measured memory_bytes: 256
use std::io::{self, BufRead, Write};

fn main() {
    let stdin = io::stdin();
    let mut iter = stdin.lock().lines().skip(1).map(|s| {
        let s = s.unwrap();
        let mut ret = [0; 26];
        for c in s.as_bytes() {
            ret[(c - b'a') as usize] += 1;
        }
        ret
    });

    let mut res = iter.next().unwrap();

    for dict in iter {
        for (i, &n) in dict.iter().enumerate() {
            if n < res[i] {
                res[i] = n
            }
        }
    }

    let mut stdout = io::stdout();
    for (i, &n) in res.iter().enumerate() {
        let c = b'a' + i as u8;
        for _ in 0..n {
            stdout.write_all(&[c]).unwrap();
        }
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
using namespace std;
pair<int,string> make(pair<int ,string> a,pair<int,string> b,char ope)
{
  pair<int ,string> tmp;
  if(ope=='+')
    tmp.first=a.first+b.first;

  if(ope=='-')
    tmp.first=a.first-b.first;

  if(ope=='*')
    tmp.first=a.first*b.first;
  tmp.second="("+a.second+" "+ope+" "+b.second+")";
    return tmp;


}

string solve(int a,int b ,int c,int d)
{
  string ans="";
  char s[]={'+','-','*'};
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++)
	{
	  string aa =" ";
	  aa[0]=a+'0';
	  string bb =" ";
	  bb[0]=(b+'0');
	  string cc =" ";
	  cc[0]=(c+'0');
	  string dd =" ";
	  dd[0]=(d+'0');
	  // cout<<a<<s[i]<<b<<s[j]<<c<<s[k]<<d<<endl;
	  //cout<<aa<<" "<<bb<<" "<<cc<<" "<<dd<<endl;
	  pair<int ,string> tmp =  make(make_pair(a,aa),make_pair(b,bb),s[i]);
	  tmp= make(tmp,make_pair(c,cc),s[j]);
	  tmp=
	    make(tmp,make_pair(d,dd),s[k]);
	  if(tmp.first==10)
	    return tmp.second;


	  tmp =  make(make_pair(a,aa),make_pair(b,bb),s[i]);
	  pair<int,string> tmp2 = make(make_pair(c,cc),make_pair(d,dd),s[k]);
	  tmp=
	    make(tmp,tmp2,s[j]);
	  if(tmp.first==10)
	    return tmp.second;
	}

  return "0";

}
int main()
{
  int a,b,c,d;
  //  char s[]={'+','-','*'};
  for(;cin>>a>>b>>c>>d,a||b||c||d;)
    {
      int data[4]={a,b,c,d};
      string ans="0";
      for(int i=0;i<4;i++)
	for(int j=0;j<4;j++)
	  for(int k=0;k<4;k++)
	    for(int l=0;l<4;l++)
	      {
		if(ans!="0")
		  {break;}
		if(i!=j && i!=k&& i!=l &&
		   j!=k && j!=l&& k!=l )
		  ans=solve(data[i],data[j],data[k],data[l]);
	      }
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int main(){
    int n;  cin >> n;
    map<ll, int> mp;
    for(int i=0; i<n; i++){
        ll x;   cin >> x;
        mp[x] += 1;
    }
    string ans="No";
    if(mp.size()<=3){
        if(mp.size()==1 && 0<mp[0]) ans="Yes";
        else if(n%3==0 && mp.size()==2){
            if(mp[0]==n/3) ans = "Yes";
        }else if(n%3==0 && mp.size()==3){
            ll p=0; bool flag=true;
            for(auto x: mp){
                p = p^x.first;
                if(x.second!=n/3) flag = false;
            }
            if(p==0 && flag) ans="Yes";
        }
    } 
    cout << ans << endl;
}

Measured memory_bytes: 5120
n,m,l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]
for i in range(n) :
    for j in range(l) :
        c = 0
        for k in range(m) :
            c += A[i][k] * B[k][j]
        print(c,end = "")
        if not j == l-1 : print(" ",end = "")
    print()



Measured memory_bytes: 6564
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long

using namespace std;

signed main()
{
    int N, x;
    cin >> N;
    vector<int> A_arr(N, 0);
    rep(i, N)
    {
        cin >> x;
        A_arr[x - 1] = i + 1;
    }
    rep(i, N)
    {
        cout << A_arr[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
N, A, B, C = [int(_) for _ in input().split()]
L = [int(input()) for i in range(N)]

from itertools import combinations

def combi(xs, left):
    for i in range(len(xs) - left):
        for r in combinations(xs, i + 1):
            yield r

def diff(a, b):
    result = a[:]
    for x in b:
        if x in result:
            result.remove(x)
    return result

def calc(xs):
    result = 10**100
    for ra in combi(xs, 2):
        sa = abs(A - sum(ra)) + len(ra) * 10 - 10
        xsa = diff(xs, ra)
        for rb in combi(xsa, 1):
            sb = abs(B - sum(rb)) + len(rb) * 10 - 10
            xsb = diff(xsa, rb)
            for rc in combi(xsb, 0):
                sc = abs(C - sum(rc)) + len(rc) * 10 - 10
                total = sa + sb + sc
                result = min(result, total)
    return result

print(calc(L))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,n) for(int i=1;i<n;i++)
using namespace std;


int main(){
	string s;
	cin>>s;
	char pre=s[0];
	reps(i,s.size()){
		if(pre==s[i]){
			cout<<"Bad";
			return 0;
		}
		else{
			pre=s[i];
		}
	}
	cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
def main():
    N=int(input())
    L=list(map(int,input().split()))
    counter=0
    for i in range(len(L)):
        for j in range(i,len(L)):
            for k in range(j,len(L)):
                if L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k]:
                    triangle=[L[i],L[j],L[k]]
                    triangle.sort()
                    if triangle[0]+triangle[1]>triangle[2]:
                        counter+=1
    print(counter)
if __name__=="__main__":
    main()


Measured memory_bytes: 67996
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define swap(a,b) a^=b^=a^=b
#define lb(x) ((x)&(-(x)))
#define inf 0x3f3f3f3f
#define N 3010
using namespace std;
typedef long long ll;
int n,m,f[N][N][2];
inline void upd(int& a,int b){a+=b;if(a>=1000000007)a-=1000000007;}
int main(){
	register int i,j,k,ans=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<=n;i++)f[0][i][i==0]=1;
	for(i=0;i<m;i++)for(j=0;j<=n;j++)for(k=0;k<2;k++)if(f[i][j][k]){
		if(j>0)upd(f[i+1][j-1][k|(j==1)],f[i][j][k]),upd(f[i+1][j][k|(j==1)],f[i][j][k]);
		if(j<n)upd(f[i+1][j+1][k],f[i][j][k]),upd(f[i+1][j][k],f[i][j][k]);
	}
	for(i=0;i<=m;i++)upd(ans,f[m][i][1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

int main(){
    int N, L;
    cin >> N >> L;
    vector<int> v;
    priority_queue<int, vector<int>, greater<int>> que;
    for(int i = 1; i <= N; i++){
        v.push_back(L + i - 1);
        que.push(abs(v[i - 1]));
    }
    int temp = que.top();
    int sum = 0;
    for(int i = 0; i < N; i++){
        if(abs(v[i]) == temp)        continue;
        
        sum += v[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/*input
4
abcd
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int cnt[26];
int main()
{
	IOS;
	int n;
	string s;
	cin>>n>>s;
	REP(i,n){
		cnt[s[i]-'a']++;
	}
	ll ans=1;
	for(int i=0;i<26;i++){
		ans=ans*(cnt[i]+1)%MOD;
	}
	ans--;
	if(ans<0) ans+=MOD;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) ((x).begin()),((x).end())
#define int ll
using pii = pair <int, int>;
#define INF 0x7f7f7f7f7f7f7f7f
const bool debug = 0;
const int mod = 1000000007;

int possible[401];
int32_t main()
{
    usecppio
    int X; cin >> X;
    for (int i = -200; i<=200; i++)
        possible[i+200] = i*i*i*i*i;
    for (int i = -200; i<=200; i++)
    {
        for (int j = -200; j<=200; j++)
        {
            if (possible[i+200]-possible[j+200]==X)
            {
                cout << i << " " << j << '\n';
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3652