akhauriyash/Code-Regression huggingface dataset:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    Sourav Verma IPG_2013  ABV_IIITMG Task @ Codeforces 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/    

#include<bits/stdc++.h>

#define ll                    long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll lcm(int x, int y) { return x * 1ll * y / (int)__gcd(x, y); }
ll hcf(ll a, ll b) {if(b>a) return (hcf(b, a)); if(a%b==0) return b; return (hcf(b, a%b));} 
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    int a,b; cin>>a>>b; string p="Zero";
    if(a>0) p="Positive";
    else if(b<0){
        p=((b-a)%2==0)? "Negative" : "Positive";
    }
    cout<<p<<"\n";
    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		if(A == 1 && B == 1) {
			System.out.println("Draw");
		}else if(A == 1) {
			System.out.println("Alice");
		}else if(B == 1) {
			System.out.println("Bob");
		}else {
			if(A > B) System.out.println("Alice");
			else if(A == B) System.out.println("Draw");
			else System.out.println("Bob");
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21844
// inputに入力データ全体が入る
function Main(input) {
    var N = input;
    var sum = 0;
    for(var i = 1; i < Math.sqrt(N-1); i++){
        if(Number.isInteger(N/i-1) && N/i-1 > i){
            sum += N/i-1;
        }
    }
    console.log(sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int binarysearch(vector<int>& a, int x)
{
	int lo = 0, mid, hi = a.size()-1;
	while(lo <= hi)
	{
		mid = (lo+hi)/2;
		if(a[mid] == x)
			return mid;
		else if(a[mid] < x)
			lo = mid+1;
		else
			hi = mid-1;
	}

	return mid;
}

int main(int argc, char const *argv[])
{
	int n, x, y;
	cin >> x >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	
	sort(a.begin(), a.end());
	int pos = binarysearch(a, x);

	if(n == 0 || a[pos] != x)
		cout << x;
	else
	{
		int f = a[0]-1, r = a.back()+1;
		for(int j = 1; pos-j >= 0; j++)
		{
			if(a[pos-j] != x-j)
			{
				f = x-j;
				break;
			}
		}

		for(int j = 1; pos+j < a.size(); j++)
		{
			if(a[pos+j] != x+j)
			{
				r = x+j;
				break;
			}
		}
		if((x-f) > (r-x))
			cout << r;
		else
			cout << f;
	}	

	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " ";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int n;
int m;
vector<vector<int>>adj;
int dist[100001];
int dfs(int node){
	if(dist[node]!=-1){
		return dist[node];
	}
	bool ok = true;
	int leaf = 0;
	for(auto p : adj[node]){
		ok = false;
		leaf = max(leaf,dfs(p));
	}
	if(ok==true){
		return dist[node]=0;
	}
	else{
		return dist[node]=1+leaf;
	}
}
int32_t main()
{
	cin >> n >> m;
	int x,y;
	adj.resize(n+1);
	int indegree[n+1]={0};
	memset(dist,-1,sizeof(dist));
	for(int i = 0 ; i < m ; i++){
		cin >> x >> y;
		indegree[y]++;
		adj[x].push_back(y);
	}
	int ans = INT_MIN;
	for(int i = 1 ; i<=n ; i++){
		if(indegree[i]==0)
		ans = max(ans,dfs(i));
	}
	
	cout << ans;
}


Measured memory_bytes: 14780
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	int N;
	string S[100];
	int countmin[26];
	int count[26];
	bool check[26];

	for (int i = 0; i < 26; i++) {

		countmin[i] = INT_MAX;
		check[i] = false;

	}

	cin >> N;
	for (int i = 0; i < N; i++) {

		cin >> S[i];

	}

	for (int i = 0; i < N; i++) {

		for (int j = 0; j < 26; j++) {

			count[j] = 0;

		}

		for (int j = 0; j < S[i].size(); j++) {

			if (S[i][j] == 'a')count[0]++;
			if (S[i][j] == 'b')count[1]++;
			if (S[i][j] == 'c')count[2]++;
			if (S[i][j] == 'd')count[3]++;
			if (S[i][j] == 'e')count[4]++;
			if (S[i][j] == 'f')count[5]++;
			if (S[i][j] == 'g')count[6]++;
			if (S[i][j] == 'h')count[7]++;
			if (S[i][j] == 'i')count[8]++;
			if (S[i][j] == 'j')count[9]++;
			if (S[i][j] == 'k')count[10]++;
			if (S[i][j] == 'l')count[11]++;
			if (S[i][j] == 'm')count[12]++;
			if (S[i][j] == 'n')count[13]++;
			if (S[i][j] == 'o')count[14]++;
			if (S[i][j] == 'p')count[15]++;
			if (S[i][j] == 'q')count[16]++;
			if (S[i][j] == 'r')count[17]++;
			if (S[i][j] == 's')count[18]++;
			if (S[i][j] == 't')count[19]++;
			if (S[i][j] == 'u')count[20]++;
			if (S[i][j] == 'v')count[21]++;
			if (S[i][j] == 'w')count[22]++;
			if (S[i][j] == 'x')count[23]++;
			if (S[i][j] == 'y')count[24]++;
			if (S[i][j] == 'z')count[25]++;

		}

		for (int i = 0; i < 26; i++) {

			if (countmin[i] >= count[i]) {
			
				countmin[i] = count[i];
				check[i] = true;

			}
		}

	}

	for (int i = 0; i < 26; i++) {

		if (count[i] > 0) {

			for (int j = 0; j < countmin[i]; j++) {

				if (i == 0)cout << "a";
				if (i == 1)cout << "b";
				if (i == 2)cout << "c";
				if (i == 3)cout << "d";
				if (i == 4)cout << "e";
				if (i == 5)cout << "f";
				if (i == 6)cout << "g";
				if (i == 7)cout << "h";
				if (i == 8)cout << "i";
				if (i == 9)cout << "j";
				if (i == 10)cout << "k";
				if (i == 11)cout << "l";
				if (i == 12)cout << "m";
				if (i == 13)cout << "n";
				if (i == 14)cout << "o";
				if (i == 15)cout << "p";
				if (i == 16)cout << "q";
				if (i == 17)cout << "r";
				if (i == 18)cout << "s";
				if (i == 19)cout << "t";
				if (i == 20)cout << "u";
				if (i == 21)cout << "v";
				if (i == 22)cout << "w";
				if (i == 23)cout << "x";
				if (i == 24)cout << "y";
				if (i == 25)cout << "z";

			}

		}

	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
A = sorted(map(int, input().split()), reverse=True)
ans = 0
q = deque([A[0]])
for i in range(1, n):
    x = q.popleft()
    ans += x
    q.append(A[i])
    q.append(A[i])
print(ans)


Measured memory_bytes: 32512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    const int U = 4;

    int dp[n+1][U+1];
    rep(i, n+1) {
        rep(j, U+1) {
            dp[i][j] = -1;
        }
    }
    
    dp[0][0] = 0;
    rep(i, n) {
        for(int j = 0; j <= U; j++) {
            if(dp[i][j] == -1) {
                continue;
            }
            for(int k = 1; k <= U && i + k <= n; k++) {
                if( j != k || s.substr(i - j, j) != s.substr(i, k) ) {
                    dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
                }
            }
        }
    }

    int ans = 0;
    for(int j = 0; j <= U; j++) {
        ans = max(ans, dp[n][j]);
    }

    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s1, s2, ans = "";
        cin >> s1 >> s2;
        int len1 = s1.length() - 1;
        int len2 = s2.length() - 1;
        int mlen = max(len1, len2);
        int pre = 0;
        for (int i = 0; i <= mlen; i++) {
            int sum = pre;
            sum += (len1 >= 0) ? s1[len1--] - '0' : 0;
            sum += (len2 >= 0) ? s2[len2--] - '0' : 0;
            pre = sum / 10;
            sum -= pre * 10;
            ans += '0' + sum;
        }
        if (pre > 0) ans += '0' + pre;
        reverse(ans.begin(), ans.end());
        if (ans.length() > 80) {
            puts("overflow");
        }
        else {
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1216
n = int(input())
s = list(input())
count_w = 0
count_e = 0
count_list = [[0] * 2 for i in range(n)]
min_num = 100000000

for i in range(n-1):
    if s[i] == 'W':
        count_w += 1
    count_list[i+1][0] = count_w

for i in range(n-1, 0, -1):
    if s[i] == 'E':
        count_e += 1
    count_list[i-1][1] = count_e

for i in range(n):
    num = count_list[i][0] + count_list[i][1]
    if num <= min_num:
        min_num = num

print(min_num)



Measured memory_bytes: 45628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; ++i)
#define vi vector<int>
#define all(c) (c).begin(), (c).end()

template <typename T> T hungarian(vector<vector<T>> &A) {
    const T infty = numeric_limits<T>::max();
    const int N = (int)A.size();
    const int M = (int)A[0].size();
    vector<int> P(M), way(M);
    vector<T> U(N, 0), V(M, 0), minV;
    vector<bool> used;

    for(int i = 1; i < N; i++) {
        P[0] = i;
        minV.assign(M, infty);
        used.assign(M, false);
        int j0 = 0;
        while(P[j0] != 0) {
            int i0 = P[j0], j1 = 0;
            used[j0] = true;
            T delta = infty;
            for(int j = 1; j < M; j++) {
                if(used[j]) continue;
                T curr = A[i0][j] - U[i0] - V[j];
                if(curr < minV[j]) minV[j] = curr, way[j] = j0;
                if(minV[j] < delta) delta = minV[j], j1 = j;
            }
            for(int j = 0; j < M; j++) {
                if(used[j])
                    U[P[j]] += delta, V[j] -= delta;
                else
                    minV[j] -= delta;
            }
            j0 = j1;
        }
        do {
            P[j0] = P[way[j0]];
            j0 = way[j0];
        } while(j0 != 0);
    }
    return -V[0];
}

main() {
    while(1) {
        int n;
        cin >> n;
        if(!n) return 0;
        vi x(n), y(n), z(n);
        rep(i, n) cin >> x[i] >> y[i] >> z[i];
        vi id(n);
        rep(i, n) {
            vi v{x[i], y[i], z[i]};
            sort(all(v));
            x[i] = v[0], y[i] = v[1], z[i] = v[2];
        }
        vector<vi> a(n + 1, vi(n + 1));
        int ans = 0;
        rep(i, n) rep(j, n) {
            if(x[i] < x[j] and y[i] < y[j] and z[i] < z[j]) { a[i + 1][j + 1] = -x[i] * y[i] * z[i]; }
        }
        rep(i, n) ans += x[i] * y[i] * z[i];
        cout << ans + hungarian(a) << endl;
    }
}


Measured memory_bytes: 3216
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(1,min(len(s)-i+1,k+1)):
#        print(j,s[i:i+j])
        list_pair.append(s[i:i+j])
    i = i + 1

list_pair = list(set(list_pair))

list_pair.sort()
print(list_pair[k-1])

Measured memory_bytes: 5068
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    string s; cin >> s;
    int n = s.size();

    int ans[n] = {};
    int a,b;
    int r,l;
    int i=0;
    int f = 0;
    while(i<n){
        if(i==0){
            a = 0;
        }else if(i==n-1){
            if(f==0){
                r = i-1;
                l = i;
                f=1;
            }
            b = i;
            srep(j,a,b+1){
                        if((r+10000000-j)%2==0){
                            ans[r]++;
                        }else{
                            ans[l]++;
                        }
            }
        }else{
            if(f==0){
                if(s[i]=='R'){
                    ;
                }else{
                    r = i-1;
                    l = i;
                    f = 1;
                }
            }else{
                if(s[i]=='L'){
                    ;
                }else{
                    b = i-1;
                    srep(j,a,b+1){
                        if((r+10000000-j)%2==0){
                            ans[r]++;
                        }else{
                            ans[l]++;
                        }
                    }
                    a = i;
                    f = 0;
                }
            }
        }
        i++;
    }

    rep(i,n){
        cout << ans[i] << ' ';
    }
    cout << endl;
    return 0;
}
 
 


Measured memory_bytes: 1024
#pragma GCC target ("sse4")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define rev(a) a.rbegin(),a.rend()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >


void solve(){
    ll m = 0,n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
    cin>>n;
    vl v(n), dp(n);
    for(auto &i : v) cin>>i;
    rep(i, n){
        if(i == 0) continue;
        if(i == 1){
            dp[i] = abs(v[i] - v[i - 1]);
            continue;
        }
        dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
    }
    cout<<dp[n - 1]<<"\n";
}

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

    /*  ll t;
    cin>>t;
    while(t--){ */
        solve();
    /* } */

}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int n;
vec c, s, f;

void solve(int start) {
    if (start == n-1) {
        cout << 0 << endl;
        return;
    }

    int res = 0;

    rep(i, n-1) {
        if (i < start) continue;

        if (res < s[i]) res = s[i];
        else {
            if (res % f[i] != 0) {
                res += f[i] - (res % f[i]);
            }
        }
        res += c[i];
    }

    cout << res << endl;
}

int main() {
    cin >> n;

    if (n == 1) {
        cout << 0 << endl;
        exit(0);
    }

    c.resize(n-1);
    s.resize(n-1);
    f.resize(n-1);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];

    rep(i, n) solve(i);
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define sq(n) ((n)*(n))
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define MEMSET(a) memset(a,0,sizeof(a))
using namespace std;

int main(){
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)cin>>c[i];
	sort(a,a+n);
	sort(c,c+n);
	long long ans=0;
	rep(i,n){
		auto ai=lower_bound(a,a+n,b[i]);
		auto ci=upper_bound(c,c+n,b[i]);
		ans+=(ai-a)*(n-(ci-c));
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;
int main(){
    int s;
    cin >> s;
    int L = s/100;
    int R = s%100;

    if(1<=L&&L<=12){
        if(1<=R&&R<=12)cout<<"AMBIGUOUS"<<endl;
        else{cout<<"MMYY"<<endl;}
    }else{
        if(1<=R&&R<=12) cout<<"YYMM"<<endl;
        else{cout<<"NA"<<endl;}
    }
}

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

const int N = 55;

int n, tot[26], tmp[26]; char S[N];

int main () {

	File();

	n = read() - 1;
	scanf ("%s", S + 1);
	For (i, 1, strlen(S + 1)) ++ tot[S[i] - 'a'];

	while (n --) {
		scanf ("%s", S + 1);
		Set(tmp, 0);
		For (i, 1, strlen(S + 1)) ++ tmp[S[i] - 'a'];
		Rep (i, 26) chkmin(tot[i], tmp[i]);
	}

	Rep (i, 26) Rep (j, tot[i]) putchar (i + 'a');

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a;
  char s[11];
  cin>>a>>s;
  if(a>=3200){
    cout<<s<<endl;
    return 0;
  }else{
    cout<<"red"<<endl;
  }
  return 0;
}

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

int main(){
  long A,B,C,D;
  cin>>A>>B>>C>>D;
  long divC,divD,divCD;
  divC=B/C-(A-1)/C;
  divD=B/D-(A-1)/D;
  int c=min(C,D),d=max(C,D),q=1;
  while(q!=0){
  	q=d%c;
    d=c;
    c=q;
  }
  divCD=B/(C*D/d)-(A-1)/(C*D/d);
  cout<<B-A+1-(divC+divD-divCD)<<endl;
}

Measured memory_bytes: 384
// Problem : A - Multiplication 1
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define int         long long int
#define vi           vector<int>
#define pii          pair<int,int>
#define vpp          vector<pii>
#define mii          map<int,int>
#define pb           push_back
#define endl        '\n'
#define rep(i,a,bb)  for(int i=a;i<bb;i++)
#define ff           first
#define ss           second
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test         int T;cin>>T;while(T--)
#define __sort(v)    sort(v.begin(),v.end())
#define __rsort(v)   sort(v.rbegin(),v.rend())
#define setbits(x)   __builtin_popcount(x)
#define zrobits(x)   __builtin_ctzint(x)
const int inf = 5 * (1e+8);
const int mod = 1e+9 + 7;

int32_t main()
{
  fast;
  int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	ll a,b,x,ans;
	cin>>a>>b>>x;
	ans=b/x-a/x;
	if(a%x==0)ans++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	string s, t;
	cin >> n >> s >> t;
	string ans = "";
	for (int i = 0; i < n; ++i) {
		ans += s[i];
		ans += t[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
k=n
keta=1
x=26
while k>x:
    k-=x
    keta+=1
    x*=26

book=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
l=[]

for i in reversed(range(1,keta)):
    s=(k-1)//(26**i)
    k-=s*(26**i)
    l.append(book[s])

l.append(book[k-1])
print("".join(l))

Measured memory_bytes: 9244
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

vector<char> ans;
void f(ll& x, ll& y, char c) {
    x++;
    y--;
    ans.push_back(c);
}

void solve() {
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<string> s(n);
    for(ll i = 0; i < n; i++) cin >> s[i];

    bool ok = true;
    for(ll i = 0; i < n; i++) {
        if(s[i] == "AB") {
            if(a == 0 && b == 0) { ok = false; break; }
            else if(a < b) f(a, b, 'A');
            else if(a > b) f(b, a, 'B');
            else if(i+1 < n && s[i+1] == "BC") f(b, a, 'B');
            else if(i+1 < n && s[i+1] == "AC") f(a, b, 'A');
            else f(a, b, 'A'); 
        }
        else if(s[i] == "AC") {
            if(a == 0 && c == 0) { ok = false; break; }
            else if(a < c) f(a, c, 'A');
            else if(a > c) f(c, a, 'C');
            else if(i+1 < n && s[i+1] == "BC") f(c, a, 'C');
            else if(i+1 < n && s[i+1] == "AB") f(a, c, 'A');
            else f(a, c, 'A'); 
        }
        else if(s[i] == "BC") {
            if(c == 0 && b == 0) { ok = false; break; }
            else if(c < b) f(c, b, 'C');
            else if(c > b) f(b, c, 'B');
            else if(i+1 < n && s[i+1] == "AB") f(b, c, 'B');
            else if(i+1 < n && s[i+1] == "AC") f(c, b, 'C');
            else f(c, b, 'C'); 
        }
    }
    if(ok) {
        cout << "Yes" << endl;
        for(auto ans_ : ans) cout << ans_ << endl;
    }
    else {
        cout << "No" << endl;
    }
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 6604
#include<stdio.h>
#include <string.h>

int main(){
    long long int x, ans=0, i;
    scanf("%lld",&x);
    for(i=1;i<=x;i++){
        if(i%3!=0&&i%5!=0){ ans+=i; }
    }
    printf("%lld",ans);
    return 0;
}

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

int main() {
  int N;
  double T, A;
  cin >> N >> T >> A;
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  
  double distance = abs(A - (T - H[0] * 0.006));
  int palace = 1;
  
  for(int i = 0; i < N; i++) {
    double temperature = T - H[i] * 0.006;
    if(distance > abs(A - temperature))
    {
      distance = abs(A - temperature);
      palace = i + 1;
    }
  }
  cout << palace << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int n;
    cin >> n;
    ll x;
    cin >> x;
    ll last = x;
    for (int i = 1; i < n; ++i) {
        cin >> x;
        last = last / __gcd(last, x) * x;
    }
    cout << last;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define init(a) memset((a),0,sizeof(a))
using namespace std;
typedef double D;
typedef vector<D> P;
const D EPS = 1e-8;

int n,m,r;
P sp[2020],tp[20],ep;
D sr[2020],tb[20];
int rm[20][2020],use[2020];

inline P mul(P p, D d){
  rep(i,p.size())p[i] *= d;
  return p;
}

inline P add(P a, P b){
  rep(i,a.size())a[i] += b[i];
  return a;
}

inline D dis2(const P &a, const P &b){
  D x = a[0]-b[0], y = a[1]-b[1], z = a[2]-b[2];
  return x*x+y*y+z*z;
}

inline D score(int i){
  return tb[i]/dis2(ep,tp[i]);
}

inline int intersect(int p, int c){
  P l = ep, r = tp[p];
  D r2 = sr[c]*sr[c];
  bool f1 = (dis2(sp[c],l)<r2+EPS), f2 = (dis2(sp[c],r)<r2+EPS);
  if(f1&&f2)return 0;
  if(f1||f2)return 1;

  rep(i,30){
    P m1 = mul(add(mul(l,2),r),1.0/3), m2 = mul(add(l,mul(r,2)),1.0/3);
    D d1 = dis2(sp[c],m1), d2 = dis2(sp[c],m2);
    if(d1<d2)r = m2;
    else l = m1;
  }
  if(dis2(sp[c],l)<r2+EPS)return 1;
  return 0;
}

int main(){
  while(scanf("%d%d%d",&n,&m,&r),n){
    rep(i,n){
      sp[i].resize(3);
      rep(j,3)scanf("%lf",&sp[i][j]);
      scanf("%lf",&sr[i]);
    }
    rep(i,m){
      tp[i].resize(3);
      rep(j,3)scanf("%lf",&tp[i][j]);
      scanf("%lf",&tb[i]);
    }
    ep.resize(3);
    rep(i,3)scanf("%lf",&ep[i]);

    vector<int> rm[20];
    rep(i,m)rep(j,n){
      if(intersect(i,j))rm[i].push_back(j);
    }

    D res = 0.0;
    D p[20];
    rep(i,m)p[i] = score(i);

    rep(bit,1<<m){

      init(use);
      D sum = 0.0;
      rep(i,m){
	if((bit>>i)&1){
	  sum += p[i];
	  rep(j,rm[i].size())use[rm[i][j]] = 1;
	}
      }

      if(accumulate(use,use+n,0)>r)continue;
      res = max(res,sum);
    }
    cout << fixed << setprecision(10) << res << endl;
  }
}

Measured memory_bytes: 1516
K = int(input())

lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lst[K-1])



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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x, y;
string s, t;
ll prime[2000000];

// < ----------- func eh ---------------- ? //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll h, m1, m2;
	cin >> h >> m1; m1 += 60 * h;
	cin >> h >> m2; m2 += 60 * h;

	cin>>k;
	m2-=k;

	cout<<max(0ll,m2-m1);newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

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

int main() {
	int a, b, c, i = 0;
	cin >> a >> b >> c;
	for (int x = a; x <= b; x++) {
		if (c % x == 0) {
			i++;
		}
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 3108
# ALDS1_3_A: Stack

#A = '1 2 + 3 4 - *'.split()
#A = '1 2 +'.split()
#A = '34 116 + 20 5 - 5 - 1 * +'.split()

A = input().split()

B = []
for v in A:
    if v in '+-*':
        o1 = B.pop()
        o2 = B.pop()
        if v == '+':
            B.append(o2 + o1)
        elif v == '-':
            B.append(o2 - o1)
        elif v == '*':
            B.append(o2 * o1)
    else:
            B.append(int(v))
    #print(B)
print(B[0])    


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

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  int max = A;
  if ( B > max ) max = B;
  if ( C > max ) max = C;
  int other;
  if ( A == max ) other = B + C;
  if ( B == max ) other = A + C;
  if ( C == max ) other = A + B;
  for ( int i = 0; i < K; i++) {
    max *= 2;
  }
  cout << max + other << endl;
}
  

Measured memory_bytes: 256
//テンプレ
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
//
signed main (){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int N,M;
   cin >> N >> M;
   vector<int> X(M);
   deque<int> L(M);
   REP(i,M)
   {
      cin >>X[i] ;
   }
   sort(ALL(X));
   REP(i,M-1)
   {
      L[i] = X[i+1] - X[i];
   }
   sort(ALL(L),greater<int>());
   REP(i,N-1)
   {
      if(L.empty())
      {
         break;
      }else {
         L.pop_front();
      }
   }
   int sum = std::accumulate(ALL(L),0);
   cout << sum <<endl;
}

Measured memory_bytes: 1920
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int n = Integer.parseInt(scanner.next());
        List<Integer> list = getPrimes(1_000_000);
        for (int l: list) {
            if (l >= n) {
                System.out.println(l);
                break;
            }
        }
    }

    static public List<Integer> getPrimes(int n) {
        boolean[] isPrime = new boolean[n + 1];
        Arrays.fill(isPrime, true);
        isPrime[0] = false;
        isPrime[1] = false;

        List<Integer> primes = new ArrayList<>();
        for (int i = 2; i <= n; i++) {
            if (isPrime[i]) {
                primes.add(i);
                for (int j = i + i; j <= n; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        return primes;
    }
}


Measured memory_bytes: 27988
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int a, b;
	int c=0;
	cin >> a >> b;
	vector<bool> d(a,false);
	for (int i = 0;i < b;i++) {
		int x;
		cin >> x;
		vector<int> e(50);
		for (int i = 0;i < x;i++) {
			cin >> e[i];
			d[e[i] - 1] = true;
		}
	}
	for (int i = 0;i < a;i++) {
		c += d[i];
	}
	cout << a-c;
}


Measured memory_bytes: 3596
# https://atcoder.jp/contests/abc048/tasks/abc048_b

a, b, n = gets.split.map(&:to_i)
res = 0
div_num_a = (a - 1) / n
div_num_b = b / n 
# p [div_num_a, div_num_b]
puts div_num_b - div_num_a

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

int main(){
  string s;
  cin >> s;
  
  int ans = 0;
  
  for(int i = 0; i<4;i++){
    if(s[i]=='-')ans--;
    else ans++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n=int(input())
for i in range(n):
    out,res=0,0
    q=deque([])
    while out<3:
        s=input()
        if s=='OUT':
            out+=1
        elif s=='HIT':
            if len(q)==3:
                res+=1
            else:
                q.append(0)
        else:
            res+=len(q)+1
            q.clear()
    print(res)


Measured memory_bytes: 6000
import fractions


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


a, b = map(int, input().split())
gcd_ = fractions.gcd(a, b)
L = prime_factorize(gcd_)
print(len(list(set(L)))+1)

Measured memory_bytes: 64108
p, q, r = map(int, input().split())
ans = 0
if p <= q:
    a = p
    b = q
    if b <= r:
        ans = a + b
    else:
        ans = a + r
else:
    a = q
    b = p
    if b <= r:
        ans = a + b
    else:
        ans = a + r
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main(){

  int s1, s2, s3, h;
  scanf("%d", &s1);
  scanf("%d", &s2);
  scanf("%d", &s3);
  scanf("%d", &h);
  printf("%d\n%d\n", (s1+s2+s3+h)/60, (s1+s2+s3+h)%60);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

struct PrimeNumber{//Check prime number.
	std::vector<int> jud;//0 or 1.
	
	PrimeNumber(int n):jud(n+1,-1){//constructor.
		jud[0]=jud[1]=0;
		for(int i=2;i<=n;++i){
			if(jud[i]==-1){
				jud[i]=1;
				for(int j=i+i;j<=n;j+=i) jud[j]=0;
			}
		}
	}
};

int main(){
	int x;
	cin>>x;
	
	PrimeNumber cl(100100);
	
	while(1){
		if(cl.jud[x]==1) break;
		x++;
	}
	
	cout<<x<<endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        private static long mod = 1000000007;

        static void Main(string[] args)
        {
            var r = ReadSplit();
            var n = r[0].Int();
            var k = r[1].Int();
            var r2 = ReadSplit();
            var l = new int[n];
            for (int i = 0; i < n; i++)
            {
                l[i] = r2[i].Int();
            }
            Array.Sort(l);
            var ans = 0L;
            for (int i = 0; i < k; i++)
            {
                ans += l[i];
            }
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, M, X;
    cin >> N >> M >> X;
    vector<int> v[N];
    int cost[SIZE];
    for(int i = 0; i < N; ++i) {
        cin >> cost[i];
        for(int j = 0; j < M; ++j) {
            int a;
            cin >> a;
            v[i].pb(a);

        }
    }

    LL res = LINF;
    for(int i = 1; i < (1 << N); ++i) {
        int sum[100] = {};
        LL c = 0;
        for(int j = 0; j < N; ++j) {
            if((i >> j) & 1) {
                c += cost[j];
                for(int k = 0; k < M; ++k) {
                    sum[k] += v[j][k];

                }
            }
        }
        bool f = true;
        for(int j = 0; j < M; ++j) {
            if(X > sum[j]) f = false;

        }
        if(f) res = min(res, c);
    }

    if(res == LINF) res = -1;
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3676
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    string t;
    cin >> t;
    rep(i, t.size()) {
        if(t[i] == '?') {
            t[i] = 'D';
        }
    }
    cout << t << endl;
}

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

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

int main() {
  
  int N,K; cin >> N >> K;
  vector<int> rsp(3);
  REP(i,3) cin >> rsp.at(i);
  string T; cin >> T;
  
  int ans=0;
  
  REP(i,N){
    if(i >= K){
      if(T.at(i) == T.at(i-K)){
        T.at(i) = 'q';
        continue;
      }
    }
    ans += rsp.at(T.at(i)%5/2);
  }
  
  cout << ans << endl;
  
  
  
  return 0;
}

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

int main(){
  int K;
  cin >> K;
  string S;
  cin >> S;
  
  int l = S.size();
  
  if(l <= K){
    cout << S << endl;
  }else{
    for(int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	pairs := make([]Pair, n)
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		pairs[i] = Pair{A: a, B: b}
	}
	sort.Sort(Pairs(pairs))

	sum := 0
	for _, p := range pairs {
		sum += p.B
		if k <= sum {
			fmt.Println(p.A)
			return
		}
	}
}

// Pair .
type Pair struct {
	A int
	B int
}

// Pairs .
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}

func (p Pairs) Less(i, j int) bool {
	return p[i].A < p[j].A
}

func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}


Measured memory_bytes: 5376
N = int(input())
stones = list(map(int,input().split()))

min_jump = [1000000000000 for i in range(N)]
min_jump[0] = 0
for i in range(1,N):
    min_jump[i] = min(abs(stones[i] - stones[i-1]) + min_jump[i-1],abs(stones[i] - stones[i-2]) + min_jump[i-2])
print(min_jump[N-1])


Measured memory_bytes: 13924
#include <stdio.h>
#include <string.h>

int l[1001][1001];

int lcs(char *x, char *y) {
// #   lcs(Xi, Yj) = 0 (if i = 0 or j = 0)
// #           lcs(Xi-1, Yj-1) + 1 (if xi = yj)
// #           max(lcs(Xi-1, Yj), lcs(Xi, Yj-1)) (if xi ≠ yj)
    int i, j;

    for (i = 0; i < strlen(x); i++) {
        for (j = 0; j < strlen(y); j++) {
            if (x[i] == y[j])
                l[i+1][j+1] = l[i][j] + 1;
            else if (l[i][j+1] > l[i+1][j])
                l[i+1][j+1] = l[i][j+1];
            else
                l[i+1][j+1] = l[i+1][j];
        }
    }
    return l[strlen(x)][strlen(y)];
}

main() {
    int i, q;
    char x[1001], y[1001];

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%s", x);
        scanf("%s", y);
        printf("%d\n", lcs(x, y));
    }
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s;
	int a='a'-'A';
	for(int i=0;i<3;++i){
		cin>>s;
		cout<<(char)(s.at(0)-a);
	}
	cout<<"\n"s;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var H, cnt int
	fmt.Scan(&H)
	w := H
	wc := 1
	for {
		cnt += wc
		if w == 1 {
			break
		}

		w /= 2
		wc *= 2
	}
	fmt.Println(cnt)

}


Measured memory_bytes: 512
if __FILE__==$0
	reads_i=lambda{|s,d|s.strip.split(d).map(&:to_i)}
	data=reads_i[gets," "]
	k=data[0]
	s=data[1]
	cnt=0
	for x in 0..k
		for y in 0..k
			z=s-(x+y)
			if x+y==s || (z<=k && z>0) then cnt+=1 end
		end
	end
	p cnt
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define fs first 
#define sc second 
#define mod 1000000007
#define eps 10e-6
#define ll long long
#define pb push_back
#define lsb(x) (x&(-x))
using namespace std;
int main()
{
    int n,even[100005],odd[100005],x;
    vector<pair<int,int>> ev,od;
    memset(odd,0,sizeof(odd));
    memset(even,0,sizeof(even));
    cin>>n;
    rep(i,n)
    {
        cin>>x;
        if(i%2==0)
        {
            even[x]++;
        }
        else
        {
            odd[x]++;
        }
    }
    rep(i,100005)
    {
        ev.pb({even[i],i});
        od.pb({odd[i],i});
    }
    sort(ev.begin(),ev.end());
    sort(od.begin(),od.end());
    reverse(ev.begin(),ev.end());
    reverse(od.begin(),od.end());
    if(ev[0].sc!=od[0].sc)
    {
        cout<<n-ev[0].fs-od[0].fs<<endl;
    }
    else
    {
        cout<<n-max(ev[0].fs+od[1].fs,ev[1].fs+od[0].fs)<<endl;
    }
    return 0;
}

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

bitset<1'000'000'007> num_exists;

void main_()
{
    int N;
    cin >> N;

    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        num_exists.flip(A);
    }

    cout << num_exists.count() << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 122240
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main(){
  	ll n,m,n1,n2;
  	n1=n2=0;
    cin>>n>>m;
  	for(int i=1;i<=m;i++)
      n1=n1*10+n;
  	for(int i=1;i<=n;i++)
      n2=n2*10+m;
    string ans1 = to_string(n1);
    string ans2 = to_string(n2);
    if(ans1 < ans2){
        cout<<ans1;
    } else {
        cout<<ans2;
    }
	return 0;
}


Measured memory_bytes: 384