akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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






ll gcd(ll a, ll b){
    return b? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

int main(){
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

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

#define MAXN 3005

using namespace std;

int n, a[MAXN];
vector<int> g[MAXN];

int DFS(int u, int pre) {
    bool iswin = false;
    for (int i = 0; i < (int)g[u].size(); ++i) {
        int v = g[u][i];
        if (v == pre)
            continue;
        iswin |= a[u] > a[v] && !DFS(v, u);
    }
//    cout << u << " " << iswin << endl;
    return iswin;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i)
        if (DFS(i, 0))
            printf("%d ", i);
}


Measured memory_bytes: 384
#include <stdio.h>

void swap(int *a,int *b){
  *a^=*b;
  *b^=*a;
  *a^=*b;
  return;
}

int main(){
  int n,p[30];
  int A,B,C,T,S=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
    scanf("%d",p+i);
  for(int i=2;i<n;i++){
    A=p[i-1];
    B=p[i];
    C=p[i+1];
    T=B;
    if(A<B) swap(&A,&B);
    if(B<C) swap(&B,&C);
    if(A<B) swap(&A,&B);
    if(T==B) S++;
  }
  printf("%d\n",S);
  return 0;
}

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

void fnInput(int& rnDivisor)
{
  cin >> rnDivisor;
}

int fnDigit(int nDivisor)
{
  set<int> seRemain;

  int nDividend = 7;
  int nDigit = 1;
  int nRemain = nDividend % nDivisor;

  while ( nRemain != 0            &&
          seRemain.count(nRemain) == 0 )
  {
    seRemain.insert(nRemain);
    nDividend = nRemain * 10 + 7;
    nRemain = nDividend % nDivisor;
    nDigit++;
  }

  if (!nRemain) return nDigit;
  else          return -1;
}
 
int main()
{
  int nDivisor;

  fnInput(nDivisor);
  cout << fnDigit(nDivisor) << endl;

  return 0;
}

Measured memory_bytes: 50472
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
 
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef complex<double> P;
typedef complex<double> Vec;
typedef pair<int, int> pii;
typedef pair<int, pii> p;
 
#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-10)
#define PI (acos(-1))
const ll MOD = 1000000007ll;

int main() {
	ll n;
	cin >> n;
	
	ll ans = 1;
	FOR(i, 1, n + 1) ans = ans * i % MOD;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
import math
S = list(input())
T = int(input())
prev = S[0]
same_cnt = 0
renzoku = []
for i in range(len(S)):
    if S[i] == prev:
        same_cnt += 1
        if i == len(S)-1:
            renzoku.append(same_cnt)
    else:
        prev = S[i]
        renzoku.append(same_cnt)
        same_cnt = 1
        if i == len(S)-1:
            renzoku.append(same_cnt)
#print(renzoku)
if S[0] != S[-1]:
    print(T*sum(list(map(lambda x: math.floor(x/2),renzoku))))
else:
    if len(renzoku) != 1:
        linked_renzoku = renzoku[:]
        tail = linked_renzoku[-1]
        linked_renzoku[0] += tail
        linked_renzoku.pop()
        #print(linked_renzoku)
        print((T-1)*sum(list(map(lambda x: math.floor(x/2),linked_renzoku))) + sum(list(map(lambda x: math.floor(x/2),renzoku))))
    else:
        print(math.floor((T*len(S))/2))




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

int main(){
  int a,b,c,d,g[101][101]={0};
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b>>c;
    for(int j=0;j<c;j++){
      cin>>d;
      g[b][d]=1;
    }
  }
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      cout<<g[i][j];
      if(a-j>=1)cout<<" ";
    }
    cout<<endl;
  }
  
  return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int n; s(n);
    string st; s(st);
    int ans = 0;
    for(int lidx = 0, ridx = n - 1; lidx < ridx; ){
        if (st[lidx]=='W'&&st[ridx]=='R'){
//            swap(st[lidx], st[ridx]);
            ans++;
            lidx++; ridx--;
        }else if(st[lidx]=='R'){
            lidx++;
        }else if(st[ridx]=='W'){
            ridx--;
        }else{
            assert(false);
        }
    }
    p(ans);
}

