akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		scanner.close();
		int[] list = new int[45];
		System.out.println(fibonacci(n, list));
	}

	static int fibonacci(int n, int[] list) {
		
		if (n < 0) {
			return 0;
		}
		if (n == 0 || n == 1) {
			return list[n] = 1;
		}
		if (list[n] != 0) {
			return list[n];
		}
		return list[n] = fibonacci(n - 1, list) + fibonacci(n - 2, list);
	}
}

Measured memory_bytes: 26344
#include<bits/stdc++.h>
#define N 1005
#define M 1001
#define P 30
using namespace std;
typedef long long ll;

int main(){
  int v,d;
  ll f[N];
  vector<ll> F;
  while(cin>>v>>d){
    f[0]=f[1]=1;
    for(int i=2;i<2+v;i++){
      f[i]=(f[i-1]+f[i-2])%M;
      F.push_back(f[i]);
    }
    sort(F.begin(),F.end());
    int ans=0;
    for(int i=1;i<F.size();i++){
      if(abs(F[i]-F[i-1])>=d)ans++;
    }
    cout<<ans+1<<endl;
    F.clear();
  }
  return 0;
}

Measured memory_bytes: 1240
class UnionFind:
    def __init__(self, n=0):
        self.d = [-1]*n
        self.u = n

    def root(self, x):
        if self.d[x] < 0:
            return x
        self.d[x] = self.root(self.d[x])
        return self.d[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return False

        self.u -= 1

        if x > y:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x

        return True

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.d[self.root(x)]

    def num_union(self):
        return self.u


N, M, *X = map(int, open(0).read().split())
X = tuple(zip(*[iter(X)]*3))

uf = UnionFind(N)
for x, y, z in X:
    uf.unite(x-1, y-1)

print(uf.num_union())


Measured memory_bytes: 119292
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 31 21:02:01 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::map<Int, Int> mp;
    for (Int x = 2; x * x <= n; x++) {
        while (n % x == 0) {
            mp[x]++;
            n /= x;
        }
    }
    if (n > 1) mp[n]++;
    Int ans = 0;
    for (auto& p : mp) {
        Int acc = 0;
        REP(x, 1, 1000000000) {
            acc += x;
            dump(acc, p.second);
            if (acc > p.second) break;
            ans++;
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

const ll INF = 2000000000;

struct Rec {
    ll x1, y1, x2, y2;

    Rec(ll x1 = 0, ll y1 = 0, ll x2 = 0, ll y2 = 0) : x1(x1), y1(y1), x2(x2), y2(y2) {
    }
};

struct Event {
    int type; //start 0, end 1
    int id;
    ll x;

    Event(int id, int type, ll x) : id(id), type(type), x(x) {
    }
};

struct EventCmp {
    bool operator()(const Event& a, const Event& b) {
        return (a.x < b.x) || (a.x == b.x && a.type > b.type);
    }
};

struct IntervalCmp {
    vector<Rec> recs;

    IntervalCmp(vector<Rec>& recs) : recs(recs) {
    }

    bool operator()(const int& a, const int& b) {
        return recs[a].y1 < recs[b].y1;
    }
};

ll intervalLength(vector<int>& intervals, vector<Rec>& recs, vector<bool>& flags) {
    ll start = -INF, end = 0;
    ll total = 0;
    for (int idx : intervals) {
        if (flags[idx]) {
            Rec& cur = recs[idx];
            if (start == -INF) {
                start = cur.y1;
                end = cur.y2;
            }
            else if (cur.y1 <= end) {
                end = max(end, cur.y2);
            } else {
                total += end - start;
                start = cur.y1;
                end = cur.y2;
            }
            //cout << "s/e " << start << " " << end << endl;
        }
    }
    if (start != -INF) {
        total += end - start;
    }
    return total;
}

int main() {
    int n;
    cin >> n;
    vector<Rec> recs(n);
    vector<Event> events;

    for (int i = 0; i < n; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        recs[i] = Rec(x1, y1, x2, y2);
        events.push_back(Event(i, 0, x1));
        events.push_back(Event(i, 1, x2));
    }

    vector<int> intervals(n);
    for (int i = 0; i < n; i++) {
        intervals[i] = i;
    }

    sort(events.begin(), events.end(), EventCmp());
    sort(intervals.begin(), intervals.end(), IntervalCmp(recs));

    int lastX = 0;
    ll lastLen = 0;
    ll area = 0;
    vector<bool> flags(n, false);
    
    for (Event event : events) {
        //cout << "event " << event.type << " " << event.id << " " << event.x << endl;
        area += (event.x - lastX) * lastLen;
        lastX = event.x;
        
        if (event.type == 0) {
            flags[event.id] = true;
        } else {
            flags[event.id] = false;
        }
        lastLen = intervalLength(intervals, recs, flags);
        //cout << "len: " << lastLen << endl;
    }
    cout << area << endl;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll x;
  cin >> x;
  cout << (x>=30 ? "Yes" : "No") << newl;
  return 0;
}

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

#define MOD 1000000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int dp[3005][3005], n, m;

string a, b;

int lcs(int x, int y){
    if(dp[x][y]!=-1){
        return dp[x][y];
    }
    if(x==n || y==m){
        return dp[x][y]=0;
    }
    if(a[x]==b[y]){
        return dp[x][y]=1+lcs(x+1, y+1);
    }
    return dp[x][y]=max(lcs(x, y+1), lcs(x+1, y));
}

int main(){
    fastio;
    memset(dp, -1, sizeof(dp));
    cin >> a >> b;
    n=(int)a.size();
    m=(int)b.size();
    lcs(0, 0);
    int i=0, j=0;
    string resp="";
    while(i<n && j<m){
        //cout << dp[i+1][j] << "  " << dp[i][j+1] << endl;
        if(a[i]==b[j]){
            resp+=a[i];
            i++, j++;
        }else if(dp[i+1][j]>dp[i][j+1]){
            i++;
        }else{
            j++;
        }
    }
    cout << resp << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int x = 0;
  
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'o') {
      x += 100;
    }  
  }    
  cout << x + 700 << endl;
}  

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int tate,yoko,mennseki,syuu;
    scanf("%d",&tate);
    scanf("%d",&yoko);
    mennseki=tate*yoko;
    syuu=tate*2+yoko*2;
    printf("%d %d\n",mennseki,syuu);

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string key;
  string ins;
  int keylen;
  int ans=0;
  int flag;
  cin>>n;
  cin>>key;
  keylen=key.size();
  for(int i=0;i<n;i++){
    cin>>ins;
    int inslen=ins.size();
    for(int j=0;j<inslen;j++){
      for(int k=1;k<inslen;k++){
	flag=1;
	for(int step=0;step<keylen;step++){
	  if(j+k*step>=inslen) flag=0;
	  if(key[step]!=ins[j+k*step]) flag=0;
	}
	if(flag){
	  ans++;
	  goto next;
	}
      }
    }
  next:;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1208
#![allow(non_snake_case)]
#![allow(unused_variables)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let B: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let mut ans = B[0] + B[N - 2];
    for i in 0..(N - 2) {
        ans += std::cmp::min(B[i], B[i + 1]);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
// abc078_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int X, Y, Z;
    cin >> X >> Y >> Z;

    print((X - Z) / (Y + Z));

    return 0;
}


Measured memory_bytes: 256
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];
int num;
vi v;
int dp[10001][2][101];
int func(int d,int ok,int sum){
    if(d==v.size()){
        if(sum%num==0) return 1;
        else return 0;
    }
    if(dp[d][ok][sum]!=-1) return dp[d][ok][sum];
    int res=0;
    for(int i=0;i<=(ok?v[d]:9);i++){
        if(i==v[d]) res=(res+func(d+1,ok,(sum+i)%num))%mod;
        else res=(res+func(d+1,0,(sum+i)%num))%mod;
    }
    dp[d][ok][sum]=res;
    return res;
    // return 0;
}
int solve(string k){
    v.clear();
    for(auto it:k) v.pb(it-'0');
    memset(dp,-1,sizeof(dp));
    return (func(0,1,0)-1+mod)%mod;
}
int32_t main()
{
    FIO
    string k;  
    cin>>k>>num;
    cout<<solve(k)%mod<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 31688
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<57;
const double pi=acos(-1);
const double eps=1e-6;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,1,1,1,0},DY[8]={1,0,-1,-1,-1,0,1,1};

ll x,y;

int main(){
	cin>>x>>y;
	if(abs(x-y)>1) cout<<"Alice"<<endl;
	else cout<<"Brown"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  string s;
  cin >> s;
  ll k=s.size();
  vl cnt(26,0);
  rep(i,26){
    rep(j,k){
      if(s[j]==abc[i]){
        cnt[i]++;
      }
    }
  }
  ll X=-1;
  rep(i,26){
    if(cnt[i]==0){
      X=i;
      break;
    }
  }
  if(X==-1){
    cout << "None" << endl;
  }
  else{
    cout << abc[X] << endl;
  }
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int,input().split()))
count = 0
odd = True
while odd == True:
  for i in range(n):
    if a[i] % 2 == 0:
      a[i] = int(a[i]/2)
    else:
      odd = False
  count += 1  

