akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, k;
  cin >> n >> k;

  string s;
  cin >> s;

  ll ans = 0;
  ll r = 0;
  ll flip_cnt = 0;
  rep(l, n) {
    for (; r < n; r++) {
      if (s[r] == '0') {
        flip_cnt++;
        for (; r < n; r++) {
          if (s[r] == '1') {
            r--;
            break;
          }
        }
      }
      if (flip_cnt == k) {
        for (; r < n - 1; r++) {
          if (s[r + 1] == '0') {
            break;
          }
        }
        break;
      }
    }

    if (r >= n) {
      r = n - 1;
    }

    chmax(ans, r - l + 1);

    // 端で探索したら終わり
    if (r == n - 1) {
      break;
    }

    flip_cnt--;
    for (; l < n; l++) {
      if (s[l] == '0') {
        break;
      }
    }
    for (; l < n - 1; l++) {
      if (s[l + 1] == '1') {
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
# 2019-11-25 06:26:24(JST)
import sys

def main():
    s, k = sys.stdin.read().split()
    k = int(k)

    if len(s) == 1:
        print(k // 2)
        sys.exit()
    
    if s.count(s[0]) == len(s):
        if len(s) % 2 == 0:
            ans = len(s) // 2 * k
        else:
            if k % 2 == 0:
                ans = len(s) * (k // 2)
            else:
                ans = len(s) * (k // 2) + len(s) // 2
        print(ans)
        sys.exit()

    count = 0
    same = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            same += 1
        else:
            if count == 0:
                first_same = same
            count += same // 2
            same = 1
    
    bl = False
    if s[-1] == s[0]:
        if same % 2 == 1 and first_same % 2 == 1:
            count += same // 2 + 1
            bl = True
        else:
            count += same // 2
    else:
        count += same // 2

    ans = count * k
    if bl:
        ans -= 1

    print(ans)

if __name__ == '__main__':
    main()


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

int c[10][10];

void solve()
{
    int H, W;
    cin >> H >> W;

    REP0 (i, 10)
    {
        REP0 (j, 10)
        {
            cin >> c[i][j];
        }
    }

    REP0 (k, 10)
    {
        REP0 (i, 10)
        {
            REP0 (j, 10)
            {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    LL ans = 0;

    REP0 (i, H)
    {
        REP0 (j, W)
        {
            int A;
            cin >> A;
            if (A >= 0)
            {
                ans += c[A][1];
            }
        }
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)

#define si(a)               scanf("%d", &a)
#define sii(a,b)            scanf("%d %d", &a, &b)
#define siii(a,b,c)         scanf("%d %d %d", &a, &b, &c)

#define CLR(a)              memset(a, 0, sizeof(a))
#define SET(a)              memset(a, -1, sizeof(a))

#define PI                  acos(-1.0)

#define pb                  push_back
#define mp                  make_pair
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for(int i=0; i<n; i++)
#define FOR1(i, n)          for(int i=1; i<=n; i++)
#define ROF(i, n)           for(int i=n-1; i>=0; i--)
#define ROF1(i, n)          for(int i=n; i>=1; i--)
#define LOOP(i, x, y)       for(int i=x; i<=y; i++)
#define fastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


typedef long long              LL;
typedef unsigned long long     ULL;
typedef vector<int>            VI;
typedef pair<int, int>         PII;
typedef pair<string, int>      PSI;
typedef pair<char, int>        PCI;

const int MAX = 3005;
const int MOD = 1e9+7;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;

//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//
//using namespace __gnu_pbds;
//
//template < typename T> using orderedSet = tree < T, null_type, less_equal < T >, rb_tree_tag, tree_order_statistics_node_update>;
//
//orderedSet < int > mySet;
//orderedSet < int > :: iterator it;

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


int dp[MAX][MAX];

int main()
{
//    READ;
//    WRITE;
    string str1, str2;
    cin >> str1 >> str2;

    int n = str1.size(), m = str2.size();

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(str1[i-1] == str2[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
        }
    }

    string ans = "";
    int i = n, j = m;
    while(i > 0 and j > 0){
            if(dp[i][j] != dp[i][j-1] and dp[i][j] != dp[i-1][j]){
                ans += str1[i-1];
                i--; j--;
            }
            else{
                if(dp[i][j] == dp[i][j-1]) j--;
                else i--;
            }
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define pb push_back
using namespace std;

const int N = 200005;
ll n, m, t, a[N], k, l[N], r[N], ans, tong;
ll b[N];
vector<pll> kq;
string s;
priority_queue< pii, vector<pii>, greater<pii> > pr;
void sol()
{
    cin >> n >> s;
    s = " " + s;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        l[i] = i - 1;
        r[i] = i + 1;
    }
    for(int i = 2; i <= n; i ++)
    {
        if(s[i-1] != s[i])
        {
            k = abs(a[i] - a[i-1]);
            pii u;
            u.fi = k;
            u.se.fi = i-1;
            u.se.se = i;
            pr.push(u);
        }

    }
    while(!pr.empty())
    {
        pii u = pr.top();
        pr.pop();
        ll x = u.se.fi, y = u.se.se;
        if(b[x] == 1 || b[y] == 1)continue;
        b[x] = 1;
        b[y] = 1;

        l[r[y]] = l[x];
        r[l[x]] = r[y];
        kq.pb({x, y});
        if(l[x] > 0 && r[y] <= n && s[l[x]] != s[r[y]])
        {
            pii v;
            v.fi = abs(a[l[x]] - a[r[y]]);
            v.se.fi = l[x];
            v.se.se = r[y];
            pr.push(v);
        }
    }
    cout << kq.size() <<'\n';
    for(pll u : kq)cout << u.fi <<" "<<u.se<<'\n';
}
ll random(ll minn, ll maxn)
{
    return minn + rand() % (maxn + 1 - minn);
}
priority_queue<ll> st;
ll uoc(ll a, ll b)
{
    while(b != 0)
    {
        ll r = a % b;
        a = b;
        b = r;
    }
    return a;
}
map<ll, ll> mp;
void test()
{
   cin >> n;
    for(int i = 1;i <= n; i ++)
    {
        cin >> a[i];
        l[i] = a[i];
        r[i] = a[i];
    }

    for(int i = 2; i <= n; i ++)
    {
        l[i] = l[i-1] ^ a[i];
    }
    for(int i = n - 1; i > 0; i --)
    {
        r[i] = r[i+1] ^ a[i];
    }
    for(int i = 1; i <= n; i ++)
    {
        if(i == 1)cout << r[i+1];
        else if(i == n)cout << l[i-1];
        else
            cout << (r[i+1] ^ l[i-1]);
        cout << " ";
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    test();
}


Measured memory_bytes: 8276
#include <iostream>

using namespace std;

int main()
{
  	int N;
  	cin >> N;
  	bool a = false;
  	for(; N > 0; ){
      	if(N % 4 * N % 7 == 0){
			a = true;
          	break;
        }else{
          	N -= 4;
        }
    }
  	if(a){
      cout << "Yes";
    }else{
      cout << "No";
    }
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef vector<bool> vb;

vb makeTable() {
	vb p(10001, true);
	p[1]=false;
	for(int i=4;i<=10000;i+=2)p[i]=false;
	for(int i=3;i<=10000;i+=2){
		if(p[i]){
			for(int j=i*2;j<=10000;j+=i)p[j]=false;
		}
	}
	return p;
}

int main() {
	vb table = makeTable();
	int N;
	while (cin >> N) {
		int cnt=0;
		for(int i=1;i<=N;i++){
			if(table[i]&&table[N-i+1]) cnt++;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;

int main()
{  fast
int n;
cin>>n;ll ans=0;
for(int i=1;i<=n;i++)
{
	ll x=n/i;
	if(n%i==0)
	x--;
	ans+=1ll*max(0ll,x);
}
cout<<ans;
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int ans = 0;

		for (int i = 1; i < B; i++) {
			ans = A * i % B;
			if (ans == C) 
				break;
		}
		if (ans == C) cout << "YES" << endl;
		else cout << "NO" << endl;
		
	
	return 0;
	}














Measured memory_bytes: 256
N, M, P = map(int, input().split())
E = [[] for _ in range(M)]
for i in range(M):
  a, b, c = map(int, input().split())
  E[i] = [a - 1, b - 1, c]
D = [None] * N
D[0] = 0
for _ in range(N):
  for a, b, c in E:
    if D[a] == None:
      continue
    if D[b] == None:
      D[b] = D[a] + c - P
    else:
      D[b] = max(D[b], D[a] + c - P)
_D = D[-1]
for _ in range(N):
  for a, b, c in E:
    if D[a] == None:
      continue
    if D[b] == None:
      D[b] = D[a] + c - P
    else:
      D[b] = max(D[b], D[a] + c - P)
if D[-1] > _D:
  print(-1)
else:
  print(max(D[-1], 0))

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

int main() {
    int x, a, b; cin >> x >> a >> b;
    if(abs(x-a)<abs(x-b)) cout << 'A' << endl;
    else cout << 'B' << endl;
}


Measured memory_bytes: 256
import math
if __name__ == "__main__":
	r = [ int(i) for i in input().split(" ")]
	n = r[0]
	m = r[1]

	ass = [ int(i) for i in input().split(" ")]

	sm = 0
	for i in range(m):
		sm += ass[i]

	print(max( -1, n-sm))

Measured memory_bytes: 10116
n=int(input())
ab=[]
for i in range(n):
  aa,bb=map(int,input().split())
  ab.append((aa,bb))
t_sum=0
ab=ab[::-1]
for a,b in ab:
  if (a+t_sum)%b!=0:
    t=b-(a+t_sum)%b
    t_sum+=t
print(t_sum)



Measured memory_bytes: 17368
N,A,B,C,D = map(int,input().split())
s = input()
#ans = 'Yes'
if C<D:
    ans = 'Yes' 
else:
    if s[B-2:D+1].count('...')>0:
        ans = 'Yes'
#    elif D-B == 1:
#        ans = 'No'
#    elif D-B == 2: 
#        if s[B-2:D].count('#')!=0:
#            ans = 'No'
    else:
        ans = 'No'
if s[A:C-1].count('##')!=0 or s[B:D-1].count('##')!=0:
    ans = 'No'
print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n+1,0);
  for (int i = 1; i < (n+1); ++i){
    int k=i;
    while (k<=n){
      b[k]++;
      k+=i;
    }
  }
  int64_t res=0;
  rep(i,n+1) {
    int64_t a=i;
    int64_t c=b[i];
    res+=(a*c);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 42324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  cout << N * N * N << '\n';
}

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

#define MAX_N (2000)
#define INF (1000000000000000000L)

using namespace std;

// min_time_catches[i][j] : min(as[i], as[i - 1], ..., as[i - j])
long min_time_catches[MAX_N][MAX_N];
// time_catches[j] : sum_i(min_time_catches)
long time_catches[MAX_N];

int main(int argc, char *argv[]) {
  // read inputs
  long N, x, as[MAX_N];
  scanf("%ld %ld", &N, &x);
  for (int i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }

  // calculate the best way to catch each slime
  long time_catch_0 = 0;
  for (int i = 0; i < N; i++) {
    const int a = as[i];
    min_time_catches[i][0] = a;
    time_catch_0 += a;
  }
  time_catches[0] = time_catch_0;
  for (int j = 1; j < N; j++) {
    long time_catch_j = 0;
    for (int i = 0; i < N; i++) {
      const long a = as[i - j >= 0 ? i - j : i - j + N];
      const long t = min(min_time_catches[i][j - 1], a);
      min_time_catches[i][j] = t;
      time_catch_j += t;
    }
    time_catches[j] = time_catch_j;
  }

  // calculate answer
  long ans = INF;
  for (int j = 0; j < N; j++) {
    ans = min(ans, time_catches[j] + x * j);
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 31488
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    lis=LI()
    S=0
    sm1=0
    for i in range(n):
        S=(S+lis[i])%mod
    S=((S%mod)**2)%mod
    for i in range(n):
        sm1=sm1+((lis[i]%mod)**2)%mod
    ans=(((S-sm1)%mod)*pow(2,mod-2,mod))%mod
    
    
    print(ans)
            
        
if __name__=="__main__":
    main()


Measured memory_bytes: 92316
A, B, C = map(int, input().split())
if A == B == C and A % 2 == 0 :
  print(-1)
else :
  ret = 0
  while A % 2 == 0 and B % 2 == 0 and C % 2 == 0 :
    A, B, C = B // 2 + C // 2, C // 2 + A // 2, A // 2 + B // 2
    ret += 1

  print(ret)


Measured memory_bytes: 38384
S = input()
length = len(S)
p1 = [0 if i % 2 == 0 else 1 for i in range(length)]
p2 = [0 if i % 2 != 0 else 1 for i in range(length)]

p1dif = 0
for i in range(length):
  if int(p1[i]) != int(S[i]):
    p1dif += 1

p2dif = 0
for i in range(length):
  if int(p2[i]) != int(S[i]):
    p2dif += 1

print(min(p1dif, p2dif))

Measured memory_bytes: 4852
import java.io.*;

class Main {
	public static void main (String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while (str != null) {
			StringBuffer strBuffer = new StringBuffer(str);
			str = strBuffer.reverse().toString();
			System.out.println(str);
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 24000
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;

    return 0;
}

Measured memory_bytes: 256
/*
sonu_verma1
*/
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
#define FOR(i, st, en, ch) for(register int i = (st); i <= (en) ; i += (ch))
#define RFOR(i, st, en, ch) for(register int i = (st); i >= (en) ; i -= (ch))
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
/*********************************************************************/
void test(int r)
{
	string s,t;
	cin>>s>>t;
	t.pop_back();
	if(s==t)
		cout<<"Yes";
	else
		cout<<"No";

}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
 
int main(){
  string s;
  cin >> s;
  ll n = s.size();
  vector<ll> a(n, 1);
  rep(i, 0, n - 1) if(s[i] == 'R' && s[i + 1] == 'R') {
    a[i + 2] += a[i];
    a[i] = 0;
  }
  rrep(i, 1, n) if(s[i] == 'L' && s[i - 1] == 'L') {
    a[i - 2] += a[i];
    a[i] = 0;
  }
  rep(i, 0, n) cout << a[i] << " \n"[i + 1 == n];
}

Measured memory_bytes: 1408
#coding:utf-8
#1_2_D
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v

def shellSort(A, n):
    G = [1]
    while True:
        g = 3*G[0] + 1
        if g > n:
            break
        G.insert(0, g)
    m = len(G)
    for i in range(m):
        insertionSort(A, n, G[i])
    return [m, G]

n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
m, G = shellSort(A, n)
print(m)
print(" ".join(map(str, G)))
print(cnt)
print("\n".join(map(str, A)))

Measured memory_bytes: 127892
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B,C,D=0,E=0,F=INF,N,M;
    string S,T;
    cin >> S >> T;
    A=S.size();
    B=T.size();
    vector<char>P(A+B);
    rep(i,0,A)P[2*i]=S[i];
    rep(i,0,B)P[2*i+1]=T[i];
    rep(i,0,A+B)NeOut(P[i]);
    cout << endl;  
}

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

int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(c-a) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  if (abs(b-a) <= d and abs(b-c) <= d) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 *  author: Haunted_Cpp
**/
 
#include <bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
 
template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
 
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
 
#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  string w;
  cin >> w;
  int mx = 0;
  int cnt = 0;
  
  for (int i = 0; i < w.size(); i++) {
    if (i && w[i] == 'R' && w[i] == w[i - 1]) {
      ++cnt;
    } else {
      mx = max(mx, cnt);
      cnt = (w[i] == 'R');
    }
  }
  mx = max(mx, cnt); 
  cout << mx << '\n';
  return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a == b && b == c && c == a){
            System.out.println("No");
        }else if(a != b && b != c && c != a){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 23252
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main() {
	int N;
	cin >> N;

	REP(i, N) {
		string s;
		map<int, char> table;
		int mi = 0, ma = 0, pos = 0;

		cin >> s;

		REP(j, s.size()) {
			if(s[j] == '-') {

			} else if(s[j] == '<') {
				pos--;
				mi = min(mi, pos);
			} else if(s[j] == '>') {
				pos++;
				ma = max(ma, pos);
			} else {
				table.insert(map<int, char>::value_type(pos, s[j]));
			}
		}

		FOR(j, mi, ma) {
			cout << table[j];
		}
		cout << endl;
	}
	
	return 0;
}

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

int main(){
  int n;
  cin>> n;
  
  int ans=0;
  int high,low;
  for (int i=0; i<5; i+=2){
    high=pow(10,i+1);
    low=pow(10,i);
    if (high<=n) ans+=9*low;
    else if (low<=n) {
      ans+=n-low+1;
      break;
    }
    else break;
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())
X = list(map(int, input().split()))

# Mで割った余りに着目する
# 余りがiの整数は余りがM-iの整数とペアになれる
# 余りがiである整数のコレクションをA, M-iである整数のコレクションをBとする
# |A| > |B| ならば Aの要素同士で |A| = |B| または |B| + 1 となるまでペアを作る
# |A| < |B| ならば Bの要素同士で |B| = |A| または |A| + 1 となるまでペアを作る
# その後、A, B間でペアを作ればよい
Y = [defaultdict(int) for i in range(M)]
for x in X:
    Y[x % M][x] += 1
S = [sum(s for s in y.values()) for y in Y]
ans = S[0] // 2 + sum(
    S[M - i] + min(
        sum(v // 2 for v in Y[i].values()),
        (S[i] - S[M - i]) // 2
    ) if S[i] >= S[M - i] else
    S[i] + min(
        sum(v // 2 for v in Y[M - i].values()),
        (S[M - i] - S[i]) // 2
    )
    for i in range(1, (M + 1) // 2)
) + (
    S[M // 2] // 2 if M % 2 == 0 else
    0
)

print(ans)


Measured memory_bytes: 39388
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

template<class T>
T GCD(T a, T b) {
	T c = max(a, b);
	T d = min(a, b);
	while (c%d != 0) {
		T t = d;
		d = c % d;
		c = t;
	}
	return d;
}

int main() {
	int n, x;
	cin >> n >> x;
	int a, b, t;
	rep(i, 0, n) {
		if (i == 0) {
			cin >> a;
			a = abs(a - x);
			t = a;
			continue;
		}
		if (i == 1) {
			cin >> b;
			b = abs(b - x);
			t = GCD(a, b);
			continue;
		}
		int c;
		cin >> c;
		c = abs(c - x);
		t = GCD(t, c);
	}
	cout << t << endl;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(){
  int N;
  int A[101];
  double sum=0;
  scanf("%d",&N);
  for(int i=0; i<N; i++){
    scanf("%d",&A[i]);
    sum+=1/(double)A[i];
  }
  printf("%lf\n",1/sum);
}

Measured memory_bytes: 128
n = int(input())
a_s = [int(item) for item in input().split()]
b_s = [int(item) for item in input().split()]
num = sum(b_s) - sum(a_s)
val1 = 0
val2 = 0
for a, b in zip(a_s, b_s):
    if b > a:
        val1 += (b - a + 1) // 2
    else:
        val2 += (a-b) 
if val1 <= num and val2 <= num:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4600
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    vec primes;
    Loop(i, 1, 101)
    {
        if (primejudge(i))
            primes.push_back(i);
    }
    ll psiz = primes.size();
    vec primecount(psiz);
    Loop(i, 1, N + 1)
    {
        ll now = i;
        loop(j, psiz)
        {
            if (now % primes[j] == 0)
            {
                while (now % primes[j] == 0)
                {
                    primecount[j]++;
                    now /= primes[j];
                }
            }
        }
    }
    ll ans = 0;
    ll n74 = 0, n24 = 0, n14 = 0, n4 = 0, n2 = 0;
    loop(i, psiz)
    {
        if (primecount[i] >= 74)
            n74++;
        if (primecount[i] >= 24)
            n24++;
        if (primecount[i] >= 14)
            n14++;
        if (primecount[i] >= 4)
            n4++;
        if (primecount[i] >= 2)
            n2++;
    }
    ans += n74;
    ans += n24 * (n2 - 1);
    ans += n14 * (n4 - 1);
    ans += n4 * (n4 - 1) * (n2 - 2) / 2;
    putout(ans);
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a>0) cout<<"Positive"<<endl;
  else if(b<0){
    if((b-a)%2==1) cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
  }else cout<<"Zero"<<endl;
  return 0;
}

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

int main()
{
    int N;
    bool prime[333333];

    cin >> N;

    fill_n(prime, 333333, true); 
    
    for ( int i = 2; i < 3333; i++ ) {
        if ( prime[i] ) {
            for ( int j = i * i; j < 333333; j += i ) { 
                prime[j] = false;
            }
        }
    }
    
    int k = 11;
    for ( int i = 0; i < N; i++ ) {
        while ( k % 5 != 1 || !prime[k] ) {
            k++;
        }
        if ( i != 0 ) {
            cout << " ";
        }
        cout << k;
        k++;
    }
    cout << endl;
    return (0);
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
void swap(int *x,int *y){int tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
//next_permutation
//from https://qiita.com/Nikkely/items/0ddca51b3c0e60afbaab
int next_permutation(int *a,int n){
    int x=-1,y=-1;
    for(int i=n-2;i>=0;i--)if(a[i]<a[i+1]){x=i;break;}
    if(x==-1)return 1;
    for(int i=n-1;x!=-1&&i>=0;i--)if(a[x]<a[i]){y=i;break;}
    if(y==-1)return 1;
    swap(&a[x],&a[y]);
    qsort(&a[x+1],n-(x+1),sizeof(int),asc_cmp);
    return 0;
}

int factional(int x){
    int fact=1;
    for(int i=x;i>1;i--)fact*=i;
    return fact;
}

int main(){
    int n;scanf("%d",&n);
    int x[n],y[n];for(int i=0;i<n;i++)scanf("%d %d",&x[i],&y[i]);

    int a[n];for(int i=0;i<n;i++)a[i]=i;
    double sum=0,tmp,x_sub,y_sub;
    do{
        tmp=0;
        for(int i=1;i<n;i++){
            x_sub=x[a[i]]-x[a[i-1]];
            y_sub=y[a[i]]-y[a[i-1]];
            tmp+=sqrt(pow(x_sub,2.0)+pow(y_sub,2.0));
        }
        //printf("%lf\n",tmp);
        sum+=tmp;
    }while(!next_permutation(a,n));

    printf("%.12lf\n",sum/factional(n));
    return 0;
}

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

using namespace std;
#define MX 1e5+1
#define pb push_back
#define prr pair<int,int> 
#define int long long
#define fir first
#define sec second


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;


       
}










Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;



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

	cin >> N >> M;
	vector<int>used(N + 1,-1);
	vector<int>v(M);
	for (auto &i : v)cin >> i;
	vector<int>ans;
	for (int i = M - 1; i >= 0; i--) {
		if (used[v[i]] == -1) {
			ans.push_back(v[i]);
			used[v[i]] = i;
		}
	}
	for (int i = 1; i <=N; i++) {
		if (used[i] == -1)ans.push_back(i);
	}
	for (auto i : ans)cout << i << endl;
}


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

int main()
{
        ll N; cin >> N;
        vector<ll> J(5, 0);
        for (int i = 0; i < N; ++i) {
                string s;
                cin >> s;
                if (s[0] == 'M') J[0]++;
                else if (s[0] == 'A') J[1]++;
                else if (s[0] == 'R') J[2]++;
                else if (s[0] == 'C') J[3]++;
                else if (s[0] == 'H') J[4]++;
        }

        ll ans = 0;
        for (int i = 0; i < 3; ++i) {
                for (int j = i+1; j < 4; ++j) {
                        for (int k = j+1; k < 5; ++k) {
                                ans += (J[k] * J[j] * J[i]);
                        }
                }
        }
        cout << ans << endl;



}


Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

X = I()

a = 10**20
q = 0.01
cnt = 0
k = 100
for i in range(1, a):
    k += k * q
    k = floor(k)
    if k >= X:
        print(i)
        exit()

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

//最後の何文字が連続かを返す関数
int first(string s){
  int i = 0;
  while(i < s.size() && s[i] == s[i+1] ){
    i++;
  }
  return i + 1;
}

//最後の何文字が連続かを返す関数
int last(string s){
  int i = s.size() -1;
  int res = 0;
  while(i > 0 && s[i] == s[i-1] ){
    res++;
    i--;
  }
  return res + 1;
}

//最初と最後の文字以外で何文字変化させればいいかを返す関数
int change_num(string s,int first, int last){
  int res = 0; //間で何文字変化させるか
  int cnt = 1; //連続した文字の数を保持
  for(int i = first; i < s.size() - last; i++){
   
    if(s[i] != s[i+1]){
      res = res + cnt / 2; 
      cnt = 1; //カウンターをリセット
      continue;
    }
    cnt ++;
  }
    return res;
}

int main(){
  //入力受け取り
  string s;
  long long k;
  cin >> s >> k;
  int n = s.size();
  
  //文字列が単一文字で構成されているとき
  if(first(s) == n){
    cout << k*n / 2 << endl;
    return 0;
  }
  
  //cout << change_num(s, first(s), last(s)) << endl;
  //cout << first(s) << " " << last(s) << endl;
  
  long long ans = change_num(s, first(s), last(s)) * k;
  
  
  //最初の文字と最後の文字が同じとき
  if(s[0] == s[n-1]){
    int first_last = first(s) + last(s);
    ans = ans + (first_last / 2) * (k -1) + first(s) / 2 + last(s) / 2 ;
    cout << ans << endl;
  }
  //最初の文字と最後の文字が違うとき
  else{
    ans = ans + (first(s) / 2 + last(s) / 2) * k; 
    cout << ans << endl;
  }
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(long int i = a;i<b;i++)
typedef vector<int> vi;

int inf = numeric_limits<int>::max();

int main(){
    long int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    FL(i,0,n){
        cin>>arr[i];
    }
    int cost[n];
    FL(i,0,n){
        cost[i] = inf;
    }
    cost[0] = 0;
    
    cost[1] = abs(arr[1]-arr[0]);
    for(long int i = 2;i<n;i++){
        long int j = i-1;
        while ((i-j<=k)&&(j>=0)){
            cost[i] = min(cost[i],cost[j]+abs(arr[i]-arr[j]));
            j--;
        }
        
    }
    cout<<cost[n-1];
    
    
}






Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 998244353;
const int N = 1e6+205;
ll dp[N];
ll rng[20][2];
void solve(){
	dp[1] = 1;
	int n,k; 
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>rng[i][0]>>rng[i][1];
	}
	ll ans = -1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
			int st = max(0ll,i-rng[j][1]-1);
			int en = max(0ll,i-rng[j][0]);
			ll add = ((dp[en]-dp[st])%mod+mod)%mod;;
			dp[i] = (dp[i]+add)%mod;
		}
		if(i==n)ans = dp[n];
		dp[i] = (dp[i]+dp[i-1])%mod;
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 5172
a,b,c,x,y=map(int,input().split())
A=a*x
B=b*y
ABa=c*x*2
ABab=b*(y-x) if y>x else 0
ABb=c*y*2
ABba=a*(x-y) if x>y else 0
print(min(A+B,ABa+ABab,ABb+ABba))

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

int main() {
	int a,cnt=0;
	cin >> a;
	if(a/100==1){
		cnt++;
	}
	if(a/10==1 || a/10==11){
		cnt++;
	}
	if(a%10==1){
	cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i++)cin >> d[i];
    sort(d.begin(),d.end());
    int k = n/2;
    int min = d[k-1];
    int max = d[k];
    cout << max - min << endl;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	// bit全探索する
	abcd := split(next())
	for i := 0; i < (1 << uint(3)); i++ {
		tmp := make([]string, 3)
		v, _ := strconv.Atoi(abcd[0])
		sum := v
		for j := 0; j < 3; j++ {
			next_v, _ := strconv.Atoi(abcd[j+1])
			if 1&(i>>uint64(j)) == 1 {
				tmp[j] = "+"
				sum += next_v
			} else {
				tmp[j] = "-"
				sum -= next_v
			}
		}
		if sum == 7 {
			ans := abcd[0]
			for i := 0; i < 3; i++ {
				ans += tmp[i] + abcd[i+1]
			}
			ans += "=7"
			fmt.Fprintln(out, ans)
			return
		}
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int a,b,c,x,y,z;

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

  if(a > b)
    {
      x = a;
      a = b;
      b = x;
    }
  if(b > c)
    {
      y = b;
      b = c;
      c = y;
    }
  if(a > b)
    {
      z = a;
      a = b;
      b = z;
    }

  printf("%d %d %d\n",a,b,c);

  return 0;
}

Measured memory_bytes: 1728
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

LL a[111111];

int main() {
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%lld", &a[i+1]);
	LL sum = 0;
	REP(i, n+1) sum += abs(a[i + 1] - a[i]);
	REP(i, n) {
		LL x = a[i];
		LL y = a[i + 1];
		LL z = a[i + 2];
		if (x > z) {
			x = -x;
			y = -y;
			z = -z;
		}
		if (x < y) {
			if (y < z)cout << sum << endl;
			else cout << sum + 2 * (z-y) << endl;
		}
		else {
			cout << sum + 2 * (y - x) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
int ask(string s){
	cout << "? " << s << '\n';
	cout << flush;
	int x;
	cin >> x;
	return x;
}
 
void answer(string s){
	cerr << s << '\n';
	cout << "! " << s << '\n';
	cout << flush;
	exit(0);
}
int len;
 
bool contains(string s){
	if(s.size() > 128) return false;
	int r = ask(s);
	if(r == len - (int)s.size()) return true;
	assert(r > len - (int)s.size());
	return false;
}
 
int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	string all;
	for(char c = 'a'; c <= 'z'; c++) all += c;
	for(char c = 'A'; c <= 'Z'; c++) all += c;
	for(char c = '0'; c <= '9'; c++) all += c;
	mt19937 mt(48);
	shuffle(all.begin(), all.end(), mt);
	cerr << all << '\n';
	// all = "abc";
	{
		char c = all.front();
		if(ask(string(128, c)) == 128){
			// does not contain
			len = ask(string(1, c));
		} else {
			len = ask(string(1, c)) + 1;
		}
	}
	string cur = "";
	for(char c : all){
		string pref = cur;
		string suff = "";
		int freq = len - ask(string(len, c));
		for(int j = 0; j < freq; j++){
			int s = 0;
			int e = (int)pref.size() + 1;
			while(s + 1 < e){
				int m = (s + e) / 2;
				if(contains(pref.substr(0, m) + string(1, c) + suff)){
					s = m;
				} else {
					e = m;
				}
			}
			suff = string(1, c) + pref.substr(s) + suff;
			pref = pref.substr(0, s);
		}
		cur = pref + suff;
	}
	answer(cur);
}

Measured memory_bytes: 3768
c = [list(map(int, input().split())) for _ in range(3)]
if c[1][1] != c[1][0] - c[0][0] + c[0][1]:
    print('No')
elif c[1][2] != c[1][0] - c[0][0] + c[0][2]:
    print('No')
elif c[2][1] != c[2][0] - c[0][0] + c[0][1]:
    print('No')
elif c[2][2] != c[2][0] - c[0][0] + c[0][2]:
    print('No')
else:
    print('Yes')


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

int main(){
	long long a,b,n;
	cin >> a >> b >> n;
	long long ans;
	long long c;
	if(b-1 >n) c = n;
	else c= b-1;
	ans = a * c / b;
	cout << ans << endl;
	return 0;
}


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

int main() {
  long long a,b,k;
  cin >> a >> b >> k;
  
  if(a >= k){
    cout << a - k << " " << b;
  }else if(a + b >= k){
    cout << 0 << " " << a + b -k;
  }else{
    cout << 0 << " " << 0;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 105

struct Info{
	Info(char arg_ch){
		ch = arg_ch;
	}
	bool operator<(const struct Info &arg) const{
		return ch > arg.ch;
	}

	char ch;
};

int len_A,len_B;
char A[NUM],input_B[NUM];
vector<Info> B;

int main(){

	scanf("%s",A);
	scanf("%s",input_B);

	for(len_A = 0; A[len_A] != '\0'; len_A++);

	for(len_B = 0; input_B[len_B] != '\0'; len_B++){

		B.push_back(Info(input_B[len_B]));
	}

	sort(A,A+len_A); //辞書順最小にする
	sort(B.begin(),B.end()); //辞書順最大にする

	for(int i = 0; i < min(len_A,len_B);i++){

		if(A[i] != B[i].ch){

			if(A[i] < B[i].ch){

				printf("Yes\n");
			}else{

				printf("No\n");
			}
			return 0;
		}
	}

	if(len_A >= len_B){

		printf("No\n");
	}else{

		printf("Yes\n");
	}

	return 0;
}


Measured memory_bytes: 256
// D - Div Game
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 素数と個数を求める
vector<pair<ll,ll>> factorize(ll n){
  vector<pair<ll,ll>> res;
  for(ll i=2L; i*i<=n; ++i){
    if (n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0){
      n /= i;
      res.back().second++;
    }
  }
  if(n != 1) res.emplace_back(n,1L);
  return res;
}

int main(){
	ll N; cin>>N;
	vector<pair<ll,ll>> P = factorize(N);
	ll ans = 0;
	for(auto x:P)
		for(ll p=x.first, c=x.second, pi=p, i=1; i<=c || pi<=N; i++, pi*=p){
			if(N%pi) continue;
			N /= pi;
			ans++;
		}
	cout<< ans <<endl;
}


Measured memory_bytes: 3612