akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vi s(n), t(n), x(n);
    rep(i, n) cin >> s[i] >> t[i] >> x[i];
    vi d(q);
    rep(i, q) cin >> d[i];

    vi xs;
    
    auto compress = [&](vi &x) {
        rep(i_, q) {
            xs.push_back(x[i_]);
        }
        sort(all(xs));
        xs.erase(unique(all(xs)), xs.end());
        rep(i_, q) {
            x[i_] = lower_bound(all(x), x[i_]) - x.begin();
        }
    };
    
    compress(d);
    
    int D = xs.size();

    vvi kk(2, vi(D, INT_MAX));
    rep(i, n) {
        s[i] -= x[i];
        t[i] -= x[i];
    }
    vector<P> S(n), T(n);
    rep(i, n) {
        S[i] = P(s[i], x[i]);
        T[i] = P(t[i], x[i]);
    }
    sort(all(S));
    sort(all(T));

    int si = 0, ti = 0;
    multiset<int> se;
    rep(i, D) {
        while(si < n and S[si].first <= xs[i]) {
            se.emplace(S[si++].second);
        }
        while(ti < n and T[ti].first <= xs[i]) {
            se.erase(se.find(T[ti++].second));
        }
        if(!se.empty()) cout << *se.begin() << '\n';
        else cout << -1 << '\n';
    }
}

Measured memory_bytes: 21108
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#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
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, m;
  cin >> n >> m;
  int v;
  bool ok = true;
  vector<int> vec;
  int s = 0;
  for (int i = 0; i < n; i++) {
    cin >> v;
    s += v;
    vec.pb(v);
  }
  int x = m;
  for (auto it : vec) {
    m -= (it * 4 * x >= s);
    if (m == 0) break;
  }
  if (m) ok = false;
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 #define ll  long long int
 //ll ans=INT_MAX,x=INT_MAX,y=INT_MAX;
 ll n,k,x=0;
 ll dp[100001][101];
ll fn(ll k, ll i, ll w[], ll v[])
{
    
    if(k<0)
    return INT_MIN;
    
    
    if(i<=-1)
    return 0;
    
    if(dp[k][i]!=-1)
    return dp[k][i];
    
    ll x=0;
    x=max((fn(k-w[i],i-1,w,v)+v[i]),fn(k,i-1,w,v));
    dp[k][i]=x;
   
    return x;
}
int main(){

//int n;
cin>>n>>k; 
ll w[n],v[n];
for(ll i=0; i<n; i++)
cin>>w[i]>>v[i];
for(ll i=0; i<=k; i++)
for(ll j=0 ; j<=n; j++)
dp[i][j]=-1;
ll ans=fn(k,n-1,w,v);
cout<<ans;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> inline void read(T &x){
	x=0;ll f=1;
	char ch = getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-f;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=x*10+ch-48;
		ch=getchar();
	}
	x=x*f;
}
int main(){
	int t;
	cin>>t;
	bool ok=true;
	for(int i=1;i<=t;i++)
	{
		if(floor((double)i*1.08)==t)
		{
			ok=false;
			cout<<i;
			break;
		}
	}
	if(ok) cout<<":(";
	return 0;
} 


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,b;
	cin>>a>>b;
	string s;
	cin>>s;
	s[b-1]-='A'-'a';
	cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll a,b,c,d;

int main(){
  ll ans=0;
  cin>>a>>b>>c>>d;

  for(ll i=0;i<200;i++){
    c-=b;
    if (c<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
    a-=d;
    if (a<=0){
      cout<<"No"<<endl;
      return 0;
    }
    
  }
  return 0;
}

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

int PON(vector<int>a){
  int count = 0;
  int size = a.size();
  for(int i = 0; i < size - 1; ++i){
    if(a.at(i) != a.at(i + 1)) ++count;
  }
  return count;
}
  
int main(){
  int N;
  cin >> N;
  vector<int>a(N + 1);
  for(int i = 0; i < N; ++i) cin >> a.at(i);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int count = PON(a);
  cout << count << endl;
}
  

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

typedef struct dice{
  int pip[6];
  int top, front, right;
}Dice;

Dice *createDice(int *a);             /* ?????????????????? */
int DiceRight(Dice D, int t, int f);  /* ????????????????????´?????°??? */
int checkDice(Dice D1, Dice D2);      /* ?????????????????????????????? */


int main(void){
  Dice *D[100];
  int i, j, k = 0, n, a[6];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < 6; j++){
      scanf("%d", &a[j]);
    }
    D[i] = createDice(a);
  }
  for(i = 0; i < n-1; i++){
    for(j = i+1; j < n; j++){
      if(checkDice(*D[i], *D[j]) != 0){
        k++;
        break;
      }
    }
  }
  if(k == 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  for(i = 0; i < n; i++){
    free(D[i]);
  }
  return 0;
}


