akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         // if (siz[rx] < siz[ry]) swap(rx,ry);
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

//     vector<ll> par;
//     vector<ll> siz;
    
//     UnionFind(ll N): par(N), siz(N,1LL) {
//         for (ll i=0;i<N;i++) par[i] = i;
//     }

//     ll root(ll x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//         siz[ry] += siz[rx];
//     }

//     bool same(ll x, ll y) {
//         ll rx = root(x);
//         ll ry = root(y);
//         return rx == ry;
//     }

//     ll size(ll x) {
//         return siz[root(x)];
//     }
// };

int main(void) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int res = 0;
    if (A<K) {
        res += A;
    } else res += K;
    K -= A;
    K -= B;
    if (K>0) {
        res -= K;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	List<List<Integer>> bookList = new ArrayList<List<Integer>>();
    	List<Double> ave = new ArrayList<Double>();
		int j = 0;
	    Scanner scan = new Scanner(System.in);

    	while(true){
    	    if(j ==0){
    	        String str = scan.nextLine();
    	    j =1;
    		if("0".equals(str)) break;
    	    }else{
    	        String str = scan.nextLine();
        		if("0".equals(str)) break;

    	    String[] result=str.split(" ", 0);
        	List<Integer> sumlist = new ArrayList<Integer>();

        	double d1 = 0.0;
        	
        	for(String d :result){
        		d1 += Integer.parseInt(d);
            	sumlist.add(Integer.parseInt(d));
        	}
        	
        	ave.add(d1/sumlist.size());
        	
        	bookList.add(sumlist);
    	    j=0;
    	    }
    	}
    	
    	int i = 0;
    	for(List<Integer> d1 :bookList){
    		int num = 0;
    		for(Integer d2 : d1){
    			if(d2<=ave.get(i)){
    				num++;
    			}
    		}
    		System.out.println(num);
    		i++;
    	}
    }
    
    
}




Measured memory_bytes: 64324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    vector<bool> in(101);
    stack<int> s;
    FOR(i, 0, n) {
        int a; cin >> a;
        if (0 < a) {
            if (in[a]) {
                cout << i + 1 << "\n";
                return 0;
            }
            s.push(a);
            in[a] = true;
        }
        else {
            if (!in[-a]) {
                cout << i + 1 << "\n";
                return 0;
            }
            if (s.empty() || s.top() != -a) {
                cout << i + 1 << "\n";
                return 0;
            }
            s.pop();
            in[-a] = false;
        }
    }
    cout << "OK\n";
}


Measured memory_bytes: 3232
import java.util.*;
class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[] input=new long[5];
        long n=sc.nextLong();
        long mintime=Long.MAX_VALUE;
        for(int i=0;i<5;i++){
            input[i]=sc.nextLong();
            if(input[i]<mintime){
                mintime=input[i];
            }
        }
        System.out.println((n%mintime==0?n/mintime:n/mintime+1)+4);
        
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int n;
int main() {
	cin >> n;
	int last = n % 10;
	if(last == 3)	cout << "bon\n";
	else if(last == 0 || last == 1 || last == 6 || last == 8)	cout << "pon\n";
	else	cout << "hon\n";
	return 0;
}

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

Measured memory_bytes: 3532
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    B=list(mi())

    X = []
    X.append(B[0])
    X.append(B[0])

    for i in range(1,N-1):
        last = X[-1]
        if last <= B[i]:
            X.append(B[i])
        else:
            X[-1] = B[i] 
            X.append(B[i])
    
    # print(X)
    print(sum(X))







if __name__ == "__main__":
    main()

Measured memory_bytes: 61412
if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    product = arr[0]
    if 0 in arr:
        product = 0
    else:
        for i in range(1, n):
            product *= arr[i]
            if product > (10**18):
                product = -1
                break
    print(product)

