akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;

int main(){
    long long N, Blue;
    cin >> N >> Blue;
    long long Red = N - Blue;
    
    vector<vector<long long>> C(2100, vector<long long>(2100, 0));
    for(long long i = 0; i < C.size(); i++){
        C[i][0] = 1;
        C[i][i] = 1;
    }
    for(long long i = 1; i < C.size(); i++){
        for(long long j = 1; j < i; j++){
            C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
            C[i][j] %= MOD;
        }
    }
    /*
    for(long long i = 1; i < C.size(); i++){
        for(long long j = 1; j < i; j++){
            if(C[i][j] < 0)cout << i << " C " << j << " is " << C[i][j] << endl;
        }
    }
    */
    
    for(int i = 1; i <= Blue; i++){
        cout << (C[Red + 1][i] * C[Blue - 1][i - 1]) % MOD << endl;
    }//*/
    return 0;
}

Measured memory_bytes: 34816
using System.Collections.Generic;
    using System.Collections;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System;

    namespace cysharp_test
    {
        class Program
        {
            static void Main (string[] args)
            {
                new Program ().solve ();
            }

            void solve ()
            {
            long[] abck = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long a = abck[0];long b = abck[1];long c = abck[2];long k = abck[3];
            long ans = 0;
            if(k > 0){
                ans += Math.Min(a, k);
                k -= ans;
            }
            if(k > 0){
                k -= Math.Min(k, b);
            }
            if(k > 0){
                ans -= k;
            }

            Console.WriteLine(ans);
            Console.ReadKey ();
            }

        }
        struct Vector2
        {
            public Vector2 (long x, long y)
            {
                this.x = x;
                this.y = y;
            }

            public long x, y;

            public static Vector2 operator + (Vector2 a, Vector2 b)
            {
                return new Vector2 (a.x + b.x, a.y + b.y);
            }

            public static Vector2 operator - (Vector2 a, Vector2 b)
            {
                return new Vector2 (a.x - b.x, a.y - b.y);
            }

            public static Vector2 operator * (Vector2 a, long scala)
            {
                return new Vector2 (a.x * scala, a.y + scala);
            }

            public static bool operator == (Vector2 a, Vector2 b)
            {
                return (a.x == b.x) && (a.y == b.y);
            }

            public static bool operator != (Vector2 a, Vector2 b)
            {
                return !(a.x == b.x) && (a.y == b.y);
            }

            public override int GetHashCode ()
            {
                return (int) (x + y);
            }

            public override bool Equals (object obj)
            {
                if (!(obj == null) && obj is Vector2)
                {
                    return (this == (Vector2) obj);
                }
                else return false;
            }

            public override string ToString ()
            {
                return ("(" + x + "," + y + ")");
            }
        }
    }

