akhauriyash/Code-Regression huggingface dataset:
M[100][100][2],Z=100,l=100000;main(i,j){
for(M[0][0][0]=M[0][0][1]=M[1][1][0]=M[1][1][1]=j=1;j<Z;j++)M[0][j][1]=M[0][j-1][1];
for(;i<Z;i++)for(M[i][0][0]=M[i-1][0][0],j=1;j<Z;j++)M[i][j][0]=(M[i-1][j][0]+M[i-1][j-1][1])%l,M[i][j][1]=(M[i][j-1][1]+M[i-1][j-1][0])%l;
for(;scanf("%d%d",&i,&j),i;)printf("%d\n",(M[i-1][j-1][0]+M[i-1][j-1][1])%l);exit(0);}

Measured memory_bytes: 676
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t=1;
	while(t--)
	{
		int d,t,s;
		cin >> d >> t >> s;
		if(d<=s*t)
		cout << "Yes";
		else
		cout << "No";
	}
}




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

int main(){
	string in;
	while( getline(cin,in), in.length() ){
		for( int i=0; i<in.length(); i++ ){
			if( in[i] == '@' ){
				char n = in[++i] - '0';
				char c = in[++i];
				for( int j=0; j<n; j++ )
					cout << c;
			}else
				cout << in[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll d;
  cin >> d;
  string ans;
  if(d == 25)
    ans = "Christmas";
  else if(d == 24)
    ans = "Christmas Eve";
  else if(d == 23)
    ans = "Christmas Eve Eve";
  else
    ans = "Christmas Eve Eve Eve";
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
  int j=0;
  long n,k;
  pair<long,long> a[100000];
  scanf("%ld %ld",&n,&k);
  for(int i=0;i<n;i++)
    scanf("%ld %ld",&a[i].first,&a[i].second);
  sort(a,a+n);
  while(k>0){
    k-=a[j].second;
    j++;
  }
  printf("%ld\n",a[j-1].first);
}


Measured memory_bytes: 1792
//abc135_c.cpp
//Sat Jul 27 20:50:28 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n+1],a2[n+1],b[n],b2[n];
	ll ans = 0;
	for (int i=0;i<n+1;i++){
		cin >> a[i];
		a2[i]=a[i];
	}
	for (int i=0;i<n;i++){
		cin >> b[i];
		b2[i] = b[i];
		if (b[i]<a[i]){
			ans += b[i];
		}else{
			ans += a[i];
			b[i]=b[i]-a[i];
			if (b[i]<a[i+1]){
				ans += b[i];
				a[i+1] = a[i+1]-b[i];
			}else {
				ans += a[i+1];
				a[i+1] = 0;
			}
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

int main() {
    int A, B, C;
    int X, Y;
    cin >> A >> B >> C;
    cin >> X >> Y;
    ll INF = 1LL << 60;
    ll MIN = INF;
    for (int i = 0; i <= 2*max(X, Y); i += 2) {
        ll money = 0; int ab = i/2;
        money += C*i;
        if (X-ab > 0) money += A*(X-ab);
        if (Y-ab > 0) money += B*(Y-ab);
        MIN = min(MIN, money);
    }
    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

struct P
{
	int x, y;
	P(int x, int y)
		: x(x), y(y) { }
	P operator-(const P& a) const { return P(x - a.x, y - a.y); }
	bool operator==(const P& a) const { return x == a.x && y == a.y; }
};
vector<P> ori(const vector<P>& v)
{
	vector<P> res;
	P rela = v[0];
	for (int i = 0; i < v.size(); ++i)
		res.push_back(v[i] - rela);
	return res;
}
vector<P> rotate(const vector<P>& v)
{
	vector<P> res;
	for (int i = 0; i < v.size(); ++i)
		res.push_back(P(-v[i].y, v[i].x));
	return res;
}
vector<P> mirror(const vector<P>& v)
{
	vector<P> res;
	for (int i = 0; i < v.size(); ++i)
		res.push_back(P(-v[i].x, v[i].y));
	return res;
}
vector<P> input()
{
	int m;
	cin >> m;
	vector<P> res;
	while (m--)
	{
		int x, y;
		cin >> x >> y;
		res.push_back(P(x, y));
	}
	return res;
}
int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<vector<P> > ok;
		ok.push_back(ori(input()));
		for (int i = 0; i < 3; ++i)
			ok.push_back(rotate(ok.back()));
		for (int i = 0; i < 4; ++i)
		{
			vector<P> a = ok[i];
			reverse(all(a));
			ok.push_back(ori(a));
		}

		for (int T = 1; T <= n; ++T)
		{
			vector<P> t = ori(input());
			bool s = false;
			for (int i = 0; i < ok.size(); ++i)
				s |= t == ok[i];
			if (s)
				cout << T << endl;
		}
		cout << "+++++" << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

    ll N;
    cin >> N;
    vector<ll> A(N);
    ll count = 0;
    ll sum = 0;
    ll minarg = 0;
    REP(i, N) {
        cin >> A[i];
        sum += abs(A[i]);
        if (A[i] < 0) count++;
        if (abs(A[minarg]) > abs(A[i])) minarg = i;
    }
    ll ans;
    if (count % 2 == 0) ans = sum;
    else{
        ans = sum - 2 * abs(A[minarg]);
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
	string S,T;
	cin >> S >> T;
	int ans(0);
	for(int i(0);i<3;++i){
		if(S[i] == T[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:500000000")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <time.h>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

#define y0 y0ChloeGraceMoretz
#define y1 y1ChloeGraceMoretz
typedef long long ll;
int nextInt() { int n; scanf("%d", &n); return n; }
ll nextLong() { ll n; scanf("%lld", &n); return n; }
const double PI = acos(-1.0);
const double EPS = 1e-9;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;

int ans[10];
set<pair<int, int> > points;
set<pair<int, int> > checked;

void f(int x0, int y0) {
	if (checked.find({x0, y0}) != checked.end()) {
		return;
	}
	int cnt = 0;
	for (int x = x0; x <= x0 + 2; ++x) {
		for (int y = y0; y <= y0 + 2; ++y) {
			if (points.find({x, y}) != points.end()) {
				++cnt;
			}
		}
	}
	if (cnt != 0) {
		++ans[cnt];
	}
	checked.insert({x0, y0});
}

int main() {
	//freopen("in.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int h, w, n;
	scanf("%d %d %d", &h, &w, &n);
	for (int i = 0; i < n; ++i) {
		int x, y;
		scanf("%d %d", &x, &y);
		points.insert({x, y});
	}
	for (set<pair<int, int> >::iterator it = points.begin();
		it != points.end();
		++it) {
		for (int xs = -2; xs <= 0; ++xs) {
			for (int ys = -2; ys <= 0; ++ys) {
				int x = (*it).first + xs;
				int y = (*it).second + ys;
				if (1 <= x && x + 2 <= h && 1 <= y && y + 2 <= w) {
					f(x, y);
				}
			}
		}
	}
	ll ans0 = ((ll)h - 2) * (w - 2);
	for (int i = 1; i <= 9; ++i) {
		ans0 -= ans[i];
	}
	printf("%lld\n", ans0);
	for (int i = 1; i <= 9; ++i) {
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 47104
import sys
sys.setrecursionlimit(4100000)

import math

import logging

from collections import defaultdict

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def prime_factor(n: int):
    """素因数分解
    
    Args:
        n (int): [description]
    
    Returns:
        [type]: [description]
    """
    res: defaultdict = defaultdict(int)
    res[1] = 1
    for i in range(2, math.ceil(math.sqrt(n))):
        while (n % i == 0):
            res[i] += 1
            n = n // i

    if (n != 1):
        res[n] = 1

    return res


def count(n):
    i = 0
    a = 1
    while (True):
        n = n - a
        if n >= 0:
            i += 1
            a += 1
        else:
            break

    return i


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    factors = prime_factor(N)

    logger.debug('{}'.format([factors]))

    ret = 0

    for key, value in factors.items():
        if key != 1:
            ret += count(value)

    print(ret)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """24"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """64"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """1000000007"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """997764507000"""
        output = """7"""
        self.assertIO(input, output)



Measured memory_bytes: 71152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;

ll D, G;
vector<pair<ll, ll>> V;
ll Min = 1e9;

int dfs(vector<ll> U){
    if(U.size() == D){
        //cout << U.size() << endl;
        ll Score = 0;
        ll n=0;
        for(int i = 0; i < D; i++){
            if(U[i] == 1) {
                Score += V[i].first*(i+1)*100 + V[i].second;
                n+=V[i].first;
            }
        }
        if(Score >= G) Min = min(Min, n);
        else {
            ll Sub = G-Score;
            for(int i = D-1; i >= 0; i--){
                if(U[i] == 1) continue;
                if((V[i].first-1)*(i+1)*100 >= Sub) n += ceil((double)Sub/(double)((i+1)*100));
                else if(V[i].first*(i+1)*100 + V[i].second >= Sub) n += V[i].first;
                else return 0;
                Min = min(Min, n);
                return 0;
            }
        }


        return 0;
    }
    for(int i = 0; i < 2; i++){
        vector<ll> temp = U;
        temp.push_back(i);
        dfs(temp);
    }
    return 0;
}

int main() {
    cin >> D >> G;
    V.resize(D);
    
    for(int i = 0; i < D; i++){
        ll p, c; cin >> p >> c;
        V[i] = {p, c};
    }  
    vector<ll> _ = {};
    dfs(_);
    cout << Min << endl;
    

}

Measured memory_bytes: 256
mod = 10**9+7
n, m = list(map(int,input().split()))
s = list(map(int,input().split()))
t = list(map(int,input().split()))
dp = [0]*(m+1)
for i in range(n)[::-1]:
    old = 0
    for j in range(m)[::-1]:
        tmp = dp[j] + dp[j+1] - old
        tmp %= mod
        if s[i]== t[j]:
            tmp += 1 + old
            tmp %= mod
        dp[j], old = tmp, dp[j]
print((dp[0]+1)%mod)

Measured memory_bytes: 41836
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define cin1(x) scanf("%d",&x)
#define cin2(x,y) scanf("%d%d",&x,&y)
#define cin3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define rr read()
#define ll long long
#define CloseIo ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll  long long 
using namespace std;
int main() {
	int n;
	cin>>n;
	int m=n;
	int ans=0;
	while(m){
		ans++;
		m/=10;
	}
	int num=0;
	if(ans%2==1) num=n-pow(10,ans-1)+1,ans--;
	for(int i=ans;i>0;){
		num=num+pow(10,i-1)-pow(10,i-2);
		i-=2;
	}
	cout<<num<<"\n";	
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN1=501;
const int MAXN2=31;
int n,c,key,res=2147483647;
int D[MAXN2][MAXN2];
int num[3][MAXN2];
inline int read(){
	int x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}
int main(){
	n=read();c=read();
	for(int i=1;i<=c;++i)
		for(int j=1;j<=c;++j)
			D[i][j]=read();
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			key=read();
			++num[(i+j)%3][key];
		}
	}
	for(int i=1;i<=c;++i){
		for(int j=1;j<=c;++j){
			if(i==j) continue;
			for(int k=1;k<=c;++k){
				if(i==k||j==k) continue;
				int ans=0;
				for(int w=1;w<=c;++w){
					if(w==i) continue;
					ans+=(D[w][i]*num[0][w]);
				}
				for(int w=1;w<=c;++w){
					if(w==j) continue;
					ans+=(D[w][j]*num[1][w]);
				}
				for(int w=1;w<=c;++w){
					if(w==k) continue;
					ans+=(D[w][k]*num[2][w]);
				}
				res=min(res,ans);
			}
		}
	}
	printf("%d",res);
	return 0;
}

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

int main()
{
   int n,j;
   long long sum=0;
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
       if(i%3==0 && i%5==0)
       {
           continue;
       }
       else if(i%3==0)
       {
           continue;
       }
       else if(i%5==0)
       {
           continue;
       }
       else
       {
           j=i;
           sum+=j;
       }
   }
   printf("%lld",sum);
   return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
char a[200000];
int  b[200000];
int  c[200000];

int main()
{
    int i,n,m,j,k,l,x=0,y;
    scanf("%s",a);
    n=strlen(a)-1;
    i=0;
    while(i<n)
    {
        if(a[i]!=a[i+1])
        {
            x++;
        }
        i++;
    }
    printf("%d",x);
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;


int ans,y,m,d;

void next_day(){
	ans++;
	
	if(m<10){
		if(y%3==0||m%2==1){
			if(d+1<=20) 
				d++;
			else
				d=1,m++;
		}else{
			if(d+1<=19) 
				d++;
			else
				d=1,m++;
		}
	}else{
		if(y%3==0||m%2==1){
			if(d+1<=20) 
				d++;
			else
				d=1,m=1,y++;
		}else{
			if(d+1<=19) 
				d++;
			else
				d=1,m=1,y++;
		}
	}
	return ;
}


int main(void){
	int n;
	cin >> n;
	while(n--){
		cin >> y >> m >> d;
		ans=0;
		while(1){
			if(y==1000 && m==1 && d==1) break;
			next_day();
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
char s[1005][1005];
int main()
{
    int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
        s[i][j]='0';
    }
    if(a==1&&b==1){
        if(h==w){
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    printf("%c","01"[i==j]);
                }
                printf("\n");
            }
        }
        else
            printf("-1");
            return 0;
    }
    else if(a*2>w||b*2>h)
        printf("-1\n");
    else if(b==0){
        for(int i=0;i<h;i++){
            for(int j=0;j<a;j++)
                s[i][j]='1';
                printf("%s\n",s[i]);
        }
    }
    else if(a==0){
        for(int i=0;i<b;i++){
            for(int j=0;j<w;j++)
                s[i][j]='1';
        }
        for(int i=0;i<h;i++){
            printf("%s\n",s[i]);
        }
    }
    else{
        for(int i=0;i<b;i++){
            for(int j=0;j<a;j++)
                s[i][j]='1';
        }
        for(int i=b;i<h;i++)
        for(int j=a;j<w;j++){
            s[i][j]='1';
        }
        for(int i=0;i<h;i++)
            printf("%s\n",s[i]);
    }
    return 0;
}


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

using namespace std;
using ll = long long;

int main(){
    int n, k;
    cin >> n >> k;
    if( n >= 10 ){
        cout << k << "\n";
    }else{
        n = 100*(10-n);
        cout << k+n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math
n=int(input())
x=list(map(int,input().split()))
s=sum(x)
st=s/n
if (st-math.floor(st))>0.5:
  p=math.ceil(st)
else:
  p=math.floor(st)
t=0
for m in x:
  t=t+((m-p)**2)
print(t)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b[101],minly=100,m,cnt=0,cnt1=0;
	cin>>a;
	for (int i=0;i<a;i++)
	{
		cin>>b[i];
		cnt+=b[i];
	}
	for (int i=0;i<a;i++)
	{
		cnt1+=b[i];
		if (abs((cnt-cnt1)-cnt1)<minly)
			minly=abs((cnt-cnt1)-cnt1);
	}
	cout<<minly<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,K;
    cin >> N >> K;
    
    int x = 1;
    for ( int i = 0; i < N; i++ ) {        
        x = min( x*2, x+K );        
    }
    
    cout << x << endl;
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
ans = 0
L = P[:X] + Q[:Y]
L.sort()
idx = 0
for i in range(X+Y):
    if idx >= C:
        break
    if L[i] < R[idx]:
        L[i] = R[idx]
        idx += 1
print(sum(L))

Measured memory_bytes: 23328
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> path(M,vector<int>(2));
  vector<vector<int>> connect(N);

  REP(m,M){
    int A, B;
    cin >> A >> B;
    A -=1;
    B -=1;
    connect[A].emplace_back(B);
    connect[B].emplace_back(A);
  }

  vector<int> length(N);
  vector<int> next(N);
  REP(n,N){
    length[n] = 100000000;
    next[n] = -1;
  }

  length[0] = 0;
  deque<vector<int>> deq;
  REP(s1,connect[0].size()){
    vector<int> vec(2);
    vec[0] = 0;
    vec[1] = connect[0][s1];
    deq.emplace_back(vec);
  }

  while(! deq.empty()){
    vector<int> vec1(2);
    vec1 = deq[0];
    deq.pop_front();
    int parent, current;
    parent = vec1[0];
    current = vec1[1];
    if (length[current] > length[parent]+1){
      length[current] = length[parent]+1;
      next[current] = parent+1;
      REP(s2,connect[current].size()){
        int child;
        child = connect[current][s2];
        if (child != parent){
          vector<int> vec2(2);
          vec2[0] = current;
          vec2[1] = child;
          deq.emplace_back(vec2);
        }
      }
    }
  }
  bool flag = true;
  REP(n,N-1){
    if (next[n+1] ==-1) flag = false;
  }
  if(flag == true){
    cout << "Yes" << endl;
    REP(n,N-1) cout << next[n+1] << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 38680
#include<map>
#include<set>
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

int n,k,a[5010],dp[17][5010],ans;

void solve(int l,int r,int dep)
{
	if(l==r)
	{
		int tmp=0;
		for (int i=max(0,k-a[l]);i<k;++i)
		{
			tmp|=dp[dep][i];
		} 	
		ans+=1-tmp;
		return;
	}
	int mid=(l+r)>>1;
	for(int i=0;i<k;++i)
	{
		dp[dep+1][i]=dp[dep][i];
	}
	for(int i=l;i<=mid;++i)
	{
		for (int j=k-1;j>=a[i];--j)
		{
			dp[dep+1][j]|=dp[dep+1][j-a[i]];
		}
	}	
	solve(mid+1,r,dep+1);
	for(int i=0;i<k;++i)
	{
		dp[dep+1][i] = dp[dep][i];
	}
	for(int i=mid+1;i<=r;++i)
	{
		for(int j=k-1;j>=a[i];--j)
		{
			dp[dep+1][j]|=dp[dep+1][j-a[i]];
		}	
	}
		
	solve(l,mid,dep+1);
}

int main()
{
	scanf("%d%d",&n,&k);
	for (int i = 1 ; i <= n ; ++ i)
	{
		scanf("%d",&a[i]);
	}	
	dp[1][0] = 1;
	solve(1,n,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int m, f, r;
    
    char grade;
    
    while(true)
    {
        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1) { break; }
        
        if(m == -1 || f == -1)
        {
            grade = 'F';
        }
        else if(m + f >= 80)
        {
            grade = 'A';
        }
        else if(m + f >= 65)
        {
            grade = 'B';
        }
        else if(m + f >= 50)
        {
            grade = 'C';
        }
        else if(m + f >= 30)
        {
            if(r >= 50)
            {
                grade = 'C';
            }
            else
            {
                grade = 'D';
            }
        }
        else
        {
            grade = 'F';
        }
        
        cout << grade << endl;
    }
    
    return 0;
}

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

def main():
    N, K = map(int, input().split())
    H = sorted([int(input()) for _ in range(N)])
    ans = 10 ** 10
    for i in range(N - K + 1):
        if H[i + K - 1] - H[i] < ans:
            ans = H[i + K - 1] - H[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 78028
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
  vll a(n);
  
  vll x(n),y(n);
  rep(i,0,n) {
    cin >> a[i];
    x[i]=a[i]+i;
    y[i]=i-a[i];
  }
 
  sort(all(x));
  ll ans=0;
  rep(i,0,n){
   ans+=upper_bound(all(x),y[i])-lower_bound(all(x),y[i]);
  
  }
  
  cout << ans << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 7960
(defun split (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(destructuring-bind
    (a b c) (split (read-line))
  (format t "~a~%"
          (if (and (char= (aref a (- (length a) 1))
                          (aref b 0))
                   (char= (aref b (- (length b) 1))
                          (aref c 0)))
              "YES"
              "NO")))


Measured memory_bytes: 15972
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let n = parse!(it);
    let a: Vec<usize> = parse!(it, n);
    let s: usize = a.iter().sum();
    let b0 = s - 2
        * (1..(n - 1))
            .filter(|i| i % 2 == 1)
            .map(|i| a[i])
            .sum::<usize>();
    let mut b = vec![b0];
    for i in 1..n {
        let prev = b[i - 1];
        b.push(2 * a[i - 1] - prev);
    }
    let b = b
        .iter()
        .map(|x| format!("{}", x))
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}", b);
}


Measured memory_bytes: 16636
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include <algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};
int n,k;

int main() {
  int a,b;
  cin >> a >> b;
  
  if(a%2 && b%2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 1024
//#include <fstream>
#include <iostream>
#include <cstring>
#define NMAX 100010

using namespace std;
//ifstream fin("tree.in");
//ofstream fout("tree.out");
int t[NMAX], n, i;
char s[NMAX];
int conditii(char s[])
{
    if (s[0] == '0' || s[n - 1] == '1')
        return 0;
    for (i = 0; i < (n - 1) / 2; ++i) {
        if(s[i] != s[n - i - 2])
            return 0;
    }
    return 1;
}
int main()
{
    cin.getline(s, NMAX);
    n = strlen(s);
    if (conditii(s) ==  0)
        cout << -1;
    else {
        int k = 2, p = 2;
        t[1] = 2;
        for (i = 1; i < n / 2; i++)
        {
            if( s[i] == '0')
                t[++k] = p;
            else {
                k++;
                t[p] = k;
                p = k;
            }
        }
        for(i = k + 1; i <= n; i++)
        {
            t[i] = p;
        }
        for (i = 1; i <= n; i++) {
            if(t[i] != 0)
                cout << i << " " << t[i] << '\n';
        }
    }
    return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

int pw(int a, int b)
{	int ans = 1;
	a %= mod;
	while (b > 0)
	{	int bit = b & 1;
		if (bit)
		{	ans *= a;
			ans %= mod;


		}
		a = a * a;
		a %= mod;
		b = b >> 1;

	}
	return ans;

}
int32_t main()
{

	int n;
	cin >> n;
	if (n == 1)
	{
		cout << 0 << endl;
	}
	else if (n == 2)
	{
		cout << 2 << endl;
	}

	else
	{

		int ans = (pw(10, n) % mod + pw(8, n) % mod) % mod;
		int res = (ans % mod - (2 * pw(9, n) % mod) + mod) % mod;
		cout << res << endl;





	}

	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h> 
using namespace std;
int64_t cnt = 1;
void so(int64_t g){
    int64_t next = g;
    if (next == 1) return;
    next = next / 2;
    cnt++;
    so(next);
}

int main(){
   int64_t h,sum = 0;
   cin >> h;

    so(h);
    for (int i = 0;i < cnt;i++){
        sum += pow(2,i);
    }

    cout << sum << endl;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n+1);
  rep(i,n+1) cin>>a[i];
  vll b(n);
  rep(i,n) cin>>b[i];
  
  ll ans=0;
  rrep(i,n){
    ll tmp=a[i+1];
    a[i+1]-=b[i];
    if(a[i+1]<=0){
      ans+=tmp;
      b[i]-=tmp;
    }else{
      ans+=b[i];
      continue;
    }
    tmp=a[i];
    a[i]=max(0LL,a[i]-b[i]);
    if(a[i]==0) ans+=tmp;
    else ans+=b[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>

using namespace std;

 struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int N;
vector<int> P;
void prime( const int N )
{
    for( int i = 2; i <= N; i++ )
    {
        bool flag = true;
        for( int j = 2; j * j <= i; j++ )
        {
            if( i % j == 0 )
            {
                flag = false;
                break;
            }
        }
        if( flag )
        {
            P.emplace_back( i );
        }
    }
}
int main()
{
	int x;
	cin >> x;
	
    N=100004;
    
    prime( N );
	
	for(int i=0;i<P.size();i++){
		if(P[i] >= x){
			cout << P[i] << endl;
			return 0;
		}
	}
    
    
    return 0;
}

Measured memory_bytes: 384
n = int(input())
listOfNoFizzBuzz = []
for i in range(n+1):
    if not(i % 3 == 0 or i % 5 == 0 or (i % 3 == 0 and i % 5 == 0)):
        listOfNoFizzBuzz.append(i)
print(sum(listOfNoFizzBuzz))

Measured memory_bytes: 29976
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

    int n ;
    cin >> n ;

    int a[2][n] ;
    for (int i = 0; i < n; i++) cin >> a[0][i] ;
    for (int i = 0; i < n; i++) cin >> a[1][i] ;

    int ans = -1 ;

  for(int j=0;j<n;j++)
  {
    int cnt = 0 ;
    for(int i=0;i<=j;i++) cnt += a[0][i] ;    
    for(int i=j;i<n;i++)  cnt += a[1][i] ;    

     ans = (ans<cnt) ? cnt : ans ; 
  }

    cout << ans << endl ;

	return 0;
}



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

#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define fill(a, z) memset(a, z, sizeof(a))
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << z << ' '
#define cnl(z) cout << z << '\n'
#define M 1000000007
#define M2 998244353
#define INF 10000000000000000000
#define MAXN 300005
#define endl "\n"
#define iip(t) \
	int t;     \
	cin >> t;
#define iip2(a, b) \
	int a, b;      \
	cin >> a >> b;
#define dip(a) \
	double a;  \
	cin >> a;
#define dip2(a, b) \
	double a, b;   \
	cin >> a >> b;
#define garr(ip)       \
	for (auto &x : ip) \
		cin >> x;
#define parr(ip)          \
	for (auto &x : ip)    \
		cout << x << " "; \
	cout << endl;
#define test   \
	int _t;    \
	cin >> _t; \
	while (_t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vp;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	string s = to_string(n);
	bool flag = false;
	for(auto it:s)
	{
		if(it == '7')
			flag = true;
	}
	cnl((flag ? "Yes" : "No"));
}

Measured memory_bytes: 3704
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;

    static int tergetX;
    static int tergetY;
    static void input()
    {
        cin = new Scanner();
        int sx = cin.nextInt();
        int sy = cin.nextInt();
        tergetX = cin.nextInt() - sx;
        tergetY = cin.nextInt() - sy;
    }
    static void solve()
    {
        input();
        for(int i = 0; i < tergetX; i++)
            Write("R");

        for (int i = 0; i < tergetY; i++)
            Write("U");

        for (int i = 0; i < tergetX; i++)
            Write("L");

        for (int i = 0; i < tergetY; i++)
            Write("D");

        Write("D");

        for (int i = 0; i < tergetX + 1; i++)
            Write("R");

        for (int i = 0; i < tergetY + 1; i++)
            Write("U");

        Write("L");

        Write("U");

        for (int i = 0; i < tergetX + 1; i++)
            Write("L");

        for (int i = 0; i < tergetY + 1; i++)
            Write("D");

        Write("R");

    }

    
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11220
<?php
$str = trim(fgets(STDIN));;
$n = intval(trim(fgets(STDIN)));
$p = $str[0];
$count = 1;
for($i = 1; $i < strlen($str); $i++){
  if($str[$i] != $str[$i-1]){
    $numArray[] = $count;
    $count = 0;
  }
  $count++;
}
if($count != 0){
  $numArray[] = $count;
}
$sum = 0;
foreach($numArray as $num){
  $sum+=floor($num/2);
}
if(count($numArray) == 1){
  echo floor(strlen($str) * $n / 2);
}elseif($str[0] == $str[strlen($str)-1]){
  $l = $numArray[0];
  $r = $numArray[count($numArray)-1];
  $diff = floor(($r+$l)/2) - floor($l/2) - floor($r/2); 
  echo $sum * $n + $diff * ($n-1);
}else{
  echo $sum * $n;
}


Measured memory_bytes: 4604
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll N; cin >> N;
    ll dp[101][4][4][4];
    rep(i, 0, 101){
        rep(j, 0, 4){
            rep(k, 0, 4){
                rep(l, 0, 4){
                    dp[i][j][k][l] = 0;
                }
            }
        }
    }
    rep(i, 0, 4){
        rep(j, 0, 4){
            rep(k, 0, 4){
                dp[3][i][j][k] = 1;
            }
        }
    }
    dp[3][0][1][2] = 0;
    dp[3][1][0][2] = 0;
    dp[3][0][2][1] = 0;
    rep(i, 4, 101){
        rep(j, 0, 4){
            rep(k, 0, 4){
                rep(l, 0, 4){
                    if(j == 0){
                        if(k == 1&&l == 2){
                            dp[i][j][k][l] = 0;
                            continue;
                        }else if(k == 2&&l == 1){
                            dp[i][j][k][l] = 0;
                            continue;
                        }
                    }else if(j == 1&&k == 0&&l == 2){
                        dp[i][j][k][l] = 0;
                        continue;
                    }
                    if(l == 2){
                        ll sum = 0;
                        rep(m, 0, 4){
                            if(m == 0){
                                if(j == 1||k == 1){
                                    continue;
                                }else{
                                    sum += dp[i-1][m][j][k];
                                    sum %= M;
                                }
                            }else{
                                sum += dp[i-1][m][j][k];
                                sum %= M;
                            }
                        }
                        dp[i][j][k][l] = sum;
                    }else{
                        ll sum = 0;
                        rep(m, 0, 4){
                            sum += dp[i-1][m][j][k];
                            sum %= M;
                        }
                        dp[i][j][k][l] = sum;
                    }
                }
            }
        }
    }
    ll h = 0;
    rep(i, 0, 4){
        rep(j, 0, 4){
            rep(k, 0, 4){
                //prt(i); prt(" "); prt(j); prt(" "); prt(k); prt(" "); 
                //prtl(dp[N][i][j][k]);
                h += dp[N][i][j][k];
            }
        }
    }
    h %= M;
    prt(h);
}



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

typedef long long ll;

ll gcd(ll a,ll b){ //最大公約数 O(log(min(a,b)))
    if(b==0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){ //最大公倍数
    ll gc=gcd(a,b);
    ll ans=(a*b)/gc;
    return ans;
}

int main(){
    ll N,M;
    cin >> N >> M;
    string s,t;
    cin >> s >> t;
    ll l=lcm(N,M);
    for(ll i=0;i<gcd(N,M);i++){
        ll x=gcd(N,M);
        ll n=i*N/x;
        ll m=i*M/x;
        if(s[n]!=t[m]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << l << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (auto i=(a); i<(b); ++i)
#define iter(it,c) for (auto it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 2147483647;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int arr[3] = {a,b,c};
    sort(arr,arr+3);

    cout << arr[0] + arr[1] << endl;

    return 0;
}



Measured memory_bytes: 256
def main():
	S = input()
	SL = int(S[0:2])
	SR = int(S[2:4])
	lm = False
	rm = False
	if 0 < SL < 13:
		lm = True
	if 0 < SR < 13:
		rm = True
	if lm and rm:
		print("AMBIGUOUS")
	elif lm and not rm:
		print("MMYY")
	elif not lm and rm:
		print("YYMM")
	else:
		print("NA")


if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int A, B; cin >> A >> B;
    if (A%3 == 0 or B%3 == 0 or (A+B)%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
struct node{
	int x,y;
};
int cmp(node a,node b){
	if(a.y==b.y){
		return a.x<b.x;
	}else
	return a.y<b.y;
}
using namespace std;
int main(){
	struct node p[100000];
	int n,m,a,b;
	cin>>n>>m;
	int Min=99999999;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		p[i].x=a;
		p[i].y=b;
		Min=min(Min,b);
	}
	sort(p,p+m,cmp);
	int sum=1;
	for(int i=1;i<m;i++){
		if(Min<=p[i].x){
			sum++;
			Min=p[i].y;
		}
	}
	cout<<sum<<endl;
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

int main() {
	ll n;
	cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; i+=2) {		
		int c = 0;
		for (int j = 1; j <= i; j+=2) {
			if (i % j == 0) c++;
		}
		if (c == 8) sum++;
	}
	cout << sum << endl;

	return 0;
}


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

using namespace std;
#define IOS cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

using ll = long long;
using ld = long double;


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

    vector<int>a(n), b(n), c(n);

    for(int i = 0; i < n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    int dp[n][3];

    dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];

    for(int i = 1; i < n; i++){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]); 
    }

    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<"\n";
    
        
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s=="Sunny")
		cout<<"Cloudy\n";
	else if(s=="Cloudy")
		cout<<"Rainy\n";
	else
		cout<<"Sunny\n";
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
AB = {i + 1: [] for i in range(10 ** 5)}
for _ in range(N):
    A, B = map(int, input().split())
    AB[A].append(B)

ans, h = 0, []
for i in range(1, M + 1):
    for b in AB[i]:
        heapq.heappush(h, -b)
    if len(h) > 0:
        ans -= heapq.heappop(h)

print(ans)


Measured memory_bytes: 26984
#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>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

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

int main() {
    ll n;
    cin >> n;
    Sieve s(1000005);
    auto fs = s.factor(n);
    int ans = 0;
    for (auto p : fs) {
      int x = p.second;
      int b = 1;
      while (b <= x) {
        x -= b;
        b++;
        ans++;
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7812