akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> tp;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<LL, pii> plpii;
typedef pair<LD, LD> pdd;
typedef pair<LD, int> pdi;
typedef pair<LD, LL> pdl;
typedef pair<int, LD> pid;
typedef pair<LL, LD> pld;
const int mod = 1e9 + 7;
const int hf = 999983;
const int N = 1e6;
LL dp[1<<16], cost[1<<16];
int a[16][16];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(int i=1;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                for(int k=j+1;k<n;k++){
                    if((i>>k)&1){
                        cost[i] += a[j][k];
                    }
                }
            }
        }
    }
    for(int i=1;i<(1<<n);i++){
        vector<int> v;
        for(int j=0;j<n;j++){
            if((i>>j)&1) v.push_back(j);
        }
        int sz = v.size();
        for(int j=1;j<(1<<sz);j++){
            int b = 0;
            for(int k=0;k<sz;k++){
                if((j>>k)&1){
                    b |= (1<<v[k]);
                }
            }
            dp[i] = max(dp[i], dp[i^b] + cost[b]);
        }
    }
    printf("%lld\n", dp[(1<<n)-1]);
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin>>n>>m;
    int s[n],t[n];
    int ww=100000000;
    int num=0,pt=0,w,w2;
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i];
    }
    for(int i=0;i<(1<<n);i++){
        pt=0;
        num=0;
        w=0,w2=0;
        for(int j=0;j<n;j++){
            if(i & (1<<j)){
                pt+=100*(j+1)*(s[j])+t[j];
                num+=s[j];
            }
            else {w=s[j]-1;w2=j+1;}
        }
        if (m>pt+w*w2*100)continue;
        else if(m<=pt)ww=min(ww,num);
        else ww=min(ww,num+(m-pt-1)/(w2*100)+1);
    }
    cout<<ww<<endl;
}


Measured memory_bytes: 256
import itertools

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

def gcd(x, y):
    return gcd(y, x % y) if y else x

n = getint()
a = getints()

lo = [0] * n
hi = [0] * n
lo[0] = a[0]
hi[n-1]=a[n-1]
for i in range(1, n):
    lo[i] = gcd(lo[i-1], a[i])

for i in range(n-2,-1,-1):
    hi[i] = gcd(hi[i+1], a[i])

mx=0
for i in range(0,n):
    c1 = lo[i-1] if i >= 1  else hi[1]
    c2 = hi[i+1] if i < n-1 else lo[n-2]
    mx=max(mx, gcd(c1,c2))


print(mx)


Measured memory_bytes: 14528
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[200100];

ll subsum[200100];