Measured memory_bytes: 21652
#include <bits/stdc++.h>
using namespace std;
long long s;
int main()
{
    scanf("%lld",&s);
    if (s<=1000000000)
    {
        printf("%d %d %d %d %lld %d\n",0,0,0,1,s,0);
        return 0;
    }
    int t=sqrt(s);
    while (1LL*t*t<s) ++t;
    for (int i=0;i<1000;i++)
        for (int j=0;j<1000;j++)
        {
            int c=t+i,d=t+j;
            if (c>1000000000||d>1000000000) continue;
            long long x=1LL*c*d-s;
            if (x==0LL)
            {
                printf("%d %d %d %d %d %d\n",0,c,d,0,d,c);
                return 0;
            }
            for (int i=1;1LL*i*i<=x;i++)
                if (x%i==0&&c>i&&d>x/i)
                {
                    int a=c-i;
                    int b=d-x/i;
                    printf("%d %d %d %d %d %d\n",0,a,b,0,d,c);
                    return 0;
                }
        }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<int> p(n);
  rep(i, n){ cin>>p[i]; p[i]--; }

  vector<ll>c(n, n+1);
  rep(i, n) c[p[i]]+=i+1;

  vector<ll>a(n), b(n);;
  rep(i, n)a[i]=i+1;
  rep(i, n)b[i]=c[i]-a[i];

//  rep(i, n)cout<<a[i]<<' ';cout<<endl;
//  rep(i, n)cout<<b[i]<<' ';cout<<endl;
//  rep(i, n)cout<<c[i]<<' ';cout<<endl;

  rep1(i, n-1){
    if(b[i-1]<=b[i]){
      ll d = b[i]-b[i-1]+1;
      for(int j=i; j<n; j++) { a[j]+=d; b[j]-=d; }
    }
  }

  ll md=0;
  for(auto c: b)md=min<ll>(md, c);
  rep(i, n)b[i]+=(1-md);

//  cout<<endl;
  rep(i, n)cout<<a[i]<<' ';cout<<endl;
  rep(i, n)cout<<b[i]<<' ';cout<<endl;
//  rep(i, n)cout<<a[i]+b[i]<<' ';cout<<endl;

  return 0;
}

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

  A = input[1].split(" ")
  for(var i=0; i < N; i++){
    A[i] = Number(A[i])
  }
  var zero_cnt = 0
  while(zero_cnt != N)
  {
    zero_cnt=0
    var min = Math.min(...A)
    for(var i=0; i < N; i++){
      var mod = A[i] % min
      if(mod !== 0){
        A[i] = mod
      }else{
        A[i] = min
        zero_cnt++
      }
    }
  }

  console.log(Math.min(...A))
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("4\n5 13 8 1000000000")

Measured memory_bytes: 27420
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
vector<ll> ans = vector<ll>(2001, 0);

//使用する関数
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;
}

bool comp(pair<int,pair<int,int>> a, pair<int, pair<int, int>> b){
	return a.first <= b.first;
}

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

	int n;
	cin >> n;

	ll ans = 0;
	REPS(i, n) {
		ans += (n - 1) / i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int, int> ii;
typedef tuple<int,int,int> i3;
typedef std::pair<int, ii> iii;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ii> vii;
typedef std::vector<iii> viii;
const int INF=10000000;
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define all(x) (x).begin(), (x).end()
const int NMAX=701;
bool adj[NMAX][NMAX];
bool visited[NMAX];
int state[NMAX];
int N,M,a,b;
int ans=NMAX*NMAX;
vector<int> indpt;
ii ANS[NMAX];

ii dfs(int u){  

  if (visited[u]) return {0,0};
  else if (!visited[u]) {
    ii temp={1,0};
    visited[u]=true;
    cerr<<u<<" | ";
    if (state[u]==-1) {indpt.push_back(u); state[u]=1;}
    vector<int> next;
    for (int i=0; i<N; i++){
      if (!adj[i][u]){
        if (state[i]==state[u]) {ans=-1; break;}
        else {
          state[i]=1-state[u];
          next.pb(i);
          cerr<<i<<" ";
        }
      }
    }
    cerr<<endl;
    for (int i: next) {
      ii t=dfs(i);
      temp.first+=t.second;
      temp.second+=t.first;
    }

    return ANS[u]=temp;


  }
}


map<i3,int> memo;

int dp(int index, int a, int b){
  i3 temp=make_tuple(index,a,b);
  if (memo.find(temp)!=memo.end()) return memo[temp]; 
  else if (index==indpt.size()){
    cerr<<"hi"<<endl;
    return memo[temp]=a*(a-1)/2+b*(b-1)/2;
  }
  else{
    int node=indpt[index];
    return memo[temp]=min(dp(index+1,a+ANS[node].first,b+ANS[node].second),dp(index+1,a+ANS[node].second,b+ANS[node].first));
  }
}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  memset(adj,false,sizeof(adj));
  memset(visited,false,sizeof(visited));
  memset(state,-1,sizeof(state));
  cin >> N >> M;
  for (int i=0; i<M; i++){
    cin >> a >> b;
    a--; b--;
    adj[a][b]=true;
    adj[b][a]=true;
  }
  for (int i=0; i<N; i++){
    adj[i][i]=true;
  }

  // for (int i=0; i<N; i++){
  //   for (int j=0; j<N; j++){
  //     if (adj[i][j]== true) cout<<1<<" ";
  //     else cout<<0<<" ";
  //   }
  //   cout<<endl;
  // }


  for (int i=0; i<N; i++){dfs(i);}



  // for (int i=0; i<N; i++){cout<<state[i]<<" ";}
  // cout<<endl;

  // for (int i: indpt){ cout<< i<<" | "<<ANS[i].first<<" "<<ANS[i].second<<endl;}



  cout<<min(ans,dp(0,0,0))<<endl;



    




  



}


