akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

long long te9 = 1000000000ll;
int main() {
	long long s;
	cin>>s;
	if (s <= te9) {// 10^9
		cout<<"0 0 1 0 0 "<<s<<endl;
		return 0;
	}
	if (s == te9*te9) {
		cout<<"0 0 "<<te9<<" 0 0 "<<te9<<endl;
		return 0;
	}
	long long x1 = s/te9+1, y2=te9;
	long long target = x1*y2 - s;
	long long x2 = 1, y1 = target;
	cout<<"0 0 "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
	return 0;
}

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

def main():
	N,A,B = map(int,input().split())

	if N==1 and A!=B:
		res = 0
	elif A>B:
		res = 0
	else:
		#res = ((N-1)*B+A)-((N-1)*A+B)+1
		res = (N-2)*(B-A) + 1
	
	print(res)
	
main()


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
 int s[3];
 int a;

 scanf("%d %d %d", &s[0], &s[1], &s[2]);
  
 if(s[0] > s[1])
 {
  a = s[0];
  s[0] = s[1];
  s[1] = a;
 }
 
 if(s[1] > s[2])
 {
 a = s[1];
 s[1] = s[2];
 s[2] = a;

 if(s[0] > s[1])
 {
  a = s[0];
  s[0] = s[1];
  s[1] = a;
 }

 }

 printf("%d %d %d\n", s[0], s[1], s[2]);

 return 0;

}

Measured memory_bytes: 1856
def changing_character(n, k, s):

    s[k-1] = s[k-1].lower()
    return "".join(s)
def main():
    n, k = map(int, input().split())
    s = list(str(input()))
    print(changing_character(n, k, s))

if __name__ == '__main__':
    main()

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;

  vector<int> LCM;
  
for(int i=0; i<A ;i++){
  if(A%(i+1)==0 && B%(i+1)==0 && (i+1)<=A && (i+1)<=B){
  LCM.push_back(i+1);
  }
}

  int ans=0;
  ans=LCM[LCM.size()-K];

cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int h = 1e9 + 10;
    int l = 0;
    while(h - l > 1)
    {
        int mid = (h + l) >> 1;
        ll tmp = 0;
        for(int i = 0; i < n; i++)
        {
            if(a[i] <= mid) continue;
            ll num = a[i] / mid;
            tmp += num;
        }
        if(tmp <= k) h = mid;
        else l = mid;
    }
    cout << h << endl;
}


Measured memory_bytes: 3988
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll N;
  cin>>N;
  ll num=0;
  ll min_=LLONG_MAX;
  FOR(i,N){
    ll tmp;
    cin>>tmp;
    if(tmp<=min_){
      num++;
      min_=tmp;
    }
  }
  cout<<num<<endl;
  return 0;
}


Measured memory_bytes: 256
/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#define dump(x) cerr<< #x << " = " << x <<endl

using namespace std;
const int INF=1<<25;
void io(){ cin.tie(0);ios::sync_with_stdio(false);}
/*printf("%.9Lf\n",cf);*/
const int MOD=1000000007;

long long a[300100];
long long acc[300100];
long long b[300100];
long long c[300100];