Measured memory_bytes: 19080
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
// #include <atcoder/all>
// using namespace atcoder;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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;
}
template <class T>
inline void dump(T& v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
template <class T, class U>
inline void dump(map<T, U>& v) {
    irep(i, v) { cout << i->first << " " << i->second << '\n'; }
}
inline string getline() {
    string s;
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 61;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */




int main() {
    
    int x;
    cin>>x;
    cout<<1-x<<endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s, t;
    cin >> s >> t;
    map<char, vector<ll>> pos;
    rep(i, len(s)) {
        pos[s[i]].push_back(i);
    }
    ll cur = 0, loop = 0;
    rep(i, len(t)) {
        if (sz(pos[t[i]]) == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto it = lower_bound(all(pos[t[i]]), cur);
        if (it == pos[t[i]].end()) {
            cur = pos[t[i]][0] + 1;
            loop++;
        }
        else {
            cur = *it + 1;
        }
    }
    cout << (loop * len(s) + cur) << endl;
    return 0;
}


Measured memory_bytes: 1736
///I don't wanna read problem's statement anymore
using namespace std;
#include<bits/stdc++.h>
#define ll long long
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define sf scanf
#define pb push_back
#define newline printf("\n");
#define pfr push_front
#define reap(i,n) for(int i=0; i<n; i++)
#define case_ printf("Case %d: ",i)
#define check printf("working\n")
#define pf printf
#define ato(v) for(auto k:v)
#define vi vector<int>
#define vll vector<ll>
#define vec_ch vector<char>
#define list_i list<int>
#define list_ll list<ll>
#define list_ch list<ch>
#define M 100005
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///AtCoder- DP editorial contest, Problem C   [Bottum Up Aproach]
ll d[105][M],w[105],v[105];
int main(){
    ios
    //read;
    //write;
    ll n,W;
    cin>>n>>W;
    for(int i=0; i<n; i++) cin>>w[i]>>v[i];
    for(int i=0; i<=W; i++){
        if(i>=w[0])
            d[0][i]=v[0];
    }
    for(int i=1; i<=n; i++){
        for(int j=0; j<=W; j++){
            if(j<w[i])
                d[i][j]=d[i-1][j];
            else
                d[i][j]=max(d[i-1][j], d[i-1][j-w[i]]+v[i]);
        }
    }
    cout<<d[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 80128
import numpy as np

def resolve():
    N, M, Q = map(int, input().split())
    L, R = np.array([list(map(int, input().split())) for _ in range(M)]).T
    P, Q = np.array([list(map(int, input().split())) for _ in range(Q)]).T
    P -= 1
    S = np.zeros(((N + 1), (N + 1)))

    # L,Rの区間にある本数
    np.add.at(S, (L,R), 1)

    # ゼータ変換（横縦累積和） axis=1:横, axis=0:縦
    S = np.cumsum(S, axis=1).cumsum(axis=0)

    ans = S[P, P] - S[P, Q] - S[Q, P] + S[Q, Q]
    print(*ans.astype(int), sep="\n")

if __name__ == "__main__":
    resolve()

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

using namespace std;

const auto INF = 1e9;
const auto NMAX = 100000 + 5;
int h[NMAX];
int dp[NMAX];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; ++i) dp[i] = INF;
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(input())
    return x

H,W = map(int,input().split())
S = int_mtx(H)
Scopy = S.copy()
for i in range(0,H):
    Scopy[i] = list(Scopy[i])

for i in range(0,H):
    for j in range(0,W):

        if S[i][j] == ".":
            cnt = 0
            for k in range(max(0,i-1),min(i+2,H)):
                for l in range(max(0,j-1),min(j+2,W)):
                    if S[k][l] == "#":
                        cnt += 1
            Scopy[i][j] = str(cnt)

for i in range(0,H):
    print("".join(Scopy[i]))

Measured memory_bytes: 27000
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

using Graph = vector<vector<int> >;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(2 * N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> ans(2 * N - 1);
    vector<int> dist(2 * N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            ans[nv] = v;
            que.push(nv);
        }
    }
    /*
    rep(v,N){
      if(dist[v] == -1){
        cout << "No" << endl;
        return 0;
      }
    }
    */
    // 結果出力 (各頂点の頂点 0 からの距離を見る)
    // for (int v = 0; v < N; ++v) cout << v << ": " << dist[v] << endl;
    cout << "Yes" << endl;
    for(ll v = 1; v < N ; v ++) cout << ans[v] + 1 << endl;
}


Measured memory_bytes: 13708
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll fact[50];
#define eps 1e-9
#define INF 1e18
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=ans*a%c;
    }
    a=a*a%c;
    b=b/2;
  }
  return ans;
}
ll ncr(ll n,ll r){
    if(r>n)return 0;
    if(r==n)return 1;
    ll z=fact[n];
    z=z*power(fact[r],mod-2,mod)%mod;
    z=z*power(fact[n-r],mod-2,mod)%mod;
    return z;
}
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n; cin>>n;
   int flag=0;
   while(n){
    if(n%10==7)flag=1;
    n/=10;
   }
   flag==1?cout<<"Yes":cout<<"No";
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

const static int MAX = 30;
int n, m, k, a, B[MAX], ans;