Measured memory_bytes: 16128
a = list(map(int,input().split()))
N = a[0]
X = a[1]
Y = a[2]
ans = list(range(N))
for k in range(1,N):
  ans[k] = 0
 
for i in range(1,N):
  for j in range(i+1,N+1):
    k = min(j-i,abs(X-i)+1+abs(j-Y))
    ans[k] = ans[k]+1
 
for t in range(1,N):
  print(ans[t])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
int N;
long T[105];

long euclid(long a,long b){
    if(b > a) swap(a,b);
    if(!(a%b)) return b; 
    long r = a % b;
    
    while(b % r != 0){
        if(r > b) swap(r,b);
        b %= r;
    }
    
    return r;
}

long lcm(long a,long b){
    long gcd = euclid(a,b);
    return gcd * (a/gcd) * (b/gcd);
}



int main(){
    cin >> N;
    rep(i,N) cin >> T[i];
    long res = 1;
    rep(i,N) res = lcm(res,T[i]);
    cout << res << endl;
}

Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	int arr[5];
	for(int i = 0; i < 5; i++)
		cin >> arr[i];
	int ans = -1;
	for(int i = 0; i < 5; i++) 
		if(arr[i] == 0) 
			ans = i + 1;
	cout << ans;
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


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

// dp[i][j] select i-th, last select is j
// up
// dp[i][j] = \sum_{k=1}^{j} dp[i-1][k]
// down
// dp[i][j] = \sum_{k=j+1}^{n-i+1} dp[i-1][k]


const int M=3005;
const int MO=1e9+7;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline void mulv(int &x,int y)
{
	x=1LL*x*y%MO;
}

char s[M];
int dp[M][M];
int sum[M];

int main()
{
	int n;
	scanf("%d%s",&n,s+2);
	for(int i=1;i<=n;i++)
		dp[1][i]=1;
	for(int i=2;i<=n;i++)
	{
		int m=n-i+1; // [1~m] left
		if(s[i]=='<')
		{
			for(int j=1;j<=m;j++)
				sum[j]=add(sum[j-1],dp[i-1][j]);
			for(int j=1;j<=m;j++)
				dp[i][j]=sum[j];
		}
		else // s[i]=='>'
		{
			sum[m+1]=dp[i-1][m+1];
			for(int j=m;j>=1;j--)
				sum[j]=add(sum[j+1],dp[i-1][j]);
			for(int j=1;j<=m;j++)
				dp[i][j]=sum[j+1];
		}
		// cout<<i<<" : ";
		// for(int j=1;j<=n;j++)
		// 	cout<<dp[i][j]<<" ";
		// cout<<endl;
	}
	printf("%d\n",dp[n][1]);
	return 0;
}

