akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        double x,y,b,p;
        cin>>x>>y>>b>>p;
        int num1=x*b+y*p;
        int num2=(x*max(b,5.0)+(y*max(p,2.0)))*(8.0/10);
        cout<<min(num1,num2)<<endl;
    }
}


Measured memory_bytes: 3264
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll a,b;
    cin>>a>>b;
    if((a+b)%3==0||a%3==0||b%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){

        solve();

    }
   


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define len(a) (int) (a).size()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define int long long
using namespace std;
void solve();
signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();
}



void solve(){
    string s; cin >> s;
    string res; res += s[0];
    for (int i = 1; i < len(s); ++i){
        while (len(res) > 1 && res[len(res) - 2] != s[i])
            res.pop_back();
        res += s[i];
    }
    if ((len(res) - len(s))&1)
        cout << "First" << endl;
    else
        cout << "Second" << endl;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int n,m;
vector<PII> v;
int main() {
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) {
		int l,r;
		scanf("%d%d",&l,&r);
		v.pb({l,-1});
		v.pb({r,1});
	}
	sort(all(v));
	int cnt=0,mcnt=0;
	for (auto p:v) {
		cnt-=p.se;
		mcnt=max(mcnt,cnt);
	}
	int l=m,r=0;
	cnt=0;
	for (auto p:v) {
		if (cnt==mcnt) r=max(r,p.fi);
		cnt-=p.se;
		if (cnt==mcnt) l=min(l,p.fi);
	}
	//printf("%d %d %d\n",mcnt,l,r);
	if (mcnt%2==1) {
		printf("%lld\n",(ll)(mcnt-1)*m+r);
	} else {
		printf("%lld\n",(ll)(mcnt-1)*m+m-l);
	}
}


Measured memory_bytes: 6988
#include<iostream>