class DAlterAltar {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    DAlterAltar solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3760
class SegTree():
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.f = function
        self.b = basement
        self.seg = [basement]*2**(self.K+1)
        self.lazy_seg = [basement]*2**(self.K+1)
        X = 2**self.K
        for i, v in enumerate(lists):
            self.seg[i+X-1] = v

        for i in range(2*X-2, 0, -2):
            self.seg[(i-1) >> 1] = self.f(self.seg[i], self.seg[i-1])

    def update(self, k, value):
        # 0-indexでa[k]の値をvalueに変更
        X = 2**self.K
        k += X-1
        self.seg[k] = value
        while k:
            k = (k-1) >> 1
            self.seg[k] = self.f(self.seg[(k << 1)+1], self.seg[(k << 1)+2])


    def query(self, L, R):
        # 0-index で[L,R)
        num = 2**self.K-1
        L += num
        R += num
        vL = self.b
        vR = self.b
        while L < R:
            if L & 1 == 0:
                vL = self.f(vL, self.seg[L])
                L += 1
            if R & 1 == 0:
                R -= 1
                vR = self.f(self.seg[R], vR)
            L >>= 1
            R >>= 1
        return self.f(vL, vR)

import sys
input=sys.stdin.readline
N=int(input())
S=list(input())
Q=int(input())
que=[tuple(input().split()) for i in range(Q)]
alpha="abcdefghijklmnopqrstuvwxyz"
Data={alpha[i]:[0]*N for i in range(26)}
for i in range(N):
    Data[S[i]][i]+=1
SEG={alpha[i]:SegTree(Data[alpha[i]],max,0) for i in range(26)}
for X,u,v in que:
    if X=="1":
        u=int(u)-1
        NOW=S[u]
        S[u]=v
        SEG[NOW].update(u,0)
        SEG[v].update(u,1)
    else:
        u,v=int(u)-1,int(v)-1
        res=0
        for j in range(26):
            res+=SEG[alpha[j]].query(u,v+1)
        print(res)
            
        
    
    


Measured memory_bytes: 604896
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int T;
ll A, B, C, D;

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

void solve() {
	cin >> T;
	while(T--) {
		cin >> A >> B >> C >> D;
		if(A < B || D < B) {
			cout << "No\n"; continue;
		}
		ll g = gcd(D, B);
		ll e = ((C - A) % g + g) % g;
		ll k;
		if(C - e < 0) k = 0;
		else k = (C - e) / g + 1;
		if(e + k * g >= B) {
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	s = S()
	print(s.replace(',',' '))

if __name__ == '__main__':
    main()

Measured memory_bytes: 26972
num,total=[int(str) for str in input().split()]

#if total>10000*num or total<1000*num or total%1000!=0:
#    print("-1 -1 -1")


total_cal=[]
num_10000=0
num_5000=0
num_1000=0
limit=50

if num<limit:
    pass
else:
    for num_cal in range(num,limit,-1):
        #print('total:',total)
        #print(num_cal)
        ave=total/num_cal
        diff=[abs(10000-ave),abs(5000-ave),abs(1000-ave)]
        if diff.index(min(diff))==0:
            total-=10000
            num_10000 += 1
        elif diff.index(min(diff))==1:
            total-=5000
            num_5000 += 1
        else:
            total-=1000
            num_1000 += 1

    num=limit
    #print(num)
    #print(total)

for i in range(num+1):
    for j in range(num+1):
        for k in range(num+1):
            total_cal.append({"nums":[i,j,k],'total':10000*i+5000*j+1000*k})

nums=[x["nums"] for x in total_cal if x['total']==total and sum(x['nums'])==num]


if total_cal!=0 and nums==[]:
    print("-1 -1 -1")
else:
    nums = [x + y for (x, y) in zip(nums[0], [num_10000, num_5000, num_1000])]
    print('{num_10000} {num_5000} {num_1000}'.format(num_10000=nums[0],num_5000=nums[1],num_1000=nums[2]))


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;




int main() {


	long double a;
	cin >> a;
	cout << fixed << setprecision(15) << (a / 3.0)*(a / 3.0)*(a / 3.0) << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll n,m; cin>>n>>m;
  vector<ll>v(m);
  rep(i,m)cin>>v[i];
  reverse(all(v));
  set<ll>s;
  rep(i,m){
    if(s.count(v[i]))continue;
    s.insert(v[i]);
    cout<<v[i]<<endl;
        }
        
  for(ll i=1; i<=n;i++){
  if(!s.count(i))cout<<i<<endl;
  }
}


Measured memory_bytes: 8328
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string N;
  cin>>N;
  if(N[0]==N[2]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3576
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
vector<ll> h;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    h.assign(n, 0);
    F0R(i, n) cin >> h[i];
    int b = 0, ch = h[0], cur = 0;
    FOR(i, 1, n)
    {
        if(h[i] <= ch)
        {
            ch = h[i];
            cur++;
        }
        else
        {
            ch = h[i];
            b = max(b, cur);
            cur = 0;
        }
    }
    cout << max(b, cur);
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n; cin >> n;
	vector<int> a(n);
	for (auto& i : a) cin >> i;
	ll ans = 1000;
	for (int i = 0; i < n - 1; ++i) {
		if (a[i] < a[i + 1]) {
			ll num = ans / a[i];
			ans += num * (a[i + 1] - a[i]);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    string X;
    cin>>X;
    stack<char>st;
    for(char x:X)
        if(x=='S')
            st.push('S');
        else{
            if(!st.empty()&&st.top()=='S')
                st.pop();
            else
                st.push('T');
        }
    cout<<st.size()<<endl;
}


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

int main() {
  int num;
  int total = 0;
  int tmpNum = 0;
  
  cin >> num;
  vector<int> vec(num);
  for(int i = 0;i < num; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  /*
  for(int i = 0;i < num; i++){
    if(tmpNum <> vec.at(i)){
      total += vec.at(i) - tmpNum;
      tmpNum = vec.at(i);
    }
  }
  */
  cout << vec.at(num-1) - vec.at(0);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  int ans = 0;
  REP(i, s.length()) FOR(j, i, s.length()) {
    bool ok = true;
    FOR(k, i, j + 1) {
      if (s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T') ok = false;
    }
    if (ok) ans = max(ans, j - i + 1);
  }
  cout << ans << '\n';
  return 0;
}


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

char a[5];
int b[5];
int main()
{
	scanf("%s",&a);
	for(int i=0;i<=3;i++)
		b[i]=a[i]-48;
	if(b[0]+b[1]+b[2]+b[3]==7)
		printf("%d+%d+%d+%d=7\n",b[0],b[1],b[2],b[3]);
	else if(b[0]+b[1]+b[2]-b[3]==7)
		printf("%d+%d+%d-%d=7\n",b[0],b[1],b[2],b[3]);
	else if(b[0]+b[1]-b[2]+b[3]==7)
		printf("%d+%d-%d+%d=7\n",b[0],b[1],b[2],b[3]);
	else if(b[0]+b[1]-b[2]-b[3]==7)
		printf("%d+%d-%d-%d=7\n",b[0],b[1],b[2],b[3]);
	else if(b[0]-b[1]-b[2]-b[3]==7)
		printf("%d-%d-%d-%d=7\n",b[0],b[1],b[2],b[3]);
	else if(b[0]-b[1]+b[2]+b[3]==7)
		printf("%d-%d+%d+%d=7\n",b[0],b[1],b[2],b[3]);
	else if(b[0]-b[1]-b[2]+b[3]==7)
		printf("%d-%d-%d+%d=7\n",b[0],b[1],b[2],b[3]);
	else if(b[0]-b[1]+b[2]-b[3]==7)
		printf("%d-%d+%d-%d=7\n",b[0],b[1],b[2],b[3]);
	return 0;
}

Measured memory_bytes: 256
def main():
    S = input()

    ans = f(S)
    ans = regex(S)

    print(ans)


def f(S):
    if S[0] != "A":
        return "WA"

    nc = S[2:-1].count("C")
    if nc != 1:
        return "WA"

    import string
    for c in S[1] + S[-1]:
        if c in string.ascii_uppercase:
            return "WA"

    return "AC"


def regex(S):
    import re

    r = re.compile("^A[a-z][^C]*C[^C]*[a-z]$")
    if r.match(S):
        return "AC"
    else:
        return "WA"


if __name__ == '__main__':
    main()


Measured memory_bytes: 3768
import java.io.*;
import java.util.*;

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		long n = in.nextLong();
		long a = n/11;
		long rem = n%11;
		long ans = 0;
		if(rem==0)ans=0;
		else if(rem<7)ans++;
		else ans+=2;
		ans+=a*2;
		out.println(ans);
		out.flush();
		out.close();  
	}

}





Measured memory_bytes: 21204
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static int[] s,a;
	static void Main(){
		Sc sc=new Sc();
		s=sc.Ia;
		a=sc.Ia;
		int ans=1;
		int m=a.Sum(),q=(int)Sqrt(m);
		for(int i = 1;i<=q;i++) {
			if(m%i==0){
				if(Fu(i)){ans=Max(i,ans);}
				if(Fu(m/i)){ans=Max(m/i,ans);}
			}
		}
		Console.WriteLine("{0}",ans);
	}
	static bool Fu(int n){
		int[][] p=new int[s[0]][];
		int q=0,r=0,o=0;
		for(int i = 0;i<s[0];i++) {
			p[i]=new int[2];
			p[i][0]=a[i]%n;
			p[i][1]=(n-p[i][0])%n;
			q+=p[i][0];
			r+=p[i][1];
		}
		Array.Sort(p,(u,v)=>u[0]-v[0]);
		bool bo=false;
		for(int i = 0;i<s[0];i++) {
			o+=p[i][0];
			r-=p[i][1];
			if(o>s[1]){break;}
			if(o-r==0){bo=true;break;}
		}
		return bo;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 15544
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll h, w, n;
	cin >> h >> w >> n;
	cout << ((n - 1) / max(w, h)) + 1;
}

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

int main() {
  string s;
  cin >> s;
  char s3, s4, s5, s6;
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,t;
	cin>>a>>b>>t;
	int biscuit=0;
	while (t>=a)
	{
		biscuit+=b;
		t-=a;
	}
	cout<<biscuit;
	return 0;
}

Measured memory_bytes: 256
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 100005, mod = 1e9 + 7;
int n;

vector<vector<int>> mul(vector<vector<int>> a, vector<vector<int>> b) {
    vector<vector<int>> res(n, vector<int>(n));
    rep(i, 0, n) {
        rep(j, 0, n) {
            rep(k, 0, n) {
                res[i][j] = int((res[i][j] + a[i][k] * (ll)b[k][j]) % mod);
            }
        }
    }
    return res;
}

vector<vector<int>> po(vector<vector<int>> a, ll x) {
    vector<vector<int>> res(n, vector<int>(n));
    rep(i, 0, n) res[i][i] = 1;
    while(x > 0) {
        if(x % 2) {
            res = mul(res, a);
        }
        a = mul(a, a);
        x /= 2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll k;
    cin >> n >> k;
    vector<vector<int>> a(n, vector<int>(n));
    rep(i, 0, n) {
        rep(j, 0, n) {
            cin >> a[i][j];
        }
    }
    a = po(a, k);
    int res = 0;
    rep(i, 0, n) {
        rep(j, 0, n) {
            res += a[i][j];
            if(res >= mod) {
                res -= mod;
            }
        }
    }
    cout << res << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int X[101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>X[i];
	ll ret=1<<30;
	int mi=0;
	FOR(i,101) {
		ll tot=0;
		FOR(x,N) tot+=(X[x]-i)*(X[x]-i);
		ret=min(ret,tot);
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int com(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    char S[10];
    scanf("%s",S);
    int s[10];
    for(int i = 0; i < strlen(S); i++){
        s[i] = S[i] - '0';
    }
    int dif[8];
    for(int i = 0; i < strlen(S)-2; i++){
        dif[i] = abs(s[i]*100 + s[i+1]*10 + s[i+2] - 753); 
    }
    qsort(dif, strlen(S)-2, sizeof(int), com);

    printf("%d\n",dif[0]);
    return 0;
}

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

const int mod = 1e9+7;

int n, q[100005];
int prime[1000005];
int dp[100005];

signed main(){
  
  for(int i=0;i<1000005;i++) prime[i] = 1;
  
  prime[0] = prime[1] = 0;
  
  for(int i=1;i*i<1000005;i++){

    if(prime[i]==0) continue;
    
    for(int j=i*2;j<1000005;j+=i) prime[j] = 0;
    
  }
  
  cin>>n;
  
  for(int i=0;i<n;i++) cin>>q[i];
  
  dp[0] = 1;
  
  for(int i=0;i<n;i++){
    
    if( prime[q[i]] == 0 ) continue;
    
    if( i == n-1 ){
      dp[i+1] += dp[i];
      dp[i+1] %= mod;
      continue;
    }
    
    if(q[i]<q[i+1]){
      dp[i+1] += dp[i];
      dp[i+1] %= mod;
    }
    
    if( i+2 == n ){
      dp[i+2] += dp[i];
      dp[i+2] %= mod;
    }
    else if(q[i]<q[i+2]){
      dp[i+2] += dp[i];
      dp[i+2] %= mod;
    }
    
  }

  cout<<dp[n]<<endl;
  
  return 0;
}



Measured memory_bytes: 12468
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAX = 100005;
int fac[MAX], inv[MAX], finv[MAX];

void pre(){
  inv[1]=1;
  for (int i = 2; i <MAX ; i++)
  {
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  }
  fac[0]=finv[0]=1;
  for (int i = 1; i < MAX; ++i)
  {
    fac[i]=fac[i-1]*i%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
int ncr(int n, int r){
  if(r<0||r>n)return 0;
  return fac[n]*finv[r]%mod*finv[n-r]%mod;
}
int n,k;
int a[101010];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  pre();
  cin >> n >> k;
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  sort(a+1,a+n+1);
  int ans = 0;
  for(int i=1;i<=n;i++){
    ans = (ans + ncr(i-1,k-1)*a[i]%mod + mod + mod )%mod;
    ans = (ans - ncr(n-i,k-1)*a[i]%mod + mod + mod )%mod;
  }
  cout << ans << endl;
  

return 0;
}
///....


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

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

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool ac_flag[100001];
VI wa_cnt(100001, 0);

void solve(long long N, long long M, std::vector<long long> p, std::vector<std::string> S){
    int ac = 0, wa = 0;
    REP(i, M) {
        if(S[i] == "AC") {
            ac_flag[p[i]] = true; 
        } else if (!ac_flag[p[i]]) {
            wa_cnt[p[i]]++;
        }
    }

    REP(i, N+1) {
        if(ac_flag[i]) {
            ac++;
            wa += wa_cnt[i];
        }
    }
    cout << ac << " " << wa << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> p(M);
    std::vector<std::string> S(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&p[i]);
        std::cin >> S[i];
    }
    solve(N, M, std::move(p), std::move(S));
    return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <bits/stdc++.h>
#define MAX_SIZE 500010
#define NIL -1
#define INFTY 2000000000
using namespace std;

struct Node { int p, l, r; };
Node T[MAX_SIZE];
int D[MAX_SIZE];

int getDepth(int u) {
    int d = 0;
    while (T[u].p != NIL) {
        u = T[u].p;
        d++;
    }
    return d;
}

void setDepth(int u, int d) {
    D[u] = d;
    if (T[u].r != NIL) setDepth(T[u].r, d);
    if (T[u].l != NIL) setDepth(T[u].l, d + 1);
}

void printNode(int v) {
    cout << "node " << v << ": parent = ";
    cout << T[v].p << ", depth = " << D[v] << ", ";
    if (T[v].p == NIL) cout << "root";
    else if (T[v].l == NIL) cout << "leaf";
    else cout << "internal node";
    cout << ", [";
    v = T[v].l;
    if (v != NIL) {
        cout << v;
        for (v = T[v].r; v != NIL; v = T[v].r) cout << ", " << v;
    }
    cout << "]" << endl;
}

int main(){
    int i, j, v, k, n, c, l, r;
    cin >> n;
    for (i=0; i < n; i++) T[i].l = T[i].r = T[i].p = NIL;
    for (i=0; i < n; i++) {
        scanf("%d %d", &v, &k);
        for (j=0; j < k; j++) {
            scanf("%d", &c);
            if (j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i=0; i < n; i++) if (T[i].p == NIL) r = i;
    setDepth(r, 0);
    for (v=0; v < n; v++) printNode(v);
    return 0;
} 


Measured memory_bytes: 7940
import math

n, q = map(int, input().split())

# make a list whose length is 2^i - 1.
n = pow(2, math.ceil(math.log2(n)))
max_v = 2147483647

A = [max_v for i in range(2 * n - 1)]


def update(i, x):
    i += n - 1
    A[i] = x

    while i > 0:
        i = (i - 1) // 2
        A[i] = min(A[i * 2 + 1], A[i * 2 + 2])

def find(a, b, k, l, r):
    if r <= a or b <= l:
        return max_v
    if a <= l and r <= b:
        return A[k]
    else:
        vl = find(a, b, k * 2 + 1, l, (l + r) // 2)
        vr = find(a, b, k * 2 + 2, (l + r) // 2, r)
        return min(vl, vr)


for i in range(q):
    com, x, y = map(int, input().split())
    if com == 0:
        update(x, y)
    else:
        ans = find(x, y + 1, 0, 0, n)
        print(ans)

Measured memory_bytes: 11212
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  kss <- replicateM m $ map read . words <$> getLine :: IO [[Int]]
  ps <- fmap (map read . words) getLine :: IO [Int]
  print $ solve n kss ps

solve :: Int -> [[Int]] -> [Int] -> Int
solve n kss ps = length $ filter allOn candidates
  where
    candidates = replicateM n [0, 1] :: [[Int]]
    allOn :: [Int] -> Bool
    allOn switches = all id . zipWith (==) ps $ map (f switches) kss
    f :: [Int] -> [Int] -> Int
    f switches (k:ss) = (sum $ map (sarr!) ss) `mod` 2
      where
        sarr = listArray (1, n) switches



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

int cmp(const void *a, const void *b){
	return *(long*)b - *(long*)a;
}

int main(void){
	int n;
	long sum = 0;
	scanf("%d", &n);
	long *a = malloc(sizeof(long) * n);
	for(int i = 0; i < n; i++)
		scanf("%ld", a + i);
	qsort(a, n, sizeof(long), cmp);

	for(int i = 1; i < n; i++){
		sum += a[i / 2];
	}

	printf("%ld\n", sum);
	return 0;
}


Measured memory_bytes: 5028
let () = Scanf.scanf "%d\n" @@ fun k ->
  let rec solve i x =
    if x = 0
    then i
    else if k < i
    then -1
    else solve (i + 1) ((10 * x + 7) mod k) in
  Printf.printf "%d\n" @@ solve 1 (7 mod k)

Measured memory_bytes: 3784
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var I=0;I<Arr.length;I++){
var n=Arr[I]-0;
var cnt=0;
for(var i=0;i<=9;i++){
   for(var j=0;j<=9;j++){
      for(var k=0;k<=9;k++){
         for(var l=0;l<=9;l++){
            if(i+j+k+l===n)cnt++;
         }
      }
   }
}
console.log(cnt);
}

Measured memory_bytes: 8464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 1e5+10;
int S[N_MAX];
bool prime[N_MAX];

vector<int> eratosthenes(int n){
  vector<int> v(1,2);
  for(int i = 3; i<=n; i+=2) v.push_back(i);
  for(int i = 1; v[i]<=sqrt(n); i++){
    for(int j = i+1; j<v.size(); j++){
      if(v[j]%v[i]==0){
        v.erase(v.begin()+j);
        j--;
      }
    }
  }
  return v;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int Q;cin >> Q;
  vector<int> v = eratosthenes(N_MAX-1);
  rep(i,v.size()) prime[v[i]] = true;
  repp(x,1,N_MAX){
    S[x] += S[x-1];
    if(prime[x] && prime[(x+1)/2]) S[x] += 1;
  }
  while(Q--){
    int l,r;cin >> l >> r;
    cout << S[r] - S[l-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1532
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n,i,ma,p,d = MAX;
ll a[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
        ma = max(ma,a[i]);
    }
    rep(i,0,n) if(a[i] != ma){
        if(abs(ma / 2 - a[i]) < d){
            d = abs(ma / 2 - a[i]);
            p = a[i];
        }
    }
    cout<<ma<<" "<<p;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	REP(kurikaesu, n) {
		vector<unsigned int> num(8);
		unsigned int check;
		unsigned int ans = 0;
		REP(i, 8)
			cin >> hex >> num[i];
		cin >> hex >> check;
		unsigned int sum;
		RE:
			sum = 0;
			REP(i, 8)
				sum += num[i]^ans;
			REP(i,32) {
				if ((sum&(1 << i)) != ((check^ans)&(1 << i))) {
					ans ^= 1 << i;
					goto RE;
				}
			}
		cout << hex << ans << endl;
	}
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) (a.begin(), a.end())
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

int sum[3*E5+1];

void solve() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	
	int t = 0;
	for (int i=0; i < n; ++i) {
		if (s[i] == 'W') {
			++t;
		}
		sum[i+1] = t;
	} 

	int ans = n+1;

	for (int i = 1; i <= n; ++i) {
		int tmp = sum[i-1] + (n-i - (sum[n]-sum[i])); 
		ans = min(ans,tmp);
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 1812
#include <iostream>
using namespace std;
int main()
{
  int n;
  string s;
  cin >> n >> s;
  string s1 = s;
  int R_count = 0,L_count = 0;
  for(int i = 0;i < s1.size();i++)
  {
    if(s1[i] == '(')
    {
      bool flag = true;
      for(int j = i;j < s1.size();j++)
      {
        if(s1[j] == ')')
        {
          s1[i] = '0';
          s1[j] = '0';
          flag = false;
          break;
        }
      }
      if(flag)
      {
        L_count++;
      }
    }
    else if(s1[i] == ')')
    {
      bool flag = true;
      for(int j = i;j >= 0;j--)
      {
        if(s1[j] == '(')
        {
          s1[i] = '0';
          s1[j] = '0';
          flag = false;
          break;
        }
      }
      if(flag)
      {
        R_count++;
      }
    }
  }
  for(int i = 0;i < R_count;i++)
  {
    cout << "(";
  }
  cout << s;
  for(int i = 0;i < L_count;i++)
  {
    cout << ")";
  }
  cout << "\n";

  return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0]);
    M = Number(tmp0[1]);

    lmin=1
    rmax=N
    for(var i=1; i<=M;i++){
        tmp1 = input[i].split(" ")
        L = Number(tmp1[0])
        R = Number(tmp1[1])
        lmin = Math.max(lmin, L)
        rmax = Math.min(rmax, R)
    }
    if(rmax-lmin+1 < 0){
        console.log(0)
    }else{
        console.log(rmax-lmin+1)
    }
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   Main("6 2\n3 6\n1 4\n");

Measured memory_bytes: 29104
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException{
    int sub1 = 0;
    int sub2 = 0;
    int i = 1;
    String s;
    int a = 0;
    int b = 0;
    int c = 0;
        while(i>0){
            BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
            s = x.readLine();
            StringTokenizer st = new StringTokenizer(s," ");
            a = Integer.parseInt(st.nextToken());
            b = Integer.parseInt(st.nextToken());
            c = Integer.parseInt(st.nextToken());
            if(a >= -1000 && a <= 1000 )
                i = -1;
            else if(b >= -1000 && b <= 1000)
                i = -1;
            else if(c >= -1000 && c <= 1000)
                i = -1;
            else
                i = 1;
         }
        sub1 = a-b;
        sub2 = b-c;
            if(sub1<0){
            if(sub2<0)
                System.out.println("Yes");
            else if(sub2>=0)
                System.out.println("No");
            }
            else if(sub1>=0)
                System.out.println("No");
    }
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int poss=0;
    for(int i=1; i<=n; i++)
    {
        int x;
        scanf("%d",&x);
        if(x==poss+1)
            poss++;
    }
    if(poss)
        cout<<n-poss;
            else
                cout<<-1;
    return 0;
}


Measured memory_bytes: 256
module Main where


main :: IO()
main = do
  getLine
  inputs <- map read . words <$> getLine
  print $ solve inputs

solve :: [Integer] -> Integer
solve = swapWithCount

swapWithCount :: [Integer] -> Integer
swapWithCount inputs = sub (0, inputs) 1 where
  sub :: (Integer, [Integer]) -> Integer -> Integer
  sub (count, [x]) index
    | x == index  = count + 1
    | otherwise   = count
  sub (count, (x:y:xs)) index
    | x == index  = sub (count + 1, x:xs) (index + 1)
    | otherwise   = sub (count, y:xs) (index + 1)


Measured memory_bytes: 18812