Measured memory_bytes: 35200
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> a(N+1);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }
    vector<int64_t> b(a.begin(), a.end());

    int64_t ans = numeric_limits<int64_t>::max();

    int64_t cnt = 0;
    for(int i=0; i<N; i++) {
        if(i%2) {
            cnt += max(a[i] - (-1L), 0L);
            a[i] = min(a[i], -1L);
            a[i+1] += a[i];
        } else {
            cnt += max(1L - a[i], 0L);
            a[i] = max(1L, a[i]);
            a[i+1] += a[i];
        }
    }
    ans = min(ans, cnt);

    cnt = 0;
    for(int i=0; i<N; i++) {
        if(i%2 == 0) {
            cnt += max(b[i] + 1L, 0L);
            b[i] = min(b[i], -1L);
            b[i+1] += b[i];
        } else {
            cnt += max(1L - b[i], 0L);
            b[i] = max(1L, b[i]);
            b[i+1] += b[i];
        }
    }
    ans = min(ans, cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
'use strict'

function main(s) {

  const str = s.split('\n')[1];
  let count = 0;

  for (let i = 0; i < str.length; i++) {

    const head = str.slice(0, i).split('');
    const rest = str.slice(i).split('');

    const bothChar = [...head, ...rest].filter(i => head.includes(i) && rest.includes(i));
    const bothNum = [...new Set(bothChar)].length;

    count = Math.max(count, bothNum);
  }

  console.log(count);
}

if (!Array.prototype.includes) {
  Object.defineProperty(Array.prototype, 'includes', {
    value: function(searchElement, fromIndex) {

      if (this == null) {
        throw new TypeError('"this" is null or not defined');
      }

      // 1. Let O be ? ToObject(this value).
      var o = Object(this);

      // 2. Let len be ? ToLength(? Get(O, "length")).
      var len = o.length >>> 0;

      // 3. If len is 0, return false.
      if (len === 0) {
        return false;
      }

      // 4. Let n be ? ToInteger(fromIndex).
      //    (If fromIndex is undefined, this step produces the value 0.)
      var n = fromIndex | 0;

      // 5. If n ≥ 0, then
      //  a. Let k be n.
      // 6. Else n < 0,
      //  a. Let k be len + n.
      //  b. If k < 0, let k be 0.
      var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);

      function sameValueZero(x, y) {
        return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y));
      }

      // 7. Repeat, while k < len
      while (k < len) {
        // a. Let elementK be the result of ? Get(O, ! ToString(k)).
        // b. If SameValueZero(searchElement, elementK) is true, return true.
        if (sameValueZero(o[k], searchElement)) {
          return true;
        }
        // c. Increase k by 1.
        k++;
      }

      // 8. Return false
      return false;
    }
  });
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9760
def dfs(now, depth):
    if used[now]:
        return 0
    if depth == N:
        return 1

    used[now] = 1
    ans = 0

    for i in range(N):
        if connect[now][i]:
            ans += dfs(i, depth + 1)

    used[now] = 0
    return ans


def main():

    for i in range(M):
        connect[a[i]][b[i]], connect[b[i]][a[i]] = 1, 1

    print(dfs(0, 1))


if __name__ == '__main__':
    N, M = map(int, input().split())
    a = [0 for i in range(M)]
    b = [0 for i in range(M)]

    for i in range(M):
        ai, bi = map(int, input().split())
        a[i] = ai - 1
        b[i] = bi - 1

    used = [0 for i in range(N)]
    connect = [[0 for i in range(N)] for i in range(N)]
    main()


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

const int INF = 100000 + 1000;

int main() {
    ll x, y;
    cin >> x >> y;
    ll count = 1;
    ll now = x;
    while (true) {
        now *= 2;
        if (now > y) {
            break;
        }
        count++;

    }

    cout << count << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	char C;
	cin >> C;

	if (C == 'a' || C == 'e' || C == 'i' || C == 'o' || C == 'u') co("vowel");
	else co("consonant");

	Would you please return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}