Dice *createDice(int *a){
  Dice *p;
  int i;

  p = (Dice *)malloc(sizeof(Dice));
  if(p == NULL){
    printf("?????¢????¢??????¨??????\n");
    return NULL;
  }
  for(i = 0; i < 6; i++){
    p->pip[i] = a[i];
  }
  p->top = 0;
  p->front = 1;
  p->right = 2;
  return p;
}

int DiceRight(Dice D, int t, int f){
  static int check[6][6] = {{-1, 2, 4, 1, 3, -1},
			    {3, -1, 0, 5, -1, 2},
			    {1, 5, -1, -1, 0, 4},
			    {4, 0, -1, -1, 5, 1},
			    {2, -1, 5, 0, -1, 3},
			    {-1, 3, 1, 4, 2, -1}};
  return D.pip[check[t][f]];
}


int checkDice(Dice D1, Dice D2){
  int i, j, s = 0, c[6] = {-1,-1,-1,-1,-1,-1};

  for(i = 0; i < 3; i++){
    for(j = 0; j < 6; j++){
      if(c[j] == -1 && c[5-j] == -1){
	if(D1.pip[i] == D2.pip[j] && D1.pip[5-i] == D2.pip[5-j]){
	  s++;
	  c[j] = i;
	  c[5-j] = 5-i;
	  break;
	}
      }
    }
  }
  if(s != 3){
    return 0;
  }
  if(DiceRight(D2, c[0], c[1]) != D2.pip[c[2]]){
    return 0;
  }
  return 1;
}

Measured memory_bytes: 584
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAX_M = 10000;

int N, M;
int r, q;
int use[MAX_M][1261];

