akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    cin>>n>>s;
    string ans=s;
    for(int i=0; i<s.length(); i++) {
        if(s[i]+n > 'Z'){
            ans[i] = ans[i]+n-26;
        } else {
            ans[i] += n;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree = 
//  tree<key, val, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;*/998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'001;

int n, m, k;

void solve(int test)
{
  int a, b;
  cin >> n >> a >> b;
  int c[3] = {0, 0, 0};
  for (int i = 0; i < n; ++i) {
    int x; cin >> x;
    if (x <= a)
      ++c[0];
    else if (x <= b)
      ++c[1];
    else
      ++c[2];
  }
  cout << min(min(c[0], c[1]), c[2]) << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
      solve(i);
  //cerr << endl << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count();
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

string s;
const string w[4] = {"dream", "dreamer", "erase", "eraser"};

int c(int p) {
  int pos = p;
  for (int i = 0; i < 4; i++) {
    if (p + w[i].size() <= s.size() && s.compare(p, w[i].size(), w[i]) == 0) {
      pos = max(p, c(p + w[i].size()));

      if (pos == s.size()) return pos;
    }
  }

  return pos;
}

int main(int argc, char *argv[])
{
  cin >> s;

  if (c(0) == s.size()) {
    puts("YES");
  } else {
    puts("NO");
  };
  return 0;
}


Measured memory_bytes: 1280
package main

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

func main() {
	N := ReadInt()
	Xs := ReadInts(N)

	sorted := append([]int{}, Xs...)
	sort.Ints(sorted)
	a, b := sorted[N/2-1], sorted[N/2]

	for _, x := range Xs {
		if x >= b {
			fmt.Println(a)
		} else {
			fmt.Println(b)
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int N,A[100],B[100];
int main(){
  cin >> N;
  for (int i=0;i<N-1;i++){
    cin >> B[i];
  }
  A[0] = B[0];A[N-1]=B[N-2]; //regardless
  
  //Split --> A[i] == B[i] only if B[i] > B[i+1]
  for (int i=0;i<N-2;i++){
    if (B[i] <= B[i+1]){
      A[i+1] = B[i];
    }
    else{
      A[i+1] = B[i+1];
    }
  }
  
  //summation
  int sum=0;
  for (int i=0;i<N;i++){
    sum += A[i];
  }
  cout << sum;
  return 0;
}


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

using namespace std;

int main(){
	int N, R;
	cin >> N >> R;
	if(N<10) cout << R+100*(10-N) << endl;
	else cout << R << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int cnt = 0;
  for(int i = i; i < N; i++) {
    if(i%2 == 0 && A.at(i)%2 == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<vector<vector<int> > > VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int n_max = 20;
const int k_max = 10;
const int s_max = 155;

void make_table(VVVI &table) {
    for (int i = 1; i <= n_max; i++) {
        for (int j = 1; j <= i; j++) {
            table[i - 1][0][j - 1] = 1;
        }
    }

    for (int b = 2; b <= k_max; b++) {
        for (int a = b; a <= n_max; a++) {
            int max = ((a * (a + 1)) - ((a - b) * (a - b + 1))) / 2;
            int min = (b * (b + 1)) / 2;
            for (int c = min; c <= max; c++) {
                if (c - a >= 1) {
                    table[a - 1][b - 1][c - 1] = table[a - 2][b - 1][c - 1] + table[a - 2][b - 2][c - a - 1];
                } else {
                    table[a - 1][b - 1][c - 1] = table[a - 2][b - 1][c - 1];
                }
            }
        }
    }
}

int main(void) {
    VVVI table(n_max, vector<vector<int> >(k_max, vector<int>(s_max, 0)));
    make_table(table);
    /*
       for (int j = 0; j < k_max; j++) {
       cout << "K = " << j + 1 <<  endl;
       for (int i = 0; i < n_max; i++) {
       cout << "N = " << i + 1<<  endl;
       for (int k = 0; k < s_max; k++) {
       cout << table[i][j][k] << " ";
       }
       cout << endl;
       }
       cout << endl;
       }
     */

    while (1) {
        int n;
        int k;
        int s;
        cin >> n >> k >> s;
        if (n == 0 && k == 0 && s == 0) {
            break;
        }
        int max = ((n * (n + 1)) - ((n - k) * (n - k + 1))) / 2;
        int min = (k * (k + 1)) / 2;
        if (s > max || s < min) {
            cout << 0 << endl; 
            continue;
        } else {
            cout << table[n - 1][k - 1][s - 1] << endl;
            continue;
        }
    }
    return 0;
}

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

int main(){
	int n,a,b[100000];
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a;
		b[a] = i;
	}
	for(int i = 1; i <= n; i++){
		cout << b[i];
		if(i != n)cout << " ";
	}
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    union_find(int size) : data(size, -1) { }
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};
signed main() {
    int n;
    cin>>n;
    vector<pii> x(n),y(n);
    REP(i,n) {
        cin>>x[i].first;
        cin>>y[i].first;
        x[i].second=y[i].second=i;
    }
    sort(ALL(x));
    sort(ALL(y));
    vector<vector<int>> edge;
    REP(i,n-1) {
        int ax=x[i].second;
        int bx=x[i+1].second;
        int cx=abs(x[i].first-x[i+1].first);
        edge.push_back({cx,ax,bx});
        int ay=y[i].second;
        int by=y[i+1].second;
        int cy=abs(y[i].first-y[i+1].first);
        edge.push_back({cy,ay,by});
    }
    union_find uf(n);
    sort(ALL(edge));
    int ans=0;
    REP(i,SZ(edge)) {
        int c=edge[i][0];
        int a=edge[i][1];
        int b=edge[i][2];
        if(uf.same(a,b)) continue;
        uf.unite(a,b);
        ans+=c;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 16428
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	ll N;
	cin >> N;
	vector<ll> B(N+1),A(N+2);
	for(int i=1;i<=N-1;i++)cin >> B[i];
	A[1] = B[1];
	A[N] = B[N-1];
	for(int i=2;i<=N-1;i++){
		A[i] = min(B[i-1],B[i]);
	}
	ll sum = 0;
	for(int i=1;i<=N;i++)sum+=A[i];
	cout << sum << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

ans=0
for i in range(N):
    if B[i]>=A[i]:
        ans+=A[i]
        rem=B[i]-A[i]
        A[i]=0
        if rem>=A[i+1]:
            ans+=A[i+1]
            A[i+1]=0
        else:
            ans+=rem
            A[i+1]-=rem
    else:
        ans+=B[i]
        A[i]-=B[i]
print(ans)

Measured memory_bytes: 73444
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
ANS = []
for i in range(A[0],A[-1]+1) :
    p = 0
    for j in range(N) :
        p += (i-A[j])**2
    ANS.append(p)
ans = min(ANS)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdio>
#include <iomanip>
using namespace std;

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define mp make_pair

const int DX[] = {1, 0, -1, 0, 1, 1, -1, -1}, DY[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  double a, b, h, m;

  cin >> a >> b >> h >> m;

  double hr, mr;

  hr = h * M_PI / 6.0 + m * M_PI / 360.0;
  double hx = a * sin(hr);
  double hy = -a * cos(hr);

  mr = m * M_PI / 30.0;
  double mx = b * sin(mr);
  double my = -b * cos(mr);

  double res = sqrtl((hx - mx) * (hx - mx) + (hy - my) * (hy - my));

  // printf("%lf\n", res);
  cout << fixed << setprecision(15) << res << endl;

}


Measured memory_bytes: 4116
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use itertools::concat;
use lazy_static::lazy_static;
// use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use std::sync::Mutex;
use superslice::*;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// lazy_static! {
//     static ref H: Mutex<Vec<i32>> = Mutex::default();
//     static ref W: Mutex<Vec<i32>> = Mutex::default();
// }

const MOD: usize = 1000_000_000 + 7;

//abc147-C
// #[fastout]
fn main() {
    input![n: usize];

    let mut a = Vec::new();
    let mut xy: Vec<Vec<_>> = Vec::new();

    for _ in 0..n {
        input![ai: usize, xyi: [(usize, usize); ai]];
        a.push(ai);
        xy.push(xyi.iter().map(|(p, is)| (*p - 1, *is)).collect());
    }

    let mut ans = -1;
    for i in 0..2usize.pow((n + 1) as u32) {
        let mut mid = 0;
        let mut is_valid = true;
        for j in 0..n {
            if (i >> j) & 1 == 0 {
                continue;
            }

            mid += 1;

            for (p, is_h) in xy[j].iter() {
                if (i >> p) & 1 != *is_h {
                    is_valid = false;
                }
            }
        }

        // eprintln!("{}, {}, {}, {}", is_valid, i, mid, 2 ^ (n + 1));
        if is_valid {
            ans = max(ans, mid);
        }
    }

    // eprintln!("{:?}", bit_counts);

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

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
    ll x ;
    cin>> x ;
    int ans=0 ;
    double yen =100 ;
    rep(i,10000){
        yen = floor(1.01*yen) ;
        ans++ ;
        if(yen>=x)
        
        break ;
    }
  
  cout <<ans<<endl ; 
    return 0;
}

Measured memory_bytes: 3636
#include <cstdlib>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    //stringstream geek(x);
    //geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
ll modInverse(ll a, ll m)
{
    a = a%m;
    for (int x=1; x<m; x++)
       if ((a*x) % m == 1)
          return x;
}
ll maxDivide(ll a, ll b)
{
  while (a%b == 0)
   a = a/b;
  return a;
}
  set<ll>ans;
void primeFactors(ll n)
{

    while (n % 2 == 0)
    {
       ans.insert(2);
        n = n/2;
    }

    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            ans.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        ans.insert(n);
}
ll is(ll no)
{   if(no==1) return 0;
    set<ll>::iterator it;
for(it=ans.begin();it!=ans.end();it++){
  no = maxDivide(no, *it);
  if(no==1) return 1;
//  if()
 // no = maxDivide(no, 3);
 // no = maxDivide(no, 5);
}
//if(no==1) return 1;
//for(it=ans.begin();it!=ans.end();it++){
//if(no==*it) return 1;
//}
  return 0;
}

int comp(string a,string b)
{
    string aa = a.append(b);
    string bb = b.append(a);

    return aa.compare(bb) > 0 ? 1: 0;

}
vector<pair<int,int> >adj[100005];
int colors[100005]={0};
void dfs(int i,int color,int prev1=-1)
{
 for(int j=0;j<adj[i].size();j++)
 {
     if(adj[i][j].first==prev1) continue;
//cout<<adj[i][j].second<<endl;
     if(adj[i][j].second&1)
     {

         colors[adj[i][j].first]=1-color;
     }
     else
         colors[adj[i][j].first]=color;
     dfs(adj[i][j].first,colors[adj[i][j].first],i);

 }
}
bool com(const pair<string,pair<int,int> >&a, const pair<string,pair<int,int> >&b )
{
    if(a.first!=b.first) return a.first<b.first;
    else return a.second.first>b.second.first;

}
int main()
{

  int n,d;
  cin>>n>>d;
  if(n%(2*d+1)==0) cout<<n/(2*d+1)<<endl;
  else cout<<(n/(2*d+1))+1 <<endl;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};


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

    vector<ll> candies(n);
    rep(i, n) cin >> candies[i];

    CumulativeSum cs(n);
    rep(i, n) cs.set(i, candies[i]);
    cs.calculate();

    map<ll, ll> happened;
    rep(i, n) happened[cs.getSum(i) % m]++;

    ll ans = 0;
    ans += happened[0];
    rep(i, n) {
        happened[cs.getSum(i) % m]--;
        ll prev = cs.getSum(i) % m;// (m - ) % m;
        ans += happened[prev];
    }

    cout << ans << endl;

    for (auto e : happened) assert(e.second == 0);

}





Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define ar2 array<int,2> 
typedef long long LL;
const int P = 1e9+7;
const int N = 1e5+5;
const double pi = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct dat{
	int a, b;
}c[N];
int n, a[N], b[N], to[N];

int main() {
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a+i);
	rep(i,1,n) scanf("%d",b+i);
	rep(i,1,n) c[i].a = a[i], c[i].b = b[i];
	
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	rep(i,1,n)if(a[i]>b[i]){
		printf("No\n"); return 0;
	}
	rep(i,1,n)if(a[i]<=b[i-1]){
		printf("Yes\n"); return 0;
	}
	
	sort(c+1,c+n+1,[](dat x,dat y){return x.b<y.b;});
	//rep(i,1,n)cout<<c[i].a<<" "<<c[i].b<<endl;
	rep(i,1,n){
		int l=1, r=n;
		while(l<=r){
			int mid = l+r>>1;
			if(c[i].a<=c[mid].b) to[i]=mid, r=mid-1;
			else l=mid+1;
		}
		//cout<<i<<" "<<to[i]<<endl;
	}
	int cnt = 1, i = 1;
	while(to[i]!=1){
		i = to[i], cnt++;
	}
	printf(cnt<n?"Yes\n":"No\n");
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int GCD(int x,int y){
  if(x<y){
    swap(x,y);
  }
  while(x%y!=0){
    int temp=x;
    x=y;
    y=temp%y;
  }
  return y;
}

int digitsum(int x){
  int sum=0;
  while(x>0){
    sum+=(x%10);
    x/=10;
  }
  return sum;
}

int main() {
  ll MOD=1000000007;
  ll n;
  cin>>n;
  ll temp=modpow(10,n,MOD)-2*modpow(9,n,MOD)+modpow(8,n,MOD);
  cout<<mod(temp,MOD)<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

vector<int> mul(int n, int k){
  vector<int> res;
  for(int i=k; i<=n; i+=k){
    res.push_back(i);
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> a(n),b(n,0);
  vector<int> ans;

  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int i=n-1;i>=0; i--){
    vector<int> t = mul(n,i+1);
    int k = b[i];
    for(auto v : t){
      k ^= b[v-1];
    }
    if(k!=a[i]){
      ans.push_back(i+1);
      b[i] ^= 1;
    }
  }

  int m = ans.size();
  cout << m << endl;
  for(int i=0; i<m; i++){
    cout << ans[i];
    if(i!=m-1) cout << " ";  
  }

  return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <set>
using namespace std;
 
int main(){
    int N,K;
    cin>>N>>K;
    set<int> st;
    int d,tmp;
    for(int i=0; i<K; i++){
    	cin>>d;
        for(int j=0; j<d; j++){
            cin>>tmp;
        	st.insert(tmp);
        }
    }
    
    cout<<N-st.size();
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int sum=0;
int n;
void DFS(long long temp,int flag){
	if(temp>n)return;
	if(temp<=n&&flag==7){
		sum++;
	}
	DFS(temp*10+3,flag|1);
	DFS(temp*10+5,flag|2);
	DFS(temp*10+7,flag|4);
}
int main(){
	scanf("%d",&n);
	DFS(0,0);
	printf("%d\n",sum);
	return 0;
}

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

using namespace std;

int n;

int main () {
	cin >> n;
	for(int i = n; i < n + 1000; i++) {
		bool bl = 0;
		for(int j = 2; j <= sqrt(i); j++) {
			if(i % j == 0) {
				bl = 1;
			}
		}
		if(bl == 0) {
			cout << i;
			return 0;
		}
	}
	return 0;
}

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

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define sz(x) ((long long int)x.size())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define forn(xx, yy) for(long long int yy = 0; yy < xx; ++yy)
#define prn(xx) cout << xx << '\n'
#define prs(xx) cout << xx << ' '
#define test cout << "TEST " << tn++ << '\n';

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int mod = 1e9 + 7;
const long long int inf = 2e9 + 13;
const long double pi = acos(-1.0);
const long double eps = 1e-9;

ll mx(ll x, ll y){ return (x>y?x:y); }
ll mn(ll x, ll y){ return (x<y?x:y); }
ll tn = 1;

void max_self(ll &x, ll y){ x = mx(x, y); }
void min_self(ll &x, ll y){ x = mn(x, y); }
void add(ll &x, ll y){ x%=mod; x += (y%mod); x%=mod; }
void mul(ll &x, ll y){ x%=mod; x *= (y%mod); x%=mod; }

ll us(ll n, ll x, ll m){
    if(!x) return 1;
    ll a = us(n, x>>1, m);
    return (((a*a)%m)*(x&1?n:1))%m;
}

int R, C, K, toplamblack = 0;
vector<vector<char>> grid;
int say(int r, int c){
    set<pll> s;
    for(int i = 0; i < R; ++i){
        if( (1<<i)&r ) for(int j = 0; j < C; ++j) if(grid[i][j] == '#') s.insert(mp(i, j));
    }
    for(int i = 0; i < C; ++i){
        if( (1<<i)&c ) for(int j = 0; j < R; ++j) if(grid[j][i] == '#') s.insert(mp(j, i));
    }
    return (toplamblack - ((int)s.size()) == K);
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> R >> C >> K;
    
    ll ans = 0;
    int r = (1<<R), c = (1<<C);
    grid.resize(R, vector<char>(C));
    for(int i = 0; i < R; ++i)
        for(int j = 0; j < C; ++j){
            cin >> grid[i][j];
            if(grid[i][j] == '#') toplamblack++;
        }

    for(int i = 0; i < r; ++i)
        for(int j = 0; j < c; ++j)
            ans += say(i, j);
    cout << ans << endl;

    return 0;
}

//cikisir



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

int main(){
  int H,W;
  while(1){
    cin >> H >> W;
    if(H==0&&W==0)break;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(j==0||j==W-1||i==0||i==H-1){
          cout << "#";
        }else{
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
  string S;
  cin>>S;
  string ans="None";
  for(char s='a';s<='z';s++){
    bool flag=true;
    for(int i=0;i<S.size();i++){
      if(S[i]==s){
        flag = false;
        break;
      }
    }
    if(flag){
      ans=s;
      break;
    }
  }
  cout<<ans;
}

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

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

  int n, x, y;
  cin >> n >> x >> y;

  map<int,int> mp;

  for (int start = 1; start <= n; ++start) {
    for (int goal = start+1; goal <= n; ++goal) {
      int k = min(goal - start, abs(start - x) + abs(goal - y) + 1);
      ++mp[k];
    }
  }

  for (int i = 1; i < n; ++i) cout << mp[i] << '\n';

  return (0);
}


Measured memory_bytes: 3708
<?php

define("MOD", 998244353);

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}

$N = $data[0][0];
$A = $data[1];

$minI = null;
$minV = null;

for ($i = -100; $i <= 100; $i++) {
    $v = 0;
    foreach ($A as $a) {
        $v += ($a - $i) * ($a - $i);
    }

    if (is_null($minV) || $v < $minV) {
        $minV = $v;
    }
}

$ans = $minV;


printf('%d', $ans);


Measured memory_bytes: 4984
#include  <stdio.h>

int main(void)


{


 int a,b;

 scanf("%d %d",&a,&b);
 
 
 if(a < b){

   printf("a < b\n");

 }

 if(a > b){

   printf("a > b\n");

 }

 if(a == b){

   printf("a == b\n");

 }

 return 0;

}

Measured memory_bytes: 580
#include <iostream>
using namespace std;
int main()
{
    int g=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='g')
            g++;
        else
            g--;
    }
    cout<<g/2<<endl;
    return 0;
}


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

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main(){
    double T, X;
    cin >> T >> X;

    double ans = T / X;
    cout << setprecision(10) << ans << endl;
}


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

#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

int main() {
	int N,K;
	cin>>N>>K;
	int ans=1;
  	if(!(N%K))ans=0;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import math


def get_total_strike_times(health: int, damage: int) -> int:
    """
    Given a monster's health and damage in integer,
    calculate the number of attack required to deplete the monster's health.
    :param health: int
    :param damage: int
    :return: int
    """
    return math.ceil(health / damage)


if __name__ == '__main__':
    print(get_total_strike_times(*map(int, input().split())))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N =1e7 + 10;
#define fi first
#define se second
#define pb push_back
int d[N],p[N],tot,v[N],num[N];
void pre() {
  d[1] = 1;
  for (int i = 2; i < N; ++i) {
    if (!v[i]) v[i] = 1, p[++tot] = i, d[i] = 2, num[i] = 1;
    for (int j = 1; j <= tot && i <= (N-1) / p[j]; ++j) {
      v[p[j] * i] = 1;
      if (i % p[j] == 0) {
        num[i * p[j]] = num[i] + 1;
        d[i * p[j]] = d[i] / num[i * p[j]] * (num[i * p[j]] + 1);
        break;
      } else {
        num[i * p[j]] = 1;
        d[i * p[j]] = d[i] * 2;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  pre();
  int x;
  cin>>x;
  LL ans=0;
  for(int i=1;i<=x;i++){
    ans+=1ll*i*d[i];
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 123432
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a .equals (b)){
			System.out.println("H");
		}else{
			System.out.println("D");
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
N = None
K = None
cnt = 0 

def rec(num_str):
    global N, K, cnt
    if len(num_str) > K:
        return
    if '7' in list(num_str) and '5' in list(num_str) and '3' in list(num_str):
        if int(num_str) <= N:
           cnt += 1
    rec(num_str+'7') 
    rec(num_str+'5') 
    rec(num_str+'3') 


if __name__ == '__main__':
    S = input()
    N = int(S)
    K = len(S)
    rec('')
    print(cnt)



Measured memory_bytes: 9108
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int limit = scanner.nextInt();
        int target = scanner.nextInt();
        int count = 0;
        int z = 0;

        for(int i=0; i<=limit; i++) {
            for(int j=0; j<=limit; j++) {
                z = target - i - j;
                if(z >= 0 && z <= limit) {
                    count += 1;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35724
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [N, A, B] = input[0].map(Number);

  let answer = 0;

  for (let i = 1; i <= N; i++) {
    const digitSum = Number(
      i
        .toString()
        .split("")
        .map(Number)
        .reduce((sum, cur) => sum + cur)
    );

    if (digitSum >= A && digitSum <= B) {
      answer += i;
    }
  }

  return answer;
};

console.log(main(read()));


Measured memory_bytes: 33920
#include <stdio.h>

int main(void)
{
        int n,a[101],i,tmp,j,index,s=0,z=0;

        scanf("%d",&n);

        for (i=0;i<n;i++)
                scanf("%d",&a[i]);

        for (i=0;i<n-1;i++) {
                index=i;
                for (j=i+1;j<n;j++)
                        if (a[j]>a[index]) index=j;
                 tmp=a[index]; a[index]=a[i]; a[i]=tmp;
   }

        for (i=0;i<n;i+=2)
                s+=a[i];

        for (i=1;i<n;i+=2)
                z+=a[i];

 printf("%d\n",s-z);
        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

const int INF = 1<<30;

int n, m, data[16], dp[2][256], in;

main(){
  while(1){
    scanf("%d%d", &n, &m);
    if(!n && !m) break;
    for(int i=0;i<m;i++) scanf("%d", &data[i]);
    for(int i=0;i<256;i++) dp[0][i] = INF;
    dp[0][128] = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<256;j++) dp[(i+1)%2][j] = INF;
      scanf("%d", &in);
      for(int j=0;j<256;j++){
        if(dp[i%2][j] == INF) continue;
        for(int k=0;k<m;k++){
          int next = j + data[k];
          if(next < 0) next = 0;
          if(next > 255) next = 255;
          dp[(i+1)%2][next] = min(dp[(i+1)%2][next], abs(in-(next)) * abs(in-(next)) + dp[i%2][j]);
        }
      }
    }
    int ans = INF;
    for(int i=0;i<256;i++) ans = min(ans, dp[n%2][i]);
    printf("%d\n", ans);
  }
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 1e9 + 7;

ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

int main2() {
  int N = nextLong();
  int K = nextLong();
  vector<ll> A(N);
  REP(i, N) A[i] = nextLong();

  ll plus = 0, zero = 0, minus = 0;
  REP(i, N) {
    if (A[i] > 0) plus++;
    if (A[i] == 0) zero++;
    if (A[i] < 0) minus++;
  }

  vector<ll> pos, neg;
  REP(i, N) {
    if (A[i] > 0) pos.push_back(A[i]);
    if (A[i] < 0) neg.push_back(abs(A[i]));
  }

  if (K == 1) {
    sort(ALL(pos));
    sort(ALL(neg));

    if (pos.size() > 0) {
      cout << pos.back() << endl;
    } else if (neg.size() > 0) {
      cout << neg[0] << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }

  if ((K % 2 == 0 && minus / 2 * 2 + plus >= K) ||
      (K % 2 == 1 && minus / 2 * 2 + plus >= K && plus >= 1)) {


    sort(ALL(pos)); reverse(ALL(pos));
    sort(ALL(neg)); reverse(ALL(neg));

    pos.push_back(0);
    pos.push_back(0);
    neg.push_back(0);
    neg.push_back(0);

    ll ans = 1;

    int a = 0, b = 0;
    if (K % 2) { K--;  ans *= pos[a]; a++; }
    for (int k = 0; k < K; k += 2) {
      ll val_a = pos[a] * pos[a+1];
      ll val_b = neg[b] * neg[b+1];
      if (val_a >= val_b) {
        (ans *= pos[a]) %= MOD;
        (ans *= pos[a+1]) %= MOD;
        a += 2;
      } else {
        (ans *= neg[b]) %= MOD;
        (ans *= neg[b+1]) %= MOD;
        b += 2;
      }
    }

    cout << ans << endl;
    return 0;

  } else if (zero > 0) {
    cout << 0 << endl;
    return 0;
  } else {

    REP(i, N) A[i] = abs(A[i]);
    sort(ALL(A));

    ll ans = 1;
    REP(k, K) {
      (ans *= A[k]) %= MOD;
    }

    cout << (MOD - ans) % MOD  << endl;

    return 0;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 6864
n = int(input())
c = 0
for a in range(1, 3501):
    for b in range(a, 3501):
        if 4*a*b - n*(a+b) > 0 and n*a*b % (4*a*b - n*(a+b)) == 0:
            c = n*a*b // (4*a*b - n*(a+b))
            print('{} {} {}'.format(a, b, c))
            break
    if c:
        break


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - To Infinity
            string s = Console.ReadLine();
            long k = long.Parse(Console.ReadLine());

            //Sの最初の文字から何文字連続して1が続くかカウント
            int ones = CountContinuousOne(s);

            if (k <= ones)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(GetSecondChar(s));
            }
        }

        static int CountContinuousOne(string s)
        {
            int count = 0;

            foreach(var c in s)
            {
                if (c == '1')
                {
                    count++;
                }
                else
                {
                    break;
                }
            }

            return count;
        }

        static string GetSecondChar(string s)
        {
            foreach(var c in s)
            {
                if (c != '1')
                {
                    return c.ToString();
                }
            }

            return "1";
        }
    }
}

Measured memory_bytes: 13140
# 並んでるやつから取ったほうがいい + 折返しのぶんは左右どっちにいってから折り返すのがいいかminで判定
# cur, cur + kで調べる
n, k = map(int, input().split())
arr = list(map(int, input().split()))
ans = 10 ** 10
for i in range(n - k + 1):
    if arr[i] < 0 and arr[i + k - 1] < 0:
        ans = min(ans, abs(arr[i]))
    elif arr[i] < 0 and 0 <= arr[i + k - 1]:
        ans = min(
            ans, abs(arr[i]) * 2 + arr[i + k - 1], abs(arr[i]) + arr[i + k - 1] * 2
        )
    elif 0 <= arr[i] <= arr[i + k - 1]:
        ans = min(ans, arr[i + k - 1])

    # print("taken from {}, ans = {}".format(arr[i : i + k], ans))
print(ans)


Measured memory_bytes: 14480
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  set<char> exists;
  for (int i = 0; i < s.size(); i++) {
    exists.insert(s[i]);
  }
  for (char c = 'a'; c <= 'z'; c++) {
    if (exists.find(c) == exists.end()) {
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint S; cin >> S;
    if (S == lint(1e18)) {
        cout << 0 << " " << 0 << " " << lint(1e9) << " " << 0 << " " << 0 << " " << lint(1e9) << "\n";
        return 0;
    }
    lint upper = S / lint(1e9) + 1, lower = lint(1e9) - S % lint(1e9);
    lint X1 = 1e9, Y2 = upper, X2 = 1, Y1 = lower;
    cout << 0 << " " << 0 << " " << X1 << " " << Y1 << " " << X2 << " " << Y2 << "\n";
    assert(X1 * Y2 - X2 * Y1 == S);
}

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

using namespace std;

using ll = long long;

template<int MOD>
struct ModInt {
   using Mint = ModInt;
   int val;
   ModInt(ll __val = 0) { fix(__val % MOD + MOD); }
   Mint& fix(int __val) { val = __val; if (val >= MOD) val -= MOD; return *this; }
   explicit operator int() { return val; }
   Mint operator + (const Mint &mt) const { return Mint().fix(val + mt.val); }
   Mint operator - (const Mint &mt) const { return Mint().fix(val - mt.val + MOD); }
   Mint operator * (const Mint &mt) const { return Mint().fix(ll(val) * mt.val % MOD + MOD); }
   Mint& operator += (const Mint &mt) { return *this = *this + mt; }
   Mint& operator -= (const Mint &mt) { return *this = *this - mt; }
   Mint& operator *= (const Mint &mt) { return *this = *this * mt; }
   Mint pow(int y) const {
      Mint x = *this;
      Mint ans(1);
      for (; y > 0; y >>= 1, x *= x) {
         if (y & 1) ans *= x;
      }
      return ans;
   }
   Mint operator -() const { return Mint().fix(MOD - val); }
   Mint inv() const { return pow(MOD - 2); }
   Mint operator / (const Mint &mt) const { return *this * mt.inv(); }
   Mint& operator /= (const Mint &mt) const { return *this / mt; }
   friend ostream& operator<<(ostream& os, const Mint& mt) { return os << mt.val; }
};

using Mint = ModInt<1000000007>;

const int MAXN = 1000100;

Mint fact[MAXN];
Mint ifact[MAXN];
Mint pow2[MAXN];
Mint pow3[MAXN];

void precalc() {
   fact[0] = 1;
   for (int i = 1; i < MAXN; ++i) fact[i] = fact[i - 1] * i;
   ifact[MAXN - 1] = fact[MAXN - 1].inv();
   for (int i = MAXN - 1; i > 0; --i) ifact[i - 1] = ifact[i] * i;
   pow2[0] = pow3[0] = 1;
   for (int i = 1; i < MAXN; ++i) {
      pow2[i] = pow2[i - 1] + pow2[i - 1];
      pow3[i] = pow3[i - 1] + pow3[i - 1] + pow3[i - 1];
   }
}

Mint C(int N, int K) {
   if (N < K || K < 0) return Mint(0);
   return fact[N] * ifact[K] * ifact[N - K];
}

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   precalc();
   int N, M, K;
   cin >> N >> M >> K;
   vector<Mint> dp(M + K + 1);
   dp[0] = 1;
   for (int i = 1; i <= M + K; ++i) {
      dp[i] = dp[i - 1] + dp[i - 1];
      if (i > M) dp[i] -= C(i - 1, M);
      if (i > K) dp[i] -= C(i - 1, K);
   }
   Mint ans = 0;
   for (int i = 0; i <= M + K; ++i) {
      ans += C(N - 1 + i, i) * dp[i] * pow3[M + K - i];
   }
   cout << ans << "\n";
   return 0;
}


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

int INF=10000000;
int N,A,B,C;
vector<int> L;

void chmin(int &a, int b) {if(a>b) a=b;}

int rec(int i, int a, int b, int c){
    if(i==N){
        if(!a||!b||!c) return INF;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }
    
    int res=rec(i+1,a,b,c);
    chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
    
    return res;
}

int main(void){
    cin>>N>>A>>B>>C;
    L.resize(N);
    for(int i=0;i<N;i++) cin>>L[i];
    
    cout<<rec(0,0,0,0)<<endl;
    
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	t := getNextString(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	u := getNextString(scanner)
	if s == u {
		a--
	}
	if t == u {
		b--
	}
	fmt.Fprintln(writer, fmt.Sprintf("%d %d", a, b))
}


Measured memory_bytes: 640
(setq n(read))(setq m(read))
(setq a(loop for i from 1 to(* 2 n)collect(read)))
(setq b(loop for i from 1 to(* 2 m)collect(read)))
(dotimes(i n)
  (setq s 1000000000)
  (setq x(nth (* i 2)a))
  (setq y(nth (1+(* i 2))a))
  (setq k 0)
  (dotimes(j m)
	(setq z(nth (* j 2)b))
	(setq w(nth (1+(* j 2))b))
	(setq n(+(abs(- x z))(abs(- y w))))
	(if(< n s)(progn(setq s n)(setq k (1+ j)))))
  (format t"~A~%"k))


Measured memory_bytes: 16360
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = 10**9

def main():
    S = input()
    alphabet = 'abcdefghijklmnopqrstuvwxyz'

    S_set = set(S)
    alphabet_set = set(alphabet)

    array = list(alphabet_set - S_set)
    array.sort()
    if len(array) == 0:
        print('None')
    else:
        print(array[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128