signed main() {
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  combination table(n+1);
  REP_FROM(i, 1, k+1) {
    cout << table.C(k-1, i-1) * table.C(n-k+1, i) % mod << endl; 
  }
  return 0; 
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int n,m;
int st,gl;
double dp[35][35][35];

int ds[35][35];
int rs[35][35];

typedef pair<int,mp> mmp;
typedef pair<double,mmp> dmp;

int main(void){
	for(;;){
		scanf("%d%d",&n,&m);
		if(n==0)break;
		scanf("%d%d",&st,&gl);
		memst(ds,-1);
		memst(rs,-1);
		rep(i,m){
			int a,b,c,d;
			scanf("%d%d%d%d",&a,&b,&c,&d);
			ds[a][b]=ds[b][a]=c; 
			rs[a][b]=rs[b][a]=d; 
		}
		
		rep(i,35)rep(j,35)rep(k,35)dp[i][j][k]=1e10;
		
		pque(dmp) que;
		que.push(dmp(0,mmp(st,mp(0,0))));
		double ans=-1;
		while(!que.empty()){
			dmp pa=que.top();
			que.pop();
			double t=pa.fir;
			int no=pa.sec.fir,
				fr=pa.sec.sec.fir,
				nv=pa.sec.sec.sec;
			if(dp[no][fr][nv]<=t)continue;
			dp[no][fr][nv]=t;
			if(no==gl && nv==1){
				ans=t;
				break;
			}
			reg(tv,max(nv-1,1),nv+1){
				rep(to,35){
					if(to==fr)continue;
					if(ds[no][to]<0)continue;
					if(rs[no][to]<tv)continue;
					double tt=t+ds[no][to]/((double)tv);
					if(dp[to][no][tv]<=tt)continue;
					que.push(dmp(tt,mmp(to,mp(no,tv))));
				}
			}
		}
		if(ans<0)printf("unreachable\n");
		else printf("%.8f\n",ans);
	}
		
			
	return 0;
}

Measured memory_bytes: 14120
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int n,m;

ll gcl(ll x,ll y){
    if(x<y) swap(x,y);
    while(y>0){
        ll t=x%y;
        x=y;
        y=t;
    }
    return x;
}

int main(){
    cin>>n;
    vector<int> a(n);
    ll sum=0;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll x=0,y=sum;
    ll m=2000000001;
    rep(i,0,n-1){
        x+=a[i];
        y-=a[i];
        m=min(m,abs(x-y));
    }

    cout<<m<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int64_t binpow(int64_t x, int64_t e) {
	int64_t m = 1000000007;
	int64_t a = 1;
	int64_t p = x;
	while (e > 0) {
		if (e % 2 == 0) {
			p = (p*p)%m; e /= 2;
		}
		else {
			a = (a*p)%m; e--;
		}
	}
	return a;
}
int64_t counter(char a, char b, char c, string s) {
	int64_t m = 1000000007;
	vector<int64_t>first(s.size() + 1);
	vector<int64_t>third(s.size() + 1);
	for (int i = 1; i < s.size() + 1; i++) {
		if (s.at(i - 1) == a)
			first.at(i) = first.at(i - 1) + 1;
		else
			first.at(i) = first.at(i - 1);
	}
	for (int i = 1; i < s.size() + 1; i++) {
		if (s.at(s.size() - i) == c)
			third.at(i) = third.at(i - 1) + 1;
		else
			third.at(i) = third.at(i - 1);
	}
	int64_t ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == b) {
			ans += (first.at(i) * third.at(s.size() - i - 1))%m;
		}
	}
	return ans%m;
}

int main() {
	int64_t m = 1000000007;
	string s;
	cin >> s;
	int64_t count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == '?')
			count++;
	}
	vector<int64_t>v(4);
	for (int i = 0; i < 4; i++) {
		v.at(i) = binpow(3, count - 3 + i);
	}
	int64_t ans = 0;
	ans += (counter('A', 'B', 'C', s) * v.at(3)) % m;
	ans += ((counter('A', 'B', '?', s) + counter('A', '?', 'C', s) + counter('?', 'B', 'C', s)) * v.at(2)) % m;
	ans += ((counter('A', '?', '?', s) + counter('?', '?', 'C', s) + counter('?', 'B', '?', s)) * v.at(1)) % m;
	ans += (counter('?', '?', '?', s) * v.at(0)) % m;
	cout << ans % m << endl;
	return 0;
}