int main() {
    scanf("%d %d", &n, &m);
    
    for ( int i = 0; i < m; i++ ) {
        B[i] = 0;
    }

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &k);

        for ( int j = 0; j < k; j++ ) {
            scanf("%d", &a);
            B[a-1]++;
        }
    }

    ans = 0;

    for ( int i = 0; i < m; i++ ) {
        if ( B[i] == n ) {
            ans++;
        }
    }
    
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
ll ksm(ll a,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans=ans*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans;
}
int main(){
	ll n,m;cin>>n>>m;
	if(n>m) swap(n,m);
	if(n<m-1) puts("0");
	else if(n==m){
		ll s=1;
		for(int i=1;i<=n;i++) s=s*i%mod;
		cout<<s*s*2%mod<<endl; 
	}
	else {
	ll x=1,y=1,s=1;
	for(int i=1;i<=m;i++){
		s=s*i%mod;
		if(i==m-1-n) x=s;
		else if(i==m-1) y=s;
	}
	x=ksm(x,mod-2);
	y=y*x%mod;
	s=y*s%mod;
	cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 3644
### constant

DXYS = [[1, 0], [0, -1], [-1, 0], [0, 1]]
INF = 1 << 30

### main

loop do
  n = gets.to_i
  break if n == 0

  xs = []
  ys = []
  rects = []
  minx = miny = INF
  maxx = maxy = 0
  
  n.times do
    x0, y1, x1, y0 = gets.split.map(&:to_i)
    rects << [x0, y0, x1, y1]
    xs << x0 << x1
    ys << y0 << y1
    minx = x0 if minx > x0
    maxx = x1 if maxx < x1
    miny = y0 if miny > y0
    maxy = y1 if maxy < y1
  end
  xs << minx - 1 << maxx + 1
  ys << miny - 1 << maxy + 1

  xs.sort!.uniq!
  ys.sort!.uniq!
  nxs = xs.length
  nys = ys.length
  
  xhash = {}
  xs.each_with_index{|x, i| xhash[x] = i}
  yhash = {}
  ys.each_with_index{|y, i| yhash[y] = i}
  #p [xhash, yhash]

  rrects =
    rects.map{|x0, y0, x1, y1| [xhash[x0], yhash[y0], xhash[x1], yhash[y1]]}
  #p rrects

  flds = Array.new(nys){Array.new(nxs){0}}
  used = Array.new(nys){Array.new(nxs){false}}
  #p flds

  for i in (0...n)
    x0, y0, x1, y1 = rrects[i]
    b = 1 << i
    for y in (y0...y1)
      for x in (x0...x1)
        flds[y][x] |= b
      end
    end
  end
  #p flds

  nr = 0
  for oy in (0...nys)
    for ox in (0...nxs)
      if ! used[oy][ox]
        nr += 1
        fld = flds[oy][ox]
        used[oy][ox] = true
        q = [[ox, oy]]

        while ! q.empty?
          ux, uy = q.shift
          DXYS.each do |dx, dy|
            vx = ux + dx
            vy = uy + dy
            if vx >= 0 && vx < nxs && vy >= 0 && vy < nys &&
               ! used[vy][vx] && flds[vy][vx] == fld
              used[vy][vx] = true
              q << [vx, vy]
            end
          end
        end
      end
    end
  end

  puts nr
end

Measured memory_bytes: 6368
def main():
    MOD = 10 ** 9 + 7
    L = input()
    N = len(L)
    dp = [0 for _ in range(N + 1)]
    dpp = [0 for _ in range(N + 1)]
    dpp[0] = 1
    for n in range(1, N + 1):
        dpp_v = dpp[n - 1]
        d = int(L[n - 1])
        dpp[n] = ((d + 1) * dpp_v) % MOD
        dp[n] = (3 * dp[n - 1] + d * dpp_v) % MOD
    print((dp[N] + dpp[N]) % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 16984
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7

sum_A = [0] * N
sum_A[0] = A[0]

for i in range(1, N):
  sum_A[i] = sum_A[i-1] + A[i]

print(sum([sa*a for sa,a in zip(sum_A[:-1], A[1:])]) % MOD)


Measured memory_bytes: 117204
MAX = 4000000 #二項係数n, k の n のsaidaiti
MOD = 1000000007

def mod_power(n, p, m)
  #フェルマーの小定理
  return 1 if p == 0
  if p % 2 == 0
    t = mod_power(n, p / 2, m)
    return t * t % m
  else
    return n * mod_power(n, p - 1, m) % m
  end
end

def cominit()
  #階乗と階乗の逆元を用意する
  @fac = []
  @fac[0] = 1
  @fac[1] = 1
  @finv = []
  @finv[0] = 1
  @finv[1] = 1

  2.upto(MAX) do |i|
    @fac[i] = @fac[i-1] * i % MOD
  end

  @finv[MAX] = mod_power(@fac[MAX], MOD - 2, MOD)
  (MAX-1).downto(2) do |i|
    @finv[i] = @finv[i+1] * (i + 1) % MOD
  end
end

def comb(n, r)
  return @fac[n] * @finv[r] * @finv[n-r] % MOD
end

def main
  r1, c1, r2, c2 = gets.chomp.split.map(&:to_i)
  ans = 0

  cominit

  (c1..c2).each do |i|
    ans -= comb(r1 + i, i + 1)
    ans += comb(r2 + i + 1, i + 1)
  end

  puts ans % MOD
end

main

Measured memory_bytes: 66756
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 998244353
#define LINF 1000000000000000007mope
#define ll long long
using namespace std;
int N;
ll data[530000],datb[530000]; // 0-indexed
void init(int n_){
	N = 1;
	while(N<=n_)N*=2;
	for(int i=0;i<=2*N;i++){
		data[i]=0;
		datb[i]=0;
	}
}
void add(int a,int b, int x,int k,int l,int r){ // add x to [a,b) k=0, l=0, r=N
	if(a <= l && r<=b){
		data[k] += x;
	}
	else if( l<b && a<r ){
		datb[k] += (min(b,r)-max(a,l)) * x;
		add( a,b,x,k*2+1,l,(l+r)/2);
		add( a,b,x,k*2+2,(l+r)/2,r);
	}
}
ll sum(int a,int b,int k,int l,int r){ // sum of [a,b)
	if(b<=l || r<=a){
		return 0;
	}
	else if(a<= l && r<=b){
		return data[k]*(r-l)+datb[k];
	}
	else{
		ll res = (min(b,r) -max(a,l)) * data[k];
		res += sum(a,b,k*2+1,l,(l+r)/2);
		res += sum(a,b,k*2+2,(l+r)/2,r);
		return res;
	}
}
int ka[214514],inv[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int res = 1;
	while(k>0){
		if(k%2)res = (res*x)%inf;
		x = (x*x)%inf;
		k >>=1;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
signed main(){
	int n;
	cin>>n;
	vector< pair<int,int> > pt;
	vector<int> x,y;
	for(int i=0;i<n;i++){
		int xx,yy;
		cin>>xx>>yy;
		pt.pb(mp(xx,yy));
		x.pb(xx); y.pb(yy);
	}
	sort( x.begin(), x.end() );
	sort( y.begin() ,y.end() );
	vector< pair<int,int> > cp;
	map<int,int> mopex,mopey;
	for(int i=0;i<n;i++){
		mopex[ x[i] ] = i;
		mopey[ y[i] ] = i;
	}
	for(int i=0;i<n;i++){
		int cx = mopex[ pt[i].first ] ;
		int cy = mopey[ pt[i].second ];
		cp.pb(mp(cx,cy));
	}
	init(n+10);
	sort( cp.begin(), cp.end() );
	vector<int> lup,ldown,rup,rdown;
	for(int i=0;i<n;i++){
		//cout<<cp[i].first<<" "<<cp[i].second<<endl;
		int cy = cp[i].second;
		lup.pb( sum( cy, n, 0, 0, N ) );
		ldown.pb( sum( 0, cy, 0, 0, N ) ) ;
		add( cy, cy+1, 1, 0, 0, N );
	}
	init(n+10);
	for(int i=n-1;i>=0;i--){
		//cout<<cp[i].first<<" "<<cp[i].second<<endl;
		int cy = cp[i].second;
		rup.pb( sum( cy, n, 0, 0, N ) ) ; 
		rdown.pb( sum( 0, cy, 0, 0, N ) );
		add( cy, cy+1, 1, 0, 0, N );
	}
	reverse( rup.begin(), rup.end() );
	reverse( rdown.begin(), rdown.end() );
	int ans = 0;
	int tmp = 1;
	for(int i=0;i<n;i++){
		//cout<<lup[i]<<ldown[i]<<rup[i]<<rdown[i]<<endl;
		ans += modpow(2,n);
		ans %= inf;
		ans += inf-modpow(2,lup[i]+rup[i]);
		ans %= inf;
		ans += inf-modpow(2,ldown[i]+rdown[i]);
		ans %= inf;
		ans += inf-modpow(2,lup[i]+ldown[i]);
		ans %= inf;
		ans += inf-modpow(2,rup[i]+rdown[i]);
		ans %= inf;
		ans += modpow(2,rdown[i]);
		ans += modpow(2,rup[i]);
		ans += modpow(2,ldown[i]);
		ans += modpow(2,lup[i]);
		ans += inf - 1;
		ans %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 58352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
/************ Combination wtih MOD ************
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// preprocess for some tables
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
// combination
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*******************************************************/
/********** UnionFind ***************
struct UnionFInd {
vector<ll> par;
UnionFInd(ll N) : par(N) {
for (ll i = 0; i < N; i++) {
par[i] = i;
}
}
ll root(ll x) {
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
if (rx == ry) return;
par[rx] = par[ry];
}
bool same(ll x, ll y) {
ll rx = root(x);
ll ry = root(y);
return rx == ry;
}
};
*************************************/
ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }

  ll r = a % b;
  while (r > 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  REP(i, n) {
    ll ai;
    cin >> ai;
    a[i] = ai / 2;
  }

  bool isok = true;
  ll cnt = 0;

  REP(i, n) {
    ll t = 0;
    ll aa = a[i];
    while (aa % 2 == 0) {
      aa = aa / 2;
      t += 1;
    }
    if (i == 0) {
        cnt = t;
    }else{
        if(cnt != t){
            isok = false;
            break;
        }
    }
  }
  if(!isok){
      cout << 0 << endl;
      exit(0);
  }

  ll kk = 1;
  REP(i, n) { kk = kk * a[i] / gcd(kk, a[i]); }
  ll tmp = m / kk;
  cout << (tmp + 1) / 2 << endl;
}

Measured memory_bytes: 4340
N,K= map(int,input().split())
S = input()
s=str("")
for i in range(len(S)):
    
    if i == K-1:
        #print(i,S[i].lower())
        s=s+S[i].lower()
    else:
        #print(i,S[i])
        s=s+S[i]
print(s)

Measured memory_bytes: 2940
#include<iostream>
#include<list>
using namespace std;
int main(){
    int N,M,Q;
    cin>>N>>M>>Q;
    list<int> L;
    for(int i=0;i<N;i++){
        L.push_back(i);
    }
    list<int>::iterator btn=L.begin();
    for(int i=0;i<M;i++){
        int a;
        cin>>a;
        if(a%2==0){
            for(int j=0;j<a;j++){
                btn++;
                if(btn==L.end()){
                    btn=L.begin();
                }
            }
        }else{
            for(int j=0;j<a;j++){
                if(btn==L.begin()){
                    btn=L.end();
                }
                btn--;
            }
        }
        list<int>::iterator it=btn;
        btn++;
        if(btn==L.end()){
            btn=L.begin();
        }
        L.erase(it);
    }
    for(int i=0;i<Q;i++){
        int q;
        cin>>q;
        list<int>::iterator it;
        for(it=L.begin();it!=L.end();it++){
            if(*it==q){
                break;
            }
        }
        if(it!=L.end()){
            cout<<1<<endl;
        }else{
            cout<<0<<endl;
        }
    }
}


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

const long mod=1e9+7;
long cnt[26];

int main()
{
    string s;
    cin>>s>>s;
    long res=0;
    for(auto& c: s) {
        ++cnt[c-'a'];
        long t=1;
        for(int i=0; i<26; ++i) if (i!=c-'a' and cnt[i]) t=t*(cnt[i]+1)%mod;
        res=(res+t)%mod;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 512
// ARC087E.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5 + 200;

typedef long long ll;

int n, ptot, ch[MAX_N][2];
ll L;
char S[MAX_N];

inline ll lowbit(ll x) { return x & (-x); }

ll dfs(int u, int dep)
{
    if (u == 0)
        return lowbit(L - dep + 1);
    return dfs(ch[u][0], dep + 1) ^ dfs(ch[u][1], dep + 1);
}

int main()
{
    scanf("%d%lld", &n, &L), ptot = 1;
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", S + 1);
        int p = 1;
        for (int j = 1; S[j]; j++)
        {
            if (ch[p][S[j] - '0'] == 0)
                ch[p][S[j] - '0'] = ++ptot;
            p = ch[p][S[j] - '0'];
        }
    }
    if (dfs(1, 0) == 0)
        puts("Bob");
    else
        puts("Alice");
    return 0;
}

Measured memory_bytes: 9228
#include <stdio.h>

int main()
{
	int i, j;
	int a[2];
	double b;
	int count = 0;

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

	j = a[0] / a[1];
	i = a[0] % a[1];
	b = (double)a[0] / a[1];

	printf("%d %d %lf\n", j, i, b);
	return 0;
}


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

#define S 0
#define H 1
#define C 2
#define D 3

int main(){
    int n;
    int card[4][13];
    char type;
    int num;

    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++){
            card[i][j] = 0;
        }
    }
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> type >> num;
        switch(type){
        case 'S':{
            card[S][num-1] = 1;
            break;}
        case 'H':{
            card[H][num-1] = 1;
            break;}
        case 'C':{
            card[C][num-1] = 1;
            break;}
        case 'D':{
            card[D][num-1] = 1;
            break;}
        }
    }

    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++){
            if(card[i][j]==0){
                if(i==S){
                    cout << "S " << j+1 << endl;
                }else if(i==H){
                    cout << "H " << j+1 << endl;
                }else if(i==C){
                    cout << "C " << j+1 << endl;
                }else{
                    cout << "D " << j+1 << endl;
                }
            }
        }
    }
    
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    int ans = 0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++)
            ans = max(ans, abs(a[j]-a[i]));
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <random>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;


ll n;
double m, a[101];

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> m;
  REP(i, n) cin >> a[i];
  double s = 0;
  REP(i, n) s += a[i];
  
  ll cnt = 0;
  REP(i, n) {
    if (a[i] >= s / (4 * m)) {
      cnt++;
    }
  }
  if(cnt >= m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <random>
#include <unordered_set>
#include <algorithm>
using namespace std;

using ll = long long;

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


template<typename T> void view(T cont) {cout << cont << endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) cout << cont[i] << " "; cout << endl;}
template<typename T> void view(const vector<T>& v) {for (const auto& f: v) cout << f << " "; cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v: vv) {view(v);}}

// #define MY_DEBUG 0

int* make_seq(int numSeq) {
    random_device seed_gen;
    mt19937 engine(seed_gen());
    int* seq = new int[numSeq];
    uniform_int_distribution<> dist(1, 5);
    rep(i, numSeq) seq[i] = dist(engine);
    return seq;
}

void print_hello() {
    cout << "Hello!" << endl;
}

int linear_search(int n, int* S, int q, int* T) {
    if (S == nullptr || T == nullptr) {
        cout << "Null" << endl;
    }
    int count = 0;
    unordered_set<int> found;
    rep(i, q) {
        int target = T[i];
        rep(j, n) {
            if (S[j] == target) {
                if (!found.count(S[j])) {
                    count++;
                    found.insert(S[j]);
                }
            }
        }
    }
    return count;
}


int main() {
    int n;
    cin >> n;
    int* S = new int[n];
    rep(i, n) cin >> S[i];
    int q;
    cin >> q;
    int* T = new int[q];
    rep(i, q) cin >> T[i];
    int answer;
    answer = linear_search(n, S, q, T);
    view(answer);
#ifdef MY_DEBUG
    int k = 0;
    while (k < 3) {
#endif
        // print_hello();
        // int* a;
        // int len = 10;
        // a = make_seq(len);
        // view(a, len);
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll k;
    string s;

    cin >> k >> s;

    cout << (s.size() <= k ? s : s.substr(0, k) + "...") << "\n";

    return 0;
}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
	int n;
	string s;
	cin>>n>>s;
	ll f=0,b=0;
	for(auto j:s)
		b+=j=='R';
	ll ans=n+2;
	amin(ans,b);
	for(int i=0;i<n;++i)
	{
		f+=s[i]=='W';
		b-=s[i]=='R';
		amin(ans,max(f,b));
	}
	cout<<ans;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1) : n(n), f(n+1) {
        f[0] = f[1] = -1;
        for (long long i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (long long j = i*i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x;}
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    vector<ll> ans(1e7+1);
    Sieve sieve(1e7+1);
    for (int i = 1; i <= 1e7; ++i) {
        if (i == 1) {
            ans[i] = 1;
            continue;
        }
        if (sieve.isPrime(i)) ans[i] = 2;
        else {
            ll x = i;
            ll f = sieve.f[i];
            int cnt = 0;
            while (x % f == 0) {
                cnt++;
                x /= f;
            }
            ans[i] = ans[x] * (cnt + 1);
        }
    }
    rep(i, 1e7+1) ans[i] *= i;
    rep(i, 1e7) ans[i+1] += ans[i];
    ll n;
    cin >> n;
    cout << ans[n] << endl;
    // auto d = enum_div(n);
    // ll ans = 0;
    
    // rep(i, sz(d)) {
    //     cout << d[i] << " " << sz(enum_div(d[i])) << endl;
    //     ans += d[i] * sz(enum_div(d[i]));
    // }
    // cout << ans << endl;
}


Measured memory_bytes: 124548
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> A;
    cin >> B;

    if(A>=10||B>=10){
        cout << -1 << endl;
    }else{
        cout << A*B << endl;
    }
    

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  bool p = false, w = false, g = false, y = false;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> S;
    
    if (S == "P") {
      p = true;
    }

    if (S == "W") {
      w = true;
    }

    if (S == "G") {
      g = true;
    }

    if (S == "Y") {
      y = true;
    }
  }

  if (p && w && g && y) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}  


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

