akhauriyash/Code-Regression huggingface dataset:
t2s m s d = m * 60 + s + d / 100.0

ans (t1:t2:_)
  | (t1 < (t2s 0 35 50)) && (t2 < (t2s 1 11 00)) = "AAA"
  | (t1 < (t2s 0 37 50)) && (t2 < (t2s 1 17 00)) = "AA"
  | (t1 < (t2s 0 40 00)) && (t2 < (t2s 1 23 00)) = "A"
  | (t1 < (t2s 0 43 00)) && (t2 < (t2s 1 29 00)) = "B"
  | (t1 < (t2s 0 50 00)) && (t2 < (t2s 1 45 00)) = "C"
  | (t1 < (t2s 0 55 00)) && (t2 < (t2s 1 56 00)) = "D"
  | (t1 < (t2s 1 10 00)) && (t2 < (t2s 2 28 00)) = "E"
  | otherwise = "NA"

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Float]]
      o = map ans i
  mapM_ putStrLn o

Measured memory_bytes: 4228
(defun kuku-list ()
  (loop :as i
        :below 9
        :collect 
          (loop :as j
                :below (+ i 1)
                :collect (* (+ i 1) (+ j 1)))))
                
(defun flat (l)
  (apply #'append l))

(let ((n (read)))
  (if (find n (flat (kuku-list)))
      (princ "Yes")
      (princ "No")))

Measured memory_bytes: 25444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,ans = 0,d,j,a;
    cin>>n>>d;
    vector<int>v[n];
    map<int,int>mp;
    for(i = 1;i <= 20;i++)
        mp[i*i] = 1;

    for(i = 0;i < n;i++)
    {
        for(j = 0;j < d;j++)
        {
            cin>>a;
            v[i].push_back(a);
        }
    }
    if(d==1)
    {
       cout<<(n*(n-1))/2<<endl;
    }
    else
    {
    int sum = 0;
    for(i = 0;i < n;i++)
    {
        for(j = i+1;j < n;j++)
        {
            for(int k = 0;k < d;k++)
            {
                sum += (v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
            }
            int mm = sqrt(sum);
            if(mm*mm==sum)
                ans++;
            sum = 0;
        }
    }
    cout<<ans<<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;
using ll = long long;
using P =pair<int,int>;

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    if(A+B<=N){
        cout<<min(A,B)<<" "<<0<<endl;
    }else{
        cout<<min(A,B)<<" "<<A+B-N<<endl;    
    }
    //cout<<min(A,B)<<" "<<A+B-N<<endl;
return 0;}
/*compile
g++ code.cpp
./a.out
run*/
/*
int f(int x){
    int y=int((x*x+4.0)/8.0);
    return y;
}
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
typedef vector<int>		vi;
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;

int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    
	lli a,b;
	cin>>a>>b;
	swap(a,b);
	if(b%a==0)cout<<b/a;
	else cout<<b/a+1;

}

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

const int maxN = 1e5 + 10;

int n, A, B;
long long low, high;
long long h[maxN];

bool ok(long long x) {
    long long curr = 0;
    for (int i = 0; i < n; ++i)
        curr += (h[i] - x * B > 0) ? ceil(1.0 * (h[i] - x * B) / (A - B)) : 0;
    return curr <= x;
}

int main() {
//    freopen("input.in", "r", stdin);
  //  freopen("output.out", "w", stdout);

    scanf("%d%d%d", &n, &A, &B);
    for (int i = 0; i < n; ++i) scanf("%lld", &h[i]), high = max(high, h[i]);

    long long ans = -1;
    while (low <= high) {
        long long mid = (low + high) / 2;
        if (ok(mid)) {
            ans = mid;
            high = mid - 1;
        } else {
            low = mid + 1;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c;
  cin >> a  >>b>>c;
if(a+b==c||b+c==a||a+c==b){
cout <<"Yes"<<endl;
}
else{
 cout <<"No"<<endl;
}
}

Measured memory_bytes: 3612
def bubble_sort(A, N):
    cnt = 0
    flag = True
    while flag:
        flag = False
        for j in range(N - 1, 0, -1):
            if A[j - 1] > A[j]:
                A[j - 1], A[j] = A[j], A[j - 1]
                flag = True
                cnt += 1
    return cnt

N = int(input())
A = list(map(int, input().split()))
cnt = bubble_sort(A, N)
print(*A)
print(cnt)


Measured memory_bytes: 5608
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut ans = 0;
    for i in 1..n + 1 {
        if format!("{}", i).len() % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
int check(string s)
{
	string t=s;
	reverse(s.begin(),s.end());
	if(s==t)
		return 1;
	else
		return 0;
}
int main()
{
	string s;
	cin>>s;
	bool ok=false;
	if(check(s))
	{
		if(check(s.substr(0,s.size()/2))&&check(s.substr(s.size()/2+1,s.size()/2)))
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl; 
	}
	else
		cout<<"No"<<endl;

	return 0;
}

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

int main(int argc, char** argv) {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (auto& e : A) std::cin >> e;
  std::sort(A.begin(), A.end());
  for (auto i = 1;i < N;++i) {
    if (A[i] == A[i-1]) {
      std::cout << "NO\n";
      return 0;
    }
  }
  std::cout << "YES\n";
}


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

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

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

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

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int n; cin>>n;
    if(n%2==0 || n%5==0){
        cout<<-1<<"\n";
    }
    else if(n==1 || n==7) cout<<1<<"\n";
    else {
        int curr=7;
        int i=2;
        while(1){
            int r=(((curr*10)%n)+7)%n;
            if(r==0){
                cout<<i<<"\n";
                return 0;
            }
            i++;
            curr=((curr*10)%n+7)%n;
        }
    }
    return 0;

}

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

Measured memory_bytes: 15048
import java.util.*;
import java.io.*;

public class Main {
  
   public static void main(String []abc) {
      Main answer = new Main();
      long solution = answer.solve();
      System.out.println(solution);
   }
   long [] dp = new long[1000000];	
   private long solve() {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int E = sc.nextInt();
      Map<Integer, List<Integer>> graph = new HashMap<>();
      for(int i=0;i<E;i++){
         int u = sc.nextInt();
         int v = sc.nextInt();
         List<Integer> children =graph.getOrDefault(u, new ArrayList<>());
         children.add(v);
         graph.put(u, children);          
      }
      Arrays.fill(dp, -1);
      long bestLength=0;
      for(int i=1;i<=N;i++){
        bestLength = Math.max(bestLength, solve(graph, i));
      }
      return bestLength;     
   }

   private long solve(Map<Integer, List<Integer>> graph, int u) {
     if (dp[u]!=-1) return dp[u];
     if (!graph.containsKey(u)) {
        dp[u]=0;
        return dp[u];
     }
     long bestChild=0;
     for(int child: graph.get(u)){
        bestChild = Math.max(bestChild, solve(graph, child));
     }
     dp[u]= 1+bestChild;
     return dp[u];
   }
}


Measured memory_bytes: 89264
#include<iostream>
#include <set>

using namespace std;

int main(){
  int n;
  cin >> n;
  
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  

  int ans=0;
  
  for(int i=0;i<n;i++){
    set<int> values;
    values.insert(s1[i]);
    values.insert(s2[i]);
    values.insert(s3[i]);
    ans += values.size() - 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans;
int l[202];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)
		scanf("%d",&l[i]);
	sort(l+1,l+2*n+1);
	for(int i=1;i<=2*n;i+=2)
		ans+=l[i];
	printf("%d",ans);
}

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


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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 (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    V<> a(n);
    cin >> a;
    V<ll> sum(n+1, 0);
    rep(i, n) {
        sum[i+1] = sum[i] + a[i];
    }
    V<ll> l(n+1,0);
    V<ll> r(n+1,0);
    rep(i, n) if(a[i]>0) l[i+1] = l[i] + a[i]; else l[i+1] = l[i];
    for(int i = n-1; i>=0; i--) {
        if(a[i] > 0) r[i] = r[i+1] + a[i];
        else r[i] = r[i+1];
    }
    ll ans = 0;
    rep(i,n-k+1) {
        chmax(ans, l[i]+(sum[i+k]-sum[i])+r[i+k]);
        chmax(ans, l[i]+r[i+k]);
    }
    cout << ans << endl;
}

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

#define int long long

const int N = 1e5 + 5, MOD = 1e9 + 7;

int32_t main(){
	
	int n; cin>>n;
	string s; cin>>s;
	int r=0, b=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R') r++;
		else b++;
	}
	if(r>b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}
 
/*

*/


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
using ull = unsigned long long;
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 (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 3000;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
class UnionFind{
    private:
        vector<ll> par;
        vector<ll> siz;
    public:
        UnionFind(ll sz){
            par.resize(sz);
            siz.assign(sz,1LL);
            rep(i,sz) par[i] = i;
        }

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

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

        bool same(ll x,ll y){
            return find(x) == find(y);
        }

        ll size(ll x){
            return siz[find(x)];
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    UnionFind g(n);
    ll a,b;
    rep(i,m){
        cin >> a >> b;
        a--,b--;
        g.unite(a,b);
    }
    vector<bool> done(n,0);
    ll ans = 0;
    rep(i,n){
        if (!done[g.find(i)]){
            ans++;
            done[g.find(i)] = 1;
        }
    }
    PRINT(ans-1);
}


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

int main(void){
    int N;
    bool flag = false;
    cin >> N;

    for(int a = 0;4*a <= N;a++){
        int b = N-4*a;

        if(b%7 == 0){
            flag = true;
            break;
        }

    }
    
    if(flag)
        cout << "Yes" << endl;

    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100001
struct edge{ int to,cost; };
typedef pair<int,int> P;

int N,M;
int d[MAX_N];
vector< edge > G[MAX_N];

int main(){
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    G[a].push_back((edge){b,c});
  }
  
  int ans=-1;  
  priority_queue< P , vector<P> , greater<P> > Q;

  fill(d,d+MAX_N, (1e9) );
  Q.push(P(1,1));
  d[1]=1;
  while(!Q.empty()){
    P p=Q.top();Q.pop();
    int pos=p.second;
    int cost=p.first;
    if(d[pos]<cost)continue;
    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(e.cost<d[pos])continue;
      if(e.to==N)ans=max(ans,e.cost);
      if(d[e.to]>e.cost){
        d[e.to]=e.cost;
        Q.push(P(d[e.to],e.to));
      }
    }
  }

  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 9584
let s = read_line () in
let n = String.length s in
let rec loop i cur acc =
    if i = n then acc else
        let cur = if String.contains "ATGC" s.[i] then cur + 1 else 0 in
        let acc = max acc cur in
        loop (i + 1) cur acc
in
loop 0 0 0 |> Printf.printf "%d\n"

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  while(cin >> n >> m && n+m){
    vector<vector<char>> v(m+1,vector<char>(n+1,' '));
    using piii = pair<int,pair<int,int>>;
    priority_queue<piii> q;
    vector<vector<int>> d(m+1,vector<int>(n+1,inf));
    {
      int x = 0,y = 0;
      rep(j,m){
        rep(i,n){
          cin >> v[j][i];
          if(v[j][i] == '&'){
            x = i;
            y = j;
          }
        }
      }
      piii pos = mp(0,mp(y,x));
      d[y][x] = 0;
      q.push(pos);
    }
    int ans = inf;
    while(q.size()){
      auto Q = q.top();q.pop();
      auto p = Q.se;
      int dpt = Q.fi;
      int x = p.se,y = p.fi;
      rep(i,4){
        int nx = x + dx[i],ny = y + dy[i];
        if(value(nx,ny,n,m)){
          if(v[y][x] == v[ny][nx] && d[ny][nx] > d[y][x]){
            d[ny][nx] = d[y][x];
            q.push(mp(-dpt,mp(ny,nx)));
          }
          else if(d[ny][nx] > d[y][x] + (v[ny][nx] == '#')){
            d[ny][nx] = (v[ny][nx] == '#') + d[y][x];
            q.push(mp(-(dpt+1),mp(ny,nx)));
          }
        }
        else{
          ans = min(ans,d[y][x]);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

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

	int A = x - a;
	int B = x - b;

	if (A < 0)
		A *= (-1);
	if (B < 0)
		B *= (-1);

	if (A < B)
		cout << "A" << endl;
	else
		cout << "B" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define SIZE 100005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
using namespace std;

int main()
{	
	ll N,K; 
	scanf("%lld %lld", &N, &K);
	ll A[N];
	for(ll i=0;i<N;i++){
	scanf("%lld", &A[i]);
	}
	ll ans,amari;
	if((N-1)%(K-1)==0)
	{amari=0;}
	else
	{amari=1;}
	ans=(N-1)/(K-1)+amari;
	printf("%lld", ans);
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <string.h>

using namespace std;
#define copy(a, b) number[a - 1] = temp[b - 1];

class Dice {
public:
	Dice() {
		for (int i = 0; i < 6; i++)
			cin >> number[i];
	}

	void rotate(char c) {
		int temp[6];
		for(int i = 0; i < 6; i++)
			temp[i] = number[i];
		switch (c) {
		case 'E':
			copy(1, 4);
			copy(4, 6);
			copy(6, 3);
			copy(3, 1);
			break;
		case 'W':
			copy(1, 3);
			copy(3, 6);
			copy(6, 4);
			copy(4, 1);
			break;
		case 'N':
			copy(5, 1);
			copy(1, 2);
			copy(2, 6);
			copy(6, 5);
			break;
		case 'S':
			copy(2, 1);
			copy(1, 5);
			copy(5, 6);
			copy(6, 2);
			break;
		}
	}
	void print(int x) {
		cout << number[x - 1] << endl;
	}
	int getnum(int x) {
		return number[x - 1];
	}
	void spin() {
		int temp[6];
		for (int i = 0; i < 6; i++)
			temp[i] = number[i];
		copy(2, 3);
		copy(3, 5);
		copy(5, 4);
		copy(4, 2);	
	}
private:
	int number[6];
};

int main() {
	Dice d;
	int n;
	int q1, q2;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> q1 >> q2;

		for (int j = 0; j < 4; j++) {
			d.rotate('S');
			if (d.getnum(1) == q1)
				break;
		}
		if (d.getnum(1) != q1) {
			while (d.getnum(1) != q1) {
				d.rotate('E');
			}
		}

		while (d.getnum(2) != q2) {
			d.spin();
		}

		d.print(3);
	}
}
		


Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

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

	if (k <= a) {
		cout << k << endl;
		return 0;
	}
	else if (k <= a + b) {
		cout << a << endl;
		return 0;
	}
	else {
		cout << a - (k - a - b) << endl;
		return 0;
	}
}


Measured memory_bytes: 3624
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        N:usize,
        M:usize,
        ABC:[(Usize1,Usize1,isize);M]
    }

    let INF = 1000000;

    let mut D = WarshallFloyd_initialize(N,INF);
    for &(a,b,c) in &ABC{
        D[a][b] = c;
        D[b][a] = c;
    }
    WarshallFloyd_run(N,&mut D);

    let ans = ABC.iter().filter(|&&(a,b,c)| D[a][b] != c).count();
    println!("{}",ans);
}

fn WarshallFloyd_initialize(N:usize,INF:isize)->Vec<Vec<isize>>{
    let mut Dist = vec![vec![INF;N];N];
    for i in 0..N{
        Dist[i][i] = 0;
    }
    Dist
}
fn WarshallFloyd_run(N:usize,Dist:&mut Vec<Vec<isize>>){
    for k in 0..N{
        for i in 0..N{
            for j in 0..N{
                Dist[i][j] = min(Dist[i][j],Dist[i][k]+Dist[k][j]);
            }
        }
    }
}

Measured memory_bytes: 2264
def main():
    N, K, S = (int(i) for i in input().split())
    if S != 10**9:
        A = [S for i in range(K)] + [S + 1 for i in range(N-K)]
    else:
        A = [S for i in range(K)] + [S - 1 for i in range(N-K)]
    print(*A)


if __name__ == '__main__':
    main()


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


int main(){
    ll N; cin >> N;
    ll num = 0;
    ll div = 10;
    if(N % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    while(div <= N){
        num += N/div;
        div *= 5;
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
int mod = 1000000007;

class Solution {
    ll qmul(ll a, ll b) {
        ll res = 1, tp = a;
        while(b) {
            if(b & 1ll) {
                res *= tp;
                res %= mod;
            }
            tp *= tp;
            tp %= mod;
            b >>= 1ll;
        }
        return res;
    }

    ll inv(ll x) {
        return qmul(x, mod - 2);
    }

    vector<ll> p;
public:
    ll e(int N, int M) {
        p = vector<ll>(M + 1, 1);
        for(int i = 1; i <= M; ++i) {
            p[i] = p[i - 1] * i;
            p[i] %= mod;
        }
        ll P1 = 1;
        for(int i = 0; i < N; ++i) {
            P1 *= (M - i);
            P1 %= mod;
        }
        P1 *= P1;
        P1 %= mod;
        ll del = 0;
        ll invt = inv(p[M - N]);
        for(int i = 1; i <= N; ++i) {
            ll nCi = p[N] * inv(p[N - i]) % mod * inv(p[i]) % mod;
            ll tmp = nCi;
            tmp *= p[M]; tmp %= mod;
            tmp *= invt; tmp %= mod;
            tmp *= p[M - i]; tmp %= mod;
            tmp *= invt; tmp %= mod;
            if(i & 1) {
                del += tmp;
            }
            else {
                del -= tmp;
            }
            del = (del + mod) % mod;
        }

        return (P1 - del + mod) % mod;

    }

};

int main() {
    int n, m;
    cin >> n >> m;
    Solution zhy;
    cout << zhy.e(n, m) << endl;
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int x, n;
    cin >> x >> n;
    int p[n];
    int ans = inf, now;
    rep (i, 0, n) cin >> p[i];
    per (i, -100, 200) {
        if (abs (x - i) <= abs (x - ans)) {
            bool chk = 1;
            rep (j, 0, n) {
                if (p[j] == i) {
                    chk = 0;
                    break;
                }
            }
            if (chk) {
                ans = i;
                now = i;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3632
s=input()
if 0 < int(s[:2]) < 13:
  if 0 < int(s[2:]) < 13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0 < int(s[2:]) < 13:
    print('YYMM')
  else:
    print('NA')
  

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  set<string> st;
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    st.insert(s);
  }

  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 19228
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long i,j,n,k,a[262144],r=1;
    scanf("%lld%lld",&n,&k);
    while(1){
        n*=2;
        if(n>k){break;}
        r++;
    }
    printf("%lld\n",r);
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,K;
  string S;
  cin>>N>>K>>S;
  int c=0;
  int ans=0;
  for(int i=1;i<N;i++){
    if(S[i-1]!=S[i])c++;
    else ans++;
  }
  int a=0;
  for(int i=0;i<c&&a<K;i++){
    if(c-i>2)ans+=2,a++,i++;
    else ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	a := readi64()
	b := readi64()
	c := readi64()
	c = c
	k := readi64()

	tmp := k - a - b
	if tmp > 0 {
		fmt.Println(a - tmp)
		return
	}
	if a > k {
		fmt.Println(k)
		return
	}
	fmt.Println(a)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

// 最大公約数
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// 最小公倍数
func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func comb(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7

	COMB_MAX = 510000
)

var (
	readString func() string
)

var (
	fac  = [COMB_MAX]int{}
	finv = [COMB_MAX]int{}
	inv  = [COMB_MAX]int{}
)

func init() {
	readString = newReadString(os.Stdin)
}

func combInit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMB_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
	}
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


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

using namespace std;

typedef long long ll;
const int Nmax = 1e5 + 5;

int E, n, T, i, j, x[Nmax];
ll dp[Nmax], A[Nmax], B[Nmax];
deque<int> dq;

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n >> E >> T;
    for(i=1; i<=n; ++i) cin >> x[i];

    for(i=1; i<=n; ++i)
    {
        A[i] = min(A[i-1], dp[i-1] - x[i-1] - 2 * x[i]);
        B[i] = dp[i-1] - x[i-1];

        while(j < i && 2 * (x[i] - x[j+1]) > T) ++j;
        while(dq.size() && B[dq.back()] >= B[i]) dq.pop_back();
        dq.push_back(i);
        while(dq.size() && dq.front() <= j) dq.pop_front();

        dp[i] = x[i] + min(dq.size() ? T + B[dq.front()] : (1LL<<60), j ? A[j] + 2 * x[i] : (1LL<<60));
    }

    cout << dp[n] + E - x[n] << '\n';

    return 0;
}


Measured memory_bytes: 3200
import heapq

n,m = map(int, input().split())
day_rews_l = [ [] for _ in range(m+1)]
for _ in range(n):
    a,b = map(int, input().split())
    if a > m: continue
    day_rews_l[a].append(b)


jobs = []
ans = 0
for i in range(1,m+1):
    for rew in day_rews_l[i]:
        heapq.heappush(jobs, (-1)*rew)
    if jobs:
        rew_i = heapq.heappop(jobs)
        ans += (-1)*rew_i

print(ans)
    

Measured memory_bytes: 89376
#include<cstdio>
#include<cctype>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define id(a,b) (a*n-n+b)
#define reg register
typedef long long ll;
template<typename T>inline T read(){
    reg T x=0;reg short f=1;reg char c=getchar();
    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
    for(;isdigit(c);x=x*10+(c^48),c=getchar());
    return x*f;
}
const int inf=0x3f3f3f3f;
int n,m,h[2005],stk[2005];
bool mp[2005][2005],a[2005][2005];
int main(){
	n=read<int>();m=read<int>();reg int ans=max(n,m);
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<=m;j++){
			reg char ch=getchar();
			while(ch!='#'&&ch!='.')ch=getchar();
			mp[i][j]=(ch=='#');
		}
	for(reg int i=1;i<n;i++)
		for(reg int j=1;j<m;j++){
			reg int cnt=(mp[i][j]+mp[i+1][j]+mp[i][j+1]+mp[i+1][j+1])&1;
			if(!cnt)a[i][j]=1;
		}
	for(reg int i=1;i<=n;i++){
		reg int top=0;
		for(reg int j=1;j<m;j++)h[j]=(a[i][j]?h[j]+1:0);
		for(reg int j=1;j<=m;j++){
			while(top&&h[j]<h[stk[top]])
				ans=max(ans,(j-stk[top-1])*(h[stk[top]]+1)),top--;
			stk[++top]=j;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8064
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int count = x;
        for (int i = 0; i < n; i++) {
            count++;
            for (int j = 1; j < d; j++) {
                int day = a[i] * j + 1;
                if (day <= d) {
                    count++;
                }
            }
        }
        int result = count;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 26708
n, m = map(int, input().split())
f = []

for i in range(n):
  f.append(list(map(int, input().split())))

num = [0 for i in range(m+1)]
  
for i in range(n):
  for j in range(1, len(f[i])):
    num[f[i][j]] += 1
    
    
cnt = 0
for i in num:
  if i == n:
    cnt += 1
    
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
ll x;

ll pangkat(ll a, ll b){
	ll curr=1;
	while(b){
		if(b&1){
			curr*=a;
		}
		a*=a;
		b/=2;
	}
	return curr;
}

int main(){
	IOS
	cin >> x;
	for(int i=-2000;i<=2000;i++){
		for(int j=-2000;j<=2000;j++){
			if(pangkat(i, 5)-pangkat(j, 5)==x){
				cout << i << ' ' << j << '\n'; return 0;
			}
		}
	}
}

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

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s>"2019/04/30"){cout<<"TBD"<<endl;}
  else cout<<"Heisei"<<endl;

  return 0;
}


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

int main(){
	int n;
	int count = 0;
	
	while (cin >> n, n != 0){

		count = 0;

		for (int i = 1; i <= n; i++){
			int x = i;
			while (x % 5 == 0){
				if (x == 0) break;
				x /= 5;
				count++;
			}
		}

		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
N = int(input())
A = map(int, input().split())
S = 0
S2 = 0
M = 10**9+7
for a in A:
  S += a
  S %= M
  S2 += a*a
  S2 %= M

# (S * S - S2)/2 
ans = (S * S - S2) * pow(2, -1, M)
ans %= M
print(ans)

Measured memory_bytes: 25200
import numpy as np
N, X, Y = map(int, input().split())
 
dist = []
for i in range(1, N):
    x = np.arange(i + 1, N + 1)
    # 直接
    d1 = np.abs(x - i)
    # i -> X -> Y -> x
    d2 = np.abs(i - X) + np.abs(Y - x) + 1
    # i -> Y -> X -> x
    d3 = np.abs(i - Y) + np.abs(X - x) + 1
    d = np.minimum(np.minimum(d1, d2), d3)
    dist.append(d)
 
dist = np.concatenate(dist)
count = np.bincount(dist, minlength=N)
print('\n'.join(count[1:].astype(str)))

Measured memory_bytes: 43896
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


// range sum query using fenwick tree
// note index starts at 1

class fenwick_tree {
	vector<long> t;
	long size;
public:
	fenwick_tree(long n) {
		t.assign(n + 1, 0);
		size = n + 1;
	}

	long LSOne(long k) {	// least significant 1-bit
		return k & (-k);
	}

	void update(long index, long val) {	// can go up or go down
		for (; index < size; index += LSOne(index)) t[index] += val;
	}

	long query_full(long a, long b) {		// range query
		return query(b) - ((a <= 1) ? 0 : query(a - 1));
	}

	long query(long b) {	// range query 1..b
		if (b < 1) return 0;

		long sum = 0;
		for (; b; b -= LSOne(b)) sum += t[b];
		return sum;
	}
};


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

	int n, q, i, j, k, l, r, x, y, z, id;
	cin >> n >> q;
	vector<int> c(n + 1), v(n + 3, 0), last(n + 1, 0), rootid(n + 1, 0), ans(q);
	fenwick_tree ft(n + 1); 
	vector<tuple<int, int, int>> query(q);

	for (i = 1; i <= n; i++) cin >> c[i];

	r = 0;
	for (i = n; i >= 1; i--) {
		v[i] = last[c[i]];
		last[c[i]] = i;
		rootid[i] = ++r;
	}

	for (i = 0; i < q; i++) {
		cin >> l >> r;
		query[i] = { l, r, i };
	}
	sort(query.rbegin(), query.rend());

	z = n + 1;
	for (auto p : query) {
		tie(l, r, id) = p;
		while (z > l) {
			z--;
			if (v[z] != 0) ft.update(v[z], 1);
		}

		x = ft.query_full(l, r);
		ans[id] = r + 1 - l - x;
	}

	for (auto p : ans) cout << p << "\n";

	return 0;
}


Measured memory_bytes: 23276
a,b,c,x,y=map(int,input().split())

ans=a*x+b*y
for ci in range(max(x,y)+1):
    sumc = 2*ci*c
    sumc += (x-ci)*a if (x-ci)>0 else 0
    sumc += (y-ci)*b if (y-ci)>0 else 0
    ans=min(ans,sumc)

print(ans)

Measured memory_bytes: 3064
n=int(input())
w=[int(i) for i in input().split()]
ans=10000
for t in range(1,n+1):
  s1=0
  s2=0
  for i in range(t):
    s1+=w[i]
  for i in range(t,n):
    s2+=w[i]
  tmp=abs(s1-s2)
  ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 3064
#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 rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"
lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

string s;
int d;
vector<vector<vector<int>>> dp;
//dp[s.size()][sum][tight]
lli func(int n, int sum, int tight){
	if(n==s.size()){
		return sum==0;
	}
	int &res=dp[n][sum][tight];
	if(res!=-1)return res;
	res=0;
	int mi=0,ma=9;
	if(tight){
		ma=s[n]-'0';
	}
	for(int i=mi;i<=ma;i++){
		int ntight = tight & (s[n]-'0'==i);
		res=add(res,func(n+1,(sum+i)%d,ntight));
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>s;
	cin>>d;
	dp.assign(s.size(),vector<vector<int>>(d,vector<int>(2,-1)));
	cout<<(func(0,0,1)-1+mod)%mod<<endl;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> x;
  for(int i(0);i<N;i++){
    int a,b;
    cin>>a>>b;
    x.push_back({a,b});
  }
  sort(x.begin(),x.end());
  ll sum(0);
  sum += x[0].first;
  sum += x[N-1].first - x[0].first;
  sum += x[N-1].second;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4308
n = int(input())
A = [*map(int, input().split())] + [0]
yen, stock = 1000, 0
now = A[0]
for nxt in A[1:]:
    if now < nxt:
        stock += yen // now
        yen -= yen // now * now
    else:
        yen += stock * now
        stock = 0
    now = nxt
print(yen + stock * now)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int x,y;
  cin >> x >> y;
  if((y-2*x) % 2 == 0 && y-2*x >=0 && (4*x-y) % 2 == 0 && 4*x - y>=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628