Measured memory_bytes: 2268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define def(x) cerr << #x << " is " << x << endl;
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(ll i=a;i<n;i++)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        ll n; cin>>n;
        vector<ll> a(n),b(n);
        FOR(i,0,n){
            cin>>a[i]>>b[i];
        }
        sort(all(a));
        sort(all(b));
        // Ranges of the median for X will be median of A to median of B and that is the final answer
        ll meda,medb;
        if(n%2){
            meda = a[n/2];
            medb = b[n/2];
        }
        if(n%2==0){
            meda = a[n/2-1]+a[n/2];
            medb = b[n/2-1]+b[n/2];
        }
        cout<<medb-meda+1;
    }   
}


Measured memory_bytes: 6308
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int F[50];
    F[0] = F[1] = 1;
    int n;
    cin >> n;
    
    for (int i = 0;i < n;i++){
        F[i+2] = F[i+1] + F[i];
    }
    
    cout << F[n] << endl;
}



Measured memory_bytes: 3092
n,m,x=map(int,input().split())
C=list()
A=list()
for i in range(n):
    X=list(map(int,input().split()))
    C.append(X[0])
    A.append(X[1:])
import itertools as it
V=list(it.product([0,1],repeat=n))
S=[10**7]*len(V)
for i in range(len(V)):
    Z=V[i]
    L=[0]*m
    for j in range(m):
        for k in range(n):
            L[j]+=A[k][j]*Z[k]
    if min(L)>=x:
        s=0
        for k in range(n):
           s+=C[k]*Z[k]
        S[i]=s
if  min(S)==10**7:
    print(-1)
else:
    print(min(S))
    

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



vector<vector<int>>adjlist;
vector<int>dp;
int Lpath(int node){
    //cout<<node<<"\n";
    if(dp[node]!=-1){
        return dp[node];
    }

    int sz = adjlist[node].size();
    int mx = 0;
    for(int i=0;i<sz;i++){
        int u = adjlist[node][i];
        mx = max(mx,Lpath(u)+1);
    }
    //cout<<"dpnode: "<<node<<" "<<dp[node]<<"\n";
    return dp[node] = mx;
}
void solve(){
    int v,e;cin>>v>>e;
    adjlist.resize(v);
    dp.resize(v,-1);
    for(int i=0;i<e;i++){
        int a,b;cin>>a>>b;
        adjlist[a-1].push_back(b-1);
    }
    int mx=0;
    for(int i=0;i<v;i++){
        mx = max(mx, Lpath(i));
    }

    cout<<mx<<"\n";
}

int main(){
    cin.tie(0);
    cout.tie(0);
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);


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