int main(){
	io();
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	acc[0]=a[0];
	for(int i=1;i<n;i++){
		acc[i]=acc[i-1]+a[i];
	}

	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	for(int i=0;i<m;i++){
		cin>>c[i];
	}
	for(int i=0;i<m;i++){
		int solve=upper_bound(a,a+n,b[i])-a-1;
		if(acc[solve]>=c[i]){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}


	return 0;
}

Measured memory_bytes: 10492
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
    int n,k,ans=0;
    cin >> n >> k;
    FOR(i,k+1,n+1){
        int a = i;
        while(a <= n){
            ans = ans + i - k;
            a += i;
        }
        a = i - (a - n);
        if(a >= k && k == 0){
        ans = ans + a;
        }else if(a >= k){
            ans = ans + a - k + 1;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
L, R = map(int, input().split())

flag = False
ans = float("inf")
for i in range(L, min(R + 1, L + 2018)):
  for j in range(i + 1, min(R + 1, L + 2019)):
    ans = min(ans, (i * j) % 2019)
    if ans == 0:
      flag = True
      break
  if flag:
    break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 7;
int lst[Max];

int main()
{
	string str;
	cin >> str;
	str.insert(str.begin(), '-');
	int n = str.size()-1;
	while (n >= 0)
	{
		n -= 2;
		string s1 = str.substr(1, n / 2);
		string s2 = str.substr(n / 2+1, n / 2);
		if (str.substr(1, n / 2) == str.substr(n / 2+1, n / 2)) break;
	}
	cout << n;
}

Measured memory_bytes: 3196
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

int main() {
    int n = nxt();
    VI memo(3, 0);  // Max points so far that ends with i
    REP(i, n) {
        VI t(3, 0), a(3);
        generate(all(a), nxt);
        REP(j, 3) {
            REP(k, 3) {
                if (k != j) t[k] = max(t[k], memo[j] + a[k]);
            }
        }
        memo = t;
    }
    printf("%d\n", max({memo[0], memo[1], memo[2]}));
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rg register
#define N 200010
using namespace std;
int n,m,a[N],mx=1e9,num;
inline int read(){
	int k=0,f=1; char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while('0'<=c&&c<='9')k=k*10+c-'0',c=getchar();
	return k*f;
}
int main(){
	n=read();
	for(rg int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+1+n); int x=a[n];
	for(rg int i=1;i<=n;i++) 
		if(abs(x-2*a[i])<mx) mx=abs(x-2*a[i]),num=a[i];
	printf("%d %d\n",x,num);
	return 0; 
} 

Measured memory_bytes: 512
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

// xx, yy, zzにそれぞれ座圧する元の配列を突っ込むとx, y, zが座圧された配列で返ってくる
// zip[座圧前] = 座圧後、unzip[座圧後] = 座圧前
VL xx, x, unzip(300010);
unordered_map<int, int> zip;
void compress() {
  x = xx;
  sort(ALL(xx));
  xx.erase(unique(ALL(xx)), xx.end());
  REP(i, xx.size()) {zip[xx[i]] = i; unzip[i] = xx[i];}
  REP(i, x.size()) x[i] = zip[x[i]];
}

ll dp[3][300010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, 3*n) {
    int xxx; cin >> xxx;
    xx.PB(xxx);
  }
  compress();

  REP(i, n) dp[0][x[i]]++;
  FOR(i, 1, 300001) dp[0][i] += dp[0][i-1];

  FOR(i, n, 2*n) dp[1][x[i]] += dp[0][x[i]-1];
  FOR(i, 1, 300001) dp[1][i] += dp[1][i-1];

  ll ret = 0;
  FOR(i, 2*n, 3*n) ret += dp[1][x[i]-1];
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 29164
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    //let mut pathes: Vec<(u32, u32)> = Vec::new();
    let mut flags: Vec<u32> = vec![0;4];
    
    for _ in 0..3{
        let line : Vec<usize> = read_as_vec();
        flags[line[0]-1] += 1;
        flags[line[1]-1] += 1;
    }
    let one_len = flags.iter().filter(|x| **x == 1).collect::<Vec<_>>().len();
    let two_len = flags.iter().filter(|x| **x == 2).collect::<Vec<_>>().len();
    if one_len ==2 && two_len == 2{
        println!("YES");
    }else{
        println!("NO");
    }
}

Measured memory_bytes: 4352
N=int(input())
p=list(map(int, input().split()))
ans = 0

for i in range(1, N-1):
    if p[i-1] > p[i] and p[i] > p[i+1]:
        ans += 1
    elif p[i-1] < p[i] and p[i] < p[i+1]:
        ans += 1
print(ans)

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int a,b;cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const i64 inf=1000000000000000000ll;
int Q;
i64 f[400];
int n;
vector<pair<i64,i64> > ex[400];
inline int F(i64 a,i64 b){
	// printf("%d %d\n",a,b);
	if(a>b)return F(b,a);
	if(a==0)return 0;
	return F(b%a,a)+1;
}
const int mod=1e9+7;
int main(){
	read(Q);
	f[0]=1;f[1]=1;int n=1;
	while(f[n]+f[n-1]<=inf){
		n++;
		f[n]=f[n-1]+f[n-2];
	}
	ex[0].pb(mk(0ll,1ll));
	ex[0].pb(mk(0ll,2ll));
	rep(i,1,n){
		for(auto x:ex[i-1]){
			i64 a=x.w1,b=x.w2;
			for(;a+b<=f[i+2];a+=b){
				if(F(b,a+b)==i)
					ex[i].pb(mk(b,a+b));
			}
		}
	}
	while(Q--){
		i64 a,b;
		scanf("%lld%lld",&a,&b);
		if(a>b)swap(a,b);
		int ans=1;
		rep(i,1,n-1){
			if(a>=f[i]&&b>=f[i+1])ans=i;else break;
		}
		printf("%d ",ans);
		i64 cnt=0;
		for(auto x:ex[ans-1]){
			if(x.w2<=a&&x.w2+x.w1<=b&&x.w1!=x.w2)cnt=(cnt+(b-x.w1)/x.w2)%mod;
			swap(a,b);
			if(x.w2<=a&&x.w2+x.w1<=b&&x.w1!=x.w2)cnt=(cnt+(b-x.w1)/x.w2)%mod;
			swap(a,b);
		}
		printf("%lld\n",(ans==1)?1ll*a*b%mod:cnt);
	}
	return 0;
}


Measured memory_bytes: 4096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    String a = in.next();
    String b = in.next();

    System.out.println(new Solver().solve(a, b));
  }
}

class Solver {
  public String solve(String s, String t) {
    int n = s.length();
    int m = t.length();
    int[][] dp = new int[n + 1][m + 1];
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (s.charAt(i - 1) == t.charAt(j - 1)) {
          dp[i][j] = dp[i - 1][j - 1] + 1;
        } else {
          dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]);
        }
      }
    }
    char[] res = new char[dp[n][m]];
    int index = dp[n][m] - 1;
    int i = n;
    int j = m;
    while (i > 0 && j > 0) {
      if (s.charAt(i - 1) == t.charAt(j - 1)) {
        res[index--] = s.charAt(i - 1);
        i--;
        j--;
      } else if (dp[i - 1][j] > dp[i][j - 1]) {
        i--;
      } else {
        j--;
      }
    }
    return new String(res);
  }
}