P calc_l(int e) {
    ll sum = subsum[e];
    int lb = 0, ub = e;
    while (ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if (subsum[mid] <= sum/2) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    if (sum-2*subsum[lb] < 2*subsum[lb+1]-sum) {
        return P(subsum[lb], sum-subsum[lb]);
    } else {
        return P(sum-subsum[lb+1], subsum[lb+1]);
    }
}

P calc_r(int e) {
    ll sum = subsum[n] - subsum[e];
    int lb = e, ub = n;
    while (ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if (subsum[mid]-subsum[e] <= sum/2) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    if (sum-2*(subsum[lb]-subsum[e]) < 2*(subsum[lb+1]-subsum[e])-sum) {
        return P(subsum[lb]-subsum[e], subsum[n]-subsum[lb]);
    } else {
        return P(subsum[n]-subsum[lb+1], subsum[lb+1]-subsum[e]);
    }
}

ll solve() {
    for (int i = 1; i <= n; i++) {
        subsum[i] = subsum[i-1] + a[i-1];
    }
    
    ll res = 1e16;
    for (int i = 2; i < n-1; i++) {
        P l = calc_l(i);
        P r = calc_r(i);
        ll p = min(l.first, r.first), q = max(l.second, r.second);
        res = min(res, q-p);
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3328
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class AC>void r(AC &x){
    x=0;
	int f=0;
	char ch=getchar();
    while(ch<'0'||ch>'9'){
		f|=(ch=='-');
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
    x=f?-x:x;
    return;
}
int n,x,y; 
int main(){
	r(n);
	r(x);
	r(y);
	if((x-y)%2==0)puts("Alice");
	else puts("Borys");
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll MOD = ll(1e9+7);
constexpr int INF = 1<<30;

int main(){
    string w;
    vector<int> cnt(26,0);
    cin >> w;
    for(int i=0;i<int(w.size());i++){
        cnt[w[i]-'a']++;
    }
    bool yes = true;
    for(int i=0;i<26;i++){
        if(cnt[i]%2 == 1) yes = false;
    }
    if(yes){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define foreach(c,it) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
using namespace std;
int n,m,i,j,a[200005],b[200005];
int main(){
	cin>>n>>m;
	rep(i,n){
		cin>>a[i];
	}
	while(m--){
		int f=0;
		rep(i,n)if(a[i]!=n) f=1;
		if(!f) break;
		rep(i,n)b[i]=0;
		rep(i,n){
			b[max(1,i-a[i])]++;
			b[min(n+1,i+a[i]+1)]--;
		}
		rep(i,n){
			b[i]+=b[i-1];
			a[i]=b[i];
		}
	}
	rep(i,n) cout<<a[i]<<(i==n?'\n':' ');
	return 0;
}

Measured memory_bytes: 5148
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b){
    if (b==0)return a;
    return gcd(b,a%b);
}
int main(void){
    // Your code here!
    int c;
    cin>>c;
    ll a,b;
    cin>>a;
    for(int i=0;i<c-1;i++){
       cin>>b;
       a=a*(b/gcd(a,b));
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int N;
  long double Totalrev = 0.0, ans;
  cin >> N ;
  long double num[N];
  for (int i = 0; i < N; i++) {
    cin >> num[i];
  }
  long double rev[N];
  for(int j=0;j<N;j++){
    rev[j] = 1 / num[j];
    Totalrev += rev[j];
  }
  ans = (1 / Totalrev);
  cout << ans <<endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        int length = scanner.nextInt();
        String[] str_nums = new String[length];
        
        for(int i=0; i<length; i++) {
            String str_num = scanner.next();
            str_nums[length - 1 - i] = str_num;
        }
        
        System.out.println(String.join(" ", str_nums));
        
        
        
    }
}


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

int tate=0, yoko=0;
vector<vector<char>>kukaku;
char kudamono;
void kazyuen(int a, int b) {
	kukaku[a][b] = 0;
	if (a - 1 > -1 && kukaku[a - 1][b] == kudamono)kazyuen(a - 1, b);
	if (a + 1 <tate && kukaku[a + 1][b] == kudamono)kazyuen(a + 1, b);
	if (b - 1 > -1 && kukaku[a][b - 1] == kudamono)kazyuen(a, b - 1);
	if (b + 1<yoko && kukaku[a][b + 1] == kudamono)kazyuen(a, b + 1);
}
int main() {
	int a, b;
	while (cin >> a >> b, a | b) {
		kukaku.clear();
		tate = a;
		yoko = b;
		for (int c = 0; c < a; c++) {
			vector<char>h(b);
			kukaku.push_back(h);
			string e;
			cin >> e;
			for (int d = 0; d < b; d++) {
				kukaku[c][d] = e[d];
			}
		}
		int s = 0;
		for (int l = 0; l < a; l++) {
			for (int r = 0; r < b; r++) {
				if (kukaku[l][r]) {
					s++;
					kudamono = kukaku[l][r];
					kazyuen(l, r);
				}
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3852
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    
    int ans=0;
    ans=min(A,K);
    K=K-A;
    if(K>0)
    {
        K=K-B;
        if(K>0){
            ans-=K;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3156
n = int(input())
s = list(input())

alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
memo = {}
for i in range(26):
    memo[alph[i]] = i
  
for i in range(len(s)):
    tmp = (memo[s[i]] + n) % 26
    s[i] = alph[tmp]
print("".join(s))

Measured memory_bytes: 39664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b % a == 0) {
            System.out.println(a + b);
        } else {
            System.out.println(b - a);
        }
    }

}

Measured memory_bytes: 21844
x, n = map(int,input().split())
a = list(map(int, input().split()))
a.sort()

nota = list()

for i in range(-1000, 1001):
    if i in a:
        continue
    nota.append(i)

nota.sort()
ans = 1000
minabs = 1000
for i in nota:
    if minabs > abs(i-x):
        minabs = abs(i-x)
        ans = i

print(ans)

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

int main(){
  int N;
  cin >> N;
  vector<int>l(N);
  vector<int>r(N);
  int ans=0;
  for(int i=0;i<N;i++){
    cin >> l[i] >> r[i];
    ans+=r[i]-l[i]+1;
  }  
  cout << ans << endl;
}

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

void _sort(string &s)
{
	for(int i=0;i<s.length()-1;i++)
	{
		for(int j=i+1;j<s.length();j++)
			if(s[i]>s[j]) swap(s[i],s[j]);
	}
}

bool _cmp(string s,string _cmp = "abc")
{
	if(s.length()!=_cmp.length()) return false;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=_cmp[i]) return false;
	}
	return true;
}

int main()
{
	string s;
	cin>>s;
	_sort(s);
	if(_cmp(s)) cout<<"Yes";
	else cout<<"No";
}

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

using ll = long long;
#define MOD 1000000007

int N;
vector<int> C;
vector<int> memo;
vector<int> nearest;
vector<int> ind;

int f(int i) {
    if (i >= nearest.size()) return 1;
    if (memo[i] != -1) return memo[i];
    if (nearest[i] == -1) {
        return memo[i] = f(i+1) % MOD;
    } else {
        return memo[i] = (f(nearest[i]) + f(i+1)) % MOD;
    }
}

int main()
{
    cin >> N;
    C.resize(N); for (auto& e : C) cin >> e;
    C.erase(unique(C.begin(), C.end()), C.end());

    ind.assign(200000+1, -1);
    nearest.assign(C.size(), -1);
    for (int i = C.size()-1; i >= 0; i--) {
        if (ind[C[i]] != -1) nearest[i] = ind[C[i]];
        ind[C[i]] = i;
    }

    memo.assign(C.size(), -1);
    ll ans = f(0);
    cout << ans << endl;
}


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

struct Node{
  int p, l, r;
};

Node T[100010];

void Preorder( int s ){
  if( s == -1 ) return;

  cout << " " << s;
  Preorder( T[s].l );
  Preorder( T[s].r );
}

void Inorder( int s ){
  if( s == -1 ) return;
  
  Inorder( T[s].l );
  cout << " " << s;
  Inorder( T[s].r );
}

void Postorder( int s ){
  if( s == -1 ) return;
  
  Postorder( T[s].l );
  Postorder( T[s].r );
  cout << " " << s;
}

int main(){
  int N; cin >> N;
  for( int i = 0; i < 100010; i++ ) T[i].p = T[i].l = T[i].r = -1;

  for( int i = 0; i < N; i++ ){
    int id, left, right;
    cin >> id >> left >> right;

    T[id].l = left;
    T[id].r = right;
    T[left].p = id;
    T[right].p = id;
  }

  for( int i = 0; i < N; i++ ){
    if( T[i].p == -1 ){
      cout << "Preorder" << endl;
      Preorder( i );
      cout << endl;

      cout << "Inorder" << endl;
      Inorder( i );
      cout << endl;

      cout << "Postorder" << endl;
      Postorder( i );
      cout << endl;

      break;
    }
  }
  
}



Measured memory_bytes: 4276
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main(){

    int n, x; cin >> n >> x;
    int m, m_min; m_min = ( 1 << 21  );
    int res = 0;

    REP(i, n){
        cin >> m;
        x -= m;
        m_min = min(m, m_min);
        res++;
    }

    res += x/m_min;

    cout << res << endl;

    return 0;
}


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

int main() {
  ll n, m; cin >> n >> m;
  map<ll,ll> M;
  ll ans = 0;
  rep(i,n) {
    ll a,b; cin >> a >> b;
    M[a]+=b;
  }
  for (auto p : M) {
    ll k = p.first;
    ll v = p.second;
    if (m - v >= 0) {
      ans += k * v;
      m -= v;
    } else {
      ans += k * m;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9840
#include<stdio.h>
int main(void)
{
	int map[16][16];
	int suu;
	int i,j;
	int n;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				map[i][j]=0;
			}
		}
		i=n/2+1;
		j=n/2;
		map[i][j]=1;
		suu=2;
		while(suu<=n*n){
			i++;
			j++;
			if(i>=n){
				i=0;
			}
			if(j>=n){
				j=0;
			}
			if(map[i][j]!=0){
				i++;
				j--;
				if(j<0){
					j=n-1;
				}
				if(i>=n){
					i=0;
				}
			}
			map[i][j]=suu;
			suu++;
		}
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				printf("%4d",map[i][j]);
			}
			printf("\n");
		}
		scanf("%d",&n);
	}
	return 0;
}

			

Measured memory_bytes: 1044
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5

test_case 1,6 == 50 delivery point
		 2,3,4,5,7 == 80 delivery point
				8,9 == 90 delivery point
				10 > 100 delivery point
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long dp[401][401];
long long geko[401][401];
int main() {
	long long n, c;
	cin >> n >> c;
	vector<pair<long long, long long>> hoge(n);
	REP(i, n) {
		cin >> hoge[i].first;
	}
	REP(i, n) {
		cin >> hoge[i].second;
	}
	for (int i = 0; i < n; ++i) {
		for (long long q = hoge[i].first; q <= hoge[i].second; ++q) {
			long long now = 1;
			for (long long j = 0; j <= c; ++j) {
				geko[i][j] += now;
				geko[i][j] %= MAX_MOD;
				now *= q;
				now %= MAX_MOD;
			}
		}
	}
	dp[0][0] = 1;
	REP(i, n) {
		for (int q = c; q >= 0; --q) {
			for (int j = 0; q + j <= c; ++j) {
				dp[i+1][q + j] += (dp[i][q] * geko[i][j]) % MAX_MOD;
				dp[i+1][q + j] %= MAX_MOD;
			}
		}
	}
	cout << dp[n][c] << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int main(void){
    int x, y;
    cin >> x >> y;
    int tmp;
    if(x > y){
        tmp = x;
        x = y;
        y = tmp;
    }
    
    while(y > 0){
        tmp = x % y;
        x = y;
        y = tmp;
    }
    
    cout << x << endl;
    
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a[4],b,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<int,int> > VP;

int main(){
    string input;
    cin>>input;
    rep(i,4)a[i]=input[i]-'0';
    rep(i,4)d(a[i]);
    rep(i,8){
        sum=a[0];
        rep(j,3){
            if(i>>j & 1)sum+=a[j+1];
            else sum-=a[j+1];
        }
        d(sum)
        d(st);
        if(sum==7){
            d(st);
            rep(j,7){
                if(j%2==1){
                    if(i>>j/2 & 1)st+="+";
                    else st+="-";
                }
                else st+=to_string(a[j/2]);
            }
            p(st+"=7");
            return 0;
        }
    }
    return 0;
}


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

#include <bits/stdc++.h>
using namespace std;

struct Happiness {
    int a;
    int b;
    int index;
};

bool cmp(const Happiness& lhs, const Happiness& rhs) {
    return lhs.a + lhs.b > rhs.a + rhs.b;
}

class CDifferentStrokes {
public:
    void solve(istream& cin, ostream& cout) {
        ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
        cout.setf(ios::fixed); cout.precision(20);

        int n; cin >> n;
        vector<Happiness> A;
        vector<Happiness> B;
        for (int i = 0; i < n; ++i) {
            int a, b; cin >> a >> b;
            Happiness h {a, b, i};
            A.push_back(h);
            B.push_back(h);
        }

        sort(A.begin(), A.end(), cmp);

        sort(B.begin(), B.end(), cmp );

        set<int> visited; int aIndex = 0, bIndex = 0;
        long long ans = 0LL;
        while (aIndex < n && bIndex < n && visited.size() < n) {
            while (aIndex < n) {
                const Happiness& h = A[aIndex];
                if (visited.find(h.index) != visited.end()) { aIndex++; continue; }
                ans += h.a;
                visited.insert(h.index);
                break;
            }
            while (bIndex < n) {
                const Happiness& h = B[bIndex];
                if (visited.find(h.index) != visited.end()) { bIndex++; continue; }
                ans -= h.b;
                visited.insert(h.index);
                break;
            }
            aIndex++;
            bIndex++;
        }
        cout << ans << endl;
    }
};


int main() {
    CDifferentStrokes solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main(){
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a/b;
	r = a%b;
	f = (double)a / (double)b;
	printf("%d %d %f", d ,r ,f);

return 0;
}

Measured memory_bytes: 1184
//@HelloElwin-20190817
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int main() {
	
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", max(a + b, max(a - b, a * b)));

	return 0;
}

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

int main(){
    vector<int> a(3) ;
    cin >> a.at(0) >> a.at(1) >> a.at(2) ;
    sort(a.begin() ,a.end()) ;
    if (a.at(0) == 5 && a.at(1) == 5 && a.at(2) == 7)
    {
        cout << "YES" << endl ;
    }
    else
    {
        cout <<"NO" << endl ;
    }
    
    

}

Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

n,x_ = map(int, input().split())
x = list(map(int, input().split()))
x.append(x_)
sa = [abs(x[i+1]-x[i]) for i in range(n)]
d = reduce(lambda a,b:gcd(a,b),sa)
print(d)

Measured memory_bytes: 16308
import math

a,b,x=map(int,input().split())
h= x/a**2

if b < 2 * h:
  print(math.atan(2*(b-h)/a) / math.pi * 180)
else:
  print((math.pi/2 - math.atan(2*x/a/b**2)) / math.pi * 180)


Measured memory_bytes: 2940
#include <stdio.h>

#define REM 1000000007

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

long long nck(long long n, long long k) {
  long long result = n;
  for (int i = 2; i <= k; i++) {
    result = result * modinv(i, REM) % REM;
    result = result * (n-i+1);
    // printf("(%d / %d)", n-i+1, i);
    result %= REM;
  }
  return result;
}

int main(void) {
  //COMinit();
  long long n, a, b;
  scanf("%lld %lld %lld", &n, &a, &b);
  long long r = modpow(2, n, REM);
  r -= 1;
  r = (r - nck(n, a)) % REM - nck(n, b);
  r = r % REM;
  r = r < 0 ? r + REM : r;
  printf("%lld\n", r);
  return 0;
}

Measured memory_bytes: 128
def larger(x, y):
	if x > y:
		return x
	return y

H, W = map(int, input().split())
field = []
for i in range(0, H):
	field.append(input())
upper = []
down = []
left = []
right = []
for i in range(0, H):
	lst1 = []
	lst2 = []
	lst3 = []
	lst4 = []
	for j in range(0, W):
		lst1.append(0)
		lst2.append(0)
		lst3.append(0)
		lst4.append(0)
	upper.append(lst1)
	down.append(lst2)
	left.append(lst3)
	right.append(lst4)
for i in range(0, H):
	cnt1 = 0
	cnt2 = 0
	for j in range(0, W):
		if field[i][j] == '#':
			cnt1 = 0
		else:
			left[i][j] = cnt1
			cnt1 += 1
		if field[i][-1-j] == '#':
			cnt2 = 0;
		else:
			right[i][-1-j] = cnt2
			cnt2 += 1
for i in range(0, W):
	cnt1 = 0
	cnt2 = 0
	for j in range(0, H):
		if field[j][i] == '#':
			cnt1 = 0
		else:
			upper[j][i] = cnt1
			cnt1 += 1
		if field[-1-j][i] == '#':
			cnt2 = 0
		else:
			down[-1-j][i] = cnt2
			cnt2 += 1
max = 0
for i in range(0, H):
	for j in range(0, W):
		if field[i][j] == '.':
			lamp = upper[i][j] + down[i][j] + left[i][j] + right[i][j] + 1
			max = larger(max, lamp)
print(max)

Measured memory_bytes: 185476
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

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

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

bool query(vector<ll> v){
  printf("?");
  YYS(w, v){
    printf(" %lld", w + 1);
  }
  printf("\n");
  fflush(stdout);
  string ans = stin();
  if(ans == "Red"){
    return true;
  }
  return false;
}

bool query(ll a, ll b, ll c = 0, ll d = 0, ll e = 0, ll f = 0){
  vector<ll> v(0);
  FOR(i, a, b){
    v.pb(i);
  }
  FOR(i, c, d){
    v.pb(i);
  }
  FOR(i, e, f){
    v.pb(i);
  }
  return query(v);
}

int main(){

  ll n = in();

  bool base = query(0, n);

  ll lb = 0, ub = n;
  while(ub - lb > 1){
    ll md = (lb + ub) / 2;
    if(query(0, n - md, n, n + md) != base){
      ub = md;
    } else {
      lb = md;
    }
  }

  vector<bool> ans(2 * n);
  FOR(i, n-ub, n){
    ans[i] = query(0, n-ub, n, n+lb, i, i+1);
  }
  FOR(i, n+lb, 2 * n){
    ans[i] = query(0, n-ub, n, n+lb, i, i+1);
  }
  FOR(i, 0, n-ub){
    ans[i] = query(n-lb, n, n+ub, 2*n, i, i+1);
  }
  FOR(i, n, n +lb){
    ans[i] = query(n-lb, n, n+ub, 2*n, i, i+1);
  }

  printf("! ");
  REP(i, 2*n){
    if(ans[i]){
      printf("R");
    } else {
      printf("B");
    }
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 724
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
from collections import deque

n = int(stdin.readline())
dll = deque()
fcode = ord('F')
lcode = ord('L')
while n:
    n -= 1
    cmd = stdin.readline().rstrip()
    if cmd.startswith('i'):
        dll.appendleft(int(cmd[7:]))
    elif cmd.startswith('d'):
        c = ord(cmd[6])
        if c == fcode:
            dll.popleft()
        elif c == lcode:
            dll.pop()
        else:
            try:
                dll.remove(int(cmd[7:]))
            except ValueError:
                pass
print(*dll)

Measured memory_bytes: 39920
import sys

def solve(a,n):
    m = a[-1]+1
    ava = [0]*m
    for rep in a:
        ava[rep] += 1
        if ava[rep]:
            for i in range(2*rep,m,rep):
                ava[i] += 2
    return ava.count(1)
 
if __name__=='__main__':
    n = int(sys.stdin.readline().rstrip())
    a = list(map(int,sys.stdin.readline().rstrip().split()))
    a.sort()
    print(solve(a,n))

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}

signed main(){
    int n ; cin >> n ;
    v<int> a(n), b(n) ;
    for( int i = 0 ; i < n ; i++ ) cin >> a[i] ;
    for( int i = 0 ; i < n ; i++ ) cin >> b[i] ;
    int prev = -1, j = 0 ;
    for( int i = 0 ; i < n ; i++ ){
        if( a[i] != prev ) j = 0 ;
        if( a[i] == b[i] ){
            for( ; j < n ; j++ ){
                if( a[i] != b[j] && a[j] != b[i] ){
                    swap( b[i], b[j] ) ;
                    break ;
                }
            }
            if( a[i] == b[i] ) {
                cout << "No" ; return 0 ;
            }
        }
        prev = a[i] ;
    }
    cout << "Yes" << endl ;
    for( int i = 0 ; i < n ; i++ ) cout << b[i] << " " ;
    return 0 ;   
}          

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

const int MOD = 1e9 + 7;
const int N = 200 + 5;

typedef vector<vector<int>> maze;
int n, m, k;
int ans = 0, cur;
int pw2[N];
bool no_vanish;

void vanish(maze& a, int stage) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (a[i][j] == 0) continue;
            int ptr = j;
            while (a[i][j] == a[i][ptr] && ptr < m) ptr += 1;
            if (ptr - j >= k) {
                for(int u = j; u < ptr; u++) {
                    cnt += a[i][u];
                    a[i][u] = 0;
                }
            }
            j = ptr - 1;
        }
    }
    if (cnt > 0) no_vanish = false;
    cur += pw2[stage] * cnt;
}

void reshape(maze& a) {
    for (int j = 0; j < m; j++) {
        vector<int> x;
        for (int i = n - 1; i >= 0; i--) {
            if (a[i][j] == 0) continue;
            x.push_back(a[i][j]);
        }
        int ptr = n - 1;
        for (int y : x) {
            a[ptr--][j] = y;
        }
        for (int i = 0; i <= ptr; i++) {
            a[i][j] = 0;
        }
    }
}

void proc(int x, int y, maze a) {
    a[x][y] = 0;
    int stage = 0;
    while(true) {
        no_vanish = true;
        reshape(a);
        // for (int i = 0; i < n; i++) {
        //     for (int j = 0; j < m; j++) {
        //         cout << a[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        vanish(a, stage++);
        // for (int i = 0; i < n; i++) {
        //     for (int j = 0; j < m; j++) {
        //         cout << a[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        if (no_vanish == true) break;
        //cout << cur << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m >> k;
    pw2[0] = 1;
    for (int i = 1; i < 29; i++) {
        pw2[i] = pw2[i - 1] * 2;
    }
    maze ini = maze(n, vector<int> (m, 0));
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            ini[i][j] = s[j] - '0';
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cur = 0;
            proc(i, j, ini);
            ans = max(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
   int n,x; cin>>n>>x;
   vector<int> d(n+1);
   d[0]=0;
   for(int i=0;i<n;i++){
      int x; cin>>x;
      d[i+1] = d[i]+x;
   }
   int ans=0;
   for(int i=0;i<n+1;i++){
      if(d[i]<=x){
         ans++;
      }
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
N = int(input())
H = input().split()

Move = 0
tmp = 0
for i in range(N-1):
    if int(H[i+1]) > int(H[i]):
        if Move <= tmp:
            Move = tmp
        tmp = 0
        
    else:
        tmp += 1     

if Move < tmp:
    Move = tmp

print(Move)

Measured memory_bytes: 11132
#include<bits/stdc++.h>
#define lli long long int 
#define pb push_back
#define MAX 1e18

using namespace std;

int main(){
	lli n;
	cin>>n;
	lli arr[2*n];
	lli ans = 0;
	for(int i=0;i<2*n;i++){
		cin>>arr[i];
	}
	sort(arr,arr+2*n);
	for(int i=0;i<2*n;i = i+2){
		ans+=arr[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int x[n],y[n],h[n];
    rep(i,n)cin>>x[i]>>y[i]>>h[i];
    rep(i,101)rep(j,101){
        int ok=true;
        int H=0;
        rep(k,n){
            if(h[k]!=0)H=h[k]+abs(x[k]-i)+abs(y[k]-j);
        }
        rep(k,n){
            if(max(H-abs(x[k]-i)-abs(y[k]-j),0)!=h[k])ok=false;
        }
        if(ok)cout<<i<<" "<<j<<" "<<H<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 20

int judge(int,int);
int n;
int A[N];

int main(){
  int q,B;
  int i;  
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
  scanf("%d",&B);
  if(judge(0,B)==1) printf("yes\n");
  else printf("no\n");
}
  return 0;
}

int judge(int factor,int m){
  int re_num;
  if(m==0) return 1;
  if(factor>=n) return 0;
  re_num=judge(factor+1,m)||judge(factor+1,m-A[factor]);
  return re_num;
}

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

using namespace std;

using ll = long long;

struct _IN {
    _IN() {
        ios::sync_with_stdio(0);
        cin.tie(0);
    }
    template <typename T>
    operator T() const {
        T x;
        cin >> x;
        return x;
    }
    template <typename Container>
    void operator()(Container& c) {
        for (auto& x : c)
            cin >> x;
    }
} IN;

const ll MAX = 1000000000000000000ll;

int main() {
    int N = IN;
    vector<ll> As(N);
    IN(As);
    ll ans = 1;
    for (auto a : As) {
        if (a == 0) {
            ans = 0;
            break;
        }
        if (ans * a > MAX || ans * a < ans) {
            ans = -1;
        } else {
            ans *= a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3988
#include <stdio.h>

void cmp(int *a, int *b) {
	int s;
	if (*a >*b) {
		s = *a;
		*a = *b;
		*b = s;
	}
	return;
}

int main(void)
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	cmp(&a, &b);
	cmp(&b, &c);
	cmp(&a, &b);
	printf("%d %d %d\n", a, b, c);
	return 0;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    string s;
    int K;
    cin >> s;
    cin >> K;
    int n = s.size();
    vector<string> v;
    FOR(l, 1, 6) {
        REP(p, n - l + 1) {
            v.push_back(s.substr(p, l));
        }
    }
    sort(v.begin(), v.end());
    unique(v.begin(), v.end());
    cout << v[K - 1] << endl;
    return 0;
}


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

int main ()
{
    int64_t ans;
    int64_t n, m;
    cin >> n >> m;

    vector<int64_t> a;
    int64_t i;
    int64_t tmp;
    for (i = 0; i < n; ++i)
    {
        cin >> tmp;
        a.push_back(tmp);
    }

    vector<pair<int64_t, int64_t>> bc;
    int64_t tmp1, tmp2;
    pair<int64_t, int64_t> tmpp;
    for (i = 0; i < m; ++i)
    {
        cin >> tmp1 >> tmp2;
        tmpp = make_pair(tmp1, tmp2);
        bc.push_back(tmpp);
    }

    sort(a.begin(), a.end());
    sort(bc.begin(), bc.end(), [](const pair<int64_t, int64_t> & x, const pair<int64_t, int64_t> & y){return x.second > y.second;});

    auto aP = a.begin();
    int64_t j;
    bool flagLoopOut = false;
    for (auto && item : bc)
    {
        for (j = 0; j < item.first; ++j)
        {
            if (aP == a.end())
            {
                flagLoopOut = true;
                break;
            }
            if (item.second > *aP)
            {
                *aP = item.second;
                ++aP;
            }
            else
            {
                flagLoopOut = true;
                break;
            }
        }
        if (flagLoopOut)
        {
            break;
        }
    }

    ans = 0;
    for (i = 0; i < n; ++i)
    {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<int> twonum(n,0), fivenum(n,0);
    REP(i, n) {
        double tmp;
        cin >> tmp;
        tmp *= 1e9;
        a[i] = llround(tmp);
        ll now = a[i];
        while (now > 0) {
            if (now % 2 != 0) break;
            twonum[i]++;
            now /= 2;
        }
        now = a[i];
        while (now > 0) {
            if (now % 5 != 0) break;
            fivenum[i]++;
            now /= 5;
        }
        twonum[i] = min(twonum[i], 18);
        fivenum[i] = min(fivenum[i], 18);
    }
    vector<vint> facts(19, vint(19, 0));
    REP(i, n) {
        facts[twonum[i]][fivenum[i]]++;
    }
    IREP(i, 19) {
        IREP(j, 19) {
            if (j+1 <= 18) facts[i][j] += facts[i][j+1];
            if (i+1 <= 18) facts[i][j] += facts[i+1][j];
            if (i+1 <= 18 && j+1 <= 18) facts[i][j] -= facts[i+1][j+1];
        }
    }
    ll ans = 0;
    REP(i, n) {
        ll nec_two = 18 - twonum[i], nec_five = 18 - fivenum[i];
        ans += facts[nec_two][nec_five];
        if (nec_two <= twonum[i] && nec_five <= fivenum[i]) {
            --ans;
        }
    }
    ans /= 2;
    cout << ans << endl;
}

int main() {
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 6424
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] a = new int[7][2];
		for(int i = 0; i < 7; i++)
			for(int u = 0; u < 2; u++)
				a[i][u] = sc.nextInt();
		
		for(int i = 0; i < 7; i++)
			System.out.println(a[i][0] - a[i][1]);
		}
	}

Measured memory_bytes: 17172
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}
const ll MOD = 1000000007;

int main()
{
    char a[50];
    cin >> a;
    int ans = 700;
    rep(i, 3){
        if(a[i] == 'o'){
            ans += 100;
        }
    }
    cout << ans << endl;
    system("pause");
    return 0;    
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int n,x,y,z;
ll dp[44][1<<18];

int main(){
  cin>>n>>x>>y>>z;

  ll mask=0;
  mask|=(1<<z);
  mask|=(1<<(z+y));
  mask|=(1<<(z+y+x));
  
  ll checker=1<<(x+y+z+1);
  checker--;
  dp[0][1]=1;

  for(int i=0;i<n;i++){
    for(int S=0;S<checker;S++){
      for(int k=1;k<=10;k++){
        int nextS=((S<<k)&checker)+1;
        if((nextS&mask)==mask) continue;

        dp[i+1][nextS]+=dp[i][S];
        dp[i+1][nextS]%=MOD;
      }
    }
  }

  ll ans=1;
  for(int i=1;i<=n;i++){
    ans*=10;
    ans%=MOD;
  }

  for(int i=0;i<checker;i++){
    ans-=dp[n][i];
    ans%=MOD;
  }

  cout<<(ans+MOD)%MOD<<endl;

  return 0;
}


Measured memory_bytes: 84224
#include <stdio.h>

int main(void)
{
	int n, m, tun, max;
	int in, out;
	int i;
	
	scanf("%d %d", &n, &m);
	tun = max = m; 
	for (i = 0; i < n; i++){
		scanf("%d %d", &in, &out);
		tun += in;
		tun -= out;
		if (tun < 0){
			printf("0\n");
			return (0);
		}
		if (max < tun){
			max = tun;
		}
	}
	
	printf("%d\n", max);
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define For(i, begin, end) for(int i=begin;i<end;i++)
#define Rep(i, n) For(i,0,n)
#define Sort(v) sort(v.begin(),v.end())
using namespace std;

int main(){
  int N;cin>>N;
  if(N==1){
    cout<<"Hello World";
  }else{
    int a,b;cin>>a>>b;
    cout<<a+b;
  }
  return 0;
}

Measured memory_bytes: 256
/*
 * zyrch - Rupanshu Yadav
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 1e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
	a %= mo;
	if(a < 0) a+=mo;
	return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
	return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}

//=========================CODE STARTS HERE=============================//

int main() {
	
	ll n, m;
	cin >> n >> m;
	
	cout << (n * (n - 1))/2 + (m * (m- 1))/2 << endl;
	
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int h,n;
  cin >> h >> n;
  vector<pp> ab(n);
  int max_a = 0;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    max_a = max(max_a,a);
    ab.at(i) = make_pair(a,b);
  }
  h += max_a;
  vector<vector<ll>> dp(n,vector<ll>(h+1,0));
  rep(i,h+1) dp.at(0).at(i) = ab.at(0).second * ((i+ab.at(0).first-1)/ab.at(0).first);
  for(int i=1;i<n;i++)rep(j,h+1){
    if(j < ab.at(i).first){
      dp.at(i).at(j) = dp.at(i-1).at(j);
    }else{
      dp.at(i).at(j) = min(dp.at(i-1).at(j),dp.at(i).at(j-ab.at(i).first)+ab.at(i).second);
    }
  }
  /*rep(i,n){
    rep(j,h+1) cout << dp.at(i).at(j) << " ";
    cout << endl;
  }*/
  ll ans = INF;
  for(int i=h-1;i>=h-max_a;i--) ans = min(ans,dp[n-1][i]);
  cout << ans << endl;                         
  return 0;
}




Measured memory_bytes: 87936
N = gets.chomp.to_i

if N == 100000
  p 90000 + 900 + 9
elsif N <= 99999 && N >= 10000
  p (N - 9999) + 900 + 9
elsif N <= 9999 && N >= 1000
  p 900 + 9
elsif N <= 999 && N >= 100
  p (N - 99) + 9
elsif N <= 99 && N >= 10
  p 9
else
  p N
end


Measured memory_bytes: 1788
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct AC{
	int x,y;	
}a[101101];
int cmp(AC x,AC y){
	return x.y<y.y;	
}
int main(){
	int x,y,n;
	scanf("%d",&n);
	for (int i=1; i<=n; i++){
		scanf("%d%d",&x,&y);
		a[i].x=x-y,a[i].y=x+y;
	}
	sort(a+1,a+1+n,cmp);
	int Now=a[1].y,ans=1;
	for (int i=2; i<=n; i++)
		if (Now<=a[i].x)	Now=a[i].y,ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024