Measured memory_bytes: 8192
def resolve():
    import heapq
    import sys
    input = sys.stdin.readline
    _, M = [int(i) for i in input().split()]
    A = [-int(i) for i in input().split()]
    heapq.heapify(A)
    for _ in range(M):
        heapq.heappush(A, -(-heapq.heappop(A) // 2))
    print(-sum(A))

resolve()


Measured memory_bytes: 20228
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

ll A[100010];
int main()
{
	int N; cin >> N;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	for (int i = 0; i < N / 2; i++) {
		ans += (A[N - 1 - i] - A[i]) * 2;
	}
	if (N % 2 == 0) {
		ans += A[N / 2 - 1] - A[N / 2];
	}
	else {
		ans += max(A[N / 2 - 1] - A[N / 2], A[N / 2] - A[N / 2 + 1]);
	}
	cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int n, m;
    ll a, b;
    ll sum = 0;
    vector<pair<ll,ll>>enagy;
    cin >> n >> m;
    rep(i, n) {
        cin >> a >> b;
        enagy.push_back(make_pair(a, b));
    }
    sort(all(enagy));
    for (auto e : enagy) {
        if (e.second <= m) {
            m -= e.second;
            sum += e.first * e.second;
        }
        else {
            sum += e.first * m;
            break;
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 5368
/**
 * @Author:      G_bg
 * @DateTime:    2019-05-19 20:06:26
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	string str;cin >> str;
	int x = 0,y = 0;
	x = (str[0]-'0')*10+(str[1]-'0');
	y = (str[2]-'0')*10+(str[3]-'0');
	if((x > 0 && x < 13) && (y > 0 && y < 13)) 
		cout << "AMBIGUOUS" << endl;
	else if(x > 0 && x < 13) cout << "MMYY" << endl;
	else if(y > 0 && y < 13) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val V = readLine()!!.split(" ").map(String::toInt)
    val C = readLine()!!.split(" ").map(String::toInt)
    V.zip(C).map { it.first - it.second }.filter { it > 0 }.sum().let(::println)
}

Measured memory_bytes: 37988
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void) {
    int n,k;
    int a = 1;
    cin >> n >> k;
    REP(i,n){
        if (a > k) {
            a += k;
        } else {
            a *= 2;
        }
    }
    cout << a;
}


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

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORV(i,a,b) for(int i=a;i*i<=b;i++)
#define Forv(i,a,b) for(int i=a;i*i<b;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define Ford(i,a,b) for(int i=a;i>b;i--)
#define Fill(s,a) memset(s,a,sizeof(s))
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int n, m, f[100001], p[100001];
long long a, b, c;

void solve()
{
    For(i, 1, m)
    {
        f[min(p[i], p[i+1])] ++;
        f[max(p[i], p[i+1])] --;
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    FOR(i, 1, m) scanf("%d", &p[i]);
    solve();
    long long ans = 0, sl = 0;
    For(i, 1, n)
    {
        scanf("%lld%lld%lld", &a, &b, &c);
        sl += f[i];
        if(sl == 0) continue;
        ans += min(a*sl, c+b*sl);
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 1988
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let K = readInt()

let listup = fix <| fun listup r n ->
  if r=1 then Seq.singleton [n]
  else
    seq {
      if n<>0 then
        yield! (listup (r-1) (n-1))
      yield! (listup (r-1) n)
      if n<>9 then
        yield! (listup (r-1) (n+1))
    }
    |> Seq.map (fun l -> n::l)
  
seq {
  for r in 1..1000 do
    for n in 1..9 do
      yield! (listup r n)
}
|> Seq.take K
|> Seq.last
|> List.fold (fun s x -> s+(string x)) ""
|> printfn "%s"


Measured memory_bytes: 16460
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N;
  cin>>N;
  if(N==1) {
cout<<"Hello World"<<endl;
  return 0;
  }
  ll A,B;
  cin>>A>>B;
  cout<<A+B<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  REP(i, n)
  cin >> l[i];
  
  sort(ALL(l));
  
  int count = 0;
  
  for(int i = 1; i < n - 1; i++){
    for(int j = 0; j < i; j++){
      for(int k = n; k > i; k--){
        if(l[i] < l[j] + l[k] && l[j] < l[k] + l[i] && l[k] < l[j] + l[i])
          count++;
      }
    }
  }
  
  printf("%d", count);
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(void){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    int n=1;
    int ans = 0;
    while(n <= N){
        if(n <= K){
            ans += X;
        }
        else{
            ans += Y;
        }
        n++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
    
    
  int main(){
      lint n,a,b;
      cin>>n>>a>>b;
      lint x=n/(a+b);
      lint y=n%(a+b);
      cout<<x*a+min(a,y);
     
  }
     
  


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

int main()
{
    //put here bitch 
    int n,k; cin>>n>>k;
    int h[1000001];
    for(int i=0;i<n;i++) cin>>h[i];
    int dp[1000001];
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k and i-j>=0;j++)
            dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int>A(N);
	for(int i = 1;i<N;i++){
		int X;
		cin >> X; 
		A[X-1]++;
	}
	for(int i = 0;i<N;i++){
		cout << A[i] <<  std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 4048
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


s = S()
a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12:
    aMM = True
else:
    aMM = False

if 1 <= b <= 12:
    bMM = True
else:
    bMM = False

if aMM and bMM:
    print("AMBIGUOUS")
elif aMM and not bMM:
    print("MMYY")
elif not aMM and bMM:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 63340
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a,b,c,d;
  cin >>n;
  a = n/1000;
  n = n-a*1000;
  b = n/100;
  n = n-b*100;
  c = n/10;
  n = n-c*10;
  d = n;
  if((a==b && b==c) || (b==c && c==d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

void solve() {

   int n;
   cin >> n;
   vector <ll> a(n);
   for (auto &i : a)
      cin >> i;

   sort(a.begin(), a.end());
   ll ans = 0;
   for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
         for (int k = j + 1; k < n; k++) {
            if (a[k] < a[i] + a[j] && a[k] != a[i] && a[i] != a[j] && a[k] != a[j]) {
               ans++;
            }
         }
      }
   }
   cout << ans << '\n';
}

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   solve();

   return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        string strOdd = Console.ReadLine();
        string strEven = Console.ReadLine();

        int intStringCount = strOdd.Length + strEven.Length;

        string strOutput = string.Empty;

        for(int i = 0; i < intStringCount; i++)
        {
            // 偶数(Even)
            if (i % 2 == 1)
            {
                strOutput += strEven[i / 2];
            }
            // 奇数(Odd)
            else
            {
                strOutput += strOdd[i / 2];
            }
        }

        Console.WriteLine(strOutput);

    }
}



Measured memory_bytes: 11092
N = int(input())
a = list()
for i in input().split(' '):
    a.append(int(i))

cost = list()
for i in range(N):
    if i == 0:
        cost.append(0)
    elif i == 1:
        cost.append(abs(a[1] - a[0]))
    else:
        c1 = abs(a[i] - a[i-1]) + cost[i-1]
        c2 = abs(a[i] - a[i-2]) + cost[i-2]
        cost.append( c1 if c1<c2  else c2)

print(cost[-1])
    
    

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

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size(), q;
	vector < int > w_s(n + 1, 0), w_t(m + 1, 0);
	for (int i = 1; i <= n; ++i)
		w_s[i] = w_s[i - 1] + int(s[i - 1] - 'A') + 1;
	for (int i = 1; i <= m; ++i)
		w_t[i] = w_t[i - 1] + int(t[i - 1] - 'A') + 1;
	cin >> q;
	while (q--) {
		int l1, r1, l2, r2;
		cin >> l1 >> r1 >> l2 >> r2;
		if ((w_s[r1] - w_s[l1 - 1]) % 3 == (w_t[r2] - w_t[l2 - 1]) % 3)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
}


Measured memory_bytes: 4256
from collections import deque

ans_list = []

def solve():
    H = int(input())
    if H == 0:
        return "end"
    grid = [list(map(int,input().split())) for _ in range(H)]
    
    def erase(i):
        res = 0
        a = grid[i]
        dq = deque()
        for j in range(5):
            if not dq:
                dq.append(a[j])
            elif dq[-1] == a[j] and a[j] != 0:
                dq.append(a[j])
            else:
                if len(dq) >= 3:
                    res += dq[-1] * len(dq)
                    # 消したところを0に書き換える
                    for nj in range(j-len(dq),j):
                        grid[i][nj] = 0
                dq.clear()
                dq.append(a[j])
        if len(dq) >= 3:
            res += dq[-1] * len(dq)
            # 消したところを0に書き換える
            for nj in range(j+1-len(dq),j+1):
                grid[i][nj] = 0
        return res
    
    def drop(j):
        b = [grid[i][j] for i in range(H)]
        dq = deque()
        for i in range(H)[::-1]:
            # 下から詰めていく 左から取り出して下から詰める
            if b[i] != 0:
                dq.append(b[i])
        for ni in range(H)[::-1]:
            if dq:
                num = dq.popleft()
            else:
                num = 0
            grid[ni][j] = num

    score = 0

    while True:
        res = 0
        for i in range(H):
            res += erase(i)
        score += res
        if res == 0:
            break
        for j in range(5):
            drop(j)
    
    return score

while True:
    ans = solve()
    if ans == "end":
        break
    ans_list.append(ans)

for ans in ans_list:
    print(ans)


Measured memory_bytes: 6052
N,K,S = map(int, input().split())

if S == 10**9:
  ans = [S]*K +[1]*(N-K)
else:
  ans = [S]*K +[S+1]*(N-K)

ans_txt=''

for s in ans:
  ans_txt += str(s)+' '

print(ans_txt)

Measured memory_bytes: 7420