int main(void){
    bool S[13],H[13],C[13],D[13];
    int i,n;
    char mark;
    int number;
    for(i=0;i<13;i++){
        S[i]=H[i]=C[i]=D[i]=false;
    }
    std::cin>>n;
    for(i=0;i<n;i++){
        std::cin>>mark>>number;
        switch(mark){
            case 'S':
                S[number-1]=true;
                break;
            case 'H':
                H[number-1]=true;
                break;
            case 'C':
                C[number-1]=true;
                break;
             case 'D':
                D[number-1]=true;
                break;
        }
    
    }
    for(i=0;i<13;i++){
        if(!S[i]) std::cout<<'S'<<" "<<i+1<<std::endl;
    }
    for(i=0;i<13;i++){
        if(!H[i]) std::cout<<'H'<<" "<<i+1<<std::endl;
    }

    for(i=0;i<13;i++){
        if(!C[i]) std::cout<<'C'<<" "<<i+1<<std::endl;
    }
    for(i=0;i<13;i++){
        if(!D[i]) std::cout<<'D'<<" "<<i+1<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 3076
list_S = list(input())
s = -1
e = -1
for i in range(len(list_S)):
    if list_S[i] == "A":
        s = i
        break

list_S.reverse()

for i in range(len(list_S)):
    if list_S[i] == "Z":
        e = len(list_S) - i
        break

print(e - s)

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll a[5];rep(i,0,4)cin>>a[i];
    rep(i,0,4){
        if(a[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    
    return 0;
}





Measured memory_bytes: 3612
//abc056_a.cpp
//Fri Oct 19 23:11:48 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	char n,m;
	cin >> n >> m;

	if ((n=='H' && m=='H') || (n=='D' && m=='D')){
		cout << "H" << endl;
	}else {
		cout << "D" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  string s;
  cin>>s;
  if(s.size()%2!=0){
    cout<<"No"<<endl;
    return 0;
  }

  for(int i=0;i<s.size();i+=2){
    if(s[i]=='h'&&s[i+1]=='i'){
      continue;
    }else{
      cout<<"No"<<endl;
      return  0;
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}




Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	P := sc.nextIntSlice(N)
	Q := sc.nextIntSlice(N)
	nums := []int{}
	for i := 1; i <= N; i++ {
		nums = append(nums, i)
	}
	var p, q int
	for cnt, ok := 1, true; ok; cnt, ok = cnt+1, nextPermutation(sort.IntSlice(nums)) {
		isP, isQ := true, true
		for i := 0; i < N; i++ {
			if nums[i] != P[i] {
				isP = false
			}
			if nums[i] != Q[i] {
				isQ = false
			}
		}
		if isP {
			p = cnt
		}
		if isQ {
			q = cnt
		}
	}

	fmt.Fprintln(wtr, abs(p-q))
	wtr.Flush()
}

func nextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int n,a,b,acnt=0,bcnt=0;
    cin >> n >> a>>b;
    string s;
    cin >> s;
    
    int len = s.size();
    rep(i,len){
        if(s[i]=='a'){
            if(acnt+bcnt < a+b){
                acnt++;
                cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
        }else if(s[i]=='b'){
            if(bcnt+acnt < a+b && bcnt < b){
                bcnt++;
                cout << "Yes" << endl;
            }else{
                cout<<"No"<<endl;
            }
        }else{
            cout<<"No"<<endl;
        }
    }

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e6 + 10, mod = 1e9 + 7;
 
ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}
ll fac[N], invfac[N];
void init(int n) {
    fac[0] = invfac[0] = 1;
    for(int i = 1 ; i <= n ; ++ i) {
        fac[i] = fac[i - 1] * i % mod;
    }
    invfac[n] = pw(fac[n], mod - 2);
    for(int i = n - 1 ; i ; -- i) {
        invfac[i] = invfac[i + 1] * (i + 1) % mod;
    }
}
ll C(int n, int m) {
    return n < m || m < 0 ? 0 : fac[n] * invfac[m] % mod * invfac[n - m] % mod;
}
 
int n, k;
ll f[2010][2010];
void upd(ll &x, ll y) {
    x = (x + y) % mod;
}
 
int main() {
    init(N - 1);
    scanf("%d%d", &n, &k);
    if(! -- k) {
        puts("1");
    } else {
        f[0][0] = 1;
        for(int i = 0 ; i <= n ; ++ i) {
            for(int j = i ; j <= n ; ++ j) {
                if(j) {
                    if(i - 1 >= 0) {
                        upd(f[i][j], f[i - 1][j]);
                    }
                    upd(f[i][j], f[i][j - 1] * C(i + (j - 1) * k + k - 1, k - 1) % mod);
                }
            }
        }
        printf("%lld\n", f[n][n] * fac[n] % mod);
    }
}

Measured memory_bytes: 109952
#https://agc023.contest.atcoder.jp/submissions/2429958
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n,x = LI()
    m = [I() for _ in range(n)]
    r = x
    for i in range(n):
        r = r - m[i]
    r = r // (min(m)) + n

    return r

print(main())

Measured memory_bytes: 5588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);


int main() {
    int r, g, b, num;
    cin >> r >> g >> b;
    num = r*100 + g*10 + b;
    
    if (num % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}


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

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

struct Info
{
    int solved, time, tid, wrong[11];
    bool operator< (const Info &rhv) const {
        return solved == rhv.solved ?
        (time == rhv.time ? tid < rhv.tid : time < rhv.time) :
        solved > rhv.solved;
    }
};

int main()
{
    int T, P, R, tid, pid, time;
    string msg;
    Info info[55];
    
    while(cin >> T >> P >> R && T)
    {
        memset(info, 0, sizeof(info));
        rep(i, T) info[i].tid = i + 1;
        rep(i, R)
        {
            cin >> tid >> pid >> time >> msg;
            --tid;
            if(msg == "CORRECT") {
                ++info[tid].solved;
                info[tid].time += time + 1200 * info[tid].wrong[pid];
            } else
                ++info[tid].wrong[pid];
        }
        sort(info, info + T);
        rep(i, T) {
            cout << info[i].tid << ' ' << info[i].solved << ' ' << info[i].time << endl;
        }
    }
}

Measured memory_bytes: 932
#include<iostream>


using namespace std;
#define MAX 500000

#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];

int cnt;


void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;

    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];

    L[n1] = R[n2] = SENTINEL;

    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }

}

void mergeSort(int A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
    return;
}

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

    cin >> n;
    for (i = 0; i < n; i++) cin >> A[i];


    mergeSort(A, n, 0, n);
    for (i = 0; i < n; i++) {
        if (i) cout << " ";
        cout << A[i];
    }

    cout << endl;

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6952
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	int n;
	cin >> n;
	if (n < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int sort(const void *a, const void *b){
    return strcmp((char*)a ,(char*)b);
}

int main(void){
    int n,maxa=1,mina=1,maxz=1,minz=1;
    scanf("%d",&n);
    char s[n][25],t[25],u[n][25];
    for (int i=0; i<n; i++){
        scanf("%s",s[i]);
    }
    scanf("%s",t);
    for (int i=0; i<n; i++){
        strcpy(u[i],s[i]);
        for (int j=0; j<strlen(u[i]); j++){
            if (u[i][j]=='?'){
                u[i][j]='a';
            }
        }
    }
    qsort ((void*)u,n,sizeof(u[0]),sort);
    for (int i=0; i<n; i++){
        if (strcmp(u[i],t)<0){
            mina++;
        }
        if (strcmp(u[i],t)<=0){
            maxa++;
        }
    }
    for (int i=0; i<n; i++){
        strcpy(u[i],s[i]);
        for (int j=0; j<strlen(u[i]); j++){
            if (u[i][j]=='?'){
                u[i][j]='z';
            }
        }
    }
    qsort ((void*)u,n,sizeof(u[0]),sort);
    for (int i=0; i<n; i++){
        if (strcmp(u[i],t)<0){
            minz++;
        }
        if (strcmp(u[i],t)<=0){
            maxz++;
        }
    }
    for (int i=fmin(mina,minz); i<=fmax(maxa,maxz); i++){
        printf("%d",i);
        if (i!=fmax(maxa,maxz)){
            printf(" ");
        }
    }
    printf("\n");
	return 0 ;
}

Measured memory_bytes: 912
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
x = I()
ans = 0
wa = 0
cont = True
while cont:
    wa += x
    ans += 1
    if wa % 360 == 0:
        cont = False
print(ans)

Measured memory_bytes: 74132
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()

{

  int a[3];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  for (int i = 0; i < 3; ++i){
                cout <<a[i]+a[i+1]<<endl;
                break;
  }



 return 0;
}








Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

void solve() {
  string s;
  cin >> s;
  ll i = 0;
  while (i < 3 && s[i] == 'S') i++;
  if (i >= 3) {
    cout << 0 << endl;
    return;
  }
  ll j = i + 1;
  while (j < 3 && s[j] == 'R') j++;

  cout << (j-i) << endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


Measured memory_bytes: 3612
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, Q = MAP()
    AB = sorted(MATINT(N-1))
    plus = [0] * N
    ans = [0] * N
    for i in range(Q):
        P, X = MAP()
        plus[P-1] += X
    for ab in AB:
        plus[ab[1]-1] += plus[ab[0]-1]
    print(*plus)

if __name__ == '__main__':
    main()


Measured memory_bytes: 91300
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
    public:
    ll H,W,N;
    map<pair<ll,ll>,ll>cnt;
    void solve(){
        ios::sync_with_stdio(false);
        cin>>H>>W>>N;
        for(ll u=0;u<N;u++){
            ll a,b;
            cin>>a>>b;
            for(ll h=-2;h<=0;h++){
                for(ll w=-2;w<=0;w++){
                    ll ta=a+h,tb=b+w;
                    if(ta>=1&&tb>=1&&ta+2<=H&&tb+2<=W)cnt[{ta,tb}]++;
                }
            }
        }
        ll ans[10]={0};
        ll sum=0;
        for(auto p:cnt){
            ans[p.second]++;
            sum++;
        }
        ans[0]=(H-2)*(W-2)-sum;
        for(int u=0;u<10;u++)cout<<ans[u]<<"\n";
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

int main(void){
    int pasta[3], juice[2];
    for(int i=0; i < 3; i++)
        cin >> pasta[i];
    for(int i=0; i < 2; i++)
        cin >> juice[i];
    
    int min = 1000000;
    for(int i=0; i < 3; i++){
        for(int j=0; j < 2; j++){
            if(pasta[i] + juice[j] - 50 < min){
                min = pasta[i] + juice[j] - 50;
            }
        }
    }
    cout << min << endl;
    return 0;

}

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

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int start = h1 * 60 + m1,
        goal  = h2 * 60 + m2;
    cout << goal - start - k << endl;

    return 0;
}



Measured memory_bytes: 3636
n = int(input())
ans = 0
bef = 0
for _ in range(n):
  a = int(input())
  if a == 0:
    bef = 0
    continue
  ans += (a + bef) // 2
  if (a + bef) % 2 == 1:
    bef = 1
  else:
    bef = 0
print(ans)

Measured memory_bytes: 69904
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

ll n, a, b, cnt;

int main() {

cin>>n;
cin>>a>>b;

if(a > b) {
    cout<<0<<'\n';
    return 0;
}

if(n == 1) {
    if(a < b) {
        cout<<0<<'\n';
        return 0;
    }
}

if(a == b) {
    cout<<1<<'\n';
} else {
    cout<<(b - a) * (n - 2) + 1<<'\n';
}


return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 2e5+10,MAX = 5000000;
#define sq(X) ((X)*(X))
#define PI 3.141592653589

int main()
{
    ll n,m,a,i,s=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a;
        s+= a;
    }
    if(s>n) cout<<"-1\n";
    else cout<<n-s<<"\n";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

bool graph [500][500][250];
bool cover [500][500];
int cur [500][500];
int N;

vector<pii> deltas = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

void dfs(int i, int j, int k) {
	graph[i][j][k] = true;
	cur[i][j] = min(cur[i][j], k);
	for (pii d : deltas) {
		int ni = d.first + i;
		int nj = d.second + j;
		int nk = k + cover[i][j];
		if (ni < 0 || ni >= N || nj < 0 || nj >= N || nk >= N || nk >= 250) continue;
		if (graph[ni][nj][nk]) continue;
		if (nk > 0 && graph[ni][nj][nk-1]) continue;
		dfs(ni, nj, nk);
	}
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	F0R(i, 500) F0R(j, 500) {
		cover[i][j] = true;
		F0R(k, 250) graph[i][j][k] = false;
	}

	F0R(i, N) F0R(j, N) {
		cur[i][j] = min(min(i, j), min(N-i-1, N-j-1));
		if (i < 250) graph[i][j][i] = true;
		if (j < 250) graph[i][j][j] = true;
		if (N-i-1 < 250) graph[i][j][N-i-1] = true;
		if (N-j-1 < 250) graph[i][j][N-j-1] = true;
	}

	int ans = 0;
	F0R(t, N*N) {
		int x; cin >> x; --x;
		int i = x/N;
		int j = x%N;
		int best = cur[i][j];
		cover[i][j] = false;
		ans += best;
		dfs(i, j, best);
	}
	print(ans);
}

Measured memory_bytes: 80952
#include <iostream>
#include <queue>
using namespace std;
struct po{int x,y,cost,cnt;};
int mp[9][9],w,h;
int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
int bfs(int sx,int sy){
  int D[9][9] = {};
  queue <po> Q;
  Q.push((po){sx,sy,6,0});
  D[sy][sx] = 6;
  while(!Q.empty()){
    po t=Q.front();Q.pop();
    if(mp[t.y][t.x]==3) return t.cnt;
    for(int i=0;i<4;i++){
      int nx=t.x+dx[i], ny = t.y+dy[i],ncost = t.cost-1;
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]==0||D[ny][nx] >= ncost) continue;
      if(mp[ny][nx] == 4) ncost = 6;
      D[ny][nx] = ncost;
      Q.push((po){nx,ny,ncost,t.cnt+1});
    }
  }
  return -1;
}
int main() {
  while(1){
    cin >>w>>h;
    if(w==0 && h==0) break;
    int sx,sy;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) {
	cin >> mp[i][j];
	if(mp[i][j] == 2) sx=j,sy=i;
      }  
    cout << bfs(sx,sy)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;


public class Main {

	static Scanner sc = new Scanner(System.in);
		
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		int n = sc.nextInt();
		int ans = -1;
		double xa, ya, ra, xb, yb, rb, l;
		
		for(int i=0; i < n ; i++){
			xa = sc.nextDouble();
			ya = sc.nextDouble();
			ra = sc.nextDouble();
			xb = sc.nextDouble();
			yb = sc.nextDouble();
			rb = sc.nextDouble();
			
			l = Math.sqrt(Math.pow(xa - xb, 2) + Math.pow(ya - yb, 2));
			
			if(ra + rb < l){
				ans = 0;
			}
			else if(Math.abs(ra - rb) <= l && l <= ra + rb){
				ans = 1;
			}
			else if(ra - rb > l){
				ans = 2;
			}
			else if(rb - ra > l){
				ans = -2;
			}
			
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 20528
#include<cstdio>

using namespace std;

int a;
bool b[100];

int main(){
	scanf("%d", &a);
	for(int i = 1; i <= 9; i++)
		for(int j = 1; j <= 9; j++)
			b[i*j] = 1;
	if(a <= 81 && b[a])
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[3010][3010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    rep(i, S.length()) {
        rep(j, T.length()) {
            if (S[i] == T[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
            else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
    }
    //cout << dp[S.length()][T.length()] << endl;
    int i = S.length(), j = T.length();
    string A;
    while(i > 0 && j > 0) {
        //cout << i << " " << j << " " << dp[i][j] << A << endl;
        if (S[i - 1] == T[j - 1]) {
            A = S[i - 1] + A;
            i--; j--;
        }
        else if (dp[i][j] == dp[i - 1][j]) i--;
        else j--;
    }
    cout << A << endl;

    return 0;
}


Measured memory_bytes: 35584
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<string> word(n);
	for(int i=0; i<n; i++){
		cin >> word.at(i);
	}
	for(int i=1; i<n; i++){
		if(word.at(i-1).at(word.at(i-1).size()-1) != word.at(i).at(0)){
			cout << "No" << endl;
			return 0;
		}
	}
	sort(word.begin(), word.end());
	for(int i=1; i<n; i++){
		if(word.at(i-1)==word.at(i)){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#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   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
ll dp[1002][1002];
void solve()
{
    ll h,w;
    cin>>h>>w;
    char a[h+2][w+2];
    for(ll i=1;i<=h;i++){
        for(ll j=1;j<=w;j++)
            cin>>a[i][j];
    }
    ll ans = 0;
    dp[0][0] = 0;
    ll j=1;
    while(j<=w && a[1][j]=='.'){
        dp[1][j]=1;
        j++;
    }
    ll i=1;
    while(i<=h && a[i][1] == '.'){
        dp[i][1]=1;
        i++;
    }
    for(ll i=2;i<=h;i++){
        for(ll j=2;j<=w;j++){
            if(a[i][j]=='.'){
                dp[i][j] = (dp[i][j]+dp[i-1][j])%bmd;
                dp[i][j] = (dp[i][j] + dp[i][j-1])%bmd;
            }
        }
    }
    cout << dp[h][w] %bmd <<"\n";

}

int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n;cin >> n;
    vector<int> f(n+1);
    for(int x = 1;x*x <= n;x++){
        for(int y = 1;y*y <=n ;y++){
            for(int z = 1;z*z <= n;z++){
                int tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                if(tmp <= n)f[tmp]++;
                else break;
            }
        }
    }
    for(int i = 1; i <= n;i++)cout << f[i] << endl;
    return 0;
}

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

int main(){
	int N;
	cin>>N;
	
	int n[N+1];
	for(int i=1;i<=N;i++){
		n[i]=i;
	}
	if(N==1){
		cout<<1<<endl;
		return 0;
	}
	//何回割れるか
	int num[N+1]={};
	for(int i=1;i<=N;i++){
		while(n[i]%2==0){
			n[i]/=2;
			num[i]++;
		}
	}
	
	int max=num[1],ans=0;
	for(int i=2;i<=N;i++){
		if(num[i]>max){
			max=num[i];
			ans=i;
		}
	}	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
/*
 ____________________________________________________________
|                                                            |
|                   Author: ay2306                           |
|____________________________________________________________|

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define MAXN 25
using namespace std;

int main(){
    string s;
    cin >> s;
    int flag = 0;
    // cout << s << endl;
    if(s[0] == 'A' && s[s.length()-1]!='C'){
        int c = 0;
        int k = -1;
        for(int i = 2; i + 1 < s.length(); ++i){if(s[i] == 'C'){c++;k=i;}}
        // cout << endl << c << endl;
        if(c == 1){
            flag = 1;
            for(int i = 1; i < s.length(); ++i){
                if(s[i] == 'C' && i==k)continue;
                else if(s[i] >= 'A' && s[i] <= 'Z'){
                    flag = 0;
                }
            }
            // cout << flag << endl;
        }
    }   
    if(flag)cout <<"AC";
    else cout << "WA";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long dp[1005][1005];
char grid[1005][1005];
#define mod 1000000007

long solve(int m,int n){
    if(m<0 || n<0){
        return 0;
    }
    if(grid[m][n]=='#'){
        return 0;
    }
    if(dp[m][n]!=-1){
        return dp[m][n]%mod;
    }
    dp[m][n]=solve(m-1,n)%mod+solve(m,n-1)%mod;
    return dp[m][n]%mod;
}

int main(){
    int h,w;cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>grid[i][j];
            dp[i][j]=-1;
        }
    }
    dp[0][0]=0;
    /*for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<grid[i][j];
        }
        cout<<'\n';
    }*/
    if(grid[0][1]=='.'){
        dp[0][1]=1;
    }
    if(grid[1][0]=='.'){
        dp[1][0]=1;
    }
    cout<<solve(h-1,w-1);
    /*for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<dp[i][j];
        }
        cout<<'\n';
    }*/
}


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

int main() {
    int N,r=5e5;;
    string S;
    cin >> N >> S;
    vector<int> e(N+2,0),w(N+2,0);

    rep(i,N) {
        w.at(i+1) = w.at(i);
        if(S.at(i) == 'W')
            w.at(i+1)++;
    }
    w.at(N+1) = w.at(N);

    rep(i,N) {
        e.at(N-i) = e.at(N+1-i);
        if(S.at(N-i-1) == 'E')
            e.at(N-i)++;
    }
    e.at(0) = e.at(1);

    
    rep(i,N)
        r = min(r, w.at(i)+e.at(i+2));

    cout << r << endl;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,m;
	long long int sum =0;
	scanf("%lld %lld",&n,&m);
	long long int arr[m];
	for(int i=0;i<m;i++){
		cin>>arr[i];
		sum = sum + arr[i];
	}
	if(sum>n)
		cout << -1 << endl;
	else 
		cout << n-sum<< endl;	
}

Measured memory_bytes: 3836
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
//const ll mod = 998244353;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
//ll a[MAX],b[MAX];


int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

ll a,b,c,d;
cin >> a >> b >> c >> d;
ll a1 = a*c , a2 = a*d, a3 = b*c , a4 = b*d;
cout << max({a1,a2,a3,a4});

  
 eNd();
  return 0;
 
}

Measured memory_bytes: 3648
n = int(input())
h_ls = list(map(int, input().split()))
mincost_ls = [float('inf')] * n
mincost_ls[0] = 0
for i in range(n-1):
    mincost_ls[i+1] = min(mincost_ls[i+1], mincost_ls[i]+abs(h_ls[i+1]-h_ls[i]))
    if i+2 < n:
        mincost_ls[i+2] = min(mincost_ls[i+2], mincost_ls[i]+abs(h_ls[i+2]-h_ls[i]))
print(mincost_ls[-1])

Measured memory_bytes: 85724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

struct Combi
{
	vector<int> fact;
	vector<int> ifact;
	vector<int> inv;
	vector<int> pow2;
	const int MOD = 998244353;
	int add(int a, int b)
	{
		a+=b;
		while(a>=MOD) a-=MOD;
		return a;
	}
	int mult(int a, int b)
	{
		return (a*1LL*b)%MOD;
	}
	int modpow(int a, int b)
	{
		int r=1;
		while(b)
		{
			if(b&1) r=mult(r,a);
			a=mult(a,a);
			b>>=1;
		}
		return r;
	}
	int choose(int a, int b)
	{
		if(a<b) return 0;
		if(b==0) return 1;
		if(a==b) return 1;
		return mult(fact[a],mult(ifact[b],ifact[a-b]));
	}
	int inverse(int a)
	{
		return modpow(a,MOD-2);
	}
	void init(int _n)
	{
		fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
		fact.resize(_n+1);
		ifact.resize(_n+1);
		inv.resize(_n+1);
		pow2.resize(_n+1);
		pow2[0]=1;
		ifact[0]=1;
		fact[0]=1;
		for(int i=1;i<=_n;i++)
		{
			pow2[i]=add(pow2[i-1],pow2[i-1]);
			fact[i]=mult(fact[i-1],i);
		}
		ifact[_n] = inverse(fact[_n]);
		for(int i=_n-1;i>=1;i--)
		{
		    ifact[i] = mult(ifact[i + 1], i + 1);
		}
		for(int i=1;i<=_n;i++)
		{
		    inv[i] = mult(fact[i-1],ifact[i]);
		}
	}
};

Combi combi;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	combi.init(1011111);
	int n,m; cin>>n>>m;
	int ans=max(m,n); 
	int ans2=0; //counts average bonus point gained from # of Y = # of N - 1 case
	for(int i=1;i<=min(n,m);i++)
	{
		ans2=combi.add(ans2,combi.mult(combi.choose(2*i-1,i-1), combi.choose(m+n-2*i,n-i))); //fix Y at (2i)-th last position and the last 2i-1 can be free as long as i-1 Y
	}
	ans2=combi.mult(ans2,combi.inverse(combi.choose(n+m,n)));
	ans=combi.add(ans,ans2);
	cout<<ans<<'\n';
}


Measured memory_bytes: 16128
def main():
    N = int(input())
    if N <= 1:
        print(1)
        return
    fib = [0]*(N+1)
    fib[0], fib[1] = 1, 1
    for i in range(2, N+1):
        fib[i] = fib[i-1] + fib[i-2]
    print(fib[N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 5600