akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>

using namespace std;

set<int> se;

int dfs(int i, int n, int m, int *k, int **s, int *p) {
    if (i == n) {
        bool can = true;
        for (int j = 0; j < m; j++) {
            int count = 0;
            for (int l = 0; l < k[j]; l++) {
                if (se.find(s[j][l]) != se.end())
                    count++;
            }
            if (count % 2 != p[j])
                can = false;
        }
        if (can)
            return 1;
        else 
            return 0;
    }

    int ans = 0;
    se.insert(i);
    ans += dfs(i+1, n, m, k, s, p);
    se.erase(i);
    ans += dfs(i+1, n, m, k, s, p);

    return ans;
}

int main() {
    int n, m;   cin >> n >> m;
    int *k = new int[m];
    int **s = new int*[m];
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        s[i] = new int[k[i]];
        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    int *p = new int[m];
    for (int i = 0; i < m; i++)
        cin >> p[i];

    cout << dfs(0, n, m, k, s, p) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; (a <= b)?i <= b:i >= b; (a <= b)?i ++: i --)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cout<<" ["<<#a<<"->"<<a<<"] "
#define next_line cout<<'\n'
using namespace std;

typedef pair<ll ,ll > pii;
typedef pair<ll,ll> pll;
typedef pair<char,ll > pci;
typedef map<ll ,ll > mii;
typedef map<ll,ll> mll;
typedef map<char,ll > mci;
typedef unordered_map<ll ,ll > umii;
typedef unordered_map<ll,ll> umll;
typedef unordered_map<char,ll > umci;
typedef vector<ll>  vll;
typedef vector<vector<ll> > vvll;

ll  n, *arr, **dp;

ll  MaxDiff(ll  be, ll  en){
    //deb(be);deb(en);next_line;
    if(be == en)
        return arr[be];
    if(dp[be][en] != -1LL)
        return dp[be][en];
    dp[be][en] = max( arr[be] - MaxDiff(be + 1, en), 
                arr[en] - MaxDiff(be, en - 1));
    return dp[be][en];
}

void solve()
{
    cin>>n;
    arr = new ll [sz(ll ) * n];
    dp = new ll  *[sz(ll  *) * n];
    F(ll , i, 0, n - 1){
        cin>>arr[i];
        dp[i] = new ll [sz(ll ) * n];
    }
    //memset(dp, -1, sz(dp) * n * n);
    F(ll , i, 0, n - 1){
        F(ll , j, 0, n - 1){
            dp[i][j] = -1LL;
            //deb(dp[i][j]);
        }
    }
    cout<<MaxDiff(0, n - 1)<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#else
    //#endif
    solve();
}


Measured memory_bytes: 75788
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{  int n,m,i,l;
	while(~scanf("%d%d",&n,&l))
	{ int a[n];
	int p=-1,s=0,t;
	for(i=l;i<(n+l);i++)
	{
	 p++;
	 a[p]=i;
	 s+=a[p];}
	t=fabs(a[0]);
	for(i=1;i<n;i++)
	{
		if(fabs(a[i])<t)
		t=fabs(a[i]);
		{
		if(a[i]<0)
		p=-t;
		else
		p=t;
	}}
	
	printf("%d\n",s-p); 
	
	
	
	}
	
}


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

using namespace std;

#define int long long

int n,q,a,b;
int x[200001], f[200001];

struct Node
{
	int val_1, val_2, lazy; // val_1 : f[i] - i, val_2 : f[i] + i
	Node(){}
}Tree[800001];

void build(int node,int l,int r)
{    	
	if (l == r)
	{
		Tree[node].val_1 = f[l] - l;
		Tree[node].val_2 = f[l] + l;
		return;
	}
	int mi = (l + r)/2;
	build(node*2,l,mi);
	build(node*2 + 1,mi + 1,r);
	Tree[node].val_1 = min(Tree[node*2].val_1,Tree[node*2 + 1].val_1);
	Tree[node].val_2 = min(Tree[node*2].val_2,Tree[node*2 + 1].val_2);
}

void diffuse(int node,int l,int r)
{
	if (Tree[node].lazy)
	{
		Tree[node].val_1 += Tree[node].lazy;
		Tree[node].val_2 += Tree[node].lazy;
		if (l != r)
		{
			Tree[node*2].lazy += Tree[node].lazy;
			Tree[node*2 + 1].lazy += Tree[node].lazy;
		}
		Tree[node].lazy = 0;
	}
}

void update(int node,int l,int r,int ll,int rr,int val)
{
	diffuse(node,l,r);
	if (r  < ll || rr < l) 
		return;
	if (ll <= l && r <= rr)
	{
		Tree[node].lazy += val;
		diffuse(node,l,r);
		return;
	}
	int mi = (l + r)/2;
	update(node*2,l,mi,ll,rr,val);
	update(node*2 + 1,mi + 1,r,ll,rr,val);
	Tree[node].val_1 = min(Tree[node*2].val_1,Tree[node*2 + 1].val_1);
	Tree[node].val_2 = min(Tree[node*2].val_2,Tree[node*2 + 1].val_2);
}