int main() {
	while (true) {
		cin >> N >> M;
		if (N == 0) {
			break;
		}
		//cout << "check1" << endl;
		
		int usePc[M+1]; // 使用しているPCの数
		int useLastStart[M+1]; // 最後に使用し始めた時間
		//int useTime[M+1]; // 使用時間
		memset(use, 0, sizeof(use));
		memset(usePc, 0, sizeof(usePc));
		memset(useLastStart, 0, sizeof(useLastStart));
		//memset(useTime, 0, sizeof(useTime));
		
		
		cin >> r;
		for (int i = 0; i < r; i++) {
			int t, n, m, s;
			cin >> t >> n >> m >> s;
			if (s == 1) {
				// ログイン
				if (usePc[m] == 0) {
					useLastStart[m] = t;
				}
				usePc[m]++;
			} else {
				// ログアウト
				usePc[m]--;
				if (usePc[m] == 0) {
					for (int j = t - 1; j >= useLastStart[m]; j--) {
						use[m][j] = 1;
					}
				}
			}
		}
		//cout << "check2" << endl;
		cin >> q;
		for (int i = 0; i < q; i++) {
			int ts, te, m;
			int ans = 0;
			cin >> ts >> te >> m;
			
			for (int j = ts; j < te; j++) {
				if (use[m][j] == 1) {
					ans++;
				}
			}
			cout << ans << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 50496
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n,w;
cin >> n >> w;
vector<i64> weight(n),value(n);
rep(i,n){
    cin >> weight[i] >> value[i];
}
vector<i64> dp(w + 1,0);
dp[0] = 0;
rep(i,n) {
    for (i64 j = w; 0 < j; j--) {
        if(j - weight[i] >= 0){
            dp[j] = max(dp[j - weight[i]] + value[i],dp[j]);
        }else{
            dp[j] = max(dp[j],dp[j - 1]);
        }
    }
}

cout << dp[w] << endl;
}

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

int w[110], v[110];
long long dp[100010];

int main(){
	int n, W;
	scanf("%d%d", &n, &W);
	for (int i = 0; i < n; i++){
		scanf("%d%d", &w[i], &v[i]);
	}
	for (int i = 0; i < n; i++){
		for (int j = W; j >= w[i]; j--){
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}
	printf("%lld\n", dp[W]);
	return 0;
}


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

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

template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

const int INF = INT_MAX / 2;

typedef vector<int> Edges;
typedef vector<Edges> Graph;

Graph g;
vector<int> ord;
vector<bool> visited;

void dfs(int cur) {
  //  cout << cur << endl;
  visited[cur] = true;
  REP(i, g[cur].size()) {
    int nxt = g[cur][i];
    if(visited[nxt] == false) {
      dfs(nxt);
    }
  }
  ord.push_back(cur);
  return;
}

int main() {
  int N, M; cin>>N>>M;
  g = Graph(N);
  visited = vector<bool>(N, false);
  REP(i,M) {
    int src, dst;
    cin>>src>>dst;
    src--; dst--;
    g[src].push_back(dst);
  }
  REP(i,N) {
    if(visited[i]  == false) {
      dfs(i);
    }
  }
  reverse(ord.begin(), ord.end());
  vector<int> rev(N);
  REP(i,N) rev[ord[i]] = i;
  //  pp(ord, ord.size());
  //  pp(rev, rev.size());
  int ans = 0;
  vector<int> dp(N, 0);
  for(int i = 0; i < N; i++) {
    int cur = ord[i];
    REP(j, g[cur].size()) {
      int nxt = g[cur][j];
      int idx = rev[nxt];
      //      cout << cur+1 << "->" << nxt+1 << " " << idx << endl;
      chmax(dp[idx], dp[i] + 1);
      chmax(ans, dp[idx]);
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

  int rem = S + 1;
  if( S == 1000000000 ) rem = 1;
  vector<int> A(N, S + 1);
  for (int i = 0; i < K; i++) cout << S << ' ';
  for (int i = K; i < N; i++) cout << rem << ' ';
  cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int n,k;
    cin >> n >> k;
    int in;
    rep(i,n)cin >> in;
    cout << ceil(double(n-1)/(k-1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <math.h>
using namespace std;

typedef long long ll;

int main(void){
    ll n;
    ll ans = 0;
    cin >> n;
    ans = n-1;
    for(ll i=1;i<=n&&i<=1000000;i++){
        if(n%i==0){
            ll x = i + n/i - 2;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  gzhffIThh
 *    created: 19.08.2020
**/
#include <bits/stdc++.h>

using namespace std;

const int N=200010;

char s[N];

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int tmp=0;
  scanf("%s",s+1);
  for(int i=1;i<=strlen(s+1);i++)tmp=(tmp+s[i]-'0')%9;
  if(tmp==0)printf("Yes\n");
	else printf("No\n");

  return 0;
}


Measured memory_bytes: 3972
use std::collections::BTreeSet;
use std::collections::BinaryHeap;

fn main() {
    use proconio::input;
    use proconio::marker::Usize1;
    input!(h: usize, w: usize);
    input!(m: usize);
    let mut bb = BTreeSet::new();
    for _ in 0..m {
        input!(a: Usize1, b: Usize1);
        bb.insert((a, b));
    }
    let mut h_cnt = vec![0; h];
    let mut w_cnt = vec![0; w];
    for &(x, y) in bb.iter() {
        h_cnt[x] += 1;
        w_cnt[y] += 1;
    }
    let (x_max, hs) = {
        let mut xh = BinaryHeap::new();
        for (x, &cnt) in h_cnt.iter().enumerate() {
            xh.push((cnt, x));
        }
        let mut hs = Vec::new();
        let (x_max, x) = xh.pop().unwrap();
        hs.push(x);
        while let Some((tmp, xx)) = xh.pop() {
            if tmp == x_max {
                hs.push(xx);
            } else {
                break;
            }
        }
        (x_max, hs)
    };
    let (y_max, ws) = {
        let mut yh = BinaryHeap::new();
        for (y, &cnt) in w_cnt.iter().enumerate() {
            yh.push((cnt, y));
        }
        let mut ws = Vec::new();
        let (y_max, y) = yh.pop().unwrap();
        ws.push(y);

        while let Some((tmp, yy)) = yh.pop() {
            if tmp == y_max {
                ws.push(yy);
            } else {
                break;
            }
        }
        (y_max, ws)
    };

    let mut found = false;
    'l: for xx in hs {
        for &yy in ws.iter() {
            if !bb.contains(&(xx, yy)) {
                found = true;
                break 'l;
            }
        }
    }
    let ans = x_max + y_max;

    if found {
        println!("{}", ans);
    } else {
        println!("{}", ans - 1);
    }
}


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

int main(){
	int n;
	
	scanf("%d",&n);
	
	if((n/100)==7||(n/10)%10==7||n%10==7){
		printf("Yes");
	}else{
		printf("No");
	}
	
	return 0;
}

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

using namespace std;

int main()
{
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    uint64_t total = 0;
    for(int i=0; i<K && i<N; i++)
        total += X;
    for(int i=K; i<N; i++)
        total += Y;
    cout << total << endl;
}


Measured memory_bytes: 764
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
if n % 1000 == 0:
    print(0)
else:
    print(1000-(n%1000))

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

int main(){
	int a,b;
  	string c = "";
  	string d = "";
  cin>>a>>b;
  
	for(int i = 0; i < a; i++) {
  		c += (char) b + '0';
  	}
	for(int i = 0; i < b; i++) {
      	d += (char) a + '0';
    }
  if(c>=d){
    cout<<d;
  }
  else{ 
    cout<<c;
  }
}

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

int signos[10];
string s;
long long int sum = 0;

long long int conver(string s){
  long long int res = 0;
  for(int i = 0; i < s.length(); i++){
    string aux = "";
    aux += s[i];
    stringstream geek(aux);
    int x = 0;
    geek >> x;
    res *= 10;
    res += x;
    //cout<<res<<endl;
    // += (10*(long long int)x);
  }
  string aux = "";
  aux += s[s.length() - 1];
  stringstream geek(aux);
  int x = 0;
  geek >> x;
  //res += x;
  return res;
}

void sumarPe(){
  int i = 0;
  string aux = "";
  while(i<s.length()){
    aux += s[i];
    if(signos[i] == 1){
      sum += (long long int)conver(aux);
      //cout<<(long long int)x<<"+";
      aux = "";
    }
    i++;
  }
  stringstream geek(aux);
  long long int x = 0;
  geek >> x;
  sum += (long long int)conver(aux);
  aux = "";
  //cout<<(long long int)x<<endl;
}
void printUnos(){
  for(int i = 0; i < s.length() - 1; i++){
    cout<<signos[i];
  }
  cout<<endl;
}

void back(int indice){
  if(signos[indice] == 0){
    signos[indice] = 1;
    sumarPe();
    //printUnos();
    for (int i = indice+1; i < s.length() - 1; i++){
			back(i);
		}
    signos[indice] = 0;
  }
}




int main(){
  cin>>s;
  for (int i = 0; i < s.length() - 1; i++){
		back(i);
	}
  long long int x = conver(s);
  //cout<<x<<endl;
  sum += (long long int)x;

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


Measured memory_bytes: 256
#coding:utf-8

def count(seq, is_positive):
    operation = 0
    sum = 0
    for i in range(n):
        sum += seq[i]
        if sum == 0:
            operation += 1
            if is_positive:
                sum -= 1
            else:
                sum += 1
        elif sum > 0 and is_positive:
            operation += abs(sum) + 1
            sum = -1
        elif sum < 0 and not is_positive:
            operation += abs(sum) + 1
            sum = 1

        if sum > 0:
            is_positive = True
        else:
            is_positive = False

    return operation


if __name__ == "__main__":
    n = int(raw_input())
    seq = map(int, raw_input().split(" "))

    print min(count(seq, False), count(seq, True))


Measured memory_bytes: 11248
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            long X = sc.nextLong();
            long goal = 100;
            int count = 0;
        	double av = 0;
            while(goal < X){
              	av = goal / 100;
                goal = goal + (long)(av);
                count++;
            }
            System.out.println(count);
          }
}

Measured memory_bytes: 35824
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#define llint long long
#define mod 1000000007

using namespace std;

llint k, x, y;
llint sgnx, sgny;

void move(llint sx, llint sy, llint tx, llint ty)
{
	llint x = sx, y = sy;
	while(1){
		if(x + k <= tx) x += k;
		else{
			llint d = tx-x;
			y += k-d, x += d;
		}
		cout << sgnx*x << " " << sgny*y << "\n";
		if(x == tx && y == ty) break;
	}
}

int main(void)
{
	cin >> k >> x >> y;
	sgnx = sgny = 1;
	if(x < 0) sgnx = -1; if(y < 0) sgny = -1;
	x = abs(x), y = abs(y);
	
	llint d = x+y, r, ans;
	if(d % 2 && k % 2 == 0){
		cout << -1 << "\n";
		flush(cout);
		return 0;
	}
	if(k > d){
		if(d % 2 == 0){
			ans = 2;
			r = 2*k - d;
		}
		else{
			cout << 3 << "\n";
			r = k - d;
			cout << sgnx*(x+r/2) << " " << sgny*(y+r/2) << "\n";
			cout << sgnx*x << " " << sgny*(k+y) << "\n";
			cout << sgnx*x << " " << sgny*y << "\n";
			flush(cout);
			return 0;
		}
	}
	else{
		if(k % 2 == 0){
			ans = (d+k-1)/k;
			r = (d+k-1)/k*k - d;
		}
		else{
			if(d % 2){
				d -= k;
				ans = (d+2*k-1)/(2*k)*2 + 1;
				r = (d+2*k-1)/(2*k)*(2*k) - d;
			}
			else{
				ans = (d+2*k-1)/(2*k)*2;
				r = (d+2*k-1)/(2*k)*(2*k) - d;
			}
		}
	}
	r /= 2;
	
	cout << ans << "\n";
	if(r == 0){
		move(0, 0, x, y);
		flush(cout);
		return 0;
	}
	
	llint cx, cy;
	if(k-r <= x) cx = k-r, cy = -r;
	else cx = x+r, cy = (k-r)-x;
	
	cout << sgnx*cx << " " << sgny*cy << "\n";
	if(cx > x){
		sgnx *= -1;
		cx *= -1, x *= -1;
	}
	move(cx, cy, x, y);
	flush(cout);
	
	return 0;
}

Measured memory_bytes: 2304
//#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

const int QMAX = 200000;
char T[QMAX], D[QMAX];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, Q;
  cin >> N >> Q;
  cin.ignore();
  string board;
  getline(cin, board);
  REP(i, Q) { cin >> T[i] >> D[i]; }
  int head = -1, tail = N;
  for (int i = Q - 1; i >= 0; --i) {
    char t = T[i];
    if (D[i] == 'L') {
      if (head + 1 < N && t == board[head + 1]) ++head;
      if (tail < N && t == board[tail]) ++tail;
    } else {
      if (tail - 1 >= 0 && t == board[tail - 1]) --tail;
      if (head >= 0 && t == board[head]) --head;
    }
  }
  cout << (tail - head - 1) << endl;
}


Measured memory_bytes: 1104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class ABC
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int ans = int.MaxValue, tmp = 0;
            for(int i = 0; i <= S.Length - 3; i++)
            {
                tmp = Math.Abs(int.Parse(S.Substring(i, 3)) - 753);
                ans = Math.Min(ans, tmp);
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int a[10010];

int f(int l, int r)
{
	int d = 1 + (int)log10(r);
	int res = 1;
	rep(i, 0, d)
	{
		res *= 10;
	}
	return res*l + r;
}

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

	int n;
	cin >> n;
	rep(i, 0, n)cin >> a[i];
	sort(a, a + n);

	int min1 = INF, min2 = INF, min3 = INF;
	rep(i, 0, min(n, 10))rep(j, 0, min(n, 10))
	{
		if (i == j)
		{
			continue;
		}
		int res = f(a[i], a[j]);
		if (res < min3)
		{
			swap(res, min3);
		}
		if (min3 < min2)
		{
			swap(min2, min3);
		}
		if (min2 < min1)
		{
			swap(min2, min1);
		}
	}

	cout << min3 << endl;

	return 0;
}


Measured memory_bytes: 3392
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll prev = 0;
    cin >> prev;
    ll res = 0;
    for(int i=1; i<N; ++i) {
        ll next = 0;
        cin >> next;
        res += min((next - prev) * A, B);
        prev = next;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int n,d,T;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
	//freopen("Cookie Breeding Machine.in","r",stdin);
	//freopen(".out","w",stdout);
	read(T);
	while(T--)
	{
		read(n,d);
		if((n-1)%2==0) printf("%d\n",127*(n-1)+d);
		else printf("%d\n",127*(n-1)+(127^d));
	}
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b[9],sum;
	while(1){
		sum=0;
		cin >> a;
		if(a==0)break;
		for(int i=0;i<9;i++){
			cin >> b[i];
			sum+=b[i];
		}
		cout << a-sum << endl;
	}
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
        cout << "Yes";
    else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
        cout << "Yes";
    else if (s[0] == s[3] && s[1] == s[2] && s[1] != s[0])
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

#define MAX 100
#define MOD 1000000007
#define pi 3.1415926535897932384246433832

#define ll long long
#define ld long double

#define vi vector <int>
#define vll vector<long long>
#define vb vector<bool>

#define vvi vector<vi>
#define vvll vector<vll>

#define all(v) (v).begin(), (v).end()
#define allrev(v) (v).rbegin(), (v).rend()
#define allcomp(v) (v).begin(), (v).end(), comp
#define allrevcomp(v) (v).rbegin(), (v).rend(), comp

#define line cout<<"\n";
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);


void solve(){
    int n,a;
    cin>>n;
    bool accept = true;

    for(int i = 1; i<=n ; i++){
        cin>>a;
        if(a%2 == 0 && accept)
            if(!(a % 3 == 0 || a % 5 == 0)) accept = false;
    }
    if(accept) cout<<"APPROVED";
    else cout<<"DENIED";

}


int main(){
    fast
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int test = 1;
    //cin>>test;
    while(test--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
int main()
{
    int n,t,a,b,c,d,e,flag=0,cnt=0,flag1=0;
    vector<int>vec;
    map<int,int>mp;

     cin>>n;
     double ans=2*pi*n;
     cout<<ans<<endl;
}


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

int main() {
    int N;
    cin >> N;
    int sum = 0, min_s = 1000000000;
    for (int i = 0; i < N; i++) {
        int s;
        cin >> s;
        sum += s;
        if (s % 10 != 0 && s < min_s)
            min_s = s;
    }

    if (sum % 10 == 0) {
        if (min_s == 1000000000) {
            cout << 0 << endl;
        } else {
            cout << sum - min_s << endl;
        }
    } else {
        cout << sum << endl;
    }

    return 0;
}

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

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;

    int cnt = 0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x) ++cnt;
            }
        }
    }
    cout << cnt << endl;
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){
  ll N;
  cin >> N;

  vector<ll> cnt(N, 0), a(N, 0);

  rep(i, 0, N){
    ll ai;
    cin >> ai;
    
    cnt[ai-1]++;
    a[i] = ai;
  }
  ll sum = 0;
  rep(i, 0, N){
    if(cnt[i] > 1){
      sum += cnt[i]*(cnt[i]-1)/2;
    }
  }

  rep(i, 0, N){
    ll ans;
    ans = sum - cnt[a[i]-1]*(cnt[a[i]-1]-1)/2 + (cnt[a[i]-1]-1)*(cnt[a[i]-1]-2)/2;

    cout << ans << endl;
    
  }

  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
int main() {
  int a,b;
  cin>>a>>b;
  int ans=1009;
  bool x=false;
  for(int i=10;i<1010;i++){
  if(i*8/100==a&&i*10/100==b){
  if(ans>i){
    ans=i;
    x=true;
  }
  }
  }
  if(x==true) cout<<ans<<endl;
  if(x==false)cout<<"-1"<<endl;
}

Measured memory_bytes: 256
from itertools import product
A,B,C,D=input().strip()
ops="+-"
for op1,op2,op3 in product(ops,ops,ops):
    if eval(A+op1+B+op2+C+op3+D)==7:
        break
print(A+op1+B+op2+C+op3+D+'=7')

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i ++ ) {
            A[i] = sc.nextLong();
        }

        long res = 0;
        for (int i = 0; i < N; i ++ ) {
            res ^= A[i];
        }
        long[] resArr = new long[N];
        for (int i = 0; i < N; i ++ ) {
            resArr[i] = A[i] ^ res;
        }
        for (int i = 0; i < resArr.length; i ++ ) {
            System.out.print(resArr[i] + " ");
        }

        System.out.println();

    }
}


Measured memory_bytes: 63632
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
int x[100005],y[100005],c[100005];
int n,k;
int num1[2005][2005],num2[2005][2005];
int get1(int a,int b,int c,int d)
{
	if(c<a||d<b) return 0;
	return num1[c][d]+num1[a-1][b-1]-num1[a-1][d]-num1[c][b-1];
}
int get2(int a,int b,int c,int d)
{
	if(c<a||d<b) return 0;
	return num2[c][d]+num2[a-1][b-1]-num2[a-1][d]-num2[c][b-1];
}
int main()
{
	n=read();k=read();int n1=0;
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read();
		x%=2*k;y%=2*k;
		char op[2];
		scanf("%s",op);
		if(op[0]=='W')
		num1[x+1][y+1]++;else 
		{
			n1++;
			num2[x+1][y+1]++;
		}
	}
	for(int i=1;i<=2*k;i++)
	{
		for(int j=1;j<=2*k;j++)
		{
			num1[i][j]+=num1[i][j-1]+num1[i-1][j]-num1[i-1][j-1];
			num2[i][j]+=num2[i][j-1]+num2[i-1][j]-num2[i-1][j-1];
		}
	}
	int ans=0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			int temp=get1(i,j,i+k-1,j+k-1)+get1(i+k,j+k,2*k,2*k)+get1(1,j+k,i-1,2*k)+get1(1,1,i-1,j-1)+get1(i+k,1,2*k,j-1)
			+(n1-get2(i,j,i+k-1,j+k-1)-get2(i+k,j+k,2*k,2*k)-get2(1,j+k,i-1,2*k)-get2(1,1,i-1,j-1)-get2(i+k,1,2*k,j-1));
			ans=max(ans,temp);
			ans=max(ans,n-temp);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 31616
#include <iostream>

int main(){
  int D;
  std::cin>>D;
  if (D==22){
    std::cout<<"Christmas Eve Eve Eve"<<std::endl;
  }
  if (D==23){
    std::cout<<"Christmas Eve Eve"<<std::endl;
  }
  if (D==24){
    std::cout<<"Christmas Eve"<<std::endl;
  }
  if (D==25){
    std::cout<<"Christmas"<<std::endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#define N 800010
using namespace std;
void read(int&x)
{
	x = 0;
	int f = 1;char s = getchar();
	while(s<'0'||s>'9'){if(s=='-')f = -1;s = getchar();}
	while(s>='0'&&s<='9')x = (x<<3)+(x<<1)+s-48,s = getchar();
	x*=f;
}
struct edge{int nxt,to;}o[N];
int n,d1[N],d2[N],head[N],I = 1,ans[N];
void add(int u,int v)
{
	o[++I] = (edge){head[u],v},head[u] = I;
	o[++I] = (edge){head[v],u},head[v] = I;
}
void dfs(int u)
{
	for(int&i = head[u];i;i = o[i].nxt)if(!d1[i/2])
	{
		int v = o[i].to;
		d1[i/2] = 1;
		if(u==v+n)ans[v] = -1;
		else if(v==u+n)ans[u] = 1;
		dfs(v);
	}
}
int main()
{
	read(n);
	for(int i = 1,a;i<=n;i++)read(a),(~a)?(d1[a]^=1,d2[a]^=1,add(i,a)):add(i,2*n+1);
	for(int i = 1,a;i<=n;i++)read(a),(~a)?(d1[a]^=1,add(i+n,a+n)):add(i+n,2*n+1);
	for(int i = 1;i<=n;i++)if(!d2[i])add(i,i+n);
	for(int i = 1;i<=n;i++)if(d1[i])puts("IMPOSSIBLE"),exit(0);
	puts("POSSIBLE");
	dfs(2*n+1);
	for(int i = 1;i<=n;i++)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 19504
def f(n):
    if n % 2 == 0:
        return False
    
    dic = {}
    res = 2
    for i in range(3, n//2 + 1):
        if n % i == 0:
            res += 1
    return res == 8

N = int(input())
if N < 105:
    print(0)
else:
    res = 0
    for n in range(105, N + 1):
        if(f(n)):
            res += 1
    print(res)

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int k,t,a,sum;
vector<int> v;

signed main() {
    cin >> k >> t;
    rep(i,t) cin >> a, v.pb(a);
    sort(all(v));
    rep(i,t-1) sum += v[i];
    cout << max(0LL, v[t-1] - sum - 1) << endl;
}


Measured memory_bytes: 256
import numpy as np

X, Y, A, B, C = map(int, input().split())
p = np.array(tuple(map(int, input().split())))
q = np.array(tuple(map(int, input().split())))
r = np.array(tuple(map(int, input().split())))

p.partition(A - X)
q.partition(B - Y)

pqr = np.concatenate((p[-X:], q[-Y:], r))
pqr.partition(len(pqr) - (X + Y))

ans = sum(pqr[-(X + Y) :])

print(ans)


Measured memory_bytes: 24960
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    int N; cin >> N;
    vi X(N); rep(i,N) cin >> X[i];
    vi Y = X;
    sort(X.begin(), X.end());
    int med[2] = {X[N/2-1], X[N/2]};
    rep(i,N){
        if(Y[i] <= med[0]) cout << med[1] << "\n";
        else cout << med[0] << "\n";
    }

    //cout << (flag?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b, h, m;
    cin>>a>>b>>h>>m;
    double ht=(pi/360)*(h*60+m);
    double mt=(pi/30)*m;
    double ang=fabs(ht-mt);
    if(ang>pi) ang = 2*pi - ang;
    cout<<fixed<<setprecision(12)<<sqrt(a*a+b*b-2.0*a*b*cos(ang))<<"\n";
    return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C,D;
  cin>>A>>B>>C>>D;
 while (true) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

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

// int main(){
//     ios::sync_with_stdio(0);
//     cin.tie(0);
//     cout.tie(0);
//     ll t=1;
//     //cin>>t;
//     while(t--){
//     	int n;
//     	cin>>n;
//     	double d;
//     	ll x;
//     	int num2,num5;
//     	map<pair<int,int>,int> num;
//     	for(int i=0;i<n;i++){
//     		cin>>d;
//     		x=llround(d*1e9);
//     		//cout<<x<<"\n";
//     		num2=0,num5=0;
//     		while(x%2==0) num2++,x/=2;
//     		//cout<<x<<"\n";
//     		while(x%5==0) num5++,x/=5;
//     		num[{num2,num5}]++;
//     	}
//     	int ans=0;
//     	for(auto p1:num){
//     		for(auto p2:num){
//     			if(p1.first.first+p2.first.first>=18 && p1.first.second+p2.first.second>=18){
//     				if(p1<p2) ans+= p1.second*p2.second;
//     				if(p1==p2)ans+=(p1.second*(p2.second-1))/2;
//     			}
//     		}
//     	}
//     	cout<<ans<<"\n";
//     }
// }



#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 100005
 
int num[19][19];
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--){
    	ll n;
    	cin>>n;
    	double d;
    	ll x,y=1000000000;
    	int num2,num5;
    	for(int i=0;i<=18;i++)
    		for(int j=0;j<=18;j++)
    			num[i][j]=0;
    	vector<pair<int,int>> vec;
    	for(int i=0;i<n;i++){
    		cin>>d;
    		x=llround(d*1e9);
    		//cout<<x<<"\n";
    		num2=0,num5=0;
    		while(x%2==0) num2++,x/=2;
    		//cout<<x<<"\n";
    		while(x%5==0) num5++,x/=5;
    		if(num2>18) num2=18;
    		if(num5>18) num5=18;
    		vec.push_back({num2,num5});
    		//cout<<num2<<" "<<num5<<"\n";
    		for(int j=0;j<=18;j++){
    			for(int k=0;k<=18;k++){
    				if(18-num2<=j && 18-num5<=k) num[j][k]++;
    			}
    		}
    	}
    	
    	ll ans=0;
    	for(int i=0;i<n;i++){
    		num2=vec[i].first;
    		num5=vec[i].second;
    		for(int j=0;j<=18;j++){
    			for(int k=0;k<=18;k++){
    				if(18-num2<=j && 18-num5<=k) num[j][k]--;
    			}
    		}
    		ans+=num[num2][num5];
    	}
    	cout<<ans<<"\n";
    }
}

Measured memory_bytes: 5432
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		while(true){
			//Input
			final int w = sc.nextInt(); final int h = sc.nextInt();
			if(w==0 && h==0){ break; }
			final int xs = sc.nextInt(); final int ys = sc.nextInt();
			final int xg = sc.nextInt(); final int yg = sc.nextInt();
			final int n = sc.nextInt();
			int[][] map = new int[h+2][w+2];
			for(int i=0; i<n; ++i){
				final int c = sc.nextInt();  final int d = sc.nextInt();
				final int x = sc.nextInt();  final int y = sc.nextInt();
				for(int ty=y; ty<y+2+2*d; ++ty){
					for(int tx=x; tx<x+2+2*Math.abs(d-1); ++tx){
						map[ty][tx] = c;
					}
				}
			}
			
			//algorithm(BFS)
			boolean f = true;
			final int[][] ofs = {
					{1, 0}, {0, 1}, {-1, 0}, {0, -1}
			};
			Queue<int[]> que = new LinkedList<int[]>();
			int next[] = {xs, ys};
			que.offer(next);
			final int col = map[next[1]][next[0]];
			if(col == 0){
				System.out.println("NG");
				continue;
			}
			map[next[1]][next[0]] = 0;
			while(!que.isEmpty()){
				next = que.poll();
				if(next[0] == xg && next[1] == yg){
					System.out.println("OK");
					f = false;
					break;
				}
				for(int i=0; i<4; ++i){
					if(map[next[1] + ofs[i][1] ][next[0] + ofs[i][0] ] == col){
						final int e[] = {
								next[0] + ofs[i][0], next[1] + ofs[i][1]
						};
						que.offer(e);
						map[e[1]][e[0]] = 0;
					}
				}
			}
			if(f){
				System.out.println("NG");
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
vector<bool>visited;
vector<vector<int>>l;
vector<int>deg;
const int mod=1000000007;
int isprime(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;

}
int isperfectsq(ll n)
{


    long double x;
    x=(long double)(sqrt((long double )(n)));
    ll y=sqrt(n);
    if(x==y)
        return 1;
        else
            return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);


   int n;
   int i;
   cin>>n;
   ll cnt=0;
   vector<ll>a(n,0);
   for(i=0;i<n;i++)
    cin>>a[i];
   sort(a.rbegin(),a.rend());
   cnt+=a[0];i=1;int j=n-2;
   while(true)
   {
       if(j){
       cnt+=a[i];
       j--;
       }
       if(j)
       {
           cnt+=a[i];
           j--;
       }
       if(j==0)
        break;
       i++;
   }
   cout<<cnt;



}










Measured memory_bytes: 4784
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <time.h>

using namespace std;
typedef long long int ll;

int main()
{
	int n;
	scanf("%d", &n);
	int dp[100001];
	int p9[10], p6[10];
	p9[0]=1; p6[0]=1;
	for(int i=1; i<10; i++){
		p9[i]=p9[i-1]*9;
		if(p9[i]>100000){
			break;
		}
	}
	for(int i=1; i<10; i++){
		p6[i]=p6[i-1]*6;
		if(p6[i]>100000){
			break;
		}
	}
	dp[0]=0;
	for(int i=1; i<=n; i++){
		dp[i]=dp[i-1]+1;
		for(int j=1; p9[j]<=i; j++){
			if(dp[i]>dp[i-p9[j]]+1) dp[i]=dp[i-p9[j]]+1;
		}
		for(int j=1; p6[j]<=i; j++){
			if(dp[i]>dp[i-p6[j]]+1) dp[i]=dp[i-p6[j]]+1;
		}
	}
	printf("%d\n", dp[n]);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

const int maxn = 201;
int floyd[maxn][maxn];

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

  int h, w;
  cin >> h >> w;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      cin >> floyd[i][j];
    }
  }
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      for(int k = 0; k < 10; k++){
        floyd[j][k] = min(floyd[j][k], floyd[j][i] + floyd[i][k]);
      }
    }
  }
  int res = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      int x;
      cin >> x;
      res += (x == -1 ? 0 : floyd[x][1]);
    }
  }
  cout << res;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  int connection[11][11];
  rep(i,11)rep(j,11) connection[i][j] = 0;

  for(int i = 0; i < M; i++){
    int k; cin >> k;
    for(int j = 0; j < k; j++){
      int s; cin >> s; s--;
      connection[i][s] = 1;
    }
  }

  vector<int> p(M);
  for(int i = 0; i < M; i++){
    int pT; cin >> pT;
    p[i] = pT;
  }

  int ans = 0;
  for(int bit = 0; bit < (1<<N); bit++){
    vector<int> toOn(M, 0);
    for(int i = 0; i < N; i++){
      if(bit & (1<<i)){
        for(int j = 0; j < M; j++){
          if(connection[j][i] == 1) toOn[j] += 1;
        }
      }
    }
    bool allOn = true;
    for(int j = 0; j < M; j++){
      if(p[j] != toOn[j]%2) allOn = false;
    }
    if(allOn) ans += 1;
  }

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



Measured memory_bytes: 256