Measured memory_bytes: 83412
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
ll modpow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return a*modpow(a,b-1)%mod;
    ll k=modpow(a,b/2);
    return k*k%mod;
}
const int max_n=510000;
ll fac[max_n], finv[max_n], inv[max_n];
// テーブルを作る前処理 O(max_n)
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_n; 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;
    }
}
// 二項係数計算 O(1)
long long modcom(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;
}
int main(){
    init();
    ll n,k;cin>>n>>k;
    ll ans=0;
    rep(i,min(n+1,k+1)){
        ll s=modcom(n,i);
        ans+=s*modcom(n-(n-i)+(n-i-1),(n-i-1))%mod;
        ans%=mod;
    }
    out(ans);
}


Measured memory_bytes: 12160
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	v := getNextInt(scanner)
	e := getNextInt(scanner)
	r := getNextInt(scanner)
	g := newGraph(v)
	for i := 0; i < e; i++ {
		s := getNextInt(scanner)
		t := getNextInt(scanner)
		d := getNextInt(scanner)
		g.appendEdge(s, t, i, d)
	}
	for i := 0; i < v; i++ {
		g.v[i].d = math.MaxInt32
	}
	g.v[r].d = 0
	for i := 0; i < v+1; i++ {
		updated := false
		for f, ee := range g.e {
			for _, e := range ee {
				if g.v[f].d == math.MaxInt32 {
					continue
				}
				if g.v[e.to].d > g.v[f].d+e.d {
					g.v[e.to].d = g.v[f].d + e.d
					updated = true
				}
			}
		}
		if i == v && updated {
			fmt.Fprintln(writer, "NEGATIVE CYCLE")
			return
		}
	}
	for i := 0; i < v; i++ {
		if g.v[i].d == math.MaxInt32 {
			fmt.Fprintln(writer, "INF")
			continue
		}
		fmt.Fprintln(writer, g.v[i].d)
	}
}

