akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N -1], dneg[2 * N -1];
bool X[N][N];

void recursive(int i){
  int j;
  if(i == N){
      printBoard();
      return;
    }
  for(j=0;j<N;j++){
      if(NOT_FREE==col[j] ||
      NOT_FREE==dpos[i+j] ||
         NOT_FREE==dneg[i - j + N - 1]) {
          continue;
        }
      row[i]=j;
      col[j]=dpos[i + j]=dneg[i - j + N - 1]=NOT_FREE;
      recursive(i+1);
      row[i]=col[j]=dpos[i + j]=dneg[i - j + N - 1]=FREE;
    }
}

void initialize(){
  int i;
  for(i=0;i<N;i++){
      row[i]=FREE;
      col[i]=FREE;
    }
  for(i=0;i<2*N-1;i++){
      dpos[i]=FREE;
      dneg[i]=FREE;
    }
}

void printBoard()
{
  int i, j;
  for(i=0;i<N;i++){
      for(j=0;j<N;j++){
          if(X[i][j]){
              if(row[i]!=j) return;
            }
        }
    }
  for(i=0;i<N;i++){
      for(j=0;j<N;j++){
          if(row[i]==j){
              printf("Q");
            }
          else{
              printf(".");
            }
        }
      printf("\n");
    }
}