print(count - 1)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],mi_cnt=0,ma_cnt,free=0;
  bool col_list[8]={};
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n;i++){
    if(a[i]<3200){
      col_list[a[i]/400]=true;
    }else{
      free++;
    }
  }
  for(int i=0;i<8;i++){
    if(col_list[i]) mi_cnt++;
  }
  ma_cnt = mi_cnt+free;
  if(mi_cnt==0) mi_cnt=1;
  cout << mi_cnt <<" "<<ma_cnt<<endl;

}


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

using namespace std;

long march[5] = {};

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

    vector<string> S;
    for(int i = 0; i < N; i++){
        string tmp;
        cin >>tmp;
        S.push_back(tmp);
    }

    for(int i = 0; i < N; i++){
        if(S[i][0] == 'M')march[0]++;
        if(S[i][0] == 'A')march[1]++;
        if(S[i][0] == 'R')march[2]++;
        if(S[i][0] == 'C')march[3]++;
        if(S[i][0] == 'H')march[4]++;
    }
    long ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            for(int k = j+1; k < 5; k++){
                ans += march[i]*march[j]*march[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6132
N = int(input())
A = [[int(i) for i in input().split()] for _ in range(N)]
roads = [[True]*N for _ in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j] > A[i][k]+A[j][k]:
                print(-1)
                exit()
            if i == j:
                roads[i][j] = False
            if i != k and j != k and A[i][j] == A[i][k]+A[j][k]:
                roads[i][j] = False


ans = 0
for i in range(N):
    for j in range(i+1, N):
        if roads[i][j] is True:
            ans += A[i][j]
print(ans)


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

int main(void){
	string s;
	cin >> s;
	string ans="";
	for(int i=0;i<s.size();i++){
		if(s[i]!='B'){
			ans= ans + s[i];
		}else{
			if(ans.size()>0){
				ans.erase(--ans.end());
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#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--)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>




int main(int argc, const char * argv[]){
    
    //Input
    int i, j, n, q, ans;
    
    //n ????????´??°???????????°??? S
    scanf("%d", &n);
    int S[n];
    for(i=0; i < n; i++){
        scanf("%d", &S[i]);
    }
    
    //q ????????°????????´??°???????????°??? T
    scanf("%d", &q);
    int T[q];
    for(i=0; i < q; i++){
        scanf("%d", &T[i]);
    }
    
    ans = 0;
    for(i=0; i < q; i++){
        for(j=0; j < n; j++){
            if(T[i] == S[j]){
                ans++;
                break;
            }
        }
        
    }
    
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define forit(it,cont) for(auto it=cont.begin();it!=cont.end();it++)
#define forv(v,cont) for(auto v:cont)
#define for0(i,n) for(i=0;i<n;i++)
#define for1(i,n) for(i=1;i<=n;i++)
#define for0r(i,n) for(i=n-1;i>=0;i--)
#define for1r(i,n) for(i=n;i>=1;i--)
#define ll long long 
const ll inf=1e16;
const ll _inf=-1e16;
ll dx[]={1,-1,0,0};
ll dy[]={0,0,1,-1};
#define mod 1000000007
ll d[100010][5];
ll a[100010][5];
int main()
{
	ll n,i,ans;
	cin>>n;
	for1(i,n)
	cin>>a[i][0]>>a[i][1]>>a[i][2];
	d[1][0]=a[1][0];
	d[1][1]=a[1][1];
	d[1][2]=a[1][2];
	for(i=2;i<=n;i++)
	{
		d[i][0]=max(a[i][0]+d[i-1][1],a[i][0]+d[i-1][2]);
		d[i][1]=max(a[i][1]+d[i-1][0],a[i][1]+d[i-1][2]);
		d[i][2]=max(a[i][2]+d[i-1][0],a[i][2]+d[i-1][1]);
	}
	ans=max(d[n][0],max(d[n][1],d[n][2]));
	cout<<ans<<endl;
	return 0;	
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    int ans[]={0,0,0,0};
    while(n--){
        string s;
        cin>>s;
        if(s=="AC"){
            ans[0]++;
        }
        if(s=="WA"){
            ans[1]++;
        }
        if(s=="TLE"){
            ans[2]++;
        }
        if(s=="RE"){
            ans[3]++;
        }
    }
    cout<<"AC x "<<ans[0]<<endl;
    cout<<"WA x "<<ans[1]<<endl;
    cout<<"TLE x "<<ans[2]<<endl;
    cout<<"RE x "<<ans[3];
    return 0; 
}

Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    unsigned long long int a[100005], b[100005];
    int i;
    for (i = 0; i < n; i++)
        scanf("%lld %lld", &a[i], &b[i]);
    unsigned long long int ans = 0;
    for (i = n - 1; i >= 0; i--)
        if (b[i] > 1 && (a[i] + ans) % b[i] > 0)
            ans += b[i] - ((a[i] + ans) % b[i]);
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
 while(1){
 int a,b;
 string op;
 cin >>a>>op>>b;
 if(op =="?") break;
 
 int ans;
 if(op =="+") ans =a+b;
 if(op =="-") ans =a-b;
 if(op =="*") ans=a*b;
 if(op =="/") ans=a/b;


 cout<<ans<<endl;
 }

}


Measured memory_bytes: 3116
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <functional>
 
using namespace std;
 
#define MAX_N 100000
 
int main()
{
    int N, A[MAX_N + 2], sum = 0;
 
    scanf("%d", &N);
 
    A[0] = 0;
    A[N + 1] = 0;
 
    for (int i = 1; i <= N; i++)
    {
        scanf("%d", &(A[i]));
        sum += abs(A[i - 1] - A[i]);
    }
 
    sum += abs(A[N] - A[N + 1]);
 
    for (int i = 1; i <= N; i++)
    {
        printf("%d\n", sum - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]));
    }
 
    return 0;
}

Measured memory_bytes: 1536
x = 99999
y = 99999
while not(x == 0 and y == 0):
    x,y = map(int,input().split())
    if x == 0 and y == 0:
        break
    else:
        if x > y:
            print(str(y) + " " + str(x))
        elif x <= y:
            print(str(x) + " " + str(y))


Measured memory_bytes: 5612
#include<stdio.h>
#define MAX 100000

int parent(int i){
  return i/2;
}
int right(int i){
  return 2*i+1;
}
  int left(int i){
    return 2*i;
  }


int main(){
  int n,i,A[MAX];

  scanf("%d",&n);

  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<n+1;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i)<=n){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i)<=n){
      printf("right key = %d, ",A[right(i)]);
    }
    printf("\n");
  }

  return 0;
}
    
    
  



