akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

struct {
  using pair = std::pair<long double, std::string>;
  bool operator ()(const pair& p, const pair& q) const {
    if (p.first != q.first) return p.first > q.first;
    return p.second < q.second;
  }
} cmp; 

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<std::pair<long double, std::string>> a;
  for (size_t i = 0; i < n; ++i) {
    char buf[32];
    scanf("%s", buf);
    std::string L = buf;

    int P, A, B, C, D, E, F, S, M;
    scanf("%d %d %d %d %d %d %d %d %d", &P, &A, &B, &C, &D, &E, &F, &S, &M);

    long double ef = F*S*M - P;
    ef /= (A+B+C) + (D+E)*M;
    a.emplace_back(ef, L);
  }

  std::sort(a.begin(), a.end(), cmp);
  for (const auto& ai: a)
    printf("%s\n", ai.second.c_str());

  puts("#");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	vector<int> A(3, 0);
	for (int i=0; i<3; i++)
		cin >>A.at(i);
	sort(A.begin(), A.end());
	cout <<A.at(0)+A.at(1) <<endl;
	return 0;
}



Measured memory_bytes: 256
n=int(input())
S=list(input())
R=[0 for _ in range(n)]
G=[0 for _ in range(n)]
B=[0 for _ in range(n)]
r=0;g=0;b=0
for i in range(n):
    if S[i]=="R":
        r+=1 
    if S[i]=="G":
        g+=1
    if S[i]=="B":
        b+=1
    R[i]=r; G[i]=g; B[i]=b
cnt=0
for i in range(n-2):
    for j in range(i,n-1):
        if S[i]==S[j]:
            continue
        if (S[i]=="R" or S[i]=="G") and (S[j]=="R" or S[j]=="G"):
            cnt+=B[-1]-B[j]
            try:
                if S[2*j-i]=="B":
                    cnt-=1
            except:
                pass
        if (S[i]=="G" or S[i]=="B") and (S[j]=="G" or S[j]=="B"):
            cnt+=R[-1]-R[j]
            try:
                if S[2*j-i]=="R":
                    cnt-=1
            except:
                pass
        if (S[i]=="B" or S[i]=="R") and (S[j]=="B" or S[j]=="R"):
            cnt+=G[-1]-G[j]
            try:
                if S[2*j-i]=="G":
                    cnt-=1
            except:
                pass
print(cnt)

Measured memory_bytes: 69224
#include<bits/stdc++.h>
using namespace std;
int n,a[55],b[55],mi=1e9,fa[55];
int find(int x)
{
	if(fa[x]==x)return x;
	fa[x]=find(fa[x]);
	return fa[x];
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)
			{
				int ans=0;
				int x=a[i]-a[j],y=b[i]-b[j];
				for(int k=1;k<=n;k++)fa[k]=k;
				for(int k=1;k<=n;k++)
					for(int p=1;p<=n;p++)
						if(a[k]+x==a[p]&&b[k]+y==b[p])
						{
							fa[find(k)]=find(p);
						}
				for(int k=1;k<=n;k++)
					if(fa[find(k)]==k)ans++;
				mi=min(mi,ans);
			}
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	cout<<mi;
}

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