int query(int node,int l,int r,int ll,int rr,int type)
{
	diffuse(node,l,r);
	if (r < ll || rr < l)
		return 1e18;
	if (ll <= l && r <= rr)
	{
		if (type == 1) return Tree[node].val_1;
		else return Tree[node].val_2;
	}			
	int mi = (l + r)/2;
	int a = query(node*2,l,mi,ll,rr,type);
	int b = query(node*2 + 1,mi + 1,r,ll,rr,type);
	return min(a,b);
}

int res = 1e18;

void cal_ans(int node,int l,int r)
{
	diffuse(node,l,r);
	if (l == r)
	{
		res = min(res,Tree[node].val_1 + l);
		return;
	}
	int mi = (l + r)/2;
	cal_ans(node*2,l,mi);
	cal_ans(node*2 + 1,mi + 1,r);
}

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

	cin >> n >> q >> a >> b;
	for (int i=1;i<=q;i++)
		cin >> x[i];
	for (int i=1;i<=n;i++)
	{
		f[i] = min(abs(a - x[1]) + abs(b - i), abs(a - i) + abs(b - x[1]));
		//cerr << f[i] << ' ';
	}
	//cerr << '\n';	
	build(1,1,n);
	for (int i=2;i<=q;i++)
	{
		int val_l = query(1,1,n,1,x[i],1) + x[i];
		int val_r = query(1,1,n,x[i],n,2) - x[i];
		update(1,1,n,1,n,abs(x[i] - x[i-1]));	
		int cur_val = query(1,1,n,x[i-1],x[i-1],1) + x[i-1];
		//cerr << '?' << cur_val << ' ' << val_l << ' ' << val_r << '\n';
		update(1,1,n,x[i-1],x[i-1],min(0LL, -(cur_val - min(val_l, val_r))));
		//for (int j=1;j<=n;j++)
		//	cerr << query(1,1,n,j,j,1) + j << ' ';
		//cerr << '\n';	
	}
	cal_ans(1,1,n);
	cout << res;
}

Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
bool equal_image(string a[], string b[], int m) {
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            if(a[i][j] != b[i][j]) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    int N, M, right_line = 0;
    cin >> N >> M;
    string A[N];
    string B[M];
    string target[M];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < M; i++) {
        cin >> B[i];
    }
    for(int i = 0; i < N-M+1; i++) {
        for(int j = 0; j < N-M+1; j++) {
            for(int k = 0; k < M; k++) {
                target[k] = A[i+k].substr(j, M);
            }
            bool equal = equal_image(target, B, M);
            if(equal) {
                cout << "Yes" << endl;
                return 0;
            }
            
        }     
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
li = [input() for i in range(m)]
conds = list(map(int, input().split()))

b_li = []
for item in li:
    tmp = item.split()[1:]
    cond = 0
    for elm in list(map(int, tmp)):
        cond = cond | (2 ** (elm - 1))
    b_li.append(cond)

cnt = 0
for i in range(2**n):
    for j in range(m):
        k =bin(i & b_li[j])
        onCnt = str(k).count('1')
        if (onCnt % 2) != conds[j]:
            break
    else:
        cnt += 1

print(cnt)


Measured memory_bytes: 3064
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

A,B = II()

print(max(2*A-1, A+B, 2*B-1))

Measured memory_bytes: 38384
n,m = map(int,input().split())

xyzl = []
for _ in range(n):
    x,y,z = map(int,input().split())
    xyzl.append((x,y,z))

ans = 0
n = 3  # すき間の個数
for i in range(2 ** n):
    bit = [1] * n
    for j in range(n):
        if ((i >> j) & 1):
            bit[j] = -1
    suml = []
    for x,y,z in xyzl:
        a = bit[0] * x + bit[1] * y + bit[2] * z
        suml.append(a)
    
    suml = sorted(suml, reverse=True)
    tmp = sum(suml[:m])
    if tmp > ans:
        ans = tmp

print(ans)

Measured memory_bytes: 40048
#include "bits/stdc++.h"
using namespace std;
int Array[100005][4] , dp[100005][4];

int main(){
    int N , i , j;
    scanf( "%d" , &N );

    for( i = 1 ; i <= N ; ++i ){
        for( j = 1 ; j <= 3 ; ++j )
            scanf( "%d" , &Array[i][j] );
    }

    dp[1][1] = Array[1][1];
    dp[1][2] = Array[1][2];
    dp[1][3] = Array[1][3];

    for( i = 2 ; i <= N ; ++i ){
        dp[i][1] = max( dp[i - 1][2] , dp[i - 1][3] ) + Array[i][1];
        dp[i][2] = max( dp[i - 1][1] , dp[i - 1][3] ) + Array[i][2];
        dp[i][3] = max( dp[i - 1][1] , dp[i - 1][2] ) + Array[i][3];
    }

    printf( "%d\n" , max( dp[N][1] , max( dp[N][2] , dp[N][3] ) ) );
    return 0;
}

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

string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define db(...) 42
#endif

using ll = long long;

const ll mod = 1e9 + 7;

int main() {
  ll ans = 1;
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++)
    ans = (i * ans) % mod;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, m, i, ans = 0;
    cin >> n >> m;
    vll dummy(n + 1, 0);
    ll x = m;
    while(m--)
    {
        ll l, r;
        cin >> l >> r;
        l--, r--;
        dummy[l]++;
        dummy[r + 1]--;
    }
    ans += (dummy[0] >= x ? 1 : 0);
    for(i = 1; i < n; i++)
        dummy[i] += dummy[i - 1], ans += (dummy[i] >= x ? 1 : 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#B
import math
n = int(input())
w = list(map(int, input().split()))
min=float('inf')
for t in range(1,n):
    a = sum(w[:t])
    b = sum(w[t:])
    # print(a, b)
    if min > abs(a - b):
        min = abs(a - b)
print(min)

Measured memory_bytes: 3060
#!/usr/bin/env python3

S = set(input())

if len(S) % 2 != 0:
    print("No")
elif ("N" in S and not "S" in S) or ("S" in S and not "N" in S) or ("W" in S and not "E" in S) or ("E" in S and not "W" in S):
    print("No")
else:
    print("Yes")







Measured memory_bytes: 8804
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.dist = [0]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            p = self.parents[x]
            self.parents[x]=self.find(self.parents[x])
            self.dist[x] += self.dist[p]
            return self.parents[x]
    def unite(self,x,y,d):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            if self.dist[x]-self.dist[y] != d:
                print("No")
                exit()
        else:
            diff = self.dist[y]+d-self.dist[x]
            if diff>=0:
                self.parents[xRoot] = yRoot
                self.dist[xRoot] += diff
                self.find(x)
            else:
                self.parents[yRoot] = xRoot
                self.dist[yRoot] += abs(diff)
                self.find(y)
N,M = map(int,input().split())
tree = UnionFind(N)
for _ in range(M):
    L,R,D = map(int,input().split())
    tree.unite(L,R,D)
print("Yes")

Measured memory_bytes: 109472
#include <iostream>
#include <set>

using namespace std;

long N, K;
long A[200001] = {0};
int num_count[2000001] = {0};


int main() {
#ifdef __APPLE__
    freopen("input2.txt", "r", stdin);
#endif
    cin >> N >> K;

    long num_of_kinds_of_nums = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (!num_count[A[i]]) ++num_of_kinds_of_nums;
        ++num_count[A[i]];
    }

    set<pair<long, long>> q;

    for (int i = 0; i < 2000001; ++i) {
        if (num_count[i]) {
            q.insert({num_count[i], i});
        }
    }

    long ans = 0;
    while (num_of_kinds_of_nums > K) {
        long num = q.begin()->second;
        long count_of_nums = q.begin()->first;
        q.erase({count_of_nums, num});
        ans += count_of_nums;
        --num_of_kinds_of_nums;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16768
{-# LANGUAGE ScopedTypeVariables, LambdaCase #-}

import qualified Data.List as List
import qualified Data.Set as Set

main :: IO ()
main = do
    [a, b] <- words <$> getContents
    putStrLn $ if (a == "H") && (b == "H") || (a == "D") && (b == "D") then "H" else "D" 

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n, t=0;
	cin >> n;
	vector<int> x(n);
	vector<int> y(n);
	rep(i, n)
		cin >> x[i];
	rep(i, n)
		cin >> y[i];
  	rep(i, n)
      	t += max(x[i]-y[i] , 0);
	cout << t << endl;
}

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

#define lowbit(a) (a&-a)
typedef long long ll;
const int maxn = 100010; const ll inf = 1LL<<60;
int N,T,E,X[maxn]; ll tree1[4*maxn],tree2[4*maxn],f[maxn];

inline int gi()
{
	char ch; int ret = 0,f = 1;
	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
	if (ch == '-') f = -1,ch = getchar();
	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
	return ret*f;
}

inline void build(int now,int l,int r)
{
	tree1[now] = tree2[now] = inf;
	if (l == r) return; int mid = (l+r) >> 1;
	build(now<<1,l,mid); build(now<<1|1,mid+1,r);
}

inline void modify(ll *tree,int now,int l,int r,int pos,ll key)
{
	if (l == r) { tree[now] = key; return; } int mid = (l+r)>>1;
	if (pos <= mid) modify(tree,now<<1,l,mid,pos,key);
	else modify(tree,now<<1|1,mid+1,r,pos,key);
	tree[now] = min(tree[now<<1],tree[now<<1|1]);
}

inline ll query(ll *tree,int now,int l,int r,int ql,int qr)
{
	if (ql == l&&qr == r) return tree[now]; int mid = (l+r)>>1;
	if (qr <= mid) return query(tree,now<<1,l,mid,ql,qr);
	else if (ql > mid) return query(tree,now<<1|1,mid+1,r,ql,qr);
	else return min(query(tree,now<<1,l,mid,ql,mid),query(tree,now<<1|1,mid+1,r,mid+1,qr));
}

int main()
{
	//freopen("G.in","r",stdin);
	//freopen("G.out","w",stdout);
	N = gi(); E = gi(); T = gi();
	for (int i = 1;i <= N;++i) X[i] = gi(),tree1[i] = tree2[i] = 1LL<<60;
	for (int i = 1;i <= N;++i)
	{
		modify(tree1,1,1,N,i,f[i-1]-2LL*(ll)X[i]-(ll)X[i-1]);
		modify(tree2,1,1,N,i,f[i-1]-(ll)X[i-1]);
		int l = 0,r = i-1,mid; f[i] = inf;
		while (l <= r)
		{
			mid = (l+r)>>1;
			if (T-2LL*(X[i]-X[mid+1]) > 0) r = mid-1;
			else l = mid+1;
		}
		if (r+1) f[i] = query(tree1,1,1,N,1,r+1)+3LL*X[i];
		if (r+2 <= i) f[i] = min(f[i],query(tree2,1,1,N,r+2,i)+(ll)X[i]+(ll)T);
	}
	cout << f[N]+(ll)E-(ll)X[N] << endl;
	return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,m,n,j,a,i,b,c;
	scanf("%d%d",&n,&a);
	if(a+n==15)
	{
		printf("+");
	}
	else if(a*n==15)
	{
		printf("*");
	}
	else
	{
		printf("x");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;ll k;
    cin>>s>>k;
    ll n = s.size();
    vector<ll> cnts;
    char prev = s[0];
    ll cnt = 0;
    rep(i,n){
        if(prev==s[i]){
            cnt++;
        }else{
            cnts.push_back(cnt);
            cnt = 1;
            prev=s[i];
        }
    }
    cnts.push_back(cnt);
    ll n_cnt = cnts.size();
    if(n_cnt==1){
        cout << (k*cnts[0]/2) << endl;
        return 0;
    }
    ll res = 0;
    repr(i,1,n_cnt-1){
        res += cnts[i]/2;
    }
    if(s[0]==s[n-1]){
        res *= k;
        res += (cnts[0]+cnts[n_cnt-1])/2*(k-1);
        res += cnts[0]/2;
        res += cnts[n_cnt-1]/2;
    }
    else{
        res += cnts[0]/2;
        res += cnts[n_cnt-1]/2;
        res *= k;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, m;
    cin >> n >> m;
    vi a(n);
    int t = 0;
    REP(i, n) {
        cin >> a[i];
        t += a[i];
    }
    SORT(a);
    if (a[n - m] >= (t + (4 * m) - 1) / (4 * m)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
int n,m; cin>>n>>m;
--n; --m;
cout<<(n*m);
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int N,x,r=1<<29;
	for(scanf("%d",&N);N--;){
		int r0=0;
		scanf("%d",&x);
		for(;x%2<1;x/=2){
			r0++;
		}
		if(r>r0){
			r=r0;
		}
	}
	printf("%d\n",r);
	return 0;
}




Measured memory_bytes: 128
<?php
 
  $hoge = explode(' ', trim(fgets(STDIN)));
 
		if((int)$hoge[1] === 1) {
			echo "0\n";
			return;
		}
		 
		$count = 1;
		$tmp = (int)$hoge[0];
		while(1) {
			if($tmp >= (int)$hoge[1]) break;
		 
			$count++;
			$tmp += (int)$hoge[0];
			$tmp--;
		 
		}
		 
		echo $count."\n";

Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	char test1[1000];
	int num1=0;
	
	cin>>test1;
	num1=strlen(test1);
	for(int i=0;i<num1;i++){
		if(test1[i]=='D'){
			test1[i]='A';
			goto AA;
		}
		if(test1[i]=='E'){
			test1[i]='B';
			goto AA;
		}
		if(test1[i]=='F'){
			test1[i]='C';
			goto AA;
		}
		if(test1[i]=='G'){
			test1[i]='D';
		}
		if(test1[i]=='H'){
			test1[i]='E';
			goto AA;
		}
		if(test1[i]=='I'){
			test1[i]='F';
			goto AA;
		}
		if(test1[i]=='J'){
			test1[i]='G';
			goto AA;
		}
		if(test1[i]=='K'){
			test1[i]='H';
			goto AA;
		}
		if(test1[i]=='L'){
			test1[i]='I';
			goto AA;
		}
		if(test1[i]=='M'){
			test1[i]='J';
			goto AA;
		}
		if(test1[i]=='N'){
			test1[i]='K';
			goto AA;
		}
		if(test1[i]=='O'){
			test1[i]='L';
			goto AA;
		}
		if(test1[i]=='P'){
			test1[i]='M';
			goto AA;
		}
		if(test1[i]=='Q'){
			test1[i]='N';
			goto AA;
		}
		if(test1[i]=='R'){
			test1[i]='O';
			goto AA;
		}
		if(test1[i]=='S'){
			test1[i]='P';
			goto AA;
		}
		if(test1[i]=='T'){
			test1[i]='Q';
			goto AA;
		}
		if(test1[i]=='U'){
			test1[i]='R';
			goto AA;
		}
		if(test1[i]=='V'){
			test1[i]='S';
			goto AA;
		}
		if(test1[i]=='W'){
			test1[i]='T';
			goto AA;
		}
		if(test1[i]=='X'){
			test1[i]='U';
			goto AA;
		}
		if(test1[i]=='Y'){
			test1[i]='V';
			goto AA;
		}
		if(test1[i]=='Z'){
			test1[i]='W';
			goto AA;
		}
		if(test1[i]=='A'){
			test1[i]='X';
			goto AA;
		}
		if(test1[i]=='B'){
			test1[i]='Y';
			goto AA;
		}
		if(test1[i]=='C'){
			test1[i]='Z';
			goto AA;
		}
		AA:;
	}
	for(int i=0;i<num1;i++){
		cout<<test1[i];
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 1108
#include <stdio.h>
int main(void)
{
	int a,b,c=1,d,e[100]={0},f[10]={1,2,3,5,4,6},i,j,g=0;
	char t[10];
	while(0==0){
		scanf("%d",&a);
		if(0==a){
			break;
		}
		for(i=0;i<a;i++){
			scanf("%s",t);
			if(t[0] == 'N'){
				b=f[0];
				f[0]=f[1];
				f[1]=f[5];
				f[5]=f[3];
				f[3]=b;
			}
			else if(t[0] == 'E'){
				b=f[0];
				f[0]=f[4];
				f[4]=f[5];
				f[5]=f[2];
				f[2]=b;
			}
			else if(t[0] == 'W'){
				b=f[0];
				f[0]=f[2];
				f[2]=f[5];
				f[5]=f[4];
				f[4]=b;
			}
			else if(t[0] == 'S'){
				b=f[0];
				f[0]=f[3];
				f[3]=f[5];
				f[5]=f[1];
				f[1]=b;
			}
			else if(t[0] == 'R'){
				b=f[1];
				f[1]=f[2];
				f[2]=f[3];
				f[3]=f[4];
				f[4]=b;
			}
			else{
				b=f[1];
				f[1]=f[4];
				f[4]=f[3];
				f[3]=f[2];
				f[2]=b;
			}
			c=c+f[0];
		}
		e[g]=c;
		g++;
		f[0]=1;
		f[1]=2;
		f[2]=3;
		f[3]=5;
		f[4]=4;
		f[5]=6;
		c=1;
	}
	for(i=0;i<g;i++){
		printf("%d\n",e[i]);
	}
	return 0;
}

Measured memory_bytes: 2580
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

constexpr ll MOD = 1e9 + 7;

ll fact(ll n) {
    if(n == 1) return 1;
    return n * fact(n-1) % MOD;
}

int main() {
    int n, m; cin >> n >> m;
    dump(fact(n)); dump(fact(m));
    if(abs(n-m) >= 2) cout << 0 << endl;
    else if(n == m) cout << ((fact(n) * fact(m)) % MOD * 2) % MOD << endl;
    else cout << (fact(n) * fact(m)) % MOD << endl;
    return 0;
}


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

int main() {
  int N;
  
  cin >> N;
  vector<int>vec(N);
  for(int i = 0;i<N;i++){
  	cin >> vec.at(i);	
  }
  //入力終わり。
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  //大きい順に変換。
  
  int Asum=0;
  int Bsum=0;
  for(int i =0; i <N; i++){
  	if(i %2== 0){
  		Asum += vec.at(i);
  	}
    else{
    	Bsum += vec.at(i);
    }
  }
  cout << Asum - Bsum <<endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> v(n);
	for (int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	const int M = 1000000007;
	vector<vector<int> > dp(n + 1, vector<int>(k + 1));
	fill(dp[n].begin(), dp[n].end(), 1);
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j <= k; ++j) {
			int l = max(0, j - v[i]);
			int r = j;
			dp[i][j] = dp[i + 1][r];
			if (l) {
				dp[i][j] += M - dp[i + 1][l - 1];
				if (dp[i][j] >= M)
					dp[i][j] -= M;
			}
			if (j) {
				dp[i][j] += dp[i][j - 1];
				if (dp[i][j] >= M)
					dp[i][j] -= M;
			}
		}
	}
	printf("%d\n", (dp[0][k] - (k ? dp[0][k - 1] : 0) + M) % M);
	return 0;
}


Measured memory_bytes: 40192
N, Y = gets.strip.split.map(&:to_i)

(0..N).each do |i|
  (0..N).each do |j|
    k = N - (i + j)
    if k >= 0 && Y.eql?(i * 10000 + j * 5000 + k * 1000)
      puts "#{i} #{j} #{k}"
      exit 
    end
  end
end

puts "-1 -1 -1"


Measured memory_bytes: 1788
#b = int(input())
#n, m = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]

x, k, d = [int(i) for i in input().split()]

kotae = 0
if(abs(x) >= abs(k*d)):
    kotae = min(abs(x+k*d),abs(x-k*d))
else:

    temp = abs(x) // abs(d)
    kotae = min(abs(x + temp * d), abs(x - temp * d))
    if((k-temp) % 2 == 1):
        kotae = abs(kotae-d)


print(kotae)

Measured memory_bytes: 61716
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    Set<Integer> set = new HashSet<>();
    boolean check = false;
    int cnt = 0;

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

    void run() {

        for (int i=0; i<n; i++) a[i] = sc.nextInt();

        int gcd = a[0];

        for (int i=0; i<n; i++) {
            gcd = gcd(gcd, a[i]);
        }

        int[] smallPrime;
        smallPrime = sieve(1000001);

//        for (int i=0; i<100+1; i++) System.out.print(smallPrime[i] + " ");

        for (int i=0; i<n; i++) {
            Map tP= factor(a[i], smallPrime);
//            System.out.print(tP);
            cnt += tP.size();
        }

//        System.out.print(set);
//        System.out.print(cnt);


        if (set.size() == cnt) {
            System.out.print("pairwise coprime");
            return;
        }


        if (gcd == 1) {
            System.out.print("setwise coprime");
            return;
        }

        System.out.print("not coprime\n");

    }

    int gcd(int c, int d) {
        if (c < d) return gcd(d, c);
        if (d == 0) return c;
        return gcd(d, c % d);
    }

    int[] sieve(int n) {
        int[] res = new int[n+1];
        for (int i=0; i<n+1; i++) res[i] = i;
        for (int i=2; i*i<n; i++) {
            if (res[i] < i) continue;
            for (int j=i*i; j<=n; j+=i) {
                if (res[j] == j) res[j] = i;
            }
        }
        return res;
    }

    Map<Integer, Integer> factor(int n, int[] min) {
        Map<Integer, Integer> map = new HashMap<>();
        while (n > 1) {
            if (map.containsKey(min[n])) {
                map.put(min[n], map.get(min[n])+1);
            } else {
                map.put(min[n], 1);
            }
            set.add(min[n]);
            n /= min[n];
        }
        return map;
    }


}



Measured memory_bytes: 71616
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>

typedef long long ll;

using namespace std;

int main() {
    int N, cnt = 0, i;

    cin >> N;

    for (i = 1; i <= N; i++) {
        if (i >= 10 && i <= 99) {
            continue;
        } else if (i >= 1000 && i <= 9999) {
            continue;
        } else if (i >= 100000 && i <= 999999) {
            continue;
        } 

        cnt++;

    }

    cout << cnt << endl;

    return 0;
}

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

int main(void){
 
    int D;
    cin >> D;
    string s = "Christmas";
    if(D == 24) s += " Eve";
    if(D == 23) s += " Eve Eve";
    if(D == 22) s += " Eve Eve Eve";
   cout << s << endl;
}

Measured memory_bytes: 3564
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// Union-Find 木 (Verified: AtCoder Typical Contest 001 B)
struct UnionFind {
private:
    const int n;
    int __size;
    vector<int> uf;
public:
    // 初期化 UnionFind uni(n) のように宣言すれば良い
    UnionFind(int _n) : n(_n), __size(_n), uf(_n, -1) {}
    // find (木の根を求める)
    int find(int x) {return (uf[x] < 0) ? x : uf[x] = find(uf[x]);}
    // x と y が同じ集合に属するかどうか
    bool same(int x, int y) {return find(x) == find(y);}
    // x が属する集合の要素数
    int size(int x) {return -uf[find(x)];}
    // 集合はいくつあるか
    int size()      {return __size;}
    // x と y の属する集合を併合
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return;
        __size--;
        if(uf[y] < uf[x]) swap(x, y);
        uf[x] += uf[y]; uf[y] = x;
    }
};

vector<int> a[100010], b[100010];
int main() {
    int N; cin >> N;
    for(int i=0; i<N; i++) {
        int x, y; cin >> x >> y;
        a[x].push_back(y);
        b[y].push_back(x);
    }
    UnionFind uf(100010);
    int64 ans = 0;
    for(int i=0; i<100010; i++) {
        for(size_t j=0; j+1<b[i].size(); j++) {
            int u = b[i][j], v = b[i][j+1];
            uf.unite(u, v);
        }
        /*
        for(size_t j=0; j+1<b[i].size(); j++) {
            int u = b[i][j], v = b[i][j+1];
            uf.unite(u, v);
        }
        */
    }

    vector< set<int> > rec(100010);
    for(int i=0; i<100010; i++) {
        int x = uf.find(i);
        for(auto e : a[i]) rec[x].insert(e);
    }

    /*
    for(int i=0; i<100010; i++) {
        if(!rec[i].size()) continue;
        fprintf(stderr, "rec[%d] = %d\n", i, rec[i].size());
    }
    */

    for(int i=0; i<100010; i++) {
        int64 sz = uf.size(i);
        ans += sz * rec[i].size();
    }
    cout << ans - N << endl;
    return 0;
}



Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  string s;
  cin>>n>>s;
 int count=0,totori=0;
  
  for(int i=0;i<n;i++){
  if(s.at(i)=='I' && count >=totori){
  count++; totori=count;}
 else if(s.at(i)=='I' && count < totori)
   count++;
    else count--;
  }
  cout <<totori<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x, y;
  cin >>x >>y;
  
  if (x==2 || y==2)
    cout << "No";
  
  else if (x==4 || x==6 || x==9|| x==11) {
    if (y==4 || y==6 || y==9|| y==11)
      cout << "Yes";
    else
      cout << "No";
  }
    
  else {
    if (!(y==4 || y==6 || y==9|| y==11))
      cout << "Yes";
    else
      cout << "No";
  }
}

Measured memory_bytes: 3604
#include <iostream>/*{{{*/
#include <iomanip>
#include <string>
#include <map>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <exception>
#include <ctime>
#include <climits>
#include <list>
#include <bitset>
#include <cassert>
using namespace std;
#define rep_n(i, a, b) for (int i=(a); i<(b); i++)
#define rep(i, n) rep_n(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define sc1(a) cin>>a 
#define sc2(a, b) cin>>a>>b
#define sc3(a, b, c) cin>>a>>b>>c
#define sc4(a, b, c, d) cin>>a>>b>>c>>d
typedef long long ll;/*}}}*/

int main() {
    int num=4;
    int a[num];
    char c[num+1]; sc1(c);
    rep (i, num) a[i]=c[i]-'0';
    
    char o[num];
    rep(i, pow(2, (num-1))) {
        int ans = a[0];
        rep(j, (num-1)) {
            if (i>>j&1) ans+=a[3-j], o[3-j]='+';
            else ans-=a[3-j], o[3-j]='-';
        }
        if (ans==7) {
            printf("%d%c%d%c%d%c%d=7\n", a[0], o[1], a[1], o[2], a[2], o[3], a[3]);
            break;
        }
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

class Card {
	public:
		char suit;
		int value;
};

void BubbleSort(vector<Card> &a, int n) {
	for(int i = 0; i < n; ++i) {
		for(int j = n - 1; j >= i + 1; j--) {
			if( a[j].value < a[j - 1].value ) swap(a[j], a[j - 1]);
		}
	}
}

void SelectionSort(vector<Card> &a, int n) {
	for(int i = 0; i < n; ++i) {
		int minj = i;
		
		for(int j = i; j < n; ++j) {
			if( a[j].value < a[minj].value ) {
				minj = j;
			}
		}
		
		swap(a[i], a[minj]);
	}
}

void print(vector<Card> &res, int n) {
	for(int i = 0; i < n; ++i) {
		if( i ) cout << " ";
		cout << res[i].suit << res[i].value;
	}
	
	cout << endl;
}

bool is_stable(vector<Card> &a1, vector<Card> &a2, int n) {
	
	bool ok = true;
	for(int i = 0; i < n; ++i) {
		if( a1[i].suit != a2[i].suit ) ok = false;
	}
	
	return ok;
}

int main(void) {
	int n;
	cin >> n;
	
	vector<Card> a1(n), a2(n);
	for(int i = 0; i < n; ++i) {
		cin >> a1[i].suit >> a1[i].value;
		a2[i] = a1[i];
	}
	
	BubbleSort(a1, n);
	SelectionSort(a2, n);
	
	print(a1, n);
	cout << "Stable" << endl;
	
	print(a2, n);
	
	if( is_stable(a1, a2, n) ) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n;

int main() {
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0) continue;
		int tmp = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0) tmp++;
	    }
		if (tmp == 8) ans++;
    }
	cout << ans;
	return 0;
}

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

constexpr int64_t MOD = 1e9 + 7; 

int main() {
    string s;
    cin >> s;
    reverse(begin(s), end(s));

    vector<vector<int>> surplus(s.size(), vector<int>(13));
    if (s[0] == '?') {
        for (int i = 0; i < 10; i++) surplus[0][i]++;
    } else {
        surplus[0][s[0] - '0']++;
    }

    for (int i = 1, t = 10; i < s.size(); i++, t = t * 10 % 13) {
        for (int n = 0; n < 13; n++) {
            if (s[i] == '?') {
                for (int m = 0; m < 10; m++) {
                    surplus[i][(n + m * t) % 13] += surplus[i-1][n];
                    surplus[i][(n + m * t) % 13] %= MOD;
                }
            } else {
                surplus[i][(n + (s[i] - '0') * t) % 13] += surplus[i-1][n];
                surplus[i][(n + (s[i] - '0') * t) % 13] %= MOD;
            }
        }
    }

    cout << surplus[s.size() - 1][5] << endl;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
// #define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
using namespace std;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 ;
const int N = 1000+5 ;
const int INF = INT_MAX ;
const int M = 200005; 


int main ( ){
fast_io();
int n , W ;
cin >> n >> W ;
vector<array<ll , 2 >>v(n+1); 
for(int  i = 1 ; i <= n ; ++ i )
cin >> v[i][0] >>v[i][1] ;
vector<ll>dp(W+1 , 0 ) ;
	for(int w =1 ; w <= W ; ++w )
		dp[w] = (w <v[1][0])?0 : v[1][1];  

	for(int i = 2 ; i <= n ; ++i)
	{
	vector<ll>new_dp(W+1 , 0 ) ; 
	for(int  w = 1 ; w <= W ; ++w ){
	
		if ( w >= v[i][0])
			 new_dp[w] = max(dp[w-v[i][0]] + v[i][1] , dp[w] ) ; 
		else
			new_dp[w] = dp[w] ; 
	
	}


dp = new_dp; 
}


cout << dp[W] ; 	
	 
return 0 ;
 
}


Measured memory_bytes: 1804
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] abcd = sc.next().toCharArray();

        sc.close();

        int a = Character.getNumericValue(abcd[0]);
        int b = Character.getNumericValue(abcd[1]);
        int c = Character.getNumericValue(abcd[2]);
        int d = Character.getNumericValue(abcd[3]);

        if (a + b + c + d == 7) {
            System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
        } else if (a + b + c - d == 7) {
            System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
        } else if (a + b - c + d == 7) {
            System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
        } else if (a + b - c - d == 7) {
            System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
        } else if (a - b + c + d == 7) {
            System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
        } else if (a - b + c - d == 7) {
            System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
        } else if (a - b - c + d == 7) {
            System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
        } else {
            System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
        }

    }
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_2_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            
            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }
        }
    }
}



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