Measured memory_bytes: 2104
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
signed main(void)
{
	int h,a;
	cin>>h>>a;
	reg int res=0;
	while(h>0)
		h-=a,++res;
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int num, tot = 0, max = 0, n, i;
	scanf ("%d",&n);
	
	for (i = 0; i < n; i++)
	{
		scanf ("%d", &num);
		
		tot += num;
		if (max < num) max = num;
	}
	if (max < tot - max) printf ("Yes");
	else printf("No");
	
	return (0);
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    H=list(map(int,input().split()))
    score=0
    ans=0
    for i in range(n-1):
        if(H[i]>=H[i+1]):
            score+=1
        else:
            score=0
        ans=max(ans,score)

    print(ans)
resolve()

Measured memory_bytes: 63856
# https://atcoder.jp/contests/abc080/tasks/abc080_b
# B - Harshad Number

n = int(input().split()[0])
n_list = [int(x) for x in str(n)]

answer = 'No'

if n % sum(n_list) == 0:
    answer = 'Yes'

print(answer)


Measured memory_bytes: 2940
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>

using namespace std;

const int inf =  (int) 1e9 + 10;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
  	cin >> a[i];
	}
	vector<long long> dp(n, inf);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = i - 1; j >= max(0, i - k); j--) {
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
	}
	cout << dp[n - 1] << '\n';
  return 0;
}



Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
  
