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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = 998244353;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 300 + 7;

int n, k;
string s;

bool read () {
	static char buf[N];
	if (scanf("%s%d", buf, &k) != 2)
		return false;
	s = buf;
	n = sz(s);
	return true;
}

int fact[N];
int rfact[N];

int add(int a, int b){
	a += b;
	if (a >= MOD)
		a -= MOD;
	if (a < 0)
		a += MOD;
	return a;
}

int mul(int a, int b){
	return a * li(b) % MOD;
}

int binpow(int a, int b){
	int res = 1;
	while (b){
		if (b & 1)
			res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int cnk(int n, int k){
	if (k == -1 && n == -1) return 1;
	if (k < 0 || k > n) return 0;
	return mul(fact[n], mul(rfact[k], rfact[n - k]));
}

void solve() {
	fact[0] = 1;
	fore(i, 1, N) fact[i] = mul(fact[i - 1], i);
	rfact[N - 1] = binpow(fact[N - 1], MOD - 2);
	for (int i = N - 2; i >= 0; --i)
		rfact[i] = mul(rfact[i + 1], i + 1);
	
	int nk = 0, cur = 0;
	forn(i, n){
		if (s[i] == '0')
			++cur;
		else
			nk += cur;
	}
	k = min(k, nk);
	k = min(k, n);
	
	vector<int> a;
	cur = 0;
	forn(i, n){
		if (s[i] == '0'){
			a.pb(cur);
			cur = 0;
		}
		else
			++cur;
	}
	a.pb(cur);
	
	reverse(all(a));
	vector<vector<vector<int>>> dp(sz(a) + 1, vector<vector<int>>(n + 1, vector<int>(k + 1, 0)));
	dp[0][0][0] = 1;
	int pr = 0;
	forn(i, sz(a)){
		forn(j, pr + 1) forn(l, k + 1) if (dp[i][j][l]){
			fore(t, 1, min(a[i], k - l) + 1)
				dp[i + 1][j + t][l + t] = add(dp[i + 1][j + t][l + t], dp[i][j][l]);
			forn(t, j + 1)
				dp[i + 1][j - t][l] = add(dp[i + 1][j - t][l], dp[i][j][l]);
		}
		pr += a[i];
	}
	
	int ans = 0;
	forn(t, k + 1)
		ans = add(ans, dp[sz(a)][0][t]);
	printf("%d\n", ans);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 58944
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	// abc114 D

	// primes under 100.
	private 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};

	public class PrimeFactorizater {
		
		public PrimeFactorizater(int max) {
		}
		
		public int[] getPrimeCount(int num) {
			int[] counts = new int[primes.length];
			Arrays.fill(counts, 0);

			for (int i=0; i<primes.length; i++) {
				int prime = primes[i];
				while (true) {
					if (num % prime == 0) {
						counts[i]++;
						num = num / prime;
					} else {
						break;
					}
				}
			}
			
			return counts;
		}
	}
	
	public void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		in.close();

		PrimeFactorizater pf = new PrimeFactorizater(N);
		int[] primesCount = new int[primes.length];
		Arrays.fill(primesCount, 0);
		
		for (int i=1; i<=N; i++) {
			int[] pfRet = pf.getPrimeCount(i);
			for(int j=0; j<pfRet.length; j++) {
				primesCount[j] += pfRet[j];
			}
		}
		
		int[] useCount = new int[primesCount.length];
		Arrays.fill(useCount, 0);
		long result = count(primesCount, useCount, 0);
		
		System.out.println(result);
	}
	
	private long count(int[] primesCount, int[] useCount, int pos) {
		long ret = 0;
		long pattern = getPattern(useCount);
		
		if (pattern == 75) {
			return 1;
		} else if (pattern > 75) {
			return 0;
		}
		if (pos >= primesCount.length) {
			return 0;
		}
		
		for (int i=0; i<=primesCount[pos]; i++) {
			useCount[pos] = i;
			ret += count(primesCount, useCount, pos+1);
		}	
		useCount[pos] = 0;

		return ret;
	}
	
	private long getPattern(int[] useCount) {
		long pattern = 1;	// count unused all elements instead of factor 1.
		for (int i=0; i<useCount.length; i++) {
			pattern *= useCount[i] + 1;
			if (pattern > 75) {
				return pattern;
			}
		}
		return pattern;
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
}


Measured memory_bytes: 23992
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;


int main()
{
  int N,K;
  cin >> N >> K;
  double initial = 1./(double)N;
  vector< vector<double> >p(2, vector<double>(K+1));

  for(int i=1;i<min(N+1,K+1);i++)
    p[0][i] = initial;

  if(K<N)
    p[0][K] = initial*(N-K+1);

  int source = 0;
  int cnt = 0;
  while(true)
    {
      cnt ++;
      /*
      for(int i=0;i<K+1;i++)
	{
	  cout << i << ":" << p[source][i] << ",";
	}
      cout << endl;
      */
      int next = (source+1)%2;
      for(int i=1;i<K+1;i++)
	p[next][i] = 0;

      p[next][0] += p[source][0];
      p[next][K] += p[source][K];
      
      for(int i=1;i<K;i++)
	{
	  p[next][0] += p[source][i]*0.5;
	  p[next][min(K, 2*i)] += p[source][i]*0.5;
	}


      source = next;      
      double remain = 0;
      for(int i=1;i<K;i++)
      	remain += p[next][i];
      if(remain<1e-12)
	break;
    }
  cout << setprecision(16);
  cout << p[source][K] << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll n;
ll arr[1000005];


int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    
    ll a,b,c;
    cin>>a>>b>>c;

    ll k;
    cin>>k;

    ll ans = min(k,a);
    
    k-=min(k,a);

    if(k>0)
    {
        k-=min(k,b);
        if(k>0)
        {
            ans -= min(k,c);
            k-=min(k,c);
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int counter1 = 0;
	int counter2 = 0;
	int tmp = 15 - s.size();
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'o') counter1++;
		else counter2++;
	}
	if (tmp + counter1 >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

typedef long long ll;

string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    int n = s.length();
    int ans = 1e9;
    for (int i = 0; i < n - 2; ++i) {
        ans = min(ans, abs(753 - (s[i] - '0') * 100 - (s[i + 1] - '0') * 10 - (s[i + 2] - '0')));
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3656
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// namespace
using namespace std;
// type
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
// input
#define INIT              ({ ios::sync_with_stdio(false); cin.tie(0); })
#define VAR(type, ...)    type __VA_ARGS__; var_scan(__VA_ARGS__);
template<typename T>
static void var_scan(T& t)
{
    cin >> t;
}
template<typename T, typename... R>
static void var_scan(T& t, R&... rest)
{
    cin >> t;
    var_scan(rest...);
}
// output
#define OUT(var)          cout << (var)
#define SPC               cout << ' '
#define TAB               cout << '\t'
#define BR                cout << '\n'
#define ENDL              cout << endl
#define FLUSH             cout << flush
// debug
#ifdef DEBUG
#define EPRINTF(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#define DUMP(var)         cerr << #var << '\t' << (var) << '\n'
#define DUMPITERABLE(i) do {                            \
        cerr << #i << '\t';                             \
        for (const auto& it : i) { cerr << it << ' '; } \
        cerr << '\n';                                   \
} while (0)
#define DUMPITERABLE2(i2) do {                          \
        cerr << #i2 << '\t';                            \
        for (const auto& it : i2) {                     \
            for (const auto& it2: it) {                 \
                cerr << it2 << ' ';                     \
            }                                           \
        }                                               \
        cerr << '\n';                                   \
} while (0)
#else
#define EPRINTF(fmt, ...)
#define DUMP(var)
#define DUMPITERABLE(i)
#define DUMPITERABLE2(i)
#endif
// util
// [l, r)
#define REP(i, n)       for (int i = 0; i < (n); i++)
#define RREP(i, n)      for (int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r)    for (int i = (l); i < (r); i++)
#define RFOR(i, r, l)   for (int i = (r)-1; i >= (l); i--)
#define REPLL(i, n)     for (ll i = 0; i < (n); i++)
#define RREPLL(i, n)    for (ll i = (n)-1; i >= 0; i--)
#define FORLL(i, l, r)  for (ll i = (l); i < (r); i++)
#define RFORLL(i, r, l) for (ll i = (r)-1; i >= (l); i--)

static constexpr int modulo = 1000000007;

static ll powmod(ll x, ll y)
{
    ll r = x;
    REP(i, y-1){
        r = r*x%modulo; // 10^9+7 - 2^31 > 0
    }
    return r;
}

int main(void)
{
    INIT;
    VAR(ll , n);
    ll r = powmod(10,n)-2*powmod(9,n)%modulo+powmod(8,n);
    OUT((r+modulo)%modulo);
    ENDL;
    return 0;
}


Measured memory_bytes: 3656
//
//  main.c
//  You Are the Judge
//
//  Created by x15071xx on 2016/06/15.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>
#include <string.h>

void swap (int array[50][4],int j,int soezi){
    int tmp;
    
    tmp=array[j][soezi];
    array[j][soezi] = array[j-1][soezi];
    array[j-1][soezi] = tmp;
    
}

int main(int argc, const char * argv[]) {
    
    int i,j,k,l;
    while (1) {
        int team[50][4] = {0};//0.??????????????? 1.???????????????????????£???2,??£?????° 3,??????
        int team_wrong[50][10] = {0};
        int t,p,r;
        int tid,pid,time;
        char message[8]={0};
        scanf("%d %d %d",&t,&p,&r);
        if (t==0&&p==0&&r==0) {
            break;
        }
        for (i=0; i<t; i++) {
            team[i][0] = i+1;
        }
        
        for (i=0; i<r; i++) {
            
            scanf("%d %d %d",&tid,&pid,&time);
            scanf("%s",message);
            
            if (strcmp(message, "CORRECT") == 0) {
                //o
                team[tid-1][2]++;
                
                team[tid-1][1] += (team_wrong[tid-1][pid-1] * 1200) + time;
            } else {
                //x
                team_wrong[tid-1][pid-1]++;
            }
        }
        
        //????????????
        
        //????????°?????????????????£?????°?????????
        for (i=0; i<t-1; i++) {
            for (j=t-1; j>i; j--) {
                if (team[j][2] > team[j-1][2]) {
                    swap(team,j,2);
                    swap(team,j,0);
                    swap(team,j,1);
                    swap(team,j,3);
                }
            }
        }
        
        //????????°??§???????????????
        for (i=0; i<t; i++) {
            if (team[i][2] != team[i+1][2]) {
                for (j=i+1; j<t; j++) {
                team[j][3]++;
                }
            }
        }
        
        //????????§?????????
        for (i=0; i<t-1; i++) {
            j=0;
            while (team[i+j][3] == team[i+j+1][3]) {
                j++;
            }
            
            for (k=0; k<i+j; k++) {
                for (l=i+j; l>k; l--) {
                    if ((team[l][1] < team[l-1][1]) && (team[l][3] == team[l-1][3])) {
                        swap(team,l,2);
                        swap(team,l,0);
                        swap(team,l,1);
                        swap(team,l,3);
                    }
                }
            }
        }
        
        for (i=0; i<t; i++) {
            printf("%d %d %d\n",team[i][0],team[i][2],team[i][1]);
        }
    }
    return 0;
}

Measured memory_bytes: 608
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = parseInt(arg[0].split(" ")[1]);
    const B = parseInt(arg[0].split(" ")[2]);
    
    const train = N * A;
    const bus  = B;
    
    console.log(Math.min(train, bus));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

vector<vector<int>> vv;
vector<int> v;
map<int, int> mp;

void dfs(int root, int add){
    v[root] += add;
    if(vv[root].empty()) return;
    for(auto itr = vv[root].begin(); itr != vv[root].end(); ++itr){
        dfs(*itr, add + mp[*itr]);
    }
    return;
}

int main()
{
    int N,Q;
    cin >> N >> Q;
    vv.resize(N+1);
    v.resize(N+1);
    for(int i = 0; i < N-1; ++i){
        int a,b;
        cin >> a >> b;
        vv[a].push_back(b);
    }
    for(int i = 0; i < Q; ++i){
        int p,x;
        cin >> p >> x;
        mp[p] += x;
    }

    dfs(1, mp[1]);

    for(int i = 1; i <= N; ++i) {
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 35968
while 1:
    f = []; s = [];
    m = input()
    if m==0: break
    for i in xrange(m):
        f.append(map(int, raw_input().split()))
    n = input()
    for i in xrange(n):
        s.append(map(int, raw_input().split()))
    for i in range(n):
        x0 = s[i][0] - f[0][0]
        y0 = s[i][1] - f[0][1]
        flg = True
        for j in range(m):
            ff = [f[j][0]+x0, f[j][1]+y0]
            if not (ff in s):
                 flg = False; break;
        if flg:
            print "%d %d"%(x0, y0)
            break;

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

/*
レート 1-399：灰色
レート 400-799：茶色
レート 800-1199：緑色
レート 1200-1599：水色
レート 1600-1999：青色
レート 2000-2399：黄色
レート 2400-2799：橙色
レート 2800-3199：赤色
*/

int main(){
    int colors[] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 5000};
    int C = 8;

    vector<int> count(C+1, 0);
    
    int N;
    cin >> N;

    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        for(int j=0;j<C+1;j++){
            if(a < colors[j]){
                count[j]++;
                break;
            }
        }
    }

    int ans = 0;
    for(int j=0;j<C;j++){
        if(count[j] > 0){
            ans++;
        }
    }
    cout << max(1, ans) << " " << ans+count[C] << endl;

    return 0;
}

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

int ans;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  
  
  for(int i = d.at(n/2-1)+1; i <= d.at(n/2); i++){
    ans++;
  }
    
  cout << ans << endl;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    ll N, A, B;
    cin >> N >> A >> B;

    ll pair = N / (A + B);
    ll amari = N % (A + B);

    if(amari > A){
        cout << (pair + 1) * A << "\n";
    }
    else{
        cout << pair * A + amari << "\n";
    }

return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;
import java.util.regex.Pattern;






public class Main {

	
	 
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static int N = (int) 1e5;
	public static void main(String[] args) {
		 FastReader sc = new FastReader();
		 int n = sc.nextInt();
		 int ans = 0;
			for(int i=1;i<=n;++i) {
				int digits = (int) (Math.log10(i)+1);
				if(digits%2 != 0) ++ans;
			}
			out.print(ans);
			
			 out.close();
		}
		
	 
		
	}

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

int main() {
	string ss;
    cin >> ss;
    int len = ss.length();
    int p = len/2;
    int g = len-len/2;
    int score = 0;
    for (int i=0; i<p; i++){
    	if (ss[i]=='g'){
    		score ++;
    	}
    }
    for (int i=p; i<len; i++){
    	if (ss[i]=='p'){
    		score --;
    	}
    }
    cout << score << endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  for (int i = 0; i < x; i++) scanf("%lld\n", &a[i]);
  for (int i = 0; i < y; i++) scanf("%lld\n", &b[i]);
  for (int i = 0; i < z; i++) scanf("%lld\n", &c[i]);
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  sort(c.rbegin(), c.rend());

  priority_queue<ll> ab;
  for (int i = 0; i < x; i++)
    for (int j = 0; j < y; j++)
      ab.push(a[i] + b[j]);

  priority_queue<ll> abc;
  for (int i = 0; i < k && ab.size(); i++) {
    ll res = ab.top();
    ab.pop();
    for (int j = 0; j < z; j++) abc.push(res + c[j]);
  }

  for (int i = 0; i < k; i++) {
    ll res = abc.top();
    abc.pop();
    printf("%lld\n", res);
  }
}


Measured memory_bytes: 43368
n,m =$stdin.gets.split.map(&:to_i)
ary = []
cnt = 0
result = 0
n.times do |i|
  ary.push($stdin.gets.split.map(&:to_i))
end
ary.sort!
n.times do |i|
  if cnt + ary[i][1]<=m
    cnt += ary[i][1]
    result += ary[i][0] * ary[i][1]
  else
    result += ary[i][0] * (m - cnt)
    break
  end
end
puts result


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

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> keyPrices(1010, -1);
    vector<int> keyTresuresInfo(1010, 0);
    for(int i = 0; i < M; i++){
        cin >> keyPrices.at(i);
        int b1 = 0;
        cin >> b1;
        for(int j = 0; j < b1; j++){
            int c = 0;
            cin >> c;
            keyTresuresInfo.at(i) += 1 << (c - 1); 
        }
    }
    int INF = 1e9;
    vector<int> dp(1 << N, INF);
    dp.at(0) = 0;
    for(int i = 0; i < M; i++){
        int info = keyTresuresInfo.at(i);
        for (int j = 0; j < (1 << N); j++){
            int jOrInfo = j | info;
            if (dp.at(jOrInfo) > dp.at(j) + keyPrices.at(i)) {
                dp.at(jOrInfo) = dp.at(j) + keyPrices.at(i);
            }
        }
    }
    int all = (1 << N) - 1;
    if(dp.at(all) == INF){
        dp.at(all) = -1;
    }
    cout << dp.at(all) << endl;
    return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

int main() {
  i64 N;
  cin >> N;
  vector<i64> d(N);
  rep(i,0,N) cin >> d[i];
  
  nth_element(begin(d), begin(d) + N / 2 - 1, end(d));
  i64 a = *(begin(d) + N / 2 - 1);
  nth_element(begin(d), begin(d) + N / 2, end(d));
  i64 b = *(begin(d) + N / 2);
  cout << b - a << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string a,b={0};
    cin>>a>>b;
    for(int i=0;i<a.size();i++){
        if(a[i]==b[i]);
        else
            goto End;
    }
    if(a.size()==(b).size()-1)
        cout<<"Yes";
    else
        End:cout<<"No";
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
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(){
    ll N,T;
    cin>>N>>T;
    vector<ll> t(N+1);
    rep(i,N) cin>>t.at(i);
    t.at(N)=1e18;
    ll ans=0;
    rep(i,N){
        if(t.at(i+1)-t.at(i)<T){
            ans+=t.at(i+1)-t.at(i);
        }else{
            ans+=T;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  string t;
  cin>>s>>t;

  if(t.erase(s.size(),1)==s){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  
return 0;
}


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

int main() {
    int n;
    while (cin>>n) {
        int f=0;
        for (int i=0;i<10;i++)
            if (n&1<<i) {
                if (f)
                    cout<<' ';
                cout<<(1<<i);
                f=1;
            }
        cout<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll ts = 1;
    ll as = 1;
    for(int i=0; i<n; i++) {
        ll t, a;
        cin >> t >> a;
        ll factor = max((ts+t-1)/t, (as+a-1)/a);
        ts = factor * t;
        as = factor * a;
    }
    cout << ts + as << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  string s,t,u;
  cin >> s >> t >> u;
  if(s[s.size()-1] == t[0] && t[t.size()-1] == u[0] )cout << "YES" << endl;
  else cout << "NO" << endl;




  

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#define pb push_back
#define mp make_pair
#define eps 1e-8
#define INF 1000000000
#define mod 1000000007
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int uii;
typedef pair<int,int> pii;
typedef pair<int, pair<int, int> >piii;
typedef unsigned long long uLL; 
typedef vector<int> vii; 
//__int128
const int maxn = 2e5;
int s[maxn];
std::vector<LL> d[maxn];

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 argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	int n;
	// ios::sync_with_stdio(false);
	// cin.tie(0);
	cin >> n;
	for(int i = 1; i < n; ++i){
		d[i].pb(0);
	}
	for(int i = 0; i < n; ++i){
		cin >> s[i];
	}
	for(LL c = 1; c < n; ++c){
		for(LL k = 1; n - 1 - k * c > c; ++k){
			d[c].pb(d[c][k - 1] + s[k * c] + s[n - 1 - k * c]);
		}
	}
	// cout << d[1][1] << endl;
	LL res = 0;
	for(LL c = 1; c < n; ++c){
		for(LL k = 0; k < (int)d[c].size(); ++k){
			LL a = n - 1 - k * c;
			// LL x = lcm(a, c);
			// if(x + a - c < n - 1) continue;
			if(a%c == 0 && a/c <= k) continue;
			// res = max(res, d[c][k]);
			if(res < d[c][k]){
				res = d[c][k];
				// printf("%d %d %d\n", c, k, d[c][k]);
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

int main() {
	string str;
	cin >> str;
	int cnt = 0;
	if (str[0] == '1') cnt++;
	if (str[1] == '1') cnt++;
	if (str[2] == '1') cnt++;
	cout << cnt << endl;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
class nCr():
    def __init__(self, n):
        self.n = n
        self.fa = [1] * (self.n + 1)
        self.fi = [1] * (self.n + 1)
        for i in range(1, self.n + 1):
            self.fa[i] = self.fa[i - 1] * i % mod
            self.fi[i] = pow(self.fa[i], mod - 2, mod)
    def comb(self, n, r):
        if n < r:return 0
        if n < 0 or r < 0:return 0
        return self.fa[n] * self.fi[r] % mod * self.fi[n - r] % mod
comb = nCr(2 * n)
c = Counter(a)
num = c.most_common()[0][0]
l, r = a.index(num), n - list(reversed(a)).index(num)
for i in range(1, n + 2):
    print((comb.comb(n + 1, i) - comb.comb(n - (r - l), i - 1)) % mod)

Measured memory_bytes: 42480
#include <atcoder/dsu>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#endif

  int n;
  cin >> n;
  vector<PII> pts(n);
  for (auto &[x, y] : pts) {
    cin >> x >> y;
  }
  VI idx(n);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.rbegin(), idx.rend(), [&](int i, int j) { return pts[i] < pts[j]; });

  auto dsu = atcoder::dsu(n);

  stack<int> stk;
  for (int i : idx) {
    int use = i;
    while (!stk.empty() && pts[stk.top()].snd > pts[i].snd) {
      if (use == i) use = stk.top();
      dsu.merge(i, stk.top());
      stk.pop();
    }
    stk.push(use);
  }

  VI ans(n);
  auto groups = dsu.groups();
  for (const auto &g : groups) {
    for (int u : g) {
      ans[u] = g.size();
    }
  }

  for (int a : ans)
    cout << a << '\n';

  return 0;
}


Measured memory_bytes: 14296
import collections

n = int(input())
List = [input() for i in range(n)]
res = []

c = collections.Counter(List)
m = 0
for v in c.values():
  m = max(m, v)
  
for k, v in c.items():
  if v == m:
    res.append(k)
    
res.sort()
for i in range(len(res)):
  print(res[i])

Measured memory_bytes: 35572
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            var answer = 0;
            for (int i = 0; i < d.Length; i++)
            {
                for (int j = i + 1; j < d.Length; j++)
                {
                    answer += d[i] * d[j];
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>

int main(){
    int R;
    std::cin>>R;

    if(R < 1200){
        std::cout<<"ABC"<<std::endl;
    }else if(R < 2800){
        std::cout<<"ARC"<<std::endl;
    }else{
        std::cout<<"AGC"<<std::endl;
    }
    return 0;
}

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

using namespace std;

void solve()
{
	int N, M;
	cin >> N >> M;
	vector<pair<int, long>> adj[N];
	while(M--)
	{
		int u, v, s;
		cin >> u >> v >> s;
		u--, v--;
		s -= 2;
		adj[u].emplace_back(v, s);
		adj[v].emplace_back(u, s);
	}
	vector<long> plus(N), minus(N), vst(2*N);
	// {v, d, x}
	queue<tuple<int, int, long>> q;
	q.emplace(0, 0, 0);
	vst[0] = 1;
	long ans = LONG_MAX;
	while (!q.empty())
	{
		auto p = q.front();
		q.pop();
		int v = get<0>(p), d = get<1>(p);
		long x = get<2>(p);
		for (auto np : adj[v])
		{
			int nv = np.first;
			long ns = np.second, nx = ns - x;
			if (d)
			{
				if (vst[nv])
				{
					if (plus[nv] != nx)
					{
						cout << 0 << endl;
						return;
					}
					continue;
				}
				plus[nv] = nx;
				vst[nv] = 1;
			}
			else
			{
				if (vst[nv+N])
				{
					if (minus[nv] != nx)
					{
						cout << 0 << endl;
						return;
					}
					continue;
				}
				minus[nv] = nx;
				vst[nv+N] = 1;
			}
			q.emplace(nv, d ^ 1, nx);
		}
	}
	//cout << "go out" << endl;
	long maxi = LONG_MAX, mini = 0, x = -1;
	for (int i = 1; i < N; i++)
	{
		//cout << i << ' ' << plus[i] << ' ' << minus[i] << endl;
		if (vst[i] && vst[i+N])
		{
			long dx = - plus[i] + minus[i];
			if (dx&1)
			{
				cout << 0 << endl;
				return;
			}
			if (x == -1)
			{
				x = dx/2;
			}
			else if (x != dx/2)
			{
				cout << 0 << endl;
				return;
			}
			ans = 1;
		}
		if (vst[i+N])
		{
			maxi = min(maxi, minus[i]);
		}
		if (vst[i])
		{
			mini = max(mini, -plus[i]);
		}
	}
	//cout << maxi << ' ' << mini << endl;
	ans = min(ans, max(maxi-mini+1, 0L));
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum =0;

    if(a==k)
    {
        cout<<a;
    }
    else
    {


    while(k--)
    {
       if(a>0)
       {
           sum++;
           a--;
       }
       else if(b>0)
       {
         b--;
       }
       else
       {
           sum--;
           c--;
       }

    }
    cout<<sum<<endl;

    }


    return 0;
}


Measured memory_bytes: 3636
using System;

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string odds = Console.ReadLine();
            string gusu = Console.ReadLine();
            string password = "";
            for (int i = 0;i < gusu.Length;i += 1)
            {
                password += odds[i].ToString() + gusu[i].ToString();
            }
            if(gusu.Length < odds.Length)
            {
                password += odds[odds.Length - 1];
            }
            Console.WriteLine(password);
        }
    }
}

Measured memory_bytes: 11092
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

-- main
main :: IO ()
main = takahashisInformation

takahashisInformation :: IO ()
takahashisInformation = do
  [c11, c12 ,c13] :: [Int] <- getLineSpc
  [c21, c22 ,c23] :: [Int] <- getLineSpc
  [c31, c32 ,c33] :: [Int] <- getLineSpc
  let c2111 = c21 - c11
      c3111 = c31 - c11
      cond1 = c2111 == c22 - c12 && c2111 == c23 - c13
      cond2 = c3111 == c33 - c13 && c3111 == c32 - c12
  if cond1 && cond2
    then
    putStrLn "Yes"
    else
    putStrLn "No"

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s,t;
    int n,m,q;
    cin >> q;
    rep(_,q){
        cin >> s >> t;
        int n = s.size();
        int m = t.size();
        // dp[i][j] := sをi文字目まで見てtをj文字目まで見た時の最大の共通部分列の長さ
        vector<vector<int>> dp(n+1,vector<int>(m+1));
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(s[i]==t[j]){
                    dp[i+1][j+1] = dp[i][j] + 1;
                }
                chmax(dp[i+1][j+1],max(dp[i][j+1],dp[i+1][j]));
            }
        }
        cout << dp[n][m] << endl;
    }
}


Measured memory_bytes: 6872
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		double a=0,ans=0,z=0;
		while(z<N){
			a=stdIn.nextDouble();
			ans+=1/a;
			z++;
		}
		System.out.println(1/ans);
	}
}

Measured memory_bytes: 24276
<?php
$S=trim(fgets(STDIN));
$Q=trim(fgets(STDIN));
for($I=0;$I<$Q;$I++){
  $C=explode(' ',trim(fgets(STDIN)));

  if($C[0][2]=='i'){
    for($i=$C[1];$i<=$C[2];$i++) print $S[$i];
    print PHP_EOL;
    continue;
  }
  if($C[0][2]=='v'){
    $l=($C[2]-$C[1]+1)>>1;
    for($i=0;$i<$l;$i++){
      $j=$C[2]-$i;
      $k=$C[1]+$i;
      $s=$S[$j];
      $S[$j]=$S[$k];
      $S[$k]=$s;
    }
    continue;
  }
  for($i=$C[1];$i<=$C[2];$i++) $S[$i]=$C[3][$i-$C[1]];
}

Measured memory_bytes: 15436
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;


int main()
{
    int H, W, N;
    cin >> H >> W;
    cin >> N;
    vector<int> a(N);
    for( int i = 0; i < N; ++i ) cin >> a[i];


    vector<int> A(H*W);  // k+1 が a[k] 個連なった配列
    int k = 0;
    for( int i = 0; i < N; ++i ){
        int count = a[i];
        while( count > 0 ) A[k++] = i+1, --count;
    }

    // c[i][j] に順番に A を代入する
    int c[100][100];
    k = 0;
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ){
            c[i][j] = A[k++];
        }
    }
    
    // c[i][j] の奇数行(1, 3, ...)だけひっくり返す
    for( int i = 1; i < H; i += 2 ){
        for( int j = 0; j < W/2; ++j ){
            swap( c[i][j], c[i][(W-1)-j] );
        }
    }
    
    // Print answer
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (int)N; i++)

const int INF = 1e9;
struct edge { int to, cost; };
struct node {
  int id, distance;
  node(int id, int distance) {
    this->id = id;
    this->distance = distance;
  }
  bool operator <(const node &theOther) const { return distance < theOther.distance; }
  bool operator >(const node &theOther) const { return distance > theOther.distance; }
};

vector<int> dijkstra(vector<vector<edge> > G, int source) {
  int V = G.size();
  vector<int> distance(V, INF);
  priority_queue<node, vector<node>, greater<node> > que;
  distance[source] = 0;
  que.push(node(source, 0));

  while(!que.empty()) {
    node n = que.top(); que.pop();
    if(distance[n.id] < n.distance) continue;
    for(int i = 0; i < G[n.id].size(); i++) {
      edge e = G[n.id][i];
      if (distance[e.to] > distance[n.id] + e.cost) {
        distance[e.to] = distance[n.id] + e.cost;
        que.push(node(e.to, distance[e.to]));
      }
    }
  }
  return distance;
}

int main () {
  int V, E, r;
  cin >> V >> E >> r;
  vector<vector<edge> > G(V);
  REP(i,E) {
    int s;
    edge e;
    cin >> s >> e.to >> e.cost;
    G[s].push_back(e);
  }
  vector<int> d = dijkstra(G, r);

  REP(i,V){
    if(d[i] == INF) {
      cout << "INF" << endl;
    } else {
      cout << d[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 18508
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int MOD = 10000;
int memo[501][10][2][2][501];
string A, B;
int M;


// x*10^nをvで割った時の余り
int calc_rest(int x, int n, int v)
{
	for(int i = 0; i < n; i++)
	{
		x -= (x / v) * v;
		x *= 10;
	}
	
	return x / 10;
}

// 数値列をディクリメントする
string dec(string S)
{
	for(int i = S.size() - 1; 0 <= i; i--)
	{
		if(S[i] != '0')
		{
			S[i]--;
			if(S[i] == '0' && i == 0 && 1 < S.size()) S = S.substr(1);
			return S;
		}
		else S[i] = '9';
	}
	
	return S;
}

// S=対象の文字列, pnt=着目している文字の場所, prv=直前の文字, ul=数字は増えるか, sp=既に最大の数より小さいことが決まっているか, rest=累積の余り, zero=最初であり0が禁止されているか
int rec(string &S, int pnt, int prv, bool inc, bool sp, int rest, bool zero)
{
	if(pnt == S.size())	return rest == 0;
	
	if(!zero && memo[pnt][prv][inc][sp][rest] != -1) return memo[pnt][prv][inc][sp][rest];
	
	int dig = S.size() - pnt;
	ll res = 0;
	
	if(inc)
	{
		int lim = (sp ? 10 : S[pnt] - '0' + 1);
		for(int i = prv + 1; i < lim; i++)
		{
			res += rec(S, pnt + 1, i, false, sp || i < S[pnt] - '0', (rest * 10 + i) % M, false);
			res %= MOD;
		}
	}
	else
	{
		for(int i = (sp ? prv - 1 : min(prv - 1, S[pnt] - '0')); zero <= i; i--)
		{
			res += rec(S, pnt + 1, i, true, sp || i < S[pnt] - '0', (rest * 10 + i) % M, false);
			res %= MOD;
		}
	}
	
	return zero ? res : memo[pnt][prv][inc][sp][rest] = res;
}

// S以下のZigZagNumberを数える
int count(string &S)
{
	if(S.size() == 1) return (S[0] - '0') / M;
	
	memset(memo, -1, sizeof memo);
	
	ll res = 9 / M;

	for(int i = 1; i < S.size(); i++)
	{
		int inc = rec(S, S.size() - i - 1, 0, true, i != S.size() - 1, 0, true);
		int fal = rec(S, S.size() - i - 1, (i == S.size() - 1 ? S[0] - '0' + 1 : 10), false, i != S.size() - 1, 0, true);
		
		res += inc + fal;
		res %= MOD;
	}
	
	return res;
}


int solve()
{
	A = dec(A);
	return (count(B) - count(A) + MOD) % MOD;
}


int main()
{
	cin >> A >> B >> M;
	cout << solve() << endl;
}

Measured memory_bytes: 39000
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int n, k;
	vector<int> a;
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	if (k > a[n - 1]) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	a.erase(unique(a.begin(), a.end()), a.end());
	int d = 1e9;
	for (int i = a.size() - 1; i > 0; --i) {
		d = min(d, a[i] - a[i - 1]);
	}

	bool mod = true;
	for (int i = 0; i < a.size(); ++i) {
		if (a[i] % d != 0) {
			mod = false;
		}
	}

	if (mod == false || (mod == true && k % d == 0)) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
 	}

	return 0;
}

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

#define MAX_N 100000

int gcd(int n, int m) {
	if (n % m) {
		return gcd(m, n%m);
	} else {
		return m;
	}
}

int main() {
	int N;
	int A[MAX_N] = {0};
	int min = 1e9+100;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A+N);
	for (int i = 1; i < N; i++) {
		min = std::min(min, gcd(A[i], A[0]));
	}
	cout << min << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*********** TEMPLATE ENDS HERE *************/

const int DIM = 3e5 + 7;

int east[DIM];
int west[DIM];

main()
{
	IOS
	
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	for(int i = 1; i <= n; i++)
		west[i] = west[i - 1] + (s[i - 1] == 'W');
	
	for(int i = n; i >= 1; i--)
		east[i] = east[i + 1] + (s[i - 1] == 'E');
	
	int turns = n;
	
	for(int i = 1; i <= n; i++)
		turns = min(turns, west[i - 1] + east[i + 1]);
	
	cout << turns;
	
}


Measured memory_bytes: 2964
#include<bits/stdc++.h>
typedef long long LL;
typedef double dl;
#define opt operator
#define pb push_back
const LL maxn=1e7+9,mod=998244353;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
LL n;
LL vis[maxn],pri[maxn],phi[maxn],cnt[maxn];
void Fir(LL N){
	LL tot(0);
	for(LL i=2;i<=N;++i){
		if(!vis[i]){
			phi[i]=2;
			cnt[i]=1; 
			pri[++tot]=i;
		}
		for(LL j=1;j<=tot && pri[j]*i<=N;++j){
			vis[i*pri[j]]=1;
			if(i%pri[j]==0){
				//phi[i*pri[j]]=phi[i]*pri[j];
				phi[i * pri[j]] = phi[i] / (cnt[i] + 1) * (cnt[i] + 2);
                cnt[i * pri[j]] = cnt[i] + 1;
				break;
			}else phi[i*pri[j]]=phi[i]*phi[pri[j]],cnt[i * pri[j]] = 1;;
		}
	}
}
int main(){
    n=Read();
    Fir(n);
    LL ans(1);
    for(LL i=1;i<=n;++i){
    	//printf("%d ",phi[i]);
    	ans+=i*phi[i];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 243260
n, m, c= list(map(int, input().split()))
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
count = 0
for i in range(n):
    ans = 0
    for j in range(m):
        ans += b[j]*a[i][j]
    ans += c
    if ans>0:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>

//ABC158A
int main(void) {
  int n, m, k, i, cou=0, tmp;
  scanf("%d %d", &n, &m);
  printf("%d", (n*(n-1)+m*(m-1))/2);
}

Measured memory_bytes: 128
l1 = [1, 3, 5, 7, 8, 10, 12]
l2 = [4, 6, 9, 11]

x, y = [int(n) for n in input().split()]

if (x in l1 and y in l1) or (x in l2 and y in l2):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 2e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
	ll n;
	cin >> n;
	ll x = 0;
	for(int i = 0; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		if(a == b)
			x++;
		else
			x = 0;
		if(x == 3)
		{
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\n";

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;
    rep(i, n)
    {
        if (v[i] > c[i])
            ans += v[i] - c[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
from heapq import heappop, heappush
n=int(input())
a=list(map(int,input().split()))
l=[0]*(n+1)
r=[0]*(n+1)
s=sum(a[:n])
t=sum(a[-n:])
l[0]=s
r[~0]=t
h=[]
H=[]
for i in range(n):
    heappush(h,a[i])
    heappush(H,-a[~i])
for i in range(n):
    s+=a[n+i]
    t+=a[~(n+i)]
    heappush(h,a[n+i])
    heappush(H,-a[~(n+i)])
    s-=heappop(h)
    t+=heappop(H)
    l[i+1]=s
    r[~(i+1)]=t
print(max(l[i]-r[i] for i in range(n+1)))

Measured memory_bytes: 38292
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define MP make_pair
#define PB push_back
#define PII pair<int, int>
typedef long long LL;
const LL P = 998244353;
const int N = 3e3+10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int p,a,x[N],y[N],b[N],rev[N];

int pw(int x,int n){
	int res = 1;
	for(;n;n>>=1,x=x*x%p)if(n&1)res = res*x%p;
	return res;
}

int main(){
	scanf("%d",&p);
	rep(i,1,p-1)rev[i] = pw(i,p-2);
	rep(i,0,p-1)x[i]=0;
	x[0] = 1;
	rep(i,0,p-1){
		memset(y,0,sizeof y);
		rep(j,0,i){
			y[j] = (y[j] - i * x[j] % p + p) % p;
			y[j+1] = (y[j+1] + x[j]) % p;
		}
		memcpy(x,y,sizeof x); 
		//rrep(j,i+1,0)cout<<x[j]<<" ";cout<<endl;
	}
	//rrep(i,p,0)cout<<x[i]<<" ";cout<<endl;
	memset(b,0,sizeof b);
	rep(i,0,p-1){
		scanf("%d",&a);
		if(a==0)continue;
		int mod = 1;
		rep(j,0,p-1)if(j!=i)mod=mod*(i-j)%p;
		mod = (mod+p)%p;
		mod = rev[mod];
		
		memset(y,0,sizeof y);
		rrep(j,p-1,0)y[j]=(x[j+1]+y[j+1]*i)%p;
		//cout<<i<<" "<<rev[mod]<<endl;
		//rrep(j,p-1,0)cout<<y[j]<<" ";cout<<endl;
		rep(j,0,p-1) b[j] = (b[j] + y[j] * mod) % p;
	}
	rep(i,0,p-1)printf("%d ",b[i]);
	return 0;
}

Measured memory_bytes: 384