int main() {
	int n;
	cin >> n;
	int h[25];
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
	bool f[25] = {};
	{
		int a = 0;
		for(int i = 0; i < n; i++) {
			if(a<=h[i]) f[i] = true;
			a = max(a,h[i]);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans += (f[i])?1:0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int n, m;
  cin >> n;
  vector<string> s(n);
  vector<string> t(m);
  rep(i,n) cin >> s[i];
  cin >> m;
  rep(i,m) cin >> t[i];
  int ans = 0;
  rep(i,n){
    string say = s[i];
    int tmp = 0;
    rep(j,n){
      if(s[j] == say) tmp++;
    }
    rep(j,m){
      if(t[j] == say) tmp--;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

class UnionFind{
public:
	vector<int> par,num;

	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UnionFind(int N):par(N),num(N,1){
		iota(par.begin(),par.end(),0);
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return ;
		if(num[u]<num[v])swap(u,v);
		num[u] += num[v];
		par[v] = u;
	}
	bool same(int u,int v){
		return find(u) == find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};
int main(){
	int N,M; cin >>N>>M;

	UnionFind uf(N);
	for(int i=0;i<M;i++){
		int u,v,z; cin >>u>>v >>z;
		u--; v--;
		uf.unite(u,v);
	}
	set<int> par;
	for(int i=0;i<N;i++){
		par.insert(uf.find(i));
	}
	cout << par.size() << endl;
	return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <math.h>

int main() {
	int N, M, k[10], s[10][10], p[10], i, j, bit, OnOff, cnt, combi = 0;

	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d", &k[i]);
		for (j = 0; j < k[i]; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	for (i = 0; i < M; i++) {
		scanf("%d", &p[i]);
	}

	for (bit = 0; bit < pow(2.0, (double)N); bit++) {
		for (i = 0; i < M; i++) {
			cnt = 0;
			for (j = 0; j < k[i]; j++) {
				OnOff = (bit >> (s[i][j] - 1)) % 2;
				cnt = cnt + OnOff;
			}
			if (cnt % 2 != p[i]) {
				break;
			}
		}
		if (i == M) {
			combi++;
		}
	}

	printf("%d\n", combi);

	return 0;
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	int n,x;
	cin>>n>>x;
	if(n<=5)
	{
		cout<<0;
	}
	else if(n>=6 && n<=12)
	{
		cout<<(x/2);
	}
	else
	cout<<x;
}

signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextInt();
        long m = sc.nextInt();
        long ans = 1;
        for (long a = 1; a * a <= m; a++) {
            if(m % a != 0){
                continue;
            }
            long b = m / a;
            if(a * n <= m){
                ans = Math.max(ans, a);
            }
            if(b * n <= m){
                ans = Math.max(ans, b);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int k=sc.nextInt();
int a=sc.nextInt();
int b=sc.nextInt();
int f=0;
for(int i=a;i<=b;i++)
{
if(i%k==0)
{
f=1;
break;
}
}
if(f==1)
System.out.println("OK");
else
System.out.println("NG");
}
}


Measured memory_bytes: 26972