struct node{
  int key;
  struct node *next;
  struct node *prev;
};
  
typedef struct node * NodePointer;
NodePointer nil;

void insert(int keydata){
    NodePointer x;
    x=malloc(sizeof(struct node));
    x->key=keydata;
    x->next=nil->next;
    x->prev=nil;
    nil->next=x;
    x->next->prev=x;
}

int delete(int keydata){
  NodePointer p;
  p=nil->next;
  while(p!=nil&&p->key!=keydata){
    p=p->next;
  }
  if(p==nil){
    return 0;
  }else{
    p->prev->next=p->next;
    p->next->prev=p->prev;
    free(p);
    return 0;
  }
}

int deleteFirst(){
    NodePointer p;
    p=nil->next;
    nil->next=p->next;
    p->next->prev=nil;
    free(p);
    return 0;
}
int deleteLast(){
    NodePointer p;
    p=nil->prev;
    p->prev->next=nil;
    nil->prev=p->prev;
    free(p);
    return 0;
}

void init(){
  nil->next=nil;
  nil->prev=nil;
}

main(){
  int n, i, keydata;
  char com[12];
  NodePointer p;
  scanf("%d",&n);
  nil=malloc(sizeof(struct node));
  init();
   
  for (i=0;i<n;i++){
    scanf("%s",com);
    if(strlen(com)>6){
      if(com[6]=='F') {
    deleteFirst();
      }else{
    deleteLast();
      }
    }else{
      scanf("%d",&keydata);
      if(com[0]=='i'){
    insert(keydata);
      }else{
    delete(keydata);
      }
    }
  }
 
  for(p=nil->next;p!=nil->prev;p=p->next){
    printf("%d ",p->key);
  }
  printf("%d\n",p->key);
  free(nil);
  return 0;
}

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