int main(){
	int x;
	int n;
	int i,j;
	int p[100];
	int d[100];
	int t;
	int ans[201];
	cin>>x>>n;
	for(i=0;i<201;i++){
		ans[i]=1;
	}
	
	if(n!=0){
		for(i=0;i<n;i++){
			cin>>p[i];
			d[i]=p[i]-x;
		}
		for(i=0;i<201;i++){
			for(j=0;j<n;j++){
				if((i-100)==d[j]){ 
					ans[i]=0;
					
				}
			}
		}
		for(i=0;i<100;i++){
			if(ans[100-i]==1){
				 t=x-i; 
				 break;
			}
			if(ans[100+i]==1){
			         t=x+i;
				 break;
			}
		}
		cout<<t;
	}else{
		cout<<x;
	}
}
	
	
	

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int b1,b2,b3;

  scanf("%d %d %d",&b1,&b2,&b3);

  if((b1 && b2) || b3){
    printf("Open\n");
  }else{
    printf("Close\n");
  }

  return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN

    ll k;cin>>k;
    cout << (k/2) * (k/2 + k%2)<<endl;
    return 0;
}

Measured memory_bytes: 256
# Tsundoku
import numpy as np
N, M, K = map(int,input().split())
A = np.array([0] + list(map(int, input().split())))
B = np.array([0] + list(map(int, input().split())))
a = np.cumsum(A)
b = np.cumsum(B)