type vertex struct {
	d int
}
type edge struct {
	to, id, d int
}
type graph struct {
	v []vertex
	e [][]edge
}

func newGraph(n int) graph {
	return graph{
		v: make([]vertex, n),
		e: make([][]edge, n),
	}
}
func (g *graph) appendEdge(from, to, id, d int) {
	g.e[from] = append(g.e[from], edge{
		to: to,
		id: id,
		d:  d,
	})
}



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

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

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

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <vector>
#include <set>

#include <map>
#include <unordered_map>
#include <deque>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    int sum = 0;
    for (int i = 0; i < M; i++) {
        int Ai;
        cin >> Ai;
        sum += Ai;
    }

    if (sum <= N) {
        cout << N - sum << endl;
    } else {
        cout << "-1" << endl;
    }

    return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	deque<char> ns;
	rep(i,s.size()){
		ns.push_back(s[i]);
	}
	bool flag=true;
	int q;
	cin>>q;
	while(q--){
		int t;
		cin>>t;
		if(t==1){
			flag=!flag;
		}else{
			int f;
			cin>>f;
			char c;
			cin>>c;
			if(flag){
				if(f==1){
					ns.push_front(c);
				}else{
					ns.push_back(c);
				}
			}else{
				if(f==2){
					ns.push_front(c);
				}else{
					ns.push_back(c);
				}
			}
		}
	}
	if(!flag){
		reverse(begin(ns),end(ns));
	}
	rep(i,ns.size()){
		cout<<ns[i];
	}
	cout<<endl;
}

Measured memory_bytes: 976
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

using namespace std;

static const uint64_t MOD = 1e9 + 7;

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

    int n, m;
    cin >> n >> m;

    vector<vector<char>> grid(n + 1, vector<char>(m + 1));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> grid[i][j];
        }
    }

    vector<vector<uint64_t>> dp(n + 1, vector<uint64_t>(m + 1, 0));

    for (int i = 0; i < n; ++i) {
        if (grid[i][0] == '#') break;
        dp[i][0] = 1;
    }

    for (int j = 0; j < m; ++j) {
        if (grid[0][j] == '#') break;
        dp[0][j] = 1;
    }

    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < m; ++j) {
            if (grid[i][j] == '#') continue;
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
            dp[i][j] %= MOD;
        }
    }

    cout << dp[n - 1][m - 1];
}


Measured memory_bytes: 9216
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,ans=0;
    cin>>n;
    for(int i=1;i<=n-1;i++)
    {
        ans+=(n-1)/i;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  ll plusans = 0, cnt = 0;
  for(int i=0; i<n; ++i){
    cnt += an[i];
    if(cnt *(i%2 ? 1:-1) >= 0){
      plusans += abs(cnt) +1;
      cnt = (i%2 ? -1:1);
    }
  }
  ll minusans = 0;
  cnt = 0;
  for(int i=0; i<n; ++i){
    cnt += an[i];
    if(cnt *(i%2 ? -1:1) >= 0){
      minusans += abs(cnt) +1;
      cnt = (i%2 ? 1:-1);
    }
  }
  cout << min(plusans, minusans) << endl;
}

Measured memory_bytes: 3756
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

u , v = 0, 0
for i in range(n):
  if a[i] > b[i]:
    u += a[i] - b[i]
  else:
    v += (b[i] - a[i]) // 2