int main(){
    int M, N;
    scanf("%d%d", &M, &N);
    int max_v = 0;
    for(int i = 0; i < M; i++){
        int v = 0;
        for(int j = 0; j < N; j++){
            int a;
            scanf("%d", &a);
            v += a;
        }
        max_v = max(max_v, v);
    }
    printf("%d\n", max_v);
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e15;


int main(){
	//ios_base::sync_with_stdio(0);
	ll N, K, ans=INF;
	ll a[20];

	cin >> N >> K;
	rep(i,N) cin >> a[i];

	rep(i,1<<N){
		ll cnt = 0, mx = 0, sum = 0;
		rep(k,N){
			if( (1<<k)&i ){
				cnt++;
				sum += max<ll>(0, mx-a[k]);
				mx = max(mx, a[k]) + 1;
			}else if( cnt < K && a[k] > mx ){
				cnt += 100;
				break;
			}
		}
		if( cnt == K ) chmin(ans, sum);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>


using namespace std;


int t;
string s;

int tbk[3][3] = {
	{ 0, 0, 0 },
	{ 0, 1, 1 },
	{ 0, 1, 2 }
};
int tbp[3][3] = {
	{ 0, 1, 2 },
	{ 1, 1, 2 },
	{ 2, 2, 2 }
};

int d[3];

int form(){

	if (s[t] >= '0' && s[t] <= '2'){
		int p = s[t] - '0';
		t++;
		return p;
	}

	if (s[t] >= 'P' && s[t] <= 'R'){
		int p = s[t] - 'P';
		t++;
		return d[p];
	}

	if (s[t] == '-'){
		t++;
		int q = form();
		return (q == 0 ? (2) : ((q == 2) ? 0 : 1));
	}

	if (s[t] == '('){
		t++;
		int p = form();
		if (s[t] == '*'){
			t++; int q = form(); t++; return tbk[p][q];
		}
		else
			if (s[t] == '+'){
				t++; int q = form(); t++; return tbp[p][q];
			}
	}
}

int ans = 0;

void dfs(int i){

	if (i == 3){
		t = 0;
		if (form() == 2)ans++;
		return;
	}

	for (int j = 0; j < 3; j++){
		d[i] = j;
		dfs(i + 1);
	}
}


int main()
{
	while (cin >> s && s != "."){
		t = 0;
		ans = 0;
		s += " ";
		dfs(0);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;
 
vector<int> res(string S){
    vector<int> re;
    int tmp = 1;
    for(int i = 1; i < S.size(); i++){
        if( S.at(i) == S.at(i-1) ){
            tmp++;
        }
        else{
            re.push_back(tmp);
            tmp = 1;
        }
    }
    re.push_back(tmp);
    return re;
}
 
int main(){
    string S;
    ll K;
    cin >> S >> K;
    ll fS, fSS;
    fS = 0;
    fSS = 0;
    
    vector<int> resS, resSS;
    resS = res(S);
    resSS = res(S+S);
    
    for(int i: resS){
        fS += i/2;
    }
    for(int i: resSS){
        fSS += i/2;
    }
    ll ans;
    if (resS.size() != 1 || S.size() % 2 == 0){
        ans = (K-1)*(fSS-fS)+fS;
    }
    else{
        ans = S.size()*K/2;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
S = input()[::-1]
l = len(S)
MOD = 10**9+7
dp = [[0]*13 for i in range(l+1)]
dp[0][0] = 1
m = 1
for i in range(1,l+1):
  c = S[i-1]
  if c=='?':
    for j in range(10):
      n = m*j
      for h in range(13):
        dp[i][(h+n)%13] += dp[i-1][h]
        dp[i][(h+n)%13] %= MOD
  else:
    c = int(c)*m
    for j in range(13):
      dp[i][(j+c)%13] += dp[i-1][j]
      dp[i][(j+c)%13] %= MOD
  m *= 10
  m %= 13
print(dp[-1][5])

Measured memory_bytes: 61532
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define hii cout << "hii" << endl
#define int ll
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 3e5;
const int mod = 1e9 + 7;
const int MOD = 1e9 + 7;
const int INF = 0;
const int LG = 21;

void solve()
{
	int n;
	cin >> n;
	long double ans = 1;
	vector<long double> v;
	for(int i = 0; i < n; i++)
	{
		long double data;
		cin >> data;
		v.push_back(data);
	}
	sort(all(v));
	for(auto x : v)
	{
		ans *= x;
		if(ans > 1e18)
		{
			cout << -1 << endl;
			return;
		}
	}
	int anss = ans;
	cout << anss << endl;
}
 
int32_t main() 
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 5424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
int a,b;
int main(){
	cin>>a>>b;
	b+=3*a;
	cout<<b/2<<endl;
}

Measured memory_bytes: 256
from itertools import groupby
N, K = map(int, input().split())
R, S, P = map(int, input().split())
D = {"r":P, "s":R, "p":S}
T = list(input())
c = 0
for i in range(K):
  gr = groupby(T[i::K])  
  for key, group in gr:
    l = len(list(group))
    d = D[key]
    c += d*((l+1)//2)
print(c)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e4 + 5);

int n, m;
vector<int> available;
vector<int> cand;

ll dp[MAX_N];

map<int, int> cost;

vector<int> ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < m; ++i) {
    int tmp;
    scanf("%d", &tmp);
    available.push_back(tmp);
  }

  cost[1] = 2;
  cost[2] = 5;
  cost[3] = 5;
  cost[4] = 4;
  cost[5] = 5;
  cost[6] = 6;
  cost[7] = 3;
  cost[8] = 7;
  cost[9] = 6;

  for (auto e: available) {
    cand.push_back(cost[e]);
  }

  for (int i = 0; i <= n; ++i) {
    dp[i] = -INF;
  }

  dp[0] = 0;

  for (int i = 1; i <= n; ++i) {
    for (auto e: cand) {
      if (i - e >= 0) {
        dp[i] = max(dp[i], dp[i - e] + 1);
      }
    }
  }

  int i = n;
  while (i > 0) {
    int tmp = -1;
    int tmp_cost = 0;

    if (dp[i] - 1 == 0) { // to gracefully use all match
      for (auto e: available) {
        // printf("%d %d %d %d\n", e, i, dp[i - cost[e]], dp[i] - 1);
        if (i - cost[e] == 0 && dp[i - cost[e]] == dp[i] - 1) {
          if (e > tmp) {
            tmp_cost = cost[e];
            tmp = e;
          }
        }
      }
    }
    else {
      for (auto e: available) {
        // printf("%d %d %d %d\n", e, i, dp[i - cost[e]], dp[i] - 1);
        if (i - cost[e] >= 0 && dp[i - cost[e]] == dp[i] - 1) {
          if (e > tmp) {
            tmp_cost = cost[e];
            tmp = e;
          }
        }
      }
    }

    if (tmp == -1) {
      printf("%d\n", 0);
      return 0;
    };

    // cout << i << ":" << tmp << endl;

    ans.push_back(tmp);
    i -= tmp_cost;
  }

  for (auto e: ans) {
    printf("%d", e);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 384
#include <cstdint>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int64_t Solve(const string& S, size_t idx, string str) {
  if (S.size() == idx) {
    stringstream ss(str);
    string item;
    int64_t sum = 0;
    while (getline(ss, item, '+')) {
      if (!item.empty()) {
        sum += stoll(item);
      }
    }
    return sum;
  }
  int64_t sum = Solve(S, idx + 1, str + S[idx]);
  if (idx != 0) {
    sum += Solve(S, idx + 1, str + "+" + S[idx]);
  }
  
  return sum;
}

int main() {
  string S;
  cin >> S;
  cout << Solve(S, 0, "") << endl;
  
  return 0;
}


Measured memory_bytes: 256
A, B, C, D, E, F = list(map(int, input().split()))

sugar = []
water = []

for i in range(31):
    for j in range(31):
        x = 100*A*i+100*B*j
        if x != 0 and x <= F:
            water.append(x)
        
n = int(F/(100+E)*E)

for k in range(n):
    for l in range(n):
        y = C*k+D*l
        if y != 0:    
            sugar.append(y)

ans_water_sugar = 100*A
ans_sugar = 0
conce = 0 

for s in list(set(sugar)):
    for w in water:
        if w+s <= F:
            if s/w <= E/100:
                if conce < s/w:
                    conce = s/w
                    ans_water_sugar = s+w
                    ans_sugar = s

print(ans_water_sugar, ans_sugar)

Measured memory_bytes: 63504
/**
 *    author:  math2do
 *    created: 12.04.2020 23:53:46
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T>
class graph {
 public:
  struct edge {
    int from;
    int to;
    T cost;
  };
 
  vector<edge> edges;
  vector<vector<int>> g;
  int n;
 
  graph(int _n) : n(_n) {
    g.resize(n);
  }
 
  virtual int add(int from, int to, T cost) = 0;
};

template <typename T>
class digraph : public graph<T> {
 public:
  using graph<T>::edges;
  using graph<T>::g;
  using graph<T>::n;
 
  digraph(int _n) : graph<T>(_n) {
  }
 
  int add(int from, int to, T cost = 1) {
    assert(0 <= from && from < n && 0 <= to && to < n);
    int id = (int) edges.size();
    g[from].push_back(id);
    edges.push_back({from, to, cost});
    return id;
  }
 
  digraph<T> reverse() const {
    digraph<T> rev(n);
    for (auto &e : edges) {
      rev.add(e.to, e.from, e.cost);
    }
    return rev;
  }
};

template <typename T>
vector <T> bellman_ford(const digraph<T> &g, int from, bool& neg = false) {
  T inf = numeric_limits<T>::max();
  vector <T> dist(g.n, inf);
  dist[from] = 0;

  auto relax = [&](auto &e) -> bool {
    bool done = false;
    int u = e.from;
    int v = e.to;
    int w = e.cost;
    if (dist[u] != inf && dist[u] + w < dist[v]) {
      dist[v] = dist[u] + w;
      done = true;
    }
    return done;
  };

  //relax all edges g.n - 1 times
  for (int qq = 1; qq <= g.n - 1; qq++) {
    for (auto &e : g.edges) {
      relax(e);
    }
  } 

  //if it relaxes more, then it contains negative cycle
  for (auto &e : g.edges) {
    if (relax(e)) {
      neg = true;
      goto end;
    } 
  }
  end : {
    return dist;
  }
  //dist[i] = distance to 'i' from 'from', inf if not reachable
  //neg = true if negative cycle is present
}

template <typename T>
constexpr T pinf = std::numeric_limits<T>::max();

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, src;
  cin >> n >> m >> src;
  digraph <int> g(n);
  for (int i = 0; i < m; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    g.add(s, t, w);
  }
  bool neg = false;
  vector <int> dist = bellman_ford(g, src, neg);
  if (neg) {
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    for (int i = 0; i < g.n; i++) {
      if (dist[i] == pinf<int>) {
        cout << "INF" << endl;
      } else {
        cout << dist[i] << endl;
      }
    }
  } 
  return 0;
}



Measured memory_bytes: 3284
using System.Text;
public partial class IntroductionToProgramming{
	public static void Main(){
		int n = int.Parse(System.Console.ReadLine());

		int[, ,] h = new int[4, 3, 10];

		for (int i = 0; i < n; i++)
		{
			string[] line = System.Console.ReadLine().Split(' ');
			h[P(line[0]), P(line[1]), P(line[2])] += int.Parse(line[3]);
		}

		for (int b = 0; b < 4; b++)
		{
			if (b != 0)
			{
				System.Console.WriteLine(new string('#', 20));
			}
			for (int f = 0; f < 3; f++)
			{
				StringBuilder sb = new StringBuilder();
				for (int r = 0; r < 10; r++)
				{
					sb.Append(" " + h[b, f, r].ToString());
				}
				System.Console.WriteLine(sb.ToString());
			}
		}
	}
	public static int P(string s)
	{
		return int.Parse(s) - 1;
	}
}

Measured memory_bytes: 5640
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;
typedef long long lint;

bool check(const vector<lint>& H, int x, const lint A, const lint B) {
    lint cnt = 0;
    for (const lint h : H) {
        const lint rest = h - x * B;
        if (rest <= 0) continue;
        cnt += (rest + A - B - 1) / (A - B);
    }
    return cnt <= x;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<lint> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    lint low = 0, high = 1e9+7;
    while (high - low > 1) {
        const int mid = (low + high) / 2;
        if (check(H, mid, A, B)) {
            high = mid;
        } else {
            low = mid;
        }
    }
    cout << high << endl;
    return 0;
}

Measured memory_bytes: 1024
n = str(input())

length = 4 #nの長さ
spaces = length -1

masterlist = []
opelist = ["+"] * spaces

for i in range(2 ** spaces):
    opelist = ["+"] * spaces

    for j in range(spaces):
        if i >> j & 1:
            opelist[j] = "-"
        else:
            opelist[j] = "+"

    masterlist.append(opelist)

for opes in masterlist:
    nls = list(n)
    for k in range(len(opes)):
        nls.insert(2*k+1,opes[k])
        #print(nls)
    nstr = ''.join(nls)
    if eval(nstr) == 7:
        print("{}=7".format(nstr))
        exit()

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

using namespace std;
const int maxN=3e2+100;
int n,m,st,fn;
int cap[maxN][maxN],excess[maxN],height[maxN];
vector<int> g[maxN];

void input()
{
  cin>>n>>m;
  //cin>>st>>fn;
  st=1; fn=n;
  for(int i=1;i<=m;i++)
    {
      int k1,k2,val;
      cin>>k1>>k2>>val;
      k1++;k2++;
      if(cap[k1][k2]==0 && cap[k1][k2]==0){
	g[k1].push_back(k2);
	g[k2].push_back(k1);
      }
      cap[k1][k2]+=val;
    }
}
int findExcessedVertex()
{
  int v=0;
  height[0]=-1;
  for(int i=1;i<=n;i++)
    if(excess[i]>0 && height[i]>height[v] && i!=st && i!=fn)
      v=i;
  return v;
}
bool push(int v)//change to multi push
{
  bool done=false;
  for(auto u :g[v])
    if(cap[v][u]>0 && height[v]==height[u]+1)
      {
	int delta=min(excess[v],cap[v][u]);
	cap[v][u]-=delta;
	cap[u][v]+=delta;
	excess[v]-=delta;
	excess[u]+=delta;
	done=true;
	return done;
      }
  return done;
}
void relabel(int v)
{
  height[v]++;
}
void GT_init()
{
  height[st]=n;
  height[fn]=0;//not done
  for(auto u:g[st])
    {
      int delta=cap[st][u];
      cap[st][u]-=delta;
      cap[u][st]+=delta;
      excess[st]-=delta;
      excess[u]+=delta;
    }
}
int Goldberg_Tarjan()
{
  GT_init();
  while(int v=findExcessedVertex())
    {
      
      //cout<<"gt"<<v<<endl;
      if(!push(v))
	relabel(v);
    }
  return excess[fn];
}
int main()
{
  input();
  int Maxflow=Goldberg_Tarjan();
  cout<<Maxflow<<endl;
  
  return 0;
}

Measured memory_bytes: 3348
n = int(input())
a = [int(i) for i in input().split()]
sum1 = [a[0]]
sum2 = [sum(a)-a[0]]
s = sum(a)
ls = []
for i in range(1,n):
    sum1.append(sum1[i-1]+a[i])
    sum2.append(s - sum1[i])

for i in range(n-1):
    ls.append(abs(sum1[i] - sum2[i]))

print(min(ls))


Measured memory_bytes: 114384
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vector2 = vector <vector  <T>>;
template <typename T> using vector3 = vector <vector2 <T>>;
template <typename T> using vector4 = vector <vector3 <T>>;
using lint = long long;
#define FOR( i, a, b ) for( lint i=(a) ; i < (b) ; ++i )
#define REP( i, n )    for( lint i= 0  ; i < (n) ; ++i )
#define ALL( v )       (v).begin(), (v).end()

bool comp( string as, int ap, string bs, int bp ) {
    if( as < bs ) {
        return true;
    } else if ( as > bs ) {
        return false;
    }

    return bp < ap;
}

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

    vector<string> S(N);
    vector<int> P(N);
    vector<int> D(N);

    REP( i, N ) {
        cin >> S[i] >> P[i];
        D[i] = i+1;
    }

    //  そーと
    REP( i, N ) {
        for( int j=N-1; j>i; j-- ) {
            if( comp(S[j],P[j],S[j-1],P[j-1]) ) {
                string temps = S[j];
                int tempp = P[j];
                int tempd = D[j];
                S[j] = S[j-1];
                P[j] = P[j-1];
                D[j] = D[j-1];
                S[j-1] = temps;
                P[j-1] = tempp;
                D[j-1] = tempd;
            }
        }
    }

    REP( i, N ) {
        cout << D[i] << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
const int Mod = 1000000007;
const int maxn = 1e4+10;
ll dp[maxn][105];
int d;
char str[maxn];
int a[maxn];
ll dfs(int pos,int left,bool limit)
{
    if(pos==-1) return (left==0);
    if(!limit && dp[pos][left]!=-1) return dp[pos][left];
    int up=limit ? a[pos] : 9;
    ll tmp=0;
    for(int i=0;i<=up;i++)
    {
        tmp=(tmp+dfs(pos-1,(left-i%d+d)%d,limit && i==a[pos]))%Mod;
    }
    if(!limit) dp[pos][left]=tmp;
    return tmp;
}
ll solve()
{
    int len=strlen(str);
    int pos=0;
    for(int i=len-1;i>=0;i--) a[pos++]=str[i]-'0';
    return dfs(pos-1,0,true);
}
int main()
{
    scanf("%s%d",str,&d);
    memset(dp,-1,sizeof(dp));
    printf("%lld\n",(solve()-1+Mod)%Mod);
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<double> a(n);
	double bunbo = 0;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		bunbo += 1/a[i];
	}
	double ans = 1/bunbo;
	printf("%.7f\n", ans);
}

Measured memory_bytes: 256
#include<cstdio>
using ll = long long;
using ull = unsigned long long;
 
int main(){
	ull N;
	char B[5];
	scanf("%llu %s", &N, B);
	ull b = 0;
	b += (B[0] - '0')*100;
	b += (B[2] - '0')*10;
	b += (B[3] - '0');
	printf("%llu\n", N*b/100ULL);
	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  string str;cin>>str;
  int alfa[30]={};
  for(int i=0;i<str.size();i++)
    alfa[str[i]-'a']++;
  bool flag=true;
  for(int i=0;i<30;i++)
    if(alfa[i]%2)flag=false;
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    map<int, int> m;
    int mi = 1000, ma = 0;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        m[a] += 1;
        mi = min(mi, a);
        ma = max(ma, a);
    }
    if(N == 1) {
        cout << "Impossible" << endl;
        return 0;
    }

    bool ok = (m[mi] >= 2 && ma & 1) || (m[mi] == 1 && ma % 2 == 0);
    ok &= (ma + 1) / 2 == mi && ma <= N - 1 && m[mi] <= 2;
    int prev = mi - 1;
    for(auto& p : m) {
        if(p.first != prev + 1) {
            ok = false;
        }
        prev = p.first;
        if(p.first == mi) {
            continue;
        }
        ok &= p.second >= 2;
    }

    if(ok) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int a[8][8], f[8], b[8], c[15], d[15];
 
void search(int n)
{
    if (n >= 8)
    {
        for (int k = 0; k < 8; ++k)
        {
            for (int j = 0; j < 8; ++j)
            {
                if (a[k][j])
                    cout << "Q";
                else
                    cout << ".";
            }
            cout << endl;
        }
    }
    else
    {
        if (f[n])
            search(n + 1);
        else
        for (int i = 0; i < 8; ++i)
        {
            if (!b[i] && !c[i + n] && !d[n - i + 7])
            {
                b[i] = 1;
                c[i + n] = 1;
                d[n - i + 7] = 1;
                a[n][i] = 1;
                search(n + 1);
                b[i] = 0;
                c[i + n] = 0;
                a[n][i] = 0;
                d[n - i + 7] = 0;
            }
        }
    }
}
 
int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        int v, c1;
        cin >> v >> c1;
        a[v][c1] = 1;
        b[c1] = 1;
        f[v] = 1;
        c[v + c1] = 1;
        d[v - c1 + 7] = 1;
    }
    search(0);
    return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int n;
	cin >> n;
	int ans = -n;
	REP(i, 0, n) {
		int tmp;
		cin >> tmp;
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256