ans = 0
j = M

for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
    
print(ans)

Measured memory_bytes: 53712
#include <stdio.h>

int main(){
	int num, eng[26] = {0}, i;
	char ch;
	while(scanf("%c", &ch) != EOF){
		if(ch >= 'a' && ch <= 'z'){
			eng[ch - 'a']++;
		} else if(ch >= 'A' && ch <= 'Z'){
			eng[ch - 'A']++;
		}
	}
	for(i = 0; i < 26; i++){
		printf("%c : %d\n", 'a' + i, eng[i]);
	}
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

int h[123];
vector<int> primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

void factorize(int x) {
  for (int p: primes) {
    for (int P = p; x % P == 0; P *= p) {
      ++h[p];
    }
  }
}

long long rek(int start, int sf = 75) {
  if (sf == 1) return 1;
  long long ret = 0;
  for (int i = start; i < primes.size(); ++i) {
    for (int j = 1; j <= h[primes[i]]; ++j) {
      if (sf % (j+1)) continue;
      ret += rek(i+1, sf / (j+1));
    }
  }
  return ret;
}

void solve() {
  int n; scanf("%d", &n);
  for (int i = 2; i <= n; ++i) {
    factorize(i);
  }
  printf("%lld", rek(0));
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int heights[100000];

int main()
{
 int N,K,i,min_diff = 1000000000;
 cin>>N>>K;
 for(i=0;i<N;i++)
 {
  cin>>heights[i];
 }
 sort(heights,heights+N);
 for(i=0;i<N-K+1;i++)
 {
  if(heights[i+K-1]-heights[i]<min_diff)
  {
      min_diff = heights[i+K-1]-heights[i];
  }
 }
 cout<<min_diff;
 return 0;
}


Measured memory_bytes: 640
r,c,k = map(int,input().split())
t = [[0 for i in range(c)] for i in range(r)]
for i in range(k):
    a,b,z = map(int,input().split())
    t[a-1][b-1] = z
dp = [[[0 for i in range(c)]for i in range(r)]for i in range(4)]
dp[0][0][0] = 0
dp[1][0][0] = t[0][0]
dp[2][0][0] = t[0][0]
dp[3][0][0] = t[0][0]
for i in range(r-1):
    dp[0][i+1][0] = dp[1][i][0]
    for j in range(1,4):
        dp[j][i+1][0] = dp[1][i][0]+t[i+1][0]
for i in range(c-1):
    dp[0][0][i+1] = 0
    for j in range(1,4):
        dp[j][0][i+1] = max(dp[1][0][i],t[0][i+1])
    for j in range(2,4):
        dp[j][0][i+1] = max(dp[2][0][i],dp[1][0][i]+t[0][i+1])
    dp[3][0][i+1] = max(dp[3][0][i],dp[2][0][i]+t[0][i+1])
for i in range(r-1):
    for j in range(c-1):
        u = max(dp[0][i+1][j],dp[3][i][j+1])
        for s in range(0,4):
            dp[s][i+1][j+1] =  u
        u = max(dp[0][i+1][j]+t[i+1][j+1],dp[1][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
        for s in range(1,4):
            dp[s][i+1][j+1] = u
        u = max(dp[1][i+1][j]+t[i+1][j+1],dp[2][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
        for s in range(2,4):
            dp[s][i+1][j+1] = u
        dp[3][i+1][j+1] = max(dp[2][i+1][j]+t[i+1][j+1],dp[3][i+1][j],dp[3][i][j+1]+t[i+1][j+1])
print(dp[3][r-1][c-1])

Measured memory_bytes: 468928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}

int main() {
  ll n, m;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  cin >> m;
  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    rep(j, b-a) swap(v.at(a+j), v.at(c+j));
  }
  rep(i, n) {
    if (i) {
      cout << ' ' << v.at(i);
    } else {
      cout << v.at(i);
    }
  }
  cout << endl;
}


Measured memory_bytes: 3104
def next(n):
    i = len(n) -1
    nine = False
    if len(n) == 1:
        if n == [9]:
            return [1,0]
        else:
            return [n[0]+1]
    while i >= 0:
        if nine:
            if n[i] == 8:
                nine = False
                if n[i] - n[i-1] != 1:
                    break
            if i == 0:
                return [1] + [0 for m in range(len(n))]
        else:
            if n[i] == 9:
                nine = True
            elif n[i] - n[i-1] != 1:
                break
        i -= 1
    n[i] += 1
    i += 1
    while i < len(n):
        n[i] = max(0, n[i-1] - 1)
        i += 1
    return n

k = int(input())
if k == 1:
    print('1')
    exit()
i = 1
n = [1]
while i < k:
    i += 1
    n = next(n)
print(*n, sep='')

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#include <cassert>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
#define vi vector<int>
using namespace std;
using ll = long long;

// ----ここから下は以前競プロをやっていた時に使っていたものです----　

const int MAX = 1000000;

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

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

struct s{
  int p,i,r;
};

//比較関数（降順）
bool cmpP(const s &a, const s &b){
  return a.p > b.p;
}

//比較関数（昇順）
bool cmpI(const s &a, const s &b){
  return a.i < b.i;
}

// ----本問について----
// 問題：平安京ウォーキング
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/2186
// 所要時間：
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll t,gx,gy,p;

ll solve() {
  vector< vector<bool> > vert(gx+1,vector<bool>(gy+1,true)),horiz(gx+1,vector<bool>(gy+1,true));
  for (int i=1; i<=gx; i++){
    vert[i][0]=false;
  }
  for (int j=1; j<=gy; j++){
    horiz[0][j]=false;
  }
  rep(i,p){
    ll x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2){
      vert[x1][max(y1,y2)]=false;
    }
    if (y1 == y2){
      horiz[max(x1,x2)][y1]=false;
    }
  }
  vector< vector<ll> > T(gx+1,vector<ll>(gy+1));
  T[0][0]=1;
  rep(i,gx+1){
    rep(j,gy+1){
      if (i !=0 || j!=0){
        if(vert[i][j]==false && horiz[i][j]==false){
          T[i][j]=0;
        } else if (vert[i][j]==false){
          T[i][j]=T[i-1][j];
        } else if (horiz[i][j]==false){
          T[i][j]=T[i][j-1];
        } else {
          T[i][j]=T[i-1][j]+T[i][j-1];
        }
      }
    }
  }

  return T[gx][gy];
}

int main()
{
  //cout << fixed << setprecision(10);
  cin >> t;
  rep(ii,t){
    cin >> gx >> gy;
    cin >> p;
    ll ans = solve();
    if (ans != 0){
      cout << ans << endl;
    } else {
      cout << "Miserable Hokusai!" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3056
L, R = map(int, input().split())
# 2019 = 3*673
p = 673
if R-L>p:
    print(0)
else:
    ans = 2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min((i*j)%2019, ans)
    print(ans)
            

Measured memory_bytes: 40176