akhauriyash/Code-Regression huggingface dataset:
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {
	int h = -1, w;
	cin >> h >> w;
	vector<string> b(h);
	for (int i = 0; i < h; ++i) {
		cin >> b[i];
	}
	int dp[102][102][2] = {};
	memset(dp, 0x3f, sizeof(dp));
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int is_black = b[i][j] != '.';
			int c = (i == 0 && j == 0) ? is_black : 1 << 30;
			if (i > 0) {
				c = min(c, dp[i - 1][j][0] + is_black);
				c = min(c, dp[i - 1][j][1]);
			}
			if (j > 0) {
				c = min(c, dp[i][j - 1][0] + is_black);
				c = min(c, dp[i][j - 1][1]);
			}
			dp[i][j][is_black] = c;
		}
	}
	cout << min(dp[h - 1][w - 1][0], dp[h - 1][w - 1][1]) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include  <set>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)

int main() {
	ll a, b, c, d, e, f, g,  i, j, n,k, m, l;
	ll v[100],sum=-100000000,h ;
	h = 0;
	cin >> n >>k;
	ll w[100];
	f = 0;
	rep(i, n) {
		cin >> v[i];
		f = f + v[i];
	}

	if (k > 2 * n)k = 2 * n;


	a =max( k / 2,n+1);
	m = 0;
	rep(i, a) {
		l = k - i + 1;
	//	if (l> n)l = n;
		rep(m, l) {
			h = 0;
			
			if (k - i >= n) {
				rep(j, n)  w[j] = v[j]; 
				h = f;
				
				sort(w, w + n);

			}
			else {
				rep(j, k - i) {

					if (j < m)
						w[j] = v[j];
					else w[j] = v[n - 1 + m - j];
					h = h + w[j];
				}

				sort(w, w + k - i);


			}

			g = 0;


			while ((g < i&&g<k-i)&& w[g] < 0) {
				h = h - w[g];
				g++;
			}



			if (h > sum)sum = h;

		}

		
	
	
	}


	cout << sum;


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<ll> enum_div(ll n) {
    std::vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    ll A, B;
    cin >> A >> B;
    A--;

    auto func = [](ll n) {
        ll tmp = (n + 1) / 2;
        if (tmp % 2 == 0)
            tmp = 0;
        else
            tmp = 1;
        if (n % 2 == 0) { return tmp xor n; }
        return tmp;
    };

    cout << (func(A) ^ func(B)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=2001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,c,k;cin>>n>>c>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll ans=0,last=-1,sum=0;
    sort(all(v));
    rep(i,n){
        if(sum==c||v[i]>last){
            ans++;
            sum=1;
            last=v[i]+k;
        }
        else sum++;
    }
    out(ans);
}

Measured memory_bytes: 1024
n = int(input())
a = [int(i) for i in input().split()]

color = [0 for i in range(9)]
for i in range(n):
    if a[i] < 3200:
        color[int(a[i] / 400)] = 1
    else:
        color[-1] += 1
# print(color[0:-1])
# print(color)
print("{} {}".format(
    max(sum(color[0:-1]), min(1, color[-1])),
    sum(color[0:-1])+color[-1]))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef long double ld;


int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(false);

    #ifdef DBG
        freopen("in", "r", stdin);
    #endif
    int n;
    cin>>n;
    cout<<24 + 24 - n;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>

int main(int, char**) {
  int a, b, ans;
  std::cin >> a >> b;
  if(a > b) std::swap(a, b);

  if(b - a >= 2) {
    ans = b * 2 - 1;
  } else {
    ans = a + b;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
int n,z,w;
int a[3000];
int main(){
	cin >> n >> z >> w;
	REP(i,n) {
		cin >> a[i];
	}
	if(n == 1) {
		cout << abs(a[0] - w) << endl;
	}else{
		cout << max(abs(a[n - 1] - w),abs(a[n - 2] - a[n - 1])) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long ans = 0;
        long sub = 0;
        sc.close();
        if(n % k == 0){
            System.out.println(0);
            return;
        }
        ans = n % k;
//        System.out.println(ans);
        sub = k - ans;
//        System.out.println(sub);
        if(ans < sub){
            System.out.println(ans);
        }else{
            System.out.println(sub);
        }        
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,acnt=0,bcnt=0;
  cin >> n;
  for(int i=0;i<n;i++)
    {
      string s1, s2;

      cin >> s1 >> s2;
      if(s1 == s2)
	{
	  acnt++;
	  bcnt++;
	}
      if(s1 > s2)
	{
	  acnt += 3;
	}
      if(s1 < s2)
	{
	  bcnt += 3;
	}
 
    }
  cout << acnt <<" " << bcnt << endl;

  return 0;
}


Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();

        System.out.println(solve(N));

        sc.close();
    }

    static int solve(long N) {
        int result = Integer.MAX_VALUE;
        for (int i = 1; (long) i * i <= N; ++i) {
            if (N % i == 0) {
                result = Math.min(result, Math.max(computeDigitNum(i), computeDigitNum(N / i)));
            }
        }

        return result;
    }

    static int computeDigitNum(long x) {
        return String.valueOf(x).length();
    }
}

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

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        final String S = in.readLine();
        int maxlength = 0;
        for (int st = 0; st < S.length(); st++) {
            for (int ed = st + 1; ed < S.length() + 1; ed++) {
                if (isATCG(S.substring(st, ed))) {
                    maxlength = Math.max(maxlength, ed - st);
                }
            }
        }
        System.out.println(maxlength);
    }


    private boolean isATCG(String s) {
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
                continue;
            } else {
                return false;
            }
        }
        return true;
    }


    static class CustomReader extends BufferedReader {

        private static final int DEFAULT_BUF_SIZE = 2048;
        // private static final int DEFAULT_BUF_SIZE = 4096;
        // private static final int DEFAULT_BUF_SIZE = 8192;
        //private static final int DEFAULT_BUF_SIZE = 16384;
        // private static final int DEFAULT_BUF_SIZE = 1048576;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}

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

int main()
{
    //while(1)
    //{
        int cnt=0,i=0,sum;
        string s;
        cin>>s;
        for(int i=0;i<3;i++)
        {
            if(s[i]=='o')
            {
              cnt+=1;
            }

        }
        sum=700+(100*cnt);
        cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var S = ReadText();

            if (N % 2 != 0) return "No";

            var T = S.Substring(0, (int)(N / 2));
            if (T + T == S) return "Yes";

            return "No";
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    char a; cin>>a;
    if ('a' <= a && a <= 'z') cout << 'a' << '\n';
    else cout << 'A' << '\n';
    return 0;
}

Measured memory_bytes: 3548
def calc_m_value(M, A, B, N, h):
    return min([M[h - A[i]]+B[i] if A[i] <= h else B[i] for i in range(N)])

H, N = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

M = [0] * (H+1)
for i in range(1, H+1):
    M[i] = calc_m_value(M, A, B, N, i)

print(M[H])

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll gcd(ll x, ll y) {
    return x ? gcd(y % x, x) : y;
}

ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    vector<ll> a(n);
    ll l = 1;
    for(auto &x : a) {
        cin >> x;
        l=lcm(l,x/2);
    }
    ll ret = 0;
    //cout << l << endl;
    for(auto &x:a){
        if(l%x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m/l+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    deque<char> dq;
    for(char s: S){
        dq.push_back(s);
    }
    bool order = true;
    for(size_t i = 0; i < Q; i++) {
        int q;
        cin >> q;
        if(q == 1) {
            order = !order;
        } else if(q == 2) {
            int f;
            char c;
            cin >> f >> c;
            if(order && f == 1 || !order && f == 2){
                dq.push_front(c);
            }else{
                dq.push_back(c);
            }
        }
    }
    if(!order){
        reverse(dq.begin(), dq.end());
    }
    for(auto x:dq){
        cout << x;
    }
    cout << endl;
}

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

int main()
{
    string  a,b;
    cin>>a>>b;
      a = a+b;
      int n = stoi( a);
      int  m = sqrt( n);
      if( m*m == n )
      {
          cout<<"Yes";
      }
      else cout<<"No";
}

Measured memory_bytes: 3612
import sys


def int1(x): return int(x) - 1
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def mi1(): return map(int1, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def lli(rows_number): return [li() for _ in range(rows_number)]


if __name__ == "__main__":
    x, n = mi()
    if n == 0:
        print(x)
        exit()
    p_l = li()
    a = list(range(0, 1000))
    for p in p_l:
        a.remove(p)
    ans = 0
    min_dif = 10000
    for i in a:
        dif = abs(i-x)
        if dif < min_dif:
            min_dif = dif
            ans = i
    print(ans)


Measured memory_bytes: 9220
import math
while True:
    n = int(input())
    if n == 0:
        break
    L = list(map(float, input().split()))
    m = sum(L) / n
    Sum = 0
    for i in range(n):
        Sum = (L[i]-m)**2 + Sum
    a = math.sqrt(Sum / n)
    print(a)



Measured memory_bytes: 5776
def otoshidama(N: int, Y: int)->int:
    Y //= 1000

    a0 = (Y-N) % 4
    b0 = ((Y-N) - 9 * a0) // 4

    m_min = max(- a0//4,  -(N-b0)//9)
    m_max = min((N-a0)//4, b0//9)+1

    for m in range(m_min, m_max):
        a = a0 + 4*m
        b = b0 - 9*m
        c = N - a - b

        if a < 0 or N < a:
            continue
        if b < 0 or N < b:
            continue
        if c < 0 or N < c:
            continue

        return (a, b, c)

    return (-1, -1, -1)


if __name__ == "__main__":
    N, Y = map(int, input().split())
    x, y, z = otoshidama(N, Y)
    print(x, y, z)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <ctime>

using namespace std;

char a[105], b[105];
int c,d,gay;


int main()
{
	scanf("%s", a);
	scanf("%s", b);
	c = strlen(a);
	d = strlen(b);
	if (c < d)
	{
		printf("LESS");
	}
	else if (c > d)
	{
		printf("GREATER");
	}
	else
	{
		gay = strcmp(a, b);
		if (gay == 0)
		{
			printf("EQUAL");
		}
		else if (gay < 0)
		{
			printf("LESS");
		}
		else
		{
			printf("GREATER");
		}
	}
	//system("pause");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
int d=365, n=26, score;
int c[27];
int s[366][27];
int a[366];
int sat[366]={};
int last[27]={};
ofstream fout("out.txt"), flog("log.txt");
uint64_t get_rand_range( uint64_t min_val, uint64_t max_val ) {

    srand((int)time(NULL));
    static mt19937_64 mt64(rand());

    uniform_int_distribution<uint64_t> get_rand_uni_int( min_val, max_val );

    return get_rand_uni_int(mt64);
}

int calcdiff(int t, int q){
    int p=a[t];
    int lp=0,rp=d+1,lq=0,rq=d+1;
    For(i,1,d+1){
        if(a[i]==p){
            if(i<t) lp=max(lp,i);
            else if(i>t) rp=min(rp,i);
        }
        else if(a[i]==q){
            if(i<t) lq=max(lq,i);
            else if(i>t) rq=min(rq,i);
        }
        if(i==t) a[i]=q;
    }
    int diff=s[t][q]-s[t][p];
    diff -= (t-lp) * (rp-t) * c[p];
    diff += (t-lq) * (rq-t) * c[q];
    return diff;
}

void greedy(){
    For(i,1,d+1){
        int mx = -(1<<30), acc = -1;
        For(con,1,n+1){
            int sati = sat[i-1] + s[i][con];
            last[con] = i;
            For(j,1,n+1){
                if(j != con) sati -= (i-last[j]) * c[j];
            }
            if(mx<sati){
                mx = sati;
                acc = con;
            }
        }
        last[acc] = i;
        sat[i] = mx;
        a[i]=acc;
        flog << sat[i] << endl;
    }    
    score = sat[d];
}

void Main(){
    clock_t start = clock();
    cin >> d;
    For(i,1,n+1) cin >> c[i];
    For(i,1,d+1) For(j,1,n+1) cin >> s[i][j];
    greedy();
    double time = static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0;
    /*while(time < 1950){
        int t = get_rand_range(1,d);
        int q = get_rand_range(1,n);
        int diff = calcdiff(t,q);
        if(diff>0){
            a[t] = q;
            score += diff;
            flog << score << endl;
        }
        time = static_cast<double>(clock() - start) / CLOCKS_PER_SEC * 1000.0;
    }*/
    For(i,1,d+1) cout << a[i] << endl;

}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007LL;

ll ipow(ll base, ll exp)
{
    ll result = 1LL;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

//const long double PI = (acos(-1));
//const long double EPS = 0.0000000001;

int n, m;
vi a;
map<ll, ll> record;

int main(void) {
    ios_base::sync_with_stdio(false); 
    cin.tie(0); 
    cout.tie(0);
    //freopen("in.txt", "r", stdin);
    cin >> n >> m;
    a.resize(n);
    rep(i,0,n) {
        cin >> a[i];
    }
    rep(i,0,m) {
        ll b, c;
        cin >> b >> c;
        if(record.find(c) != record.end()) {
            record[c] += b;
            record[c] = min(record[c], (ll)n);
        } else {
            record[c] = b;
        }
    }

    ll cnt = n;
    auto it = record.rbegin();
    while(cnt > 0 && it != record.rend()) {
        ll b = it->S;
        ll c = it->F;
        //cout << b << " : " << c << endl;
        for(int i=0; i<b; ++i) {
            a.pb(c);
        }
        cnt -= b;
        it++;
    }

    sort(all(a));

    ll total = 0;
    per(i,sz(a)-n,sz(a)) {
        total += (ll)a[i];
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 8056
#include <iostream>
#include <vector>
#include <map>

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    map<int,int> mp;
    int ans = 0;
    for (int i=0; i<n; i++) {
        if (mp[a[i]] == i+1) {
            ans++;
        }
        mp[i+1] = a[i];
    }


    cout << ans << endl;
}


Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int k,n;
int a[200010];

void solve(){
    cin >> k >> n;
    rep(i,n){
        cin >> a[i];
    }
    int ans=k-(a[0]+(k-a[n-1]));
    rep(i,n-1){
        ans=min(ans,k-(a[i+1]-a[i]));
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

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


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


// テーブルを作る前処理
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;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
        prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


int main() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<ll> p(A+1, 0), q(B+1, 0), r(C+1, 0);
    for(ll i = 0; i < A; i++) cin >> p[i];
    for(ll i = 0; i < B; i++) cin >> q[i];
    for(ll i = 0; i < C; i++) cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    r.insert(r.end(), p.begin(), p.begin() + X);
    r.insert(r.end(), q.begin(), q.begin() + Y);
    sort(r.begin(), r.end(), greater<ll>());

    ll sum = 0;
    for(ll i = 0; i < X + Y; i++) sum += r[i];
    cout << sum << endl;

    return 0;    
}



Measured memory_bytes: 5872
n = int(input())
lines = list(input())
b_lines= [0 for i in range(len(lines)+1)]
w_lines=[0 for i in range(len(lines)+1)]

for i in range(len(lines)):
    if lines[i] == '#':
        b_lines[i+1]=b_lines[i]+1
    else:
        b_lines[i+1]=b_lines[i]

for i in reversed(range(len(lines))):
    if lines[i] == '.':
        w_lines[i]=w_lines[i+1]+1
    else:
        w_lines[i]=w_lines[i+1]

ans = list()
for i in range(n+1):
    ans.append(b_lines[i]+w_lines[i])
print(min(ans))

Measured memory_bytes: 22308
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


void solve() {
	int n, m; cin >> n >> m; if (n == 0 and m == 0) exit(0);
	vector<bitset<500>> vs(n); for (int i = 0; i < n; i++) cin >> vs[i];
	int res = 0;
	if (n < m) {
		for (int S = 0; S < (1 << n); S++) {
			int cnt = 0;
			bitset<500> f;
			for (int i = 0; i < n; i++) {
				if (S >> i & 1) {
					cnt++;
					f ^= vs[i];
				}
			}
			if (f.count() == 0) chmax(res, cnt);
		}
	}
	else {
		vector<vector<int>> dp(2, vector<int>(1 << m, -1));
		int cur = 0;
		int nxt = 1;
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			int S = vs[i].to_ulong();
			for (int i = 0; i < (1 << m); i++) dp[nxt][i] = -1;
			for (int T = 0; T < (1 << m); T++) {
				if (dp[cur][T] == -1) continue;
				chmax(dp[nxt][T], dp[cur][T]);
				chmax(dp[nxt][T ^ S], dp[cur][T] + 1);
			}
			swap(cur, nxt);
		}
		chmax(res, dp[cur][0]);
	}
	cout << res << "\n";
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		solve();
	}

}


Measured memory_bytes: 60308
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    int ans=1;
    for(int i=0;i<a+b+1;i++){
        if(i==a){
            if(s[i]=='-') continue;
            else{
                ans=0;
                break;
            }
        }
        int k=s[i]-'0';
        if(k<0 || k>9){
            ans=0;
            break;
        }
    }
    if(ans)
        cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  int n;cin>>n;
  vector<int> s(n,0);
  ll pre;cin>>pre;
  for(int i=1;i<n;i++){
    ll h;cin>>h;
    if(pre>=h)s[i]=s[i-1]+1;
    else s[i]=0;
    pre=h;
  }
  int mx=0;
rep(i,n){
  //cout<<s[i]<<endl;
  mx= max(mx,s[i]);
}
cout<<mx<<endl;
  return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;


int main() {
    int n;
    cin >> n;
    vector<int> dp(n+1);
    vector<int> h(n+1);

    for (int i = 1; i <= n; ++i) {
        cin >> h[i];
    }

    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= n; ++i) {
        dp[i] = min(abs(h[i-1] - h[i]) + dp[i-1], abs(h[i-2] - h[i]) + dp[i-2]);
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mkp make_pair
#define mod 1000000007
#define F first
#define S second
#define ld long double
#define f(i,l,f,n) for(i=(l); i<(n) && !(f); i++)
#define endl "\n"

int countt[100000+1], arr[100000+1];

int jump(int pos, int k)
{
    if(pos<=0)
    return 0;
    else if(countt[pos]!=-1)
    return countt[pos];
    else
    {
        for(int i=1; i<=k; i++)
        {
            if(pos-i>=0)
            {
                if(countt[pos]==-1)
                countt[pos] = jump(pos-i, k)+abs(arr[pos]-arr[pos-i]);
                else
                countt[pos]=min(countt[pos], jump(pos-i, k)+abs(arr[pos]-arr[pos-i]));
            }
            else break;
        }
    }
    return countt[pos];
}

void solve()
{
    int i, j, k, n;
    cin>>n>>k;
    f(i,0,0,n)
    cin>>arr[i];
    memset(countt, -1, sizeof(countt));
    cout<<jump(n-1, k);
    // cout<<endl;
    // f(i,0,0,n)
    // cout<<countt[i]<<" ";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t=1, i=0;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<i++<<": "<<solve()<<endl;
        solve();
    }
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(),v.end());
  if(n%3!=0) {
    if(v[n-1]==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  int x=n/3;
  if(v[0]==v[x-1]&&v[x]==v[2*x-1]&&v[2*x]==v[n-1]){
    int a=v[0];
    int b=v[x];
    int c=v[2*x];
    int d=a^b;
    if(d==c) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 4032
from collections import Counter

N, K = map(int, input().split())

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

c = Counter(A)
kind = len(c.values())

if kind <= K:
    print(0)

else:
    dropnum = 0
    drop = kind - K
    lst = list(c.values())
    lst.sort(reverse = True)
    for _ in range(drop):
        dropnum += lst.pop()
    print(dropnum)
    

Measured memory_bytes: 32556
#include<bits/stdc++.h>
using namespace std;
inline long long read(){
	long long x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 200005
long long n,a[MN];
long long ans;
int main(){
	n=read();bool ok=0;
	a[1]=read();if(a[1]>0) ok=1;
	register int i,j;
	for(i=2;i<=n;i++){
		a[i]=read();
		if(a[i]-a[i-1]>1) ok=1;
	}
	if(ok){
		puts("-1");
		return 0;
	}
	i=j=2;
	while(i<=n){
		for(;a[j+1]==a[j]+1;j++);
		ans+=a[j];i=j+1;j++;
	}
	printf("%lld\n",ans);
	return 0;
}


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


ll ans=0;

void heikou(ll m, ll M){
  if(M%m==0){
    ans+=(M/m*2-1)*m;
    return;
  }else{
    ans+=(M/m*2)*m;
    heikou(min(m,M-M/m*m),max(m,M-M/m*m));
  }
}

int main(){
  ll N,X;
  cin >> N >> X;
  ans+=N;
  heikou(min(X,N-X),max(X,N-X));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int N, A[100], j, key;
    
    scanf("%d", &N);
    for(int i = 0; i < N; i++)
        scanf("%d", &A[i]);
    for(int i = 0; i < N; i++)
    {
        key = A[i];
        j = i-1;
        while(j >= 0 && A[j] > key)
        {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = key;
        for(j = 0; j < N-1; j++) printf("%d ", A[j]);
        printf("%d\n", A[N-1]);
    }
    return 0;
}



Measured memory_bytes: 2732
N=int(input())
lineup=[7,17,37,47,107,127,137,157,167,197,227,257,277,307,317,337,347,367,397,467,487,557,577,587,607,617,677,727,757,797,827,857,877,887,907,947,967,977,997,1087,1097,1117,1187,1217,1237,1277,1297,1307,1327,1367,1427,1447,1487,1567,1597,1607]
print(*lineup[:N])
	

Measured memory_bytes: 61852
from collections import deque

if __name__ == "__main__":
	n = int(input())
	d = deque()
	for i in range(n):
		command = input()
		if command == 'deleteFirst':
			d.popleft()
		elif command == 'deleteLast':
			d.pop()
		else:
			cmd, key = command.split()
			if cmd == 'insert':
				d.appendleft(key)
			elif cmd == 'delete':
				try:
					d.remove(key)
				except:
					pass
	print(' '.join(d))


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;
    cout << n * n * n << endl;

    return 0;
}

Measured memory_bytes: 256
//2006情報オリンピック問3「シーザー暗号」
#include<stdio.h>

int main(void)
{

	char str[1001];
	int s = 0;

	scanf("%s",str);
	while(str[s] != '\0'){
		str[s] = str[s] <= 'C' ? 'Z' - ('C' - str[s]) : str[s] - 3;
		s++;
	}

	printf("%s\n",str);

	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES 1
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007ll
#define INF 1000000000000000000ll
#define EPS 1e-9
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll A, B, C;
string S;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> A >> S;
	B = S[0] - '0';
	C = 10 * (S[2] - '0') + (S[3] - '0');
	
	cout << A * B + A * C / 100;
	
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	static int[] sq={1,4,9,16,25,36,49,64,81,100,121,144,169,14*14,15*15,16*16,17*17};
	static boolean[][] dp;
	static int n,ans;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			n = cin.nextInt();
			if(n==0)break;
			ans=0;
			dp=new boolean[301][sq.length];
			for(int i = 0;i<301;i++){
				for(int j = 0;j<sq.length;j++){
					dp[i][j]=false;
				}
			}
			dp[0][0]=dfs(0,0);
			System.out.println(ans);
		}

	}
	static boolean dfs(int sum,int depth){
		if(depth==sq.length)return false;
		if(dp[sum][depth]){ans++;return true;}
		if(sum==n){
			dp[sum][depth]=true;
			ans++;return true;
		}
		
		for(;sum<=n;){
			dp[sum][depth]=dfs(sum,depth+1);
			sum+=sq[depth];
		}
		return false;
	}
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;

ll mod = 998244353;

ll powmod(ll b){
    ll r = 1;
    ll c = mod-2;
    for (; c>0; c>>=1, b=b*b%mod){
        if (c&1)    r = r*b%mod;
    }
    return r;
}
 
ll powdiv(ll a, ll b){
    return a * powmod(b) % mod;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, a, b, k;
    cin >> n >> a >> b >> k;

    vector<ll> combmemo(n+5, 1);

    ll res = 1;
    rep(i, n+1){
        res *= powdiv(n-i, i+1);
        res %= mod;
        combmemo[i+1] = res;
    }

    ll cnt = 0;
    rep(ax, n+1){
        ll rem = k - a*ax;
        if(rem < 0)    break;
        if(rem%b != 0) continue;
        
        ll bx = rem/b;
        if(n < bx) continue;
        if(a*ax + b*bx != k) continue;
        ll l = combmemo[ax];
        ll r = combmemo[bx];
        cnt += ((l%mod) * (r%mod)) % mod;
        cnt %= mod;
    }
    

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
using namespace std;

int n, a[110000];
long long ans;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	int mi = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] > mi + 1) {
			ans += (a[i] - 1) / (mi + 1);
			mi = max(mi, 1);
		}else {
			mi = max(mi, a[i]);
		}
	}
	// printf("%d\n", mi);
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
using Graph = vector<vector<ll> >;
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; }
const ll INF = 1e18;

//input
ll t;
ll n,a,b,c,d;

map<ll,ll>mp;

ll rec(ll x){
    if(x==0){
        mp[0]=0;
        return 0;
    }
    if(x==1){
        mp[1]=d;
        return d;
    }
    if(mp[x]>0)return mp[x];
    ll res = INF;
    if(x%2==0){
        chmin(res,rec(x/2)+a);
    }
    else{
        chmin(res,rec((x+1)/2)+a+d);
        chmin(res,rec((x-1)/2)+a+d);
    }
    if(x%3==0){
        chmin(res,rec(x/3)+b);
    }
    else{
        ll u = (x+3)/3;
        chmin(res,rec(u)+b+(u*3-x)*d);
        ll l = x/3;
        chmin(res,rec(l)+b+(x-l*3)*d);
    }
    if(x%5==0){
        chmin(res,rec(x/5)+c);
    }
    else{
        ll u = (x+4)/5;
        chmin(res,rec(u)+c+(u*5-x)*d);
        ll l = x/5;
        chmin(res,rec(l)+c+(x-l*5)*d);
    }
    if(x<=1e18/d)chmin(res,x*d);
    mp[x]=res;
    return res;
}

int main(){
    cin >> t;
    rep(test,t){
        mp.clear();
        cin >> n >> a >> b >> c >> d;
        cout << rec(n) << endl;
        /*
        for(auto it=mp.begin();it!=mp.end();it++){
            cout << it->first << ':' << it->second << endl;
        }
        */
    }
    
    return 0;
}


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

using namespace std;

int main()
{
  static char s[100010];
  scanf("%s",s);
  int i=0;
  int F=0;
  while(s[i]!=0){
    if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'){
      i+=5;
      F=1;
    }
    else if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'){
      i+=5;
      F=2;
    }
    else{
      if(F==1&&s[i]=='e'&&s[i+1]=='r'){
	i+=2;
      }
      else if(F==2&&s[i]=='r'){
	i++;
      }
      else{
	break;
      }
      F=0;
    }
  }
  puts(s[i]?"NO":"YES");
  return 0;
}


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

int main()
{
	std::vector<long long> n(5);
	long long k,ans; std::cin >> k;
	for (int i = 0;i < 5;i++) { std::cin >> n[i]; }

	ans = (k-1) / *(std::min_element(n.begin(), n.end())) + 5;

	std::cout << ans << std::endl;

	return 0;
}

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

int main()
{
	int n;
	cin >> n;

	int person[10][3][4] = { 0 };
	int i;
	int b, f, r, v;
	for (i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		person[r - 1][f - 1][b - 1] = person[r - 1][f - 1][b - 1] + v;
	}
	int j, k;
	for (k = 0; k < 4; k++) {
		for (j = 0; j < 3; j++) {
			for (i = 0; i < 10; i++) {
				cout << " " << person[i][j][k];
			}
			cout << endl;
		}
		if(k!=3) cout << "####################\n";
	}

	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll N, K;
  cin >> N >> K;

  ll ans = 0;
  while (N > 0)
  {
    N /= K;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())

memo = 0

if n == 1 or n ==2:
    print(n)
    exit()


for i in range(1,n):
    memo += i
    if n <= memo:
        check = i
        break

ans = []

for i in range(check,0,-1):
    n -= i
    #print(i,n)
    ans.append(i)
    if n < i:
        ans.append(n)
        break
ans.sort()

for i in ans:
    print(i)

Measured memory_bytes: 41584
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S;
  cin>>S;
  int Q;
  cin>>Q;
  string v1,v2;
  bool flipped=false;
  REP(q,Q){
    int T;
    cin>>T;
    if(T==1){
      flipped = !flipped;
    }else{
      int F;
      char C;
      cin>>F>>C;
      if((F==1 and !flipped) or (F==2 and flipped)){
        v1.push_back(C);
      }else{
        v2.push_back(C);
      }
    }
  }
  reverse(ALL(v1));
  string ans =v1+S+v2;
  if(flipped)reverse(ALL(ans));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1348
#include <iostream>
#include <cmath>
using namespace std;
double EPS=1e-10;
double add(double a, double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b)) ) return 0;
	else return a+b;
}
int main()
{
	int n ; cin >> n ;
	while(n--)
	{
		double x[2],y[2],r[2];
		for(int i=0;i<2;i++) cin >> x[i] >> y[i] >> r[i] ;
		double dist=sqrt( add( (x[1]-x[0])*(x[1]-x[0]),(y[1]-y[0])*(y[1]-y[0]) ) );
		int ans=0;
		if(dist<add(r[0],-r[1])) ans=2; //dist<r[0]-r[1]
		else if(dist<add(r[1],-r[0])) ans=-2; //dist<r[1]-r[0]
		else if(add(dist,-add(r[0],r[1])) <=0 ) ans=1; //dist<=r[0]+r[1]
		cout << ans << '\n' ;
	}
}

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

using namespace std;

const int N = 1e5 + 90;

long long n, x, y, ans;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> x >> y;
	for (int i = 0; i < N; i++) {
		if (((i * 8) / 100) == x && i / 10 == y) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}


Measured memory_bytes: 256