int main() {
	int n;
	int tmp;
	int num = 1;
	int s = 0;

	scanf("%d", &n);

	for(int i = 0; i < n; i++) {
		scanf("%d", &tmp);
		if(tmp == num) {
			s++;
			num++;
		}
	}

	printf("%d\n", (s == 0 ? -1 : n - s));
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<vector>
#include<string>
using namespace std;
long long mod(string num, long long a) 
{ 
    // Initialize result 
    long long res = 0; 
  
    // One by one process all digits of 'num' 
    for (long long i = 0; i < num.length(); i++) 
         res = (res*10 + (int)num[i] - '0') %a; 
  
    return res; 
} 
  
int main()
{   long long k,diff,last;
string n;
cin>>n>>k;
long long s = mod(n,k);
if(abs(s-k)< s)
s =mod(to_string(k),s);
cout<<s;
return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

long long gcd (long long a , long long b) {
   if (b == 0) return a;
   return gcd(b, a % b);
}
map<ll, ll> prime_factors(ll n) {
    map<ll, ll> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(ll i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

int main() {
   ll A, B;
   cin >> A >> B;
   ll g = gcd(A, B);
   map<ll, ll> res = prime_factors(g);
   ll ans = 0;
   for(map<ll, ll>::iterator it = res.begin(), end = res.end(); it != end; ++it) {
      // cout << it->first << "^" << it->second << endl;
      ans++;
      if (it->first == 1) ans = 0;
   }
   cout << ans + 1 << endl;
   return 0;
}


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

int main() {
  int n;
  cin >> n;
  int cnt[26];
  rep(i, 26) cnt[i] = 50;
  rep(i, n) {
    string s;
    cin >> s;
    int tmp[26];
    rep(j, 26) tmp[j] = 0;
    rep(j, s.length()) ++tmp[s[j]-'a'];
    rep(j, 26) cnt[j] = min(cnt[j], tmp[j]);
  }
  rep(i, 26) {
    rep(j, cnt[i]) printf("%c", i+'a');
  }
  cout << endl;
  return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
	int a,b;
	string s;
	cin >> a >> b >> s;
	for (int i = 0; i < a; i++) {
		if (s[i] < '0' or s[i] > '9') {
			goto no;
		}
	}
	if (s[a] != '-') {
		goto no;
	}
	for (int i = a+1; i < a+b+1; i++) {
		if (s[i] < '0' or s[i] > '9') {
			goto no;
		}
	}
	cout << "Yes" <<endl;
	return 0;
no:
	cout << "No" << endl;
	return 0;

	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys


def main():
    S = input()
    ary = ['N' in S, 'W' in S, 'S' in S, 'E' in S]

    if ary[0] == ary[2] and ary[1] == ary[3]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
#pragma GCC optimize ("trapv")

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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;
 
typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;
typedef long double C; 

#define trace(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(){
	fastio;
	

	int n; cin>>n;
	vi v(n);
	rep(i,0,n) cin>>v[i];
	int ans=1e9;
	rep(i,-101,101){
		int foo=0;
		rep(j,0,n){
			foo+=(v[j]-i)*(v[j]-i);
		}
		ans=min(ans,foo);
	}


	cout<<ans<<endl;


	return 0;
}


/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/

/*
tip:
 crtl+B to find errors in the code  
*/


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  int n,m;
  cin>>n>>m;
  vector<int> yk;
  for(int i=1;i<=sqrt(m);i++){
    if(m%i==0){
      yk.push_back(i);
      yk.push_back(m/i);
    }
  }
  sort(yk.begin(),yk.end());
  double ch=m/n;
  int ans=0;
  for(int i=0;yk[i]<=ch&&i<yk.size();i++){
    ans=yk[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        
# 二項係数
def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if not (0<=r and r<=n):
        return 0
    
    return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod


from collections import Counter

MOD = 10**9+7

n = ni()
a = list(li())

# 被っている数の後にある数の個数を把握
cnt = Counter(a)
db = 0
for k,v in cnt.items():
    if v == 2:
        db = k
        
front = a.index(db)
back = a[::-1].index(db)

# 二項係数の準備
inv = inv_mod(n+1,MOD)
fac = fact(n+1, MOD)
facInv = fact_inv(n+1,inv,MOD)

# 出力
for k in range(1, n+2):
    ans = nCr(n+1,k,MOD,fac,facInv) - nCr(front+back,k-1,MOD,fac,facInv)
    if ans < 0:
        ans += MOD
    
    print(ans)

Measured memory_bytes: 27024
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
map<string,ll> S;
  string s,t;
  cin>>s>>t;
  ll a,b;
  cin>>a>>b;
  S[s]=a;
  S[t]=b;
  string u;
  cin>>u;
  S[u]--;
  cout<<S[s]<<" "<<S[t]<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
  char s[102];
  int i, slen, k, ans, count=0;
  cin >> s >> k;
  slen=strlen(s);
  for(i=0; i<slen; i++){
    if(s[i]=='1') count++;
    else {
      ans=s[i]-'0';
      break;}
  }
    if(count>=k) cout << 1;
    else cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int a, b, m;
	scanf("%d%d%d", &a, &b, &m);
	vector<int> A(a), B(b);
	for (int i = 0; i < a; ++i) scanf("%d", &A[i]);
	for (int i = 0; i < b; ++i) scanf("%d", &B[i]);
	int ans = *min_element(A.begin(), A.end()) + *min_element(B.begin(), B.end());
	for (int i = 0; i < m; ++i) {
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		--x;
		--y;
		ans = min(ans, A[x] + B[y] - c);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 4036
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var AB = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var answer = 0;
            for (var x = AB[0]; x <= AB[1]; x++)
            {
                var s = x.ToString();
                var isValid = true;
                for (int l = 0, r = s.Length - 1; l < r; l++, r--)
                {
                    if (s[l] != s[r])
                    {
                        isValid = false;
                        break;
                    }
                }
                if (isValid) answer++;

            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 3e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int arr[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  ll x;
  cin >> x;
  ll base = 0;
  while(x) {
    x /= 2;
    ++base;
  }
  cout << (1ll << base) - 1;
  return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N, X;
  cin >> N >> X;
  vector< int > A(N);
  cin >> A;

  int64 ret = 0;
  for(int i = 0; i < A.size(); i++) {
    int more = max(0, A[i] - X);
    ret += more;
    A[i] -= more;
  }

  for(int i = 1; i < A.size(); i++) {
    int more = max(0, A[i] + A[i - 1] - X);
    ret += more;
    A[i] -= more;
  }

  cout << ret << endl;
}


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

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		ans += (B - A + 1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int dp[1100][11000];
const int INF = 1001001001;
int main()
{
    int h,n;
    cin >> h >> n;
    rep(i,n+1)rep(j,h+1)dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        rep(j,h+1){
            dp[i+1][j] = min(dp[i][j],dp[i+1][j-a]+b);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 45312
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>
 
#define rep(i,n) for(int i=0; i < n; i++)
using namespace std;
#define PI 3.1415
 
int main()
{
    double r;
    cin >> r;
    
 
    cout << 2* r * PI << endl;
    return 0;
}

Measured memory_bytes: 3736
N = int(input())
A = list(map(int, input().split()))
l = A[0]
r = 0
indexl = 1
indexr = N-1
for i in range(N-1):
	if l <= r:
		l += A[indexl]
		indexl += 1
	elif l > r:
		r += A[indexr]
		indexr -= 1
print(abs(l-r))

Measured memory_bytes: 26060
#include<stdio.h>
#include<math.h>

#include<iostream>
#include<algorithm>
using namespace std;
long long int ww = -1;
void wow(long long int q[3]) {
	sort(q,q+3);
	long long int r = q[2]-q[0];
	if(ww==-1)	ww = r;
	else	ww = min(r,ww);
}

int main() {
	long long int h,w,i,j;
	scanf("%lld%lld",&h,&w);
	if(h%3==0||w%3==0) {
		ww = 0;
	} else {
		long long int a[6],b[6];
		a[0]=h/3;
		b[0]=w/3;
		a[1]=a[0]+1;
		b[1]=b[0]+1;
		a[2]=a[0]+2;
		b[2]=b[0]+2;
		a[3] = h/2;
		b[3] = w/2;
		a[4]=a[0]-1;
		b[4]=b[0]-1;
		a[5]=a[0]-2;
		b[5]=b[0]-2;
		for(i=0; i<6; i++) {
			for(j=0; j<6; j++) {
				if(a[i]>=0&&b[j]>=0&&a[i]<=h&&b[j]<=w) {
					long long int q[3];
					q[0]= a[i]*w;
					q[1]=(h-a[i])*b[j];
					q[2] =(h-a[i])*(w-b[j]);
					wow(q);
					q[0]= b[j]*h;
					q[1]=(w-b[j])*a[i];
					q[2] =(w-b[j])*(h-a[i]);
					wow(q);
					q[0]= (h-a[i])*w;
					q[1]=(a[i])*b[j];
					q[2] =(a[i])*(w-b[j]);
					wow(q);
					q[0]= (w-b[j])*h;
					q[1]=(b[j])*a[i];
					q[2] =(b[j])*(h-a[i]);
					int c=q[0];
					wow(q);
				}
			}
		}
		for(i=0; i<6; i++) {
			for(j=i; j<6; j++) {
				if(b[i]>=0&&b[j]>=0&&b[i]+b[j]<=w) {
					long long int q[3];
					q[0]= b[i]*h;
					q[1]=b[j]*h;
					q[2] =(w-b[i]-b[j])*h;
					wow(q);
				}
			}
		}
		for(i=0; i<6; i++) {
			for(j=i; j<6; j++) {
				if(a[i]>=0&&a[j]>=0&&a[i]+a[j]<=h) {
					long long int q[3];
					q[0]= a[i]*w;
					int b3 = q[0];
					q[1]=a[j]*w;
					q[2] =(h-a[i]-a[j])*w;
					wow(q);
				}
			}
		}

	}
	printf("%lld",ww);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int so[100100];
int ev[100100];
int ae,ao;
int anse,anso;
int sume,sumo;
int od[100100];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>so[i];
    for(int i=0;i<n;i++){
        if(i%2) ev[so[i]]++;
        else od[so[i]]++;
    }
    for(int i=0;i<100100;i++){
        if(anse<=ev[i]){
            ae=anse;
            anse=ev[i];
            sume=i;
        }
        else if(ae<ev[i]) ae=ev[i];
        if(anso<=od[i]){
            ao=anso;
            anso=od[i];
            sumo=i;
        }
        else if(ao<od[i]) ao=od[i];
    }
    if(sumo!=sume) cout<<n-anse-anso;
    else cout<<min(n-anse-ao,n-anso-ae);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;
    ll n,k;
    cin>>n>>k;
    map<int,int> m;
    n = n - k*(n/k);
    ll ans = n;
    while(m[n]==0){
        m[n]++;
        n = abs(n - k);
        ans = min(ans,n);
    }
    cout<<ans;
}

//Total solved problems:-3


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

int main(){
  vector<string> S(2);
  for (int i = 0; i < 2; i++){
    cin >> S.at(i);
  }
  if (S.at(0).at(0) == S.at(1).at(2) && S.at(0).at(1) == S.at(1).at(1) && S.at(0).at(2) == S.at(1).at(0)){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
struct threeElements{
int f,s,t;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   int a,b;
    cin>>a>>b;
    cout<<a*b;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N,Q;
    long long S,T;

    cin >> N >> Q >> S >> T;

    vector<long long> A;

    for(int i=0; i<=N; ++i) {
        long long temp,before;
        cin >> temp;
        if(i==0) {
            A.push_back(temp);
            before=temp;
        }
        else {
            A.push_back(temp-before);
            before=temp;
        }
    }

    long long temp=0;

    for(int i=1; i<=N; ++i) {
        if(A[i]>0) temp-=S*A[i];
        else temp-=T*A[i];
    }

    for(int j=0; j<Q; ++j) {
        long long l,r,x,a;
        cin >> l >> r >> x;

        a=A[l];
        if(a>0) temp+=S*a;
        else temp+=T*a;

        A[l]+=x;
        if(A[l]>0) temp-=S*A[l];
        else temp-=T*A[l];

        if(r<N) {
            a=A[r+1];
            if(a>0) temp+=S*a;
            else temp+=T*a;

            A[r+1]-=x;
            if(A[r+1]>0) temp-=S*A[r+1];
            else temp-=T*A[r+1];
        }

        cout << temp << endl;
    }

    return 0;
}

Measured memory_bytes: 4984
#include<bits/stdc++.h>
#include<cmath>
#include<string>
#include<algorithm>

using namespace std;

int main()
{

    int n,x=0,h,k;cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>h;
        if(h>=k) x++;
    }
    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
 
int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, n) {
        cin >> h[i];
    }

    if(n == 1) {
        cout << "Yes" << endl;
        return 0;
    }

    int nowmaxh = 0;
    rep(i, n) {
        if(nowmaxh < h[i]) {
            nowmaxh = h[i];
        }

        if(2 + h[i] <= nowmaxh) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes";
    
    cout << endl;
    return 0;
}

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

class Osa_k {
private:
    int n;
    vector<int> factor;
public:
    Osa_k(int _n):n(_n) {
        factor.assign(n, 0);
        iota(factor.begin(), factor.end(), 0);
        for(int i = 2; i < n; i++) {
            if(factor[i] != i)continue;
            for(int j = i + i; j < n; j += i) factor[j] = i;
        }
    }

    vector<pair<int,int>> fact(int v) {
        unordered_map<int, int> ret;
        while(v != factor[v]) {
            ret[factor[v]]++;
            v /= factor[v];
        }
        if(v != 1)ret[v]++;
		vector<pair<int,int>> t;
		for(auto i : ret)t.push_back(i);
        return t;
    }

    vector<int> divisor(int v) {
        vector<int> que = {1};
        vector<pair<int,int>> a = fact(v);
        for(auto i : a) {
            int num = 1;
            vector<int> nxt;
            for(int j = 0; j <= i.second; j++) {
                int m = que.size();
                for(int k = 0; k < m; k++)nxt.push_back(num * que[k]);
                num *= i.first;
            }
            que = nxt;
        }
        sort(que.begin(), que.end());
        return que;
    }

}fact(1000001);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> in(1000001);
    for(int i = 0; i < n; i++)cin >> a[i], in[a[i]]++;
    int sum = 0;
 
    for(int i = 0; i < n; i++) {
        vector<int> num = fact.divisor(a[i]);
        int res = 0;
        for(int j = 0; j < (int)num.size(); j++) {
            res += in[num[j]];
        }
        if(res == 1)sum++;
    }
    cout << sum << '\n';
}

Measured memory_bytes: 11892
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

typedef long long ll;
int N,M,P;
ll D[2510];
ll inf = 1e18;
struct edge {int from,to; ll cost;};

vector<edge> v;

void shortest_path(int s){
	for(int i=1;i<=N;i++) D[i] = inf;
	D[s] = 0;
	for(int j=0;j<N-1;j++){
		for(int i=0;i<v.size();i++){
			edge e = v[i];
			if(D[e.from] != inf && D[e.to] > D[e.from] + e.cost){
				D[e.to] = D[e.from] + e.cost;
			}
		}
	}
}

void find_negative_loop(){
	for(int i=1;i<=N;i++){
		for(int j=0;j<v.size();j++){
			edge e = v[j];
			if(D[e.to]!=inf && D[e.to] > D[e.from] + e.cost){
				D[e.to] = -inf;
			}
		}
	}
}

int main(){
	cin >> N >> M >> P;
	for(int i=0;i<M;i++){
		int a,b,c;
		cin >> a >> b >> c;
		v.push_back((edge{a,b,P-c}));
	}
	shortest_path(1);
	ll ans = max(-D[N],0LL);
	find_negative_loop();
    cout << (D[N]==-inf? -1:ans) << endl;
}


Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
#include<numeric>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

ll comb(ll i, ll j)
{
  if (i < j) {
    ll tmp = j;
    j = i;
    i = tmp;
  }

  if (j > i - j) {
    j = i-j;
  }
  if (j == 0) return 1;

  ll bunsi = 1; ll bunbo = 1;
  for (int k = j; k > 0; k--) {
    bunbo *= k;
  }
  ll tmp = i;
  for (int l = j; l > 0; l--) {
    bunsi *= tmp--;
  }
  return bunsi / bunbo;
}

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

  int oddNum = 0;
  int evenNum = 0;

  rep(i, n) {
    if (a[i] & 1) oddNum++;
    else evenNum++;
  }

  ll zentori = pow(2, n);
  ll kitori = 0;
  // 奇数を奇数こいれることを考える
  for (int i = 0; i <= oddNum; i++) {
    if (!(i & 1)) continue;
    kitori += comb(oddNum, i) * pow(2, evenNum);
    // oddNum C i を pow(2, oddNum) にかけてkitoriに加算
  }

  if (p) {
    cout << kitori << endl;
  } else {
    cout << zentori - kitori << endl;
  }
}




Measured memory_bytes: 4036
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊

    let (_, x, _) = (io.chars(), io.chars(), io.chars());
    println!("A{}C", x[0]);
}

static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include <stdio.h>


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

Measured memory_bytes: 128
from collections import defaultdict
import heapq

def dijkstra(G, s):
    q = []
    heapq.heapify(q)
    prev = [None] * len(G.keys())
    dist = [float('inf')] * len(G.keys())
    dist[s] = 0
    for v in sorted(G.keys()):
        heapq.heappush(q, (dist[v],v))
    while True:
        try:
            _, u = heapq.heappop(q)
        except:
            break
        for v, d in G[u]:
            tmp = dist[u] + d
            if dist[v] > tmp:
                dist[v] = tmp
                prev[v] = u
                heapq.heappush(q, (tmp, v))
    return dist

n, m, s, t = map(int, input().split())
G1 = defaultdict(list)
G2 = defaultdict(list)

for i in range(m):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    G1[u].append((v, a))
    G1[v].append((u, a))
    G2[u].append((v, b))
    G2[v].append((u, b))

dist1 = dijkstra(G1, s-1)
dist2 = dijkstra(G2, t-1)

mv = 0
ans = []
for i in range(n-1, -1, -1):
    mv = max(mv, 10**15 - dist1[i] - dist2[i])
    ans.append(mv)

ans.reverse()
for a in ans:
    print(a)

Measured memory_bytes: 125272
#include<iostream>
#include<algorithm>

using namespace std;


int solve(int y, int m, int d){
	int res = 0;
	while(y != 1000){
		d++;
		if(m%2==1 || y%3==0){
			if(d == 21){
				d = 1;
				m++;
			}
		} 
		else{
			if(d == 20){
				d = 1;
				m++;
			}
			}
		if(m == 11){
			y++;
			m = 1;
		}
		res++;
	}
	return res;
}  	

int main(){
	int n, y, m, d;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> y >> m >> d;
		cout << solve(y, m, d) << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
# ABC073D - joisino's travel
from heapq import heapify, heappop, heappush
from itertools import permutations


def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
    dist = [float("inf")] * size
    queue = [(0, start)]
    unchecked = size - 1  # vertex_0 won't appear in 1-idx graph
    heapify(queue)
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        dist[v] = cost
        for next_cost, u in G[v]:
            if cost + next_cost < dist[u]:
                heappush(queue, (cost + next_cost, u))
        unchecked -= 1
        if not unchecked:
            break
    return dist


def main():
    global G, N
    N, M, R, *RABC = map(int, open(0).read().split())
    visit, ABC = RABC[:R], RABC[R:]
    G = [[] for _ in range(N + 1)]
    for v, u, cost in zip(*[iter(ABC)] * 3):
        G[v].append((cost, u)), G[u].append((cost, v))
    dist = {v: dijkstra(G, N + 1, v) for v in visit}
    ans = float("inf")
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9836
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))
  

def gcd(a, b):
    """最大公約数"""
    if b == 0: return a
    return gcd(b, a % b)


def main():
    a, b, k = Input()
    k -= 1
    data = sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True)

    print(data[k])

main()

Measured memory_bytes: 9172
import java.util.*;

public class Main {
	static long L;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		L = sc.nextLong();
		String[] s = new String[N];
		for(int i=0; i<N; i++)
			s[i] = sc.next();
		
		Arrays.sort(s);

		long xor=0;
		if(s[0].charAt(0)=='1')
			xor ^= grundy(L);
		xor ^= move("", s[0]);
		for(int i=0; i<N-1; i++) {
			xor ^= move(s[i], s[i+1]);
		}
		xor ^= move(s[N-1], "");
		if(s[s.length-1].charAt(0)=='0')
			xor ^= grundy(L);
		
		System.out.println(xor==0 ? "Bob" : "Alice");
		sc.close();
	}
	
	static long grundy(long n) {
		long ans=1;
		while(n%ans==0)
			ans<<=1;
		return ans;
	}
	
	static long move(String s, String t) {
		String prefix = getPrefix(s, t);
		return up(s, prefix) ^ down(prefix, t);
	}
	
	static long up(String s, String t) {
		long ans = 0;
		for(int i=s.length()-1; i>t.length(); i--) {
			if(s.charAt(i)=='0')
				ans ^= grundy(L-i);
		}
		return ans;
	}
	
	static long down(String s, String t) {
		long ans = 0;
		for(int i=s.length()+1; i<t.length(); i++) {
			if(t.charAt(i)=='1')
				ans ^= grundy(L-i);
		}
		return ans;
	}
	
	static String getPrefix(String s1, String s2) {
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<s1.length() && i<s2.length() && s1.charAt(i)==s2.charAt(i); i++)
			sb.append(s1.charAt(i));
		
		return sb.toString();
	}
}


Measured memory_bytes: 31732
#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;

int n;
int k;
int h[100010];

int dp[10][100010];
int a, b, c;

int main(){
    cin >> n;
    cin >> a >> b >> c;
    dp[0][0] = a;
    dp[1][0] = b;
    dp[2][0] = c;

    for (int i = 1; i < n; ++i) {
        cin >> a >> b >> c;
        dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a;
        dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b;
        dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c;

    }


    cout << max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]) << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
//#include <climits>
//#include <cstdio>
//#include <string>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define VEC vector<int>
// vector<VEC> v (n, VEC(n))
//loop(i,n)loop(j,n)dp[i][j]=-1;
//printf("%d\n", n);
int main()
{
	string n;
	cin >> n;
	loop(i, n.size() - 8)
	{
		cout << n[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int d1[1000001]={},d2[1000001]={};
int main(){
	int n,i=0,j=0;
	int pollock1[181]={},pollock2[46]={};
	for(i=1;i*(i+1)*(i+2)/6<1000000;i++){
		pollock1[i-1]=i*(i+1)*(i+2)/6;
		if(pollock1[i-1]%2)
		pollock2[j++]=pollock1[i-1];
	}
	for(i=0;i<1000001;i++){
		d1[i]=9999999;
		d2[i]=9999999;
	}
	for(i=0;i<180;i++)
		d1[pollock1[i]]=1;
	for(i=0;i<45;i++)
		d2[pollock2[i]]=1;
	
	for(i=1;i<1000001;i++){
		for(j=0;j<180;j++){
			if(d1[i] && i+pollock1[j]<1000001){
				d1[i+pollock1[j]]=min(d1[i+pollock1[j]],d1[i]+1);
			}
		}
	}
	for(i=1;i<1000001;i++){
		for(j=0;j<45;j++){
			if(d2[i] && i+pollock2[j]<1000001){
				d2[i+pollock2[j]]=min(d2[i+pollock2[j]],d2[i]+1);
			}
		}
	}
	while(cin>>n,n){
		cout<<d1[n]<<' '<<d2[n]<<endl;
	}
}

Measured memory_bytes: 8972
#include<stdio.h>
int main(void){
  int a;
  scanf("%d",&a);
  int L=a/100;
  int R=a%100;
  if(1<=L && L<=12){
    if(1<=R && R<=12){
      printf("AMBIGUOUS\n");
    }else{
      printf("MMYY\n");
    }
  }else{
    if(1<=R && R<=12){
      printf("YYMM\n");
    }else{
      printf("NA\n");
    }
  }
  return 0;
}


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

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

    lint cnt = 0;
    while(a > 0 && c > 0) {
        cnt++;
        if(cnt&1) {
            c -= b;
        } else {
            a -= d;
        }
        // cout << a << " " << c << endl;
    }

    cout << (a > 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int a,b,c,k;
  scanf("%d %d %d %d",&a,&b,&c,&k);
  if(a >= k) printf("%d",k);
  else if(a+b >= k) printf("%d" ,a);
  else printf("%d",a-(k-a-b));
}

Measured memory_bytes: 1732
n = int(input())
a = list(map(int, input().split()))
a2 = [i - a[i] for i in range(n)]
a3 = [a[i] + i for i in range(n)]
b2 = {}
for i in a2:
    b2.setdefault(i, 0)
    b2[i] += 1
b3 = {}
for i in a3:
    b3.setdefault(i, 0)
    b3[i] += 1
ans = 0
for i, j in b2.items():
    b3.setdefault(i, 0)
    ans += j * b3[i]
print(ans)

Measured memory_bytes: 83616
def solve(N, A, B, C, D):
    d = {0:0, 1:D}
    s = set()
    return dfs(N, A, B, C, D, d, s)

def dfs(n, A, B, C, D, d, s):
    if n in d:
        return d[n]
    if n in s:
        return float('inf')
    
    s.add(n)
    ans = float('inf')
    
    p = n % 2
    if p == 0:
        ans = min(ans, dfs(n // 2, A, B, C, D, d, s) + A)
    else:
        ans = min(ans, dfs((n - p) // 2, A, B, C, D, d, s) + A + D * p)
        ans = min(ans, dfs((n + (2 - p)) // 2, A, B, C, D, d, s) + A + D * (2 - p))

    q = n % 3
    if q == 0:
        ans = min(ans, dfs(n // 3, A, B, C, D, d, s) + B)
    else:
        ans = min(ans, dfs((n - q) // 3, A, B, C, D, d, s) + B + D * q)
        ans = min(ans, dfs((n + (3 - q)) // 3, A, B, C, D, d, s) + B + D * (3 - q))
    
    r = n % 5
    if r == 0:
        ans = min(ans, dfs(n // 5, A, B, C, D, d, s) + C)
    else:
        ans = min(ans, dfs((n - r) // 5, A, B, C, D, d, s) + C + D * r)
        ans = min(ans, dfs((n + (5 - r)) // 5, A, B, C, D, d, s) + C + D * (5 - r))
    
    ans = min(ans, D * n)
    
    d[n] = ans
    return ans

T = int(input())
for _ in range(T):
    N, A, B, C, D = map(int,input().split())
    ans = solve(N, A, B, C, D)
    print(ans)

Measured memory_bytes: 11712
N = int(input())
A = list(map(int, input().split()))
ans = 0
flag = True
while True:
	for i in range(len(A)):
		if A[i] % 2 != 0:
			flag = False
		A[i] = A[i] / 2
	if flag == False:
		break
	ans += 1
print(ans)

Measured memory_bytes: 3060
use std::error::Error;
use std::io;

struct Bit {
    array: Vec<i32>,
}

impl Bit {
    fn add(&mut self, index: usize, value: i32) {
        let mut next_index = index;
        while next_index < self.array.len() {
            self.array[next_index] += value;
            next_index += (next_index as i64 & -(next_index as i64)) as usize;
        }
    }

    fn sum(&self, index: usize) -> i64 {
        let mut next_index = index as i64;
        let mut result = 0i64;
        while next_index > 0 {
            result += self.array[next_index as usize] as i64;
            next_index -= (next_index as i64 & -(next_index as i64));
        }
        result
    }
}

pub fn main() {
    if let Err(e) = run() {
        panic!("failed.");
    }
}

// find the first item match.
fn find(sorted_array: &Vec<i64>, target: i64) -> usize {
    let mut left = 0usize;
    let mut right = sorted_array.len();
    while left < right {
        let middle = (right - left) / 2 + left;
        if sorted_array[middle] < target {
            left = middle + 1;
        } else {
            right = middle;
        }
    }
    left
}

fn run() -> Result<(), Box<Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    let first_line: Vec<i32> = input
        .split_whitespace()
        .map(|s| s.trim().parse::<i32>().unwrap())
        .collect();
    let n = first_line[0];
    let k = first_line[1] as i64;
    input.clear();
    let mut b = vec![0i64; 1 + n as usize];

    for i in 1..1 + n as usize {
        io::stdin().read_line(&mut input);
        let number: i64 = input.trim().parse().unwrap();
        input.clear();
        b[i] = b[i - 1];
        b[i] += number;
        b[i] -= k;
    }

    let mut sorted_array = b.clone();
    sorted_array.sort();
    let mut c = vec![0; 1 + n as usize];
    for i in 0..1 + n as usize {
        c[i] = find(&sorted_array, b[i]);
    }
    let mut result = 0i64;
    let mut bit = Bit {
        array: vec![0; 2 + n as usize],
    };
    for i in 0..1 + n as usize {
        result += bit.sum(c[i] + 1);
        bit.add(c[i] + 1, 1);
    }
    println!("{:?}", result);
    Ok(())
}


Measured memory_bytes: 12668
import java.util.*;
import java.lang.*;

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

Measured memory_bytes: 22740
#include <iostream>

using namespace std;

int main() {
	int cup[3] = {1, 0, 0};
	string str;
	int index1, index2;
	while (cin >> str) {
		index1 = str[0] - 'A';
		index2 = str[2] - 'A';
		swap(cup[index1], cup[index2]);
//		cout << cup[0] << " " << cup[1] << " " << cup[2] << endl;
	}
	for (int i = 0; i < 3; i++)
		if (cup[i] == 1)
			cout << (char)('A' + i) << endl;
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
int main(){
    int n,m,cnt =0;
    double sum =0;
    cin >> n>>m;
    int arr[n];
    fo(i,n){
        cin >> arr[i];
        sum += arr[i];
    }
    sort(arr, arr+n ,greater<int>());
    sum = (sum)/(4*m);
    fo(i,n){
        if(arr[i]>=sum){
            ++cnt;
        }
        if(cnt==m){
            break;
        }
    } 
    if(cnt==m){
        cout <<"Yes";
    }   
    else{
        cout << "No";
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long int  ll;
ll  v[200009];
int main() {
	// #ifndef ONLINE_JUDGE
	// 	// for getting input from input.txt
	// 	freopen("input.txt", "r", stdin);
	// 	// for writing output to output.txt
	// 	freopen("output.txt", "w", stdout);
	// #endif
	ll n,t,ans =0;
	cin>>n>>t;
	// ans = t;
	// vector<ll> v(n,0);
	for (ll i = 1; i <=n; ++i)
	{
		cin>>v[i];
	}
	for (ll i = 1; i <= n-1; ++i)
	{
		if(v[i+1] - v[i] <= t){
			ans = ans + (v[i+1]-v[i]);
		}	
		else{
			ans = ans + t;
		}
	}

	cout<<ans+t<<"\n";
	return 0;
    }
	

Measured memory_bytes: 1792
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

#define P 998244353

int a[3000];
int b[3001][3001];
int main(void){
	int n=nextint();
	int s=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	b[0][0]=1;
	for(int i=0; i<=n; i++){
		for(int j=s-a[i]+1; j<=s; j++){
			b[i+1][j]=b[i][j]*2%P;
		}
		for(int j=s-a[i]; j>=0; --j){
			b[i+1][j]=b[i][j]*2%P;
			b[i+1][j]%=P;
			b[i+1][j+a[i]]+=b[i][j];
			b[i+1][j+a[i]]%=P;
		}
	}
	printf("%d\n", b[n][s]);
}


Measured memory_bytes: 36788
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int po[]=new int[n];
        for(int i=0;i<n;i++)po[i]=sc.nextInt();
        int count=0;
        for(int i=0;i<n;i++){
            boolean b=true;
            for(int j=0;j<i;j++){
                if(po[i]<po[j])b=false;
            }
            if(b)count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22740