int main(){
  int i, j, k, r, c;

  initialize();

  for(i=0;i<N;i++){
      for(j=0;j<N;j++){
          X[i][j]=false;
        }
    }
  scanf("%d",&k);
  for(i=0;i<k;i++){
      scanf("%d %d",&r,&c);
      X[r][c]=true;
    }
  recursive(0);
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323



void solve()
{
       ll d, g, p[15], c[15];
       cin>>d>>g;
       rep(i,0,d) cin>>p[i]>>c[i];
       ll ans=inf;
       for(ll mask = 0; mask < (1 << d); mask++)
       {
              ll s=0, num=0, rest_max = -1;
              for(ll i = 0; i < d; i++)
              {
                     if((mask >> i) & 1)
                     {
                            s += 100*(i+1)*p[i] + c[i];
                            num += p[i];
                     }
                     else rest_max = i;
              }
              if(s < g)
              {
                     ll s1 = 100*(rest_max + 1);
                     ll need = (g - s + s1 -1) / s1;
                     if(need >= p[rest_max]) continue;
                     num += need;
              }
              ans = min(ans, num);
       }
       cout << ans << endl;
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string s;
bool used[26];
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++) used[s[i]-'a'] = 1;
	vector<string>cand;
	for(int i=0;i<26;i++){
		if(!used[i]){
			string t = s;
			t.pb('a'+i);
			cand.pb(t);
		}
	}
	for(int i=0;i<s.size();i++){
		for(int j=0;j<26;j++){
		    string t="";
			for(int k=0;k<i;k++){
				if(s[k]-'a'==j) goto nxt;
			}
			if(s[i]-'a'>=j) goto nxt;
			
			for(int j=0;j<i;j++) t.pb(s[j]);
			t.pb('a'+j);
			cand.pb(t);
			break; nxt:;
		}
	}
	if(cand.empty()){
		puts("-1"); return 0;
	}
	SORT(cand);
	cout<<cand[0]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]==s[1]&&s[2]==s[3]&&s[1]==s[2]){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0,j;i<s.size()-1;++i){
		if(s[i]=='@')
			continue;
		bool flag=false;
		for(j=i+1;j<s.size()&&!flag;++j)
			if(s[i]==s[j])
				flag=true;
		if(!flag){
			cout<<"No"<<endl;
			return 0;
		}
		s[j-1]='@';
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int t1, t2;
    ll a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    a1 *= t1, a2 *= t2, b1 *= t1, b2 *= t2;
    a2 += a1, b2 += b1;
    if(a2 == b2){
        cout << "infinity\n";
        return 0;
    }
    if(a2 < b2){
        swap(a1, b1);
        swap(a2, b2);
    }
    ll d = a2 - b2, c = b1 - a1;
    ll ans = 0;
    if(c > 0){
        ans = (c - 1) / d + 1;
        ans *= 2;
        --ans;
        if(c % d == 0)  ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
a = [int(input()) for i in range(N)]
cnt = 1
jumpto = a[0]
if jumpto==2:
  print(cnt)
  exit()
for i in range(N):
  jumpto = a[jumpto-1]
  cnt += 1
  if jumpto ==2:
    print(cnt)
    exit()
print(-1)


Measured memory_bytes: 80172
N, M = map(int, input().split())
A = list(input().split())
A = list(map(int, A))
#A = list(map(int, input().split()))

A.sort(reverse=True)
#print(A)
#print(A[M-1], sum(A), 4*M, sum(A)/(4*M))

if A[M-1] >= sum(A)/(4*M):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
//In The Name Of GOD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 8*1001+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);

bool find_if(const vector<int> &vec,const int &x){
  bool dp[vec.size()+1][4*maxn];
  memset(dp,0,sizeof dp);
  dp[0][2*maxn-1]=true;
  for(int i=0;i<vec.size();i++){
    for(int j=maxn;j<3*maxn-1;j++){
      dp[i+1][j]=max(dp[i][j-vec[i]],dp[i][j+vec[i]]);
    }
  }
  return dp[vec.size()][x+2*maxn-1];
}

int main(){
  IO;
  string s;
  cin>>s;
  int x,y;
  cin >> x >> y;
  int all=0;
  bool f=false;
  vector<int> ans[2];
  for(int i=0;i<s.size();i++){
    if(s[i]=='T'){
      ans[f].pb(all);
      all = 0;
      f = !f;
    }else{
      all++;
    }
  }
  ans[f].pb(all);
  vector<int> ans0(ans[0].begin()+1,ans[0].end());
  vector<int> ans1=ans[1];
  if(find_if(ans0,x-ans[0][0])&&find_if(ans1,y)){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  // for(int i=0;i<ans[0].size();i++)cout<<ans[0][i]<<' ';
  // cout<<endl;
  // for(int i=0;i<ans[1].size();i++)cout<<ans[1][i]<<' ';
  // cout<<endl;
}

Measured memory_bytes: 124544
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION

//SOLVE
void solve(void)
{
  string str;
  cin>>str;
  int COUNT = 0;
  for (int i = 0; i < str.size(); i++)
  {
    if(str[i] == '0') COUNT++;
    else COUNT--;
    // DEBUG(COUNT);
  }
  cout<<str.size() - abs(COUNT)<<endl;
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 512
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashSet<Integer> set = new HashSet<Integer>();
	set.add(sc.nextInt());
	set.add(sc.nextInt());
	set.add(sc.nextInt());
	System.out.println(set.size());
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			250
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	ll h,a,ans;
	cin>>h>>a;
	if(a >= h)
	{
		ans = 1;
	}
	else
	{
		ans = h/a;
		if(h%a)
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1 << 30;
// const ll INF = 1LL << 62;
// --------------------------------------------------------


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

    int N; cin >> N;
    string S; cin >> S;

    int ans = 0;
    for (char c1 = '0'; c1 <= '9'; c1++) {
        for (char c2 = '0'; c2 <= '9'; c2++) {
            set<char> T;
            int d = 1;
            for (auto s : S) {
                if (d == 1) {
                    if (s == c1) d++;
                } else if (d == 2) {
                    if (s == c2) d++;
                } else {
                    T.insert(s);
                }
            }
            ans += SZ(T);
        }
    }
    cout << ans << '\n';

    return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int Max_A = 1e6+5;
const int INF = 1e8;

int divisor[Max_A];

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	rep(i,Max_A) divisor[i]=i;
	for(int i=2; i*i<Max_A; i++){
		if(divisor[i]==i){
			for(int j=2; j*i<Max_A; j++) divisor[j*i]=i;
		}
	}
	map<int,int> mp;
	rep(i,N){
		int a=A[i];
		vector<int> p;
		while(a!=1){
			int s=p.size();
			if(s==0) p.emplace_back(divisor[a]);
			else if(divisor[a]!=p[s-1]){
				p.emplace_back(divisor[a]);
			}
			a/=divisor[a];
		}
		rep(j,p.size()) mp[p[j]]++;
	}
	bool pairwise=true, setwise=true;
	for(auto itr:mp){
		int num=itr.second;
		if(num>=2) pairwise=false;
		if(num==N) setwise=false;
	}
	rep(i,N) if(A[i]==1) setwise=true;
	if(pairwise) cout << "pairwise coprime" << endl;
	else if(setwise) cout << "setwise coprime" << endl;
	else cout << "not coprime" << endl;

	return 0;
}

Measured memory_bytes: 14624
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  map<int, int> m;
  int n, input;
  bool flag = false;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> input;
    if(m.count(input) == 0){
      m[input] = 1;
    }else{
      flag = true;
    }
  }
  if(flag == false) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 10752
from collections import Counter

N = int(input())
A = Counter(list(map(int, input().split())))

ans = [0, 0]
for k in sorted(A.keys(), reverse=True):
    if A[k] >= 2:
        ans.append(k)
    if A[k] >= 4:
        ans.append(k)
ans = sorted(ans)
print(ans[-1]*ans[-2])


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

using namespace std;
using ll = long long;


int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = 0;
    ans += (n / (a + b))* a;
    n -= (a + b) * (n / (a + b));
    ans += min(n, a);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

vector<int> V;

ll solve(const int N, const int K) {
    const int R = min(N, K);
    ll ans = 0LL;

    for (int i = 0; i <= R; i++) {
        for (int j = 0; j <= R - i; j++) {
            for (int k = 0; k <= K - (i + j); k++) {
                vector<int> jewels;
                for (int l = 0; l < i; l++) {
                    jewels.push_back(V[l]);
                }
                for (int r = N - 1; r >= N - j; r--) {
                    jewels.push_back(V[r]);
                }
                sort(jewels.begin(), jewels.end());
                reverse(jewels.begin(), jewels.end());
                int size = (int) jewels.size();
                for (int x = 0; x < min(size, k); x++) {
                    if (jewels.back() > 0) {
                        break;
                    }
                    jewels.pop_back();
                }

                ll acc = 0LL;
                for (int x = 0; x < (int) jewels.size(); x++) {
                    acc += jewels[x];
                }
                // printf("i: %d, j: %d, k: %d, acc: %lld\n", i, j, k, acc);
                chmax(ans, acc);
            }
        }
    }

    return ans;
}

int main(void) {
    int N, K;
    cin >> N >> K;

    V.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }

    cout << solve(N, K) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector> 
#include<algorithm>
#include<string>
#include<tuple>
using namespace std;
int main() {
  string s;
  cin >> s;
  if(s=="SUN"){
    cout << 7 << endl;
  }
  if(s=="MON"){
    cout << 6 << endl;
  }
  if(s=="TUE"){
    cout << 5 << endl;
  }
  if(s=="WED"){
    cout << 4 << endl;
  }
  if(s=="THU"){
     cout << 3 << endl;
  }
  if(s=="FRI"){
    cout << 2 << endl;
  }
  if(s=="SAT"){
    cout << 1 << endl;
  }
}

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

int n, k;
map<int,int>cnt;
const int N = 1e5 + 10;
int x[N];

int main() {
	scanf("%d %d", &n, &k);
	
	int s = 0;
	
	for(int i = 0 ; i < n ; i++){
		scanf("%d", &x[i]);
		
		x[i] %= k;
		
		if(i){
			x[i] += x[i - 1];
			x[i] %= k;
		}
		
		cnt[x[i]]++;
	}	
	
	long long tot = 0LL;
	int f = 0;
	
	for(int i = 0 ; i < n ; i++){
		tot += cnt[f];
		cnt[x[i]]--;
		f = x[i];
	}
	
	printf("%lld\n", tot);
	
	return 0;
}

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



int main(){
  int n;
  cin >>n;
  int a[n],b[n];
  rep(i,n){
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  rep(i,n){
    if(a[i]>=b[n/2]){cout << b[n/2-1] << endl;}else{cout << b[n/2] << endl;}
  }
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <ctime>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<ll> vl;
typedef vector< vector<ll> > vvl;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forv(i, v) forn(i, v.size())
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back

int main() {
#ifdef NEREVAR_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n; cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    vi as = a;
    sort(all(as));
    int cnt = 0;
    for (int i = 0; i < n; i += 2) {
        int p = int(lower_bound(all(as), a[i]) - as.begin());
        if (p % 2) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
p = na()

ans = 0
m = 1 << 60
for i in range(n):
    m = min(m, p[i])
    if m >= p[i]:
        ans += 1
print(ans)

Measured memory_bytes: 25696
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    string s;
    cin >> s;
    if(s.size() % 2 == 0) {
        if(s[0] == s[s.size() - 1])
            cout << "First" << endl;
        else
            cout << "Second" << endl;
        ;
    } else {
        if(s[0] == s[s.size() - 1])
            cout << "Second" << endl;
        else
            cout << "First" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
S = list(input())


for i in range (len(S)):
    if S[i] == "A":
        S[i] = "1"
    elif S[i] == "G":
        S[i] = "1"
    elif S[i] == "C":
        S[i] = "1"
    elif S[i] == "T":
        S[i] = "1"

S2 = "".join(S)

for i in range (len(S)+1)[::-1]:
    A = "".join("1" * i)
    if A in S2:
        print(i)
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
int main(){	
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    int n , k ;
	    cin >> n >> k;
	    if(n * 500 >= k)
	    	cout << "Yes" << endl;
	    else
	    	cout << "No" << endl;
		
	
 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
c = 0

for i in range(n):
  if a[i] > 0:
    d = min(a[i], b[i])
    c += d
    a[i] -= d
    b[i] -= d

  if b[i] > 0:
    d = min(a[i+1], b[i])
    c += d
    a[i+1] -= d
    b[i] -= d

print(c)


Measured memory_bytes: 18624
n, mw = map(int, input().split())
goods = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(mw+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(mw+1):
        w, v = goods[i]
        if j >= w:
            dp[i+1][j] = max(dp[i][j], dp[i][j - w] + v)
        else: dp[i+1][j] = dp[i][j]
print(dp[n][mw])

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

int main() {
  string S;
  cin >> S;
  
  int count = 0;
  if ( S.at(0) == 'R') {
    count++;
    if (S.at(1) == 'R') {
      count++;
      if(S.at(2) == 'R') {
        count++;
      }
    }
  }
  else {
    if(S.at(1) == 'R') {
      count++;
      if(S.at(2) == 'R') {
        count++;
      }
    }
    else {
      if(S.at(2) == 'R') {
        count++;
      }
    }
  }
  
  cout << count << endl;
}  

Measured memory_bytes: 3628
N=int(input())
A=[]
for i in range(N):
  A.append(int(input()))

A_sorted = sorted(A,reverse=True)

if N%2:
  a1=2*(sum(A_sorted[:N//2])-sum(A_sorted[N//2:]))+A_sorted[N//2]+A_sorted[N//2+1]
  a2=2*(sum(A_sorted[:N//2+1])-sum(A_sorted[N//2+1:]))-A_sorted[N//2]-A_sorted[N//2-1]
  print(max(a1,a2))
else:
  print(2*(sum(A_sorted[:N//2])-sum(A_sorted[N//2:]))-A_sorted[N//2-1]+A_sorted[N//2])

Measured memory_bytes: 8284
n;main(r,i){
scanf("%d",&n);r=n;
for(i=2;i*i<=n;i++)if(n%i==0)for(r=1LL*r*(i-1)/i;n%i==0;n/=i);
if(--n)r=1LL*r*n/(n+1);
n=!printf("%d\n",r);
}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()
{
	int N;
	int x = 0;
	int max_x = -10000;
	string S;
	cin >> N;
	cin	>> S;

	for (int i = 0; i < N; ++i) {
		if (S[i] == 'I') {
			x = x + 1;
		}
		else {
			x = x - 1;
		}

		if (max_x < x) {
			max_x = x;
		}

	}
	
	if (max_x < 0) max_x = 0;

	cout << max_x << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	double sum = 0;
	for (int i = 0; i < N; i++) {
		double A;
		cin >> A;
		sum += 1 / A;
	}
	printf("%.15lf\n", 1 / sum);
}

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

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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() {

	int N,ans=0;
	cin >> N;
	ll a[N];

	for(int i = 0; i < N; i++) {
		cin >> a[i];
		while(a[i] % 2 == 0) {
			a[i] /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;


class Main {

	public static void main(String[] args) {   

		Scanner scanner = new Scanner(System.in);
		
		while(true){
		int n=scanner.nextInt();
		if(n == 0){
			break;
		}
		double sum =0;
		double[] s; // 
		s = new double[n];
		 double a=0;
		
		for(int i=0;i<n;i++){
		double S  = scanner.nextDouble();
		s[i]=S;
		sum=sum+S;
		}
		
		for(int i=0;i<n;i++){
			
			a =a+Math.pow(s[i]-(sum/n),2);
			
		}
		
		System.out.println(Math.sqrt(a/n));
		
		}
		scanner.close();
	}
}



Measured memory_bytes: 39972
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int D,N;
cin >> D >> N;
int S = 1; for (int i = 0; i < D; i++) S *= 100;
if(N == 100) N = 101;
cout << N * S << endl;
return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a int
	str := ""
	fmt.Scan(&a)

	for {
		b := (a - 1) % 26
		a = (a - 1) / 26
		str = fmt.Sprintf("%c%s", 'a'+b, str)
		if a == 0 {
			break
		}
	}
	fmt.Println(str)
}


Measured memory_bytes: 1832
import math
def calc_area_and_circumference(r):
    pi = math.pi
    s = pi * r **2
    l = 2 * pi * r

    print("{0:0.5f} {1:0.5f}".format(s, l))

if __name__ == "__main__":
    param = input()
    r = float(param)
    calc_area_and_circumference(r)


Measured memory_bytes: 5652
#include<stdio.h>
int main()
{
    int p,q,r,maxx=0;
    scanf("%d%d%d",&p,&q,&r);
    if(p>maxx)maxx=p;
    if(q>maxx)maxx=q;
    if(r>maxx)maxx=r;
    printf("%d\n",p+q+r-maxx);
}


Measured memory_bytes: 128
from operator import itemgetter
n, m = map(int, input().split())
ab = sorted([list(map(int, input().split()))
             for i in range(m)], key=itemgetter(1))

removed = -1

ans = 0

for a, b in ab:
    if a > removed:
        removed = b - 1
        ans += 1
print(ans)


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

int main()
{
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    int turn = 0;
    string ans;

    while(1)
    {
        if (s[turn].empty()) {
            ans = turn + 'A';
            break;
        }
        int tmp = s[turn][0] -'a';
        s[turn].erase(0, 1);
        turn = tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N,X,T;	cin>>N>>X>>T;
	int ans=N/X;
	if(N%X) ans++;
	ans*=T;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int field[110][110];

int main()
{
	int h, w, n;
	cin >> h >> w >> n;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int j = 0,num = 1,k=0,add = 1;
	for (int i = 0; i < h; i++) {
		while (1) {
			field[i][j] = num;
			a[k]--;
			if (a[k] <= 0) {
				k++;
				num++;
			}
			j += add;
			if (j >= w || j < 0) {
				if(j >= w)j = w - 1;
				else j = 0;
				add *= -1;
				break;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << field[i][j];
			if (j != w - 1)cout << " ";
		}
		cout << endl;
	}
	return	0; 
}


Measured memory_bytes: 384
pos = 0
postorder = []
def reconstruction(l, r):
    global pos
    global postorder
    if l >= r:
        return
    # print(pos)
    c = preorder[pos]
    m = inorder.index(c)
    pos += 1
   
    # 左側を復元
    reconstruction(l, m)
    # 右側を復元
    reconstruction(m + 1, r)
    postorder.append(c)

n = int(input())
preorder = list(map(int, input().split()))
inorder = list(map(int, input().split()))

reconstruction(0, n)
print(" ".join(map(str, postorder)))


Measured memory_bytes: 5600
require 'set'; require 'prime'
INF=Float::INFINITY
n,k = gets.chomp.split.map(&:to_i)
h = gets.chomp.split.map(&:to_i)

h.sort!
h=h.slice(0,n-k)

if h && !h.empty?
  puts h.inject(:+)
else
  puts 0
end


Measured memory_bytes: 20160
#include<stdio.h>
int main(void){
  int i,n=0;
  char s[17],t[17]={"CODEFESTIVAL2016"};
  scanf("%s",s);
  for(i=0;i<17;i++)if(s[i]!=t[i])n++;
  printf("%d",n);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool vis[10000005]={0};
int main()
{
    ll n,ans=0,end;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        end=n/i;
        ans=ans+(i*(end*(end+1)))/2;
    }
    cout<<ans<<'\n';
    return 0;
}

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

#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int cnt;

void insertionSort(int N,int *A,int g){
    REP2(i,g,N){
        int v = A[i];
        int j = i-g;
        while(j >= 0 && A[j]>v){
            A[j+g]= A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}
void shellSort(int N,int *A){
    cnt = 0;
    int r = 1;
    vector<int>G;
    while(r <= N){
        G.push_back(r);
        r *= 2;
    }
    int m = G.size();
    reverse(G.begin(),G.end());
    cout << m << endl;
    REP(i,m) cout << G[i]<<" \n"[i == m-1];
    REP(i,m) insertionSort(N,A,G[i]);
    cout << cnt << endl;
}


int main(){
    int N;
    cin >> N;
    int A[N];
    REP(i,N)cin >> A[i];
    shellSort(N,A);
    REP(k,N)cout << A[k] << endl;
    return 0;
}





Measured memory_bytes: 6992
#include<stdio.h>
#include<stdlib.h>

#define N 3

int pl[N][N],tmp[N][N];
int Dx[4]={0,1,0,-1},Dy[4]={1,0,-1,0};

void em(int *a,int *b){
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(!pl[i][j]){
	*a = j;
	*b=i;
      }
    }
  }
}

void SW(int *a,int *b){
  int tmp;
  tmp =*a;
  *a = *b;
  *b = tmp;
}

int cal(){
  int i,A,S=0;
  for(i=0;i<9;i++){
    A = pl[i/3][i%3];
    if(A){
      A--;
      S += abs(i/3-A/3) + abs(i%3 - A%3);
    }
  }
  return S;
}

int df(int a,int b,int P,int D,const int shin){
  int i,hi,A,B,result;
  hi = cal();
  if(hi==0){
    return D;
  }
  if(D+hi>shin){
    return -1;
  }

  for(i=0;i<4;i++){
    A = a+Dx[i];
    B = b+Dy[i];
    if(~P && i==(P+2)%4) {
      continue;
    }
    if(!(0<=A && A<3 && 0<=B && B<3)){
      continue;
    }
    SW(&pl[b][a],&pl[B][A]);
    result = df(A,B,i,D+1,shin);
    if(~result){
      return result;
    }
    SW(&pl[b][a],&pl[B][A]);
  }
  return -1;
}

int main(){
  int i,j,li,TA,a,b;

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

    em(&a,&b);
    for(li=0;li<100;li++){
      for(i=0;i<3;i++){
	for(j=0;j<3;j++){
	  tmp[i][j]=pl[i][j];
	}
      }
	TA = df(a,b,-1,0,li);
	if(TA!=-1){
	  printf("%d\n",TA);
	  break;
	}

	for(i=0;i<3;i++){
	  for(j=0;j<3;j++){
	    pl[i][j]=tmp[i][j];
	  }
	}

	TA = -1;
	if(li==99){
	      printf("%d\n",TA);
	    }
      }

    return 0;
	    }



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
char t[100005];
int sc[3];
int dp[100005][3];
int win[1005], last[100005];
int main(){
    int n, k, r, s, p;
    scanf("%d%d", &n, &k);
    scanf("%d%d%d", &sc[0], &sc[1], &sc[2]);
    win['r'] = 2;
    win['s'] = 0;
    win['p'] = 1;
    scanf("%s", t+1);
    for(int i=1;i<=n;i++){
        last[i%k] = max(last[i%k], i);
        if(i <= k){
            dp[i][win[t[i]]] = sc[win[t[i]]];
        }
        else{
            for(int l=0;l<3;l++){
                for(int r=0;r<3;r++){
                    if(l == r) continue;
                    if(win[t[i]] == r){
                        dp[i][r] = max(dp[i][r], dp[i-k][l] + sc[r]);
                    }
                    else{
                        dp[i][r] = max(dp[i][r], dp[i-k][l]);
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i=0;i<k;i++){
        if(last[i] == 0) continue;
        ans += max(dp[last[i]][0], max(dp[last[i]][1], dp[last[i]][2]));
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
int main(){
	ll n, k; cin >> n >> k;
	cout << min(n % k, k - n % k);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<functional>
#define len(a) sizeof(a)/sizeof(a[0])
#define sort_asc(a,b) sort(a,a+b)
#define sort_dsc(a,b,dataType) sort(a,a+b,greater<dataType>())
#define IN cin>>
#define OUT cout<<
#define PI 3.14159265358979323846D
#define forr(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define pb push_back
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define vi vector<int>
#define nl endl
typedef long long int ll;
using namespace std;
void f();
int main()
{
    int t=1;
    //IN t;
    for(int i=0;i<t;++i) {f(); if(i!=t-1) OUT endl; else continue;}
    //{OUT "Case "<<i<<":"<<f(); if(i!=t-1) OUT endl; else continue;}
    return 0;
}
void f()
{
    int x;
    IN x;
    x==0 ? OUT '1' : OUT '0';
}


Measured memory_bytes: 3632
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int main(){
    int d,l,r;
    cin >> l >> r >> d;
    cout << r/d-(l-1)/d << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <regex>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    string s;
    cin >> s;
    regex r("^A?KIHA?BA?RA?");
    if (regex_match(s, r)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
print("Yes" if count == N else "No")


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    string g;
    cin >> g;
    if (g == "#") return 0;
    
    int y, m, d;
    cin >> y >> m >> d;
    if (y >= 32 || (y == 31 && m >= 5)) {
      cout << "? " << y - 30 << " " << m << " " << d << '\n';
    }
    else {
      cout << g << " " << y << " " << m << " " << d << '\n';
    }
  }
}


Measured memory_bytes: 3160
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();
        System.out.println((n+x-1)/x * t);
        sc.close();

    }

}


Measured memory_bytes: 35724
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N;
    cin >> N;
    ll minD = LINF;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ll j = N / i;
            minD = min(minD, i - 1 + j - 1);
        }
    }
    cout << minD << '\n';
}


Measured memory_bytes: 256
//
// Created by yamunaku on 2019/11/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

struct edge{
    int to;
    int id;
};

vector<vector<edge>> e;
vi ans;

void dfs(int x, int p, int c){
    int now = 1;
    if(now == c) now++;
    for(auto &nx:e[x]){
        if(nx.to == p) continue;
        ans[nx.id] = now;
        dfs(nx.to, x, now);
        now++;
        if(now == c) now++;
    }
}

int main(){
    // CFS;
    int n;
    cin >> n;
    e = vector<vector<edge>>(n);
    int u, v;
    rep(i, n - 1){
        cin >> u >> v;
        e[u - 1].push_back({v - 1, i});
        e[v - 1].push_back({u - 1, i});
    }
    ans = vi(n - 1);
    dfs(0, 0, -1);
    int k = 0;
    rep(i, n - 1) k = max(k, ans[i]);
    cout << k << endl;
    rep(i, n - 1){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define INF 100000 //枚数無限 制約n<=50,000より十分

int main(){
  int N,M;
  cin>>N>>M;
  vi c(M+1, 0);
  for(int i=1; i<=M; i++)cin>>c[i];

  vi dp(N+1); //j円払う最小枚数
  for(int i=0; i<=N; i++)dp[i] = INF; //もともと無限枚必要
  dp[0] = 0; //0円払うのは0枚

  for(int i=1; i<=M; i++){
    for(int j=1; j<=N; j++){
      //上記の漸化式の otherwise のケースだけ書き換えが発生しうる
      if(j>=c[i])dp[j] = min(dp[j], dp[j-c[i]]+1);
    }
  }
  int ans = dp[N];
  cout<<ans<<endl;
}


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

int main() {
	string x;
	string y = "+", z = "-";
	cin >> x;
	int a = x[0] - '0';
	int b = x[1] - '0';
	int c = x[2] - '0';
	int d = x[3] - '0';
	if (a + b + c + d == 7) {
		cout << a << y << b << y << c << y << d;
	}
	else if (a + b + c - d == 7) {
		cout << a << y << b << y << c << z << d;
	}
	else if (a + b - c + d == 7) {
		cout << a << y << b << z << c << y << d;
	}
	else if (a - b + c + d == 7) {
		cout << a << z << b << y << c << y << d;
	}
	else if (a + b - c - d == 7) {
		cout << a << y << b << z << c << z << d;
	}
	else if (a - b + c - d == 7) {
		cout << a << z << b << y << c << z << d;
	}
	else if (a - b - c + d == 7) {
		cout << a << z << b << z << c << y << d;
	}
	else if (a - b - c - d == 7) {
		cout << a << z << b << z << c << z << d;
	}
	cout << "=7\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
int main() 
{
 
int i,c=0;
string s;
for( i=0;i<4;i++)
{
	cin>>s[i];
}
for(i=0;i<3;i++)
{
	if(s[i]==s[i+1])
     c=c+1;	
}
if(c!=0)
cout<<"Bad";
else if(c==0)
cout<<"Good";

return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    int c=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='x'){
            c++;
        }
    }
    cout << (15-c>=8?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a=0;
	int b=0;
	int c=0;
	
	printf("");
	scanf("%d %d %d",&a,&b,&c);
	
	while(1){
		if(a>=0 && a<=100 && b>=0 && b<=100 && c>=0 && c<=100){
			break;
		}else{
			printf("");
			scanf("%d %d %d",&a,&b,&c);
			continue;
		}	
	}
	
	if(a<b){
		if(b<c){
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	} else {
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
# -*- coding: utf-8 -*-
# ITP1_11_A

class Dice:
    def __init__(self, num):
        self.num = num
        
    def show(self):
        """ 出目を表示する """
        print(self.num[0])
        
    def roll(self, direction):
        """ NSEWへ転がしたときの処理 """
        new_num = []
        if direction == "N":
            data = [1, 5, 2, 3, 0, 4]
        elif direction == "S":
            data = [4, 0, 2, 3, 5, 1]
        elif direction == "E":
            data = [3, 1, 0, 5, 4, 2]
        elif direction == "W":
            data = [2, 1, 5, 0, 4, 3]
        for i in data:
            new_num.append(self.num[i])
        self.num = new_num
        
dice_num = list(map(int, input().split()))
dice_roll = input()

dice1 = Dice(dice_num)

for direction in dice_roll:
    dice1.roll(direction)
dice1.show()



Measured memory_bytes: 5604
n = int(input())
lst = [i for i in map(int, input().split())]
cnt = 0
for i in range(n-2):
    if lst[i] >= lst[i+1] and lst[i+1] >= lst[i+2] and lst[i] != lst[i+1] and lst[i+1] != lst[i+2]:
        cnt += 1
    elif lst[i] <= lst[i+1] and lst[i+1] <= lst[i+2] and lst[i] != lst[i+1] and lst[i+1] != lst[i+2]:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
using namespace std;

void call(int n)
{
	int i = 1;
	int x;
	int flag = 0;

	while (i <= n) {
		x = i;
		if (x % 3 == 0 ){
			cout << " " << i;
			if (++i <= n) continue; else break;
		}
		do {
			if (x % 10 == 3) {
				cout << " " << i;
				if (++i <= n) {
					flag = 1;
					break;
				}
			}
			x /= 10;
		} while (x);

		if (flag) {
			flag = 0; 
			continue;
		}
		if (++i > n) break;
	}
	cout << endl;
}

int main(int argc, char* argv[])
{
	int n;
	char temp[100];

	fgets(temp, sizeof(temp), stdin);
	sscanf(temp, "%d", &n);
	call(n);
	return 0;
}

Measured memory_bytes: 3228
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
 
char a[101][101]={0};
long long b[101][101]={0},n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
	for(int j=1;j<=m;j++){
		cin>>a[i][j];
	}
}
for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
		if(a[i][j]!='#')
		{
		if(a[i-1][j+1]=='#')b[i][j]++;
		if(a[i-1][j-1]=='#')b[i][j]++;
		if(a[i-1][j]=='#')b[i][j]++;
		if(a[i][j+1]=='#')b[i][j]++;
		if(a[i][j-1]=='#')b[i][j]++;
		if(a[i+1][j+1]=='#')b[i][j]++;
		if(a[i+1][j-1]=='#')b[i][j]++;
		if(a[i+1][j]=='#')b[i][j]++;
		}
		else b[i][j]=10;
	}
}
for(int i=1;i<=n;i++)
{
	for(int j=1;j<=m;j++)
	{
		if(b[i][j]==10)cout<<"#";
		else cout<<b[i][j];
	}
	cout<<endl;
	}	
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>

main(){
	
	int i, j;
	char c[1200];
	
	for(i=0;i<1200;i++){
		scanf("%c",&c[i]);
		
		if(c[i]=='\n')break;
		
		else if(islower(c[i])!=0){
			c[i]=toupper(c[i]);
		}
		else if(isupper(c[i])!=0){
			c[i]=tolower(c[i]);
		}
		
		printf("%c",c[i]);
	}
	
	printf("\n");
		
	return 0;
}

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

int main() {
  int n;
  long long d;
  cin >> n >> d;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char *argv[])
{
    char s[1200];
    
    fgets(s, sizeof(s), stdin);
    char *p = s;
    do {
        if (islower(*p))
            *p = toupper(*p);
        else
            *p = tolower(*p);
    } while (*(++p));
    printf("%s", s);

    return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<=n;i++){
        int x=i;
        if(x%3!=0&&x%5!=0)
            ans+=x;
    }
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3652
#N = int(input())
N,K= map(int,input().split())
S,P,R= map(int,input().split())
T = list(input())
#v =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]
res =[]
answer = T.count('s')*S+T.count('p')*P+T.count('r')*R

l = [0]*N
for i in range(K,N):
    if T[i] == T[i-K]:
        if T[i]==('s'):
            answer -= S
            l[i]=1
        elif T[i]==('p'):
            answer -= P
            l[i]=1
        elif T[i]==('r'):
            answer -= R
            l[i]=1

for j in range(K*2,N):
    if T[j] == T[j-K] and T[j] == T[j-K*2] and l[j-K]==1 and l[j-K*2]==0:
        if T[j]==('s'):
            answer += S
            l[j] = 0
        elif T[j]==('p'):
            answer += P
            l[j] = 0
        elif T[j]==('r'):
            answer += R
            l[j] = 0
print(answer)


Measured memory_bytes: 49136
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
        }

        Arrays.sort(A);

        long ans = 0;
        if (N % 2 == 0) {
           for (int i = 0; i < N/2 - 1; i++) {
               ans = ans + A[N/2 + i] + A[N/2 + i + 1] - 2*A[i];
           }
           ans = ans + A[N-1] - A[N/2 -1];
        } else {
            for (int i = 0; i < N/2 - 1; i++) {
                ans = ans + A[N/2 + i + 1] + A[N/2 + i + 2] - 2*A[i];
            }
            ans = ans + A[N-1] - A[N/2 -1];
            ans += Math.max(A[N/2 + 1] - A[N/2], A[N/2] - A[N/2 - 1]);
        }

        System.out.println(ans);
    }
}

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

int main(){

  int n,q,m;
  int in;
  int max,date;
  int sum[100];

  while(cin >> n >> q){
    if(n==0&&q==0){ break; }

    for(int i=0; i<100; i++){ sum[i] = 0;}
    max = 0; date = 0;

    for(int i=0; i<n; i++){
      cin >> m;
      for(int j=0; j<m; j++){
        cin >> in;
        sum[in-1]++;
      }
    }

    for(int i=0; i<100; i++){
        if(sum[i]>max && sum[i]>=q){
            max=sum[i]; date=i+1;
        }
    }

    cout << date << endl;

  }


  return 0;
}

Measured memory_bytes: 1160