if u > v:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<bool> ans(n);
  rep(i, 2){
    rep(j, 2){
      ans.at(0) = i, ans.at(1) = j;
      rep(k, n){
        int k1 = k, k2 = (k+1) % n, k3 = (k+2) % n;
        bool m = (s.at(k2) == 'o');
        if(ans.at(k2) == false) m ^= 1;
        if(m == true) ans.at(k3) = ans.at(k1);
        else ans.at(k3) = !ans.at(k1);
      }
      if(ans.at(0) == i && ans.at(1) == j){
        rep(i, n){
          char o;
          if(ans.at(i) == true) o = 'S';
          else o = 'W';
          cout << o;
        }
        cout << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(System.Console.ReadLine().Trim());
        int[] line = Array.ConvertAll(System.Console.ReadLine().Trim().Split(' '),int.Parse);

        Dictionary<int, int> s = new Dictionary<int, int>();
        Dictionary<int, int> t = new Dictionary<int, int>();
        Dictionary<int, int> tmp;

        for (int i = 0; i < n ; i++)
        {
           
            tmp = (i % 2 == 0) ? s: t;

            if(tmp.ContainsKey(line[i]))
            {
                tmp[line[i]]++;
            }
            else
            {
                tmp.Add(line[i], 1);
            }
        }

        //if (s.Count == 1 && t.Count == 1 && s.First().Key != t.First().Key)
        //{
        //    //すでにVVV
        //    System.Console.WriteLine("{0}",0);
        //    return;
        //}

        int s1 = 0, s2 = 0, t1 = 0, t2 = 0;

        s = s.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
        t = t.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

        s1 = s[s.Keys.ToList()[0]];
        t1 = t[t.Keys.ToList()[0]];

        if(s.Keys.ToList()[0] != t.Keys.ToList()[0])
        {
            //最頻値が異なればsもtも最頻値で置換
            System.Console.WriteLine("{0}", (n - s1 - t1));

        }
        else{

            //最頻値が同じならいずれかを2番目の頻度の値で置換
            if (s.Count > 1) s2 = s[s.Keys.ToList()[1]];
            if (t.Count > 1) t2 = t[t.Keys.ToList()[1]];

            //sを最頻値で、tを二番目で書き換え
            //tを最頻値で、sを二番目で書き換え
            int sRlt = n - s1 - t2;
            int tRlt = n - s2 - t1;

            System.Console.WriteLine("{0}", Math.Min(sRlt, tRlt));

        }


    }

    


}


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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i <= n; i++){
    for (int j = 0; j <= m; j++){
      if(i* (m-j) + j* (n-i) == k){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main(void)
{
	int much;

	while(cin >> much, much > 0){
		int c = 0;

		much = 1000 - much;

		if(much >= 500){
			c += (int)(much / 500);
			much %= 500;
		}
		if(much >= 100){
			c += (int)(much / 100);
			much %= 100;
		}
		if(much >= 50){
			c += (int)(much / 50);
			much %= 50;
		}
		if(much >= 10){
			c += (int)(much / 10);
			much %= 10;
		}
		if(much >= 5){
			c += (int)(much / 5);
			much %= 5;
		}
		c += much;

		cout << c << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 REPO(i, n) for(int i = 1;i <= n;i++)
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define ll long long
#define MOD 1000000007


ll n, m, q, now = 0, ans = 0, s[600][600];
int main() {
	cin >> m >> n >> q;
	REP(i, n) {
		ll a, b; cin >> a >> b;
		s[a][b]++;
	}
	REP(i, 600) {
		REPR(j, 545) {
			s[j][i] += s[j + 1][i];
		}
	}

	REP(i, 600) {
		REP(j, 545) {
			s[i][j + 1] += s[i][j];
		}
	}
	REP(i, q) {
		ll a, b; cin >> a >> b;
		cout << s[a][b] << endl;
	}
}



Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int main()
{
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(1     <= i && i <= 9    ) ans++;
        if(100   <= i && i <= 999  ) ans++;
        if(10000 <= i && i <= 99999) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while True :
    i = input().split()
    r = int(i[0])
    op = i[1]
    l = int(i[2])
    if op == '?':
        break
    else:
        if op == '+':
            print(str(r+l))
        elif op == '-':
            print(str(r-l))
        elif op == '*':
            print(str(r*l))
        else :
            print(str(r//l))
        

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 2e5 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n, m;
char type[N];
int ok[N][2];

bool bad[N];
vector <int> G[N];

int main(){
	scanf("%d %d", &n, &m);
	scanf("%s", type + 1);

	for(int i = 1; i <= m; ++i){
		int u, v;
		scanf("%d %d", &u, &v);
		
		ok[u][type[v] - 'A']++;
		ok[v][type[u] - 'A']++;

		G[u].push_back(v);
		G[v].push_back(u);
	}
	
	queue <int> Q;
	for(int i = 1; i <= n; ++i)
		if(ok[i][0] == 0 || ok[i][1] == 0){
			bad[i] = true;
			Q.push(i);
		}
	
	while(!Q.empty()){
		int u = Q.front();
		Q.pop();
		
		for(int v: G[u]){
			if(bad[v])
				continue;
			
			ok[v][type[u] - 'A']--;
			if(ok[v][0] == 0 || ok[v][1] == 0){
				bad[v] = true;
				Q.push(v);
			}
		}
	}
	
	for(int i = 1; i <= n; ++i)
		if(!bad[i]){
			puts("Yes");
			return 0;
		}
	
	puts("No");
	return 0;
}

Measured memory_bytes: 12544
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int A = in.nextInt();
            out.println(X < A ? 0 : 10);
        }

    }
}



Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define f first
#define s second
#define inf 999999999999
#define N  500009
#define M  (L+R)/2
#define ll long long
#define pb push_back
using namespace std;

unsigned ll n,m,i,j,ans,sum,k,a,b;

int main()
{

	ios::sync_with_stdio(0);
	
	cin>>k>>a>>b;
	
	if(a+2<b && k>=a+1)
	{
		ans=b; k-=a+1;
		if(k%2==0)
		ans+=(k/2)*(b-a);
		else
		ans+=(k/2)*(b-a)+1;
		cout<<ans<<endl;
	} else {
		cout<<k+1<<endl;
		return 0;
	}


	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W; cin>>H>>W;
    vector<vector<char>> Q(H+2,vector<char>(W+2,'.'));
    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
                cin >> Q[i][j];
        }
    }
    int dx[4]={-1,0,0,1};
    int dy[4]={0,1,-1,0};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            bool can=false;
            if(Q[i][j]=='#'){
                for(int k=0;k<4;k++){
                    if(Q[i+dx[k]][j+dy[k]]==Q[i][j]){
                        can=true;
                    }
                }
                if(!can){
                    cout<<"No";
                    return 0;
                }
            }
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main( void )
{
    char tcard[101];
    char hcard[101];
    int i, n, cmp, tpoint = 0, hpoint = 0;
     
    scanf("%d", &n);
     
    for(i = 0; i < n; i++){
        scanf("%s %s", tcard, hcard);
         
        cmp = strcmp(tcard, hcard);
         
        if(cmp > 0){
            tpoint += 3;
        } else if(cmp < 0){
            hpoint += 3;
        } else {
            tpoint++;
            hpoint++;
        }
    }
     
    printf("%d %d\n", tpoint, hpoint);
     
    return 0;
}


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

template<class T>inline void readin(T &res) {
	static char ch;T flag = 1;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;
	res=ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	res*=flag;
}

int n, f[2][2], cur;
char ss[100];
int main() {
	scanf("%d",&n);
	for( int i = 1, x; i <= n; i++ ) {
		scanf("%d",&x);
		if(i==1) f[cur][(x&1)^1]=2, f[cur][x&1]=1;
		else {
			cur^=1;
			if(x&1) {
				f[cur][1]=f[cur^1][1];
				f[cur][0]=3*f[cur^1][0]+2*f[cur^1][1];
			} else {
				f[cur][1]=2*f[cur^1][1];
				f[cur][0]=3*f[cur^1][0]+f[cur^1][1];
			}
		}
	}
	printf("%d\n",f[cur][0]);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int manhattan(int x1, int x2, int y1, int y2);

int main()
{
  int n, m, *a, *b, *c, *d;
  int i, j, temp, min, minj;
  scanf("%d%d", &n, &m);
  a = (int *)malloc(sizeof(int) * n);
  b = (int *)malloc(sizeof(int) * n);
  c = (int *)malloc(sizeof(int) * m);
  d = (int *)malloc(sizeof(int) * m);

  for(i=0; i<n; i++){
    scanf("%d%d", a+i, b+i);
  }
  for(i=0; i<m; i++){
    scanf("%d%d", c+i, d+i);
  }

  for(i=0; i<n; i++){
    min = manhattan(a[i], b[i], c[0], d[0]);
    minj = 0;
    for(j=1; j<m; j++){
      temp = manhattan(a[i], b[i], c[j], d[j]);
      if(temp < min){
        min = temp;
        minj = j;
      }
    }
    printf("%d\n", minj+1);
  }
  free(a);
  free(b);
  free(c);
  free(d);

  return 0;
}

int manhattan(int x1, int y1, int x2, int y2)
{
  return(abs(x1-x2) + abs(y1-y2));
}

Measured memory_bytes: 128
a,b,k=map(int,input().split())
for i in range(k//2):
    if a%2==1:a-=1
    a,b=a//2,b+a//2
    if b%2==1:b-=1
    a,b=a+b//2,b//2
if k%2==1:
    if a%2==1:a-=1
    a,b=a//2,b+a//2
print(a,b)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

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

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    HashMap<Integer, HashSet<Integer>> graph;
    int[] indegree;
    int[] dp;
    boolean[] visited;
    void findMax(int row) {
        visited[row]=true;
        if(!graph.containsKey(row))
            return;
        for(int neig : graph.get(row)) {
            dp[neig] = Math.max(dp[neig], dp[row]+1);
            indegree[neig]--;
            if(indegree[neig]==0)
                findMax(neig);
        }
    }
    void solve() throws IOException {
        int n = readInt();
        int m = readInt();
        visited = new boolean[n+1];
        graph = new HashMap<>();
        indegree = new int[n+1];

        for(int i=0;i<m;i++){
            int s = readInt();
            if(!graph.containsKey(s))
                graph.put(s, new HashSet<Integer>());
            int e = readInt();
            graph.get(s).add(e);
            indegree[e]++;
        }

        int max = 0;
        dp = new int[n+1];
        for(int no=1;no<=n; no++) {
            if(!visited[no] && indegree[no]==0)
                findMax(no);
        }
        for(int i=1;i<=n;i++)
                if(dp[i]>max)
                    max=dp[i];
        System.out.println(max);
    }
}


Measured memory_bytes: 90172
#include<iostream>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;

int N;
ll A[2000];
set<ll> sosu;

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

void bunkai(ll a){
    for(ll waru = 2; waru * waru <= a; waru++){
        while(a % waru == 0)a /= waru, sosu.insert(waru);
    }
    if(a != 1)sosu.insert(a);
}

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        bunkai(A[i]);
    }
    ll ans = 0;
    for(auto it = sosu.begin(); it != sosu.end(); it++){
        ll sum = 0;
        ll waru = (*it);
        for(int i = 0; i < N; i++){
            if(A[i] == 1)continue;
            if(A[i] % waru == 0)sum += A[i];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define int long long
 // queue<pair<int,int>> que;
signed main() {
  int h,w,n;
  cin>>h>>w>>n;
  map<pair<int,int>,int> mp;
  int a,b;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<=2;j++){
      for(int u=0;u<=2;u++){
        if(a-j>0&&b-u>0&&a-j<=h-2&&b-u<=w-2)mp[make_pair(a-j,b-u)]++;
      }
    }

  }
  int ans[10]={};
  ans[0]=(h-2)*(w-2);
  for(auto itr=mp.begin();itr!=mp.end();++itr){
    ans[itr->second]++;
    //cerr<<itr->first.first<<' '<<itr->first.second<<' '<<itr->second<<endl;
    ans[0]--;
  }
  for(int i=0;i<10;i++)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 56448
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

/*
int main(void){
  string S;
  cin >> S;
  for(ll i = 0; i < pow(2, N); i++){
    ll now = S[0] - '0';
    ll I = i;
    vector<bool> op(N);
    rep(j, N){
      op[j] = I % 2;
      I / = 2;
    }
    if(now == 7){
      cout << S[0];
      for(ll j = 0; j < 3; j++){
        if((i>>j)&1) cout << '+';
        else cout << "-";
        cout << S[j+1];
      }
      cout << "=7";
      cout << endl;
      return 0;
    }
  }


  for(int i = 0; i < 30; i++){
    cout << char('0' - 15 + i) << endl;
  }
}
*/

int main(void){
  int N;
  cin >> N;
  vector<int> A(4);
  //cin >> A >> B >> C >> D;
  A[0] = N/1000;
  A[1] = N/100%10;
  A[2] = N/10%10;
  A[3] = N%10;
  for(int bit = 0;bit < (1<<3);bit++){
    int sum = A[0];
    for(int i = 0;i < 3;i++){
      if((bit>>i)&1){
        sum += A[i+1];
      }else{
        sum -= A[i+1];
      }
    }
    if(sum == 7){
      cout << A[0];
      for(int j = 0;j < 3;j++){
        if((bit>>j)&1){
          cout << '+' ;
        }else{
          cout << '-';
        }
        cout << A[j+1];
      }
      cout << '=' << 7 <<endl;
      break;
    }
  }
return 0;

}


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

def f(a,b,x,y):
    aa,bb = -1,-1
    
    for i in range(1000,0,-1):
        if i*(100+x)//100 == a:
            aa = i
            break
    for i in range(1000,0,-1):
        if i*(100+x)//100 == b:
            bb = i
            break     
    if aa == -1 or bb == -1:
        return 0

    return aa*(100+y)//100 + bb*(100+y)//100

while True:
    x,y,s = map(int,input().split())
    if (x,y,s) == (0,0,0):
        exit()
    
    res = 0
    for a in range(1,s):
        b = s - a
        res = max(res,f(a,b,x,y))
    print(res)


Measured memory_bytes: 5628
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll m = max(a*c, b*d);
    ll x = max(a*d, b*c);
    pr(max(x, m));
    return 0;}

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

int main(void) {
    int N;
    cin >> N;
    bool F[N][10];
    ll P[N][11];
    for (int i=0; i<N; i++) for (int j=0; j<10; j++) cin >> F[i][j];
    for (int i=0; i<N; i++) for (int j=0; j<11; j++) cin >> P[i][j];

    int F_N[N];
    ll ans;
    int cnt = 1;
    int flg,dig;
    ll tmp;
    while (cnt < pow(2, 10) ) {
        flg = cnt;

        for (int i=0; i<N; i++) F_N[i] = 0;

        dig = 0;
        while (flg > 0) {
            if (flg % 2 == 1) {
                for (int i=0; i<N; i++) {
                    if (F[i][dig]) F_N[i]++;
                }
            }
            flg >>= 1;
            dig++;
        }

        tmp = 0;
        for (int i=0; i<N; i++) tmp += P[i][F_N[i]];

        if (cnt == 1) ans = tmp;
        else ans = max(ans, tmp);

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;




long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
class Ans{
public:
	long long x;
	long long y;
	long long x_;
	long long y_;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	string s;
	cin>>s;
	s+='0';
	long long ans=0;
	for(int i=0;i<s.length()-1;i++){
		if(s[i]!=s[i+1])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    typedef struct gotiusa{
        string name;
        vi v;
        int score;
    }gotiusa;
    int n;
    while(cin>>n,n){
        vi array(100000,0);
        vector<gotiusa>hoge(n+1);
        rep(i,n){
            cin>>hoge[i].name;
            int m; cin>>m;
            rep(j,m){
                int temp; cin>>temp;
                hoge[i].v.push_back(temp);
                array[temp]++;
            }
            
        }
        gotiusa ujimatu;
        ujimatu.score=INF;
        ujimatu.name="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzgotiusa is a god";
        rep(i,n){rep(j,hoge[i].v.size()){
            if(!(j))hoge[i].score=0;
            if(n-array[hoge[i].v[j]]==n);
            else if(!(n-array[hoge[i].v[j]])){
                hoge[i].score++;
            }
            else hoge[i].score+=n-array[hoge[i].v[j]]+1;
        }
            if(ujimatu.score>hoge[i].score)
                ujimatu=hoge[i];
            else if(ujimatu.score==hoge[i].score&&ujimatu.name>hoge[i].name)
                ujimatu=hoge[i];
        }
        cout<<ujimatu.score<<" "<<ujimatu.name<<endl;
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <float.h>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  double r;
  cin >> r;
  double l,  s;
  l = M_PI * r * 2;
  s = M_PI * r * r;
  printf("%f %f\n",s,l);
  return 0;
}



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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	ll a,b;	cin >>a>>b;
	
	if(a>b) cout<<a-1<<endl;
	
	if(a<=b) cout<<a<<endl;
	
    return 0;
}

Measured memory_bytes: 256