akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <list>
#include <set>
#include <map>
#include <string>
#include <sstream>

using namespace std;

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

    int D, N;
    cin  >> D >> N;

    if(D==0) {
        if(N==100)
            cout << 101;
        else
            cout << N;
    }
    else if(D==1)
    {
        if(N==100)
            cout << 10100;
        else {
            N *= 100;
            cout << N;
        }
    }
    else{
        if(N==100)
            cout << 1010000;
        else {
            N *= 10000;
            cout << N;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

    int x; cin>>x;
    
    if(x==2){
        cout << x << ln;
        return 0;
    }

    for(;;){
        for(int i=2; i<x; i++){
            if(x%i==0){
                break;
            }
            else if((i+1)==x){
                cout << x << ln;
                return 0;
            }
        }
        x++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;
struct edge { int v, w; };
const ll INF = LLONG_MAX / 3;
const int MOD = 1e9 + 7;
 
pair<vector<ll>, vector<int>> dijkstra(int N, vector<vector<edge>>& G, int s) {
    vector<ll> d(N, INF); d[s] = 0;
    vector<int> way(N); way[s] = 1;
    priority_queue<ll_i, vector<ll_i>, greater<ll_i>> pq;
    pq.push(ll_i(0, s));
    while (pq.size()) {
        ll_i p = pq.top(); pq.pop();
        int u = p.second;
        if (p.first > d[u]) continue;
        for (edge e: G[u]) {
            if (d[e.v] > d[u] + e.w) {
                d[e.v] = d[u] + e.w;
                way[e.v] = 0;
                pq.push(ll_i(d[e.v], e.v));
            }
            if (d[e.v] == d[u] + e.w)
                way[e.v] = (way[e.v] + way[u]) % MOD;
        }
    }
    return {d, way};
}
 
int main() {
    int N, M; cin >> N >> M;
    vector<int> a(M), b(M), c(M);
    rep(i, M) scanf("%d%d%d", &a[i], &b[i], &c[i]), a[i]--, b[i]--;
    vector<vector<edge>> G(N), _G(N);
    rep(i, M) G[a[i]].pb({b[i], c[i]}), _G[b[i]].pb({a[i], c[i]});
    auto z = dijkstra(N, G, 0), _z = dijkstra(N, _G, 1);
    vector<ll> d = z.first, _d = _z.first;
    vector<int> way = z.second, _way = _z.second;
    ll D = d[1]; int WAY = way[1];
    rep(i, M) {
        int u = a[i], v = b[i];
        if (d[u] + c[i] + _d[v] == D && (ll)way[u] * _way[v] % MOD == WAY)
            printf("SAD\n");
        else if (d[v] + c[i] + _d[u] < D)
            printf("HAPPY\n");
        else
            printf("SOSO\n");
    }
}

Measured memory_bytes: 19796
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


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

    int g= 0;
    REP(i,N) {
        int num;
        cin >> num;
        if (num %2 ==0) g++;
    }

    cout << int(pow(3,N)-pow(2,g)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INF 2001
#define WHITE 0
#define BLACK 1
#define GRAY 2

int MST(int);

int m[MAX][MAX]; //m[u][v]にuからvへの辺の重みを記録

int main(){
  int n, x;
  int i, j;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d", &x);
      if(x == -1) m[i][j] = INF;
      else m[i][j] = x;
    }
  }

  printf("%d\n", MST(n));

  return 0;
}

int MST(int n){
  int color[n]; //color[v]にvの状態を記録
  int d[n]; //MSTに属する頂点と属さない頂点をつなぐ辺の最小の重み
  int p[n]; //p[v]にvの親を記録
  int min, ans = 0;
  int u; //MSTに新たに加える頂点
  int i, v;

  //初期化
  for(i=0;i<n;i++){
    color[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;
  p[0] = -1; //始点は親なし

  while(1){
    min = INF; //重みの最小値を十分大きな値に設定
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < min){
	min = d[i];
	u = i;
      }
    }

    if(min == INF) break;

    color[u] = BLACK;

    for(v=0;v<n;v++){
      if(color[v] != BLACK && m[u][v] != INF){
	if(m[u][v] < d[v]){
	  d[v] = m[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }

  for(i=0;i<n;i++) ans += d[i];

  return ans;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> edg[N];
int dis[N][3];
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int n, m; cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    edg[u].push_back(v);
  }
  for(int i = 1; i <= n; i++) for(int j = 0; j < 3; j++) dis[i][j] = -3; // 设成-3是因为如果结果要除以3，不存在时-3/3=-1
  int s, t; cin >> s >> t;
  queue<pair<int, int>> q;
  dis[s][0] = 0;
  q.push({s, 0});
  while(!q.empty()) {
    const int cx = q.front().first, cy = q.front().second, ny = (cy + 1) % 3;
    q.pop();
    for(int i = 0; i < int(edg[cx].size()); i++) {
      const int nx = edg[cx][i];
      if(dis[nx][ny] == -3) {
        q.push({nx, ny});
        dis[nx][ny] = dis[cx][cy] + 1;
      }
    }
  }
  cout << dis[t][0] / 3 << "\n";
}

Measured memory_bytes: 7040
def main():
    N, M, K = (int(i) for i in input().split())
    ans = set()
    for i in range(M+1):
        for j in range(N+1):
            if N-j >= 0 and M-i >= 0:
                ans.add((N-j)*i + (M-i)*j)
    if K in ans:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 51176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;

int a[maxn];
int main()
{
	int n,k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> a[i];
	int ans = (n - 1) / (k - 1);
	if((n- 1) % (k - 1) == 0) cout << ans << endl;
	else cout << ans + 1 << endl;
}

Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [a, b, c] <- map strToInt . words <$> getLine
    -- 出力
    putStrLn $ if (c >= a && c <= b) then "Yes" else "No"


Measured memory_bytes: 508
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));

        while (true) {
            final String input = inputReader.readLine();
            if (input == null) {
                break;
            }
            String testString = input;
            while (true) {
                if (testString.matches("(^|.* )(the|this|that)( |\\.).*")) {
                    break;
                }
                char[] temp = testString.toCharArray();
                for (int i = 0; i < temp.length; i++) {
                    if (temp[i] < 'a' || temp[i] > 'z') continue;
                    final char c = (char) (temp[i] + 1);
                    temp[i] = c > 'z' ? 'a' : c;
                }
                testString = String.valueOf(temp);
            }
            System.out.println(testString);
        }
    }
}

Measured memory_bytes: 9856
import sys

fin = sys.stdin.readline
N = fin().split()[0]
a_list = [int(elem) for elem in fin().split()]

rain_list = []

all_rain = sum(a_list)

# 1つだけ除いた降雨量
all_wo_one = sum([a_list[i] for i in range(0, len(a_list)-1, 2)]) * 2

# 最後のやつの雨量
rain_list.append(str(all_rain - all_wo_one))
for each_rain in a_list[:-1][::-1]:
    rain_list.append(str(2*each_rain - int(rain_list[-1])))

print(' '.join(rain_list[::-1]))


Measured memory_bytes: 73316
#include <iostream>
#include <vector>

int main(int argc, char const *argv[]) {
  int N, M;
  std::cin >> N >> M;
  int a, b;
  std::vector<int> v(N+1);
  for (size_t i = 0; i < M; i++) {
    std::cin >> a >> b;
    ++v[a];
    ++v[b];
  }

  for (size_t i = 1; i < N+1; i++) {
    std::cout << v[i] << '\n';
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef pair < int, int> pii;
typedef pair < ll, ll> pll;
typedef pair < double, double > pdd;
typedef pdd pt;
typedef vector < int > vi;

const int N = 3e5 + 500;
const int M = 1e6 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const int OFF = (1 << LOG);

ll a[N], m1[N][2], m2[N][2], m1s[N][2], m2s[N][2],bst = 0;
int n;


int main(){
    scanf("%d", &n);
    ll sum = 0, st = 0, cur = 0;
    ll sol = (ll)INF * INF;
    for(int i = 0;i<n;i++){
        scanf("%lld", a + i);
        sum += a[i];
        while(cur <= sum / 2 && st < i){
            cur += a[st];st++;
        }
        m1[i][0] = cur;
        m2[i][0] = sum - cur;
        m1[i][1] = cur - a[st - 1];
        m2[i][1] = sum - cur + a[st - 1];
    }
    st = n - 1;
    sum = 0;cur = 0;
    for(int i = n - 1;i>=0;i--){
        sum += a[i];
        while(cur <= sum / 2 && st > i){
            cur += a[st];st--;
        }
        m1s[i][0] = cur;
        m2s[i][0] = sum - cur;
        m1s[i][1] = cur - a[st + 1];
        m2s[i][1] = sum - cur + a[st + 1];
    }
    for(int i = 1;i<n-2;i++){
        for(int k = 0;k<2;k++){
            for(int l = 0;l<2;l++){
                ll mx = max(max(m1[i][k], m2[i][k]), max(m1s[i + 1][l], m2s[i + 1][l]));
                ll mi = min(min(m1[i][k], m2[i][k]), min(m1s[i + 1][l], m2s[i + 1][l]));
                sol = min(sol, mx - mi);
            }
        }
    }
    printf("%lld\n", sol);
    return 0;
}


Measured memory_bytes: 20736
L = 100005
n,c = map(int,input().split(" "))

# arr[col] には、区間の始まり ==> 1,区間中 ==> 0,区間終わり ==> -1
# 連続した区間は結合した形で表現される

arr = [[0]*L for _ in range(c)]

for i in range(n):
    s,t,col = map(int,input().split(" "))
    arr[col-1][s-1] += 1
    arr[col-1][t-1] -= 1

imos = [0]*L

#全チャンネルを同時に考えたいもす法
for i in range(c):
    for p in range(L):
        if arr[i][p] == 1: imos[p] += 1    
        if arr[i][p] == -1: imos[p+1] -= 1


#累積和をとれば、区間内の最大のrec数は値のmax.
ans = 0
for i in range(1,L):
    imos[i] += imos[i-1]
    ans = max(ans, imos[i])

print(ans)


Measured memory_bytes: 29556
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,x,a[101],c=0,c1=0,i;
	scanf("%d%d%d",&n,&m,&x);
	for(i=0;i<m;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]<x)
			c++;
		if(a[i]>x)
			c1++;
	}
	if(c<c1)
		printf("%d",c);
	else
		printf("%d",c1);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main() {
	int n, a, b;
	unsigned long long va, vb;
	unsigned long long aa, bb;
	cin >> n;
	cin >> va >> vb;

	for (int i = 1; i < n; i++) {
		cin >> a >> b;
		aa = va / a;
		if (va % a != 0) {
			aa++;
		}

		bb = vb / b;
		if (vb % b != 0) {
			bb++;
		}

		if (aa > bb) {
			va = aa * a;
			vb = aa * b;
		}
		else {
			va = bb * a;
			vb = bb * b;
		}
	}
	cout << va + vb << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <deque>
#include <set>
using namespace std;
#define MOD 1000000007
long long kaizyo(int N);
long long P(int N, int M);
long long pow(int a, int n) {
	long long result = 1;
	for (int i = 0; i < n; i++) {
		result *= a;
		result = result % MOD;
	}
	return result;
}
int main()
{
	int D,T,S;
	cin >> D>>T>>S;
	if (S*T >= D) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}
long long kaizyo(int N) {
	long long result = 1;
	for (int i = 2; i <= N; i++) {
		result *= i;
		result = result % MOD;
	}
	return result;
}
long long P(int N,int M) {
	long long result = 1;
	for (int i = (N-M+1); i <= N; i++) {
		result *= i;
		result = result % MOD;
	}
	return result;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
typedef unsigned long long int   ull;
typedef long long int            ll;
#define pi                 acos(-1);
int main()
{
    int n,a,b,i,p=0;
    cin>>n>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%n==0)
        {
            p=1;
            cout<<"OK"<<endl;
            break;
        }
    }
    if(p==0)
        cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c,d;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d)){
		printf("%lld\n",max(a*b,c*d));
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			String[] list = br.readLine().split(" ");
			int num01 = Integer.parseInt(list[0]);
			int num02 = Integer.parseInt(list[2]);
			if (list[1].equals("+")) {
				System.out.println(num01 + num02);
			} else if (list[1].equals("-")) {
				System.out.println(num01 - num02);
			} else if (list[1].equals("*")) {
				System.out.println(num01 * num02);
			} else if (list[1].equals("/")) {
				System.out.println(num01 / num02);
			} else {
				break;
			}
		}
	}
}

Measured memory_bytes: 24344
#include <iostream>
#include<algorithm>
using namespace std;
int h[400000]= { 0 };


int main()
{
	char c;
	char old='1';
	int n = 1;
	int p, k;
	cin >> p >> k;
	for (int i = 1; i <= p; i++) {
		cin >> c;
		if (c == old)h[n]++;
		else {
			n++;
			h[n]++;
		}
		old = c;

	}
	if (n % 2 == 0)n++;
	int ans = 0;
	/*if (n <= 7){
		for (int i = 1; i <=11; i += 2) {
			int co = 0;
			for (int j = i; j <= i + 2 * k; j++) {
				co += h[j];
			}
			if (co > ans)ans = co;
		}
		cout << ans << endl;
	}*/
	//else {
//	int x = n - 2 * k - 1 + 1;
//	if (x < n)x = n;

		for (int i = 1; i <= n; i += 2) {
			int co = 0;
			for (int j = i; j <= i + 2 * k; j++) {
				co += h[j];
			}
			if (co > ans)ans = co;
		}
		cout << ans << endl;
	//}

}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;


int main() {
	
	int a, b;

	cin >> a >> b;

	printf("%d %d %lf\n", a / b, a%b, (double)a / (double)b);

	//system("pause");
	return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int n,dis[2][N],op;
vector<int>e[N];
void dfs(int u,int fa){
	dis[op][u]=dis[op][fa]+1;
	for(int v:e[u]){
		if(v!=fa) dfs(v,u);
 	}
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		e[u].pb(v),e[v].pb(u);
	} 
	dfs(1,0);
	op=1;
	dfs(n,0);
	int s=0;
	for(int i=1;i<=n;i++) s+=dis[0][i]<=dis[1][i];
	puts(s>n-s?"Fennec":"Snuke");
	return 0;
}

Measured memory_bytes: 14564
#include<iostream>
#include<string>
#include<algorithm>
#define INF 0x3f3f3f3f
std::string s;
int len;
int ans=INF;
int main(){
	std::cin>>s;
	len=s.size();
	for(int i=0;i<len;i++){
		if(s[i]!=s[i-1]) ans=std::min(ans,std::max(i,len-i));
	}
	ans=std::min(ans,len);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

#define rad (180/M_PI)
 
int main(void){
    double A,B,X;
    cin >> A >> B >> X;
    double sqa=A*B;
    X/=A;
    double half=rad*atan(B/A);
    if(X>=A*B/2){
        double wa=sqa-X;
        double b=wa/A*2.0;
        double ans=rad*atan(b/A);
        cout << ans << endl;
    }
    else{
        double wa=X;
        double b=wa/B*2.0;
        double ans=rad*atan(b/B);
        cout << 90.0-ans << endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int n;
    cin>>n;
    set<string> s;
    rep(i,n){
        string str;
        cin>>str;
        s.insert(str);
    }
    cout<<s.size()<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 19156
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;

int memo[210][210][210];

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int k; cin >> k;
    ll ans = 0;
    for(int i = 1; i <= k; ++i) {
        for(int j = 1; j <= k; ++j) {
            for(int l = 1; l <= k; ++l) {
                if(memo[i][j][l] != 0) ans += memo[i][j][l];
                else {
                    memo[i][j][l] = std::gcd(i, std::gcd(j, l));
                    ans += memo[i][j][l];
                }
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 37144
#!usr/bin/env python3

def string_two_numbers_spliter():
    x, y = [int(i) for i in input().split()]
    return x, y


def swap_two_numbers_asc(x, y):
    x, y = y, x
    return x, y


def main():
    while True:
        x, y = string_two_numbers_spliter()
        if x == 0 and y == 0:
            break
        if x > y:
            x, y = swap_two_numbers_asc(x, y)
        print('%d %d' % (x, y))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7760
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int a,b,k,cnt = 0;
  vector<int> n;
  cin >> a >> b >> k;
  for (int i = 1; i <= 100; i++){
    if (a % i == 0 && b % i == 0){
      n.push_back(i);
      cnt++;
    }
  }
  reverse(n.begin(), n.end());
  cout << n[k-1] << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }

signed main(){
	ll n,m; cin>>n>>m;
	priority_queue<ll> q;
	rep(i,0,n){
		ll a; cin>>a;
		q.push(a);
	}
	while(m--){
		ll k=q.top(); q.pop();
		k/=2; q.push(k);
	}
	ll ans=0;
	rep(i,0,n){
		ans+=q.top();
		q.pop();
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
  
  int N,X;
  cin >> N >> X;
  
  int c = 1;
  int D = 0;
  
  for(int i = 0; i < N; i++){
    int L;
    cin >> L;
    D = D + L;
    
    if(D > X){
      break;
    }
    c++;
  }
    cout << c << endl;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(2)]

    max = 0

    for i in range(n):
        tmp = 0
        for j in range(i + 1):
            tmp += a[0][j]
        for j in range(i, n):
            tmp += a[1][j]

        if tmp > max:
            max = tmp

    print(max)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define pb push_back

const int mod = 1e9 + 7;
const int maxn = 1e3 + 10;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);

struct Edge{
	int v,next;
}edge[maxn*maxn];
int head[maxn*maxn],tot=0;
int n,in[maxn*maxn];
int a[maxn][maxn];
int id[maxn][maxn];
int day[maxn*maxn];

void init(int n){
	tot=0;
	for(int i=1;i<=n;i++) head[i]=-1;
}
void add(int u,int v){
	edge[tot].v=v;
	edge[tot].next=head[u];
	head[u]=tot++;
}
void tuopu(int n)
{
	queue<int>Q;
	for(int i=1;i<=n;i++)
	{
		if(in[i]==0)
		{
			Q.push(i); 
			day[i] = 1;
			//cout << i << endl;
		}
	}
	while(!Q.empty())
	{
		int u=Q.front();
		Q.pop();
		for(int i=head[u];i!=-1;i=edge[i].next)
		{
			int v=edge[i].v;
			//cout << v << endl;
			in[v]--;
			day[v] = day[u] + 1;
			if(!in[v])
			{
				Q.push(v);
			}
		}
	}
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
   	cin >> n;
   	rep(i,1,n) rep(j,1,n-1) cin >> a[i][j];
   	int cnt = 0;
   	rep(i,1,n) rep(j,i + 1, n) id[i][j] = id[j][i] = ++cnt;
   	init(cnt);
   	rep(i,1,n) {
   		rep(j,2,n - 1) {
   			//cout << id[i][a[i][j - 1]] << " " << id[i][a[i][j]] << endl;
   			add(id[i][a[i][j - 1]],id[i][a[i][j]]);
   			in[id[i][a[i][j]]]++;
   		}
   	}
   	tuopu(cnt);
   	rep(i,1,cnt){
   		if(in[i]){
   			cout << -1 << endl;
   			return 0;
   		}
   	}
   	int ans = 0;
   	rep(i,1,cnt) ans = max(ans,day[i]);
   	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27904
#include <bits/stdc++.h>
using namespace std;
#define H 200000
int v[H+1];

int main(void){
    for(size_t i=0; i<H+1; i++){ v[i] = INT_MAX; }
    int h, w, n, x, y;
    scanf("%d %d %d\n", &h, &w, &n);
    for(int i=0; i<n; i++){
        scanf("%d %d\n", &x, &y);
        v[x] = y<v[x] ? y : v[x];
    }
    int right = 1;
    for(int x=1; x<h; x++){
        if(v[x+1]<right+1){
            printf("%d\n", x);
            return 0;
        }else if(v[x+1]>right+1){
            right++;
        }
    }
    printf("%d\n", h);
    return 0;
}


Measured memory_bytes: 1024
n, a, b = map(int, input().split())
li = [b - 1, n - a]
if (b - a) % 2 == 1:
    li.append((n - (a + (n - b))) // 2 + (n - b) + 1)
    li.append((b - (a - 1) - 1) // 2 + (a - 1) + 1)
else:
    li.append((b - a) // 2)
print(min(li))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main() {
    fastio
	ll n,t,i,j,x,k;
	cin>>n;
	
	ll a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	
	x=0;
	for(i=0;i<n;i++){
	    for(j=i+1;j<n;j++){
	        for(k=j+1;k<n;k++){
	            if(a[i]==a[j] || a[j]==a[k] || a[i]==a[k])
	            continue;
	            
	            if(a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[i]+a[k]>a[j])
	            x++;
	        }
	    }
	}
	cout<<x<<endl;
	
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 20000000000000000
#define mod 998244353
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 200005

ll a[ma],tr[ma*3],b[ma];

void update(ll n,ll b,ll e,ll x,ll val)
{
    if(b==e)
    {
        tr[n]=val;
        return;
    }
    ll mid=(b+e)>>1,l=n*2,r=l+1;
    if(x<=mid)update(l,b,mid,x,val);
    else update(r,mid+1,e,x,val);
    tr[n]=max(tr[l],tr[r]);
}

ll query(ll n,ll b,ll e,ll x,ll y)
{
    if(b>y||e<x)return 0;
    if(b>=x&&e<=y)return tr[n];
    ll mid=(b+e)>>1,l=n*2,r=l+1;
    ll p=query(l,b,mid,x,y);
    ll p1=query(r,mid+1,e,x,y);
    return max(p,p1);
}

vector<ll>adj[ma];
void dfs(ll u,ll par)
{
    ll pre=query(1,1,200000,a[u],a[u]);
    ll p=query(1,1,200000,1,a[u]-1)+1;
    if(p>pre)
    update(1,1,200000,a[u],p);
    b[u]=tr[1];
    for(auto p:adj[u])
    {
        if(p==par)continue;
        dfs(p,u);
    }
    if(p>pre)
    update(1,1,200000,a[u],pre);
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll i,j,x,y,n;
    while(cin>>n)
    {
        map<ll,ll>mp;
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
            mp[a[i]];
        }
        ll cn=0;
        for(auto x:mp)mp[x.ff]=++cn;
        for(i=1;i<=n;i++)a[i]=mp[a[i]];

        for(i=1;i<n;i++)
        {
            cin>>x>>y;
            adj[x].pb(y);adj[y].pb(x);
        }
        dfs(1,-1);
        for(i=1;i<=n;i++)cout<<b[i]<<endl;

    }
    return 0;
}


Measured memory_bytes: 41996
#include<stdio.h>

int makenum(int num,int n);
int if753(int num);

int main()
{
    int n,i,j=0,flag=1;
	scanf("%d",&n);
	printf("%d",makenum(3,n)+makenum(5,n)+makenum(7,n));
}

int makenum(int num,int n)
{
	if(num>n)return 0;
	if(num>100000000)return if753(num);
	else return (if753(num)+makenum(num*10+3,n)+makenum(num*10+5,n)+makenum(num*10+7,n));
}

int if753(int num)
{
	int buk[10]={0};
	while(num!=0)
	{
		buk[num%10]++;
		num/=10;
	}
	if((buk[3])&&(buk[5])&&(buk[7]))return 1;
	else return 0;
}

Measured memory_bytes: 128
import itertools
n = int(input())
a = [0] * 5
for i in range(n):
    s = input()
    if s[0] == "M":
        a[0] += 1
    if s[0] == "A":
        a[1] += 1
    if s[0] == "R":
        a[2] += 1
    if s[0] == "C":
        a[3] += 1
    if s[0] == "H":
        a[4] += 1
ar = list(itertools.combinations([0,1,2,3,4], 3))
ans = 0
for i in range(len(ar)):
    ans += a[ar[i][0]] * a[ar[i][1]] * a[ar[i][2]]
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int A,B,ans=0,tap=1;
    cin>>A>>B;
    for(;;){
        if(tap>=B)break;
        tap+=A-1;
        ans++;
    }
    cout<<ans<<endl;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;
int calc_color(int rate){
    int color;
    if(rate<400){
        color=0;
    }
    else if(rate<800){
        color=1;
    }
    else if(rate<1200){
        color=2;
    }
    else if(rate<1600){
        color=3;
    }
    else if(rate<2000){
        color=4;
    }
    else if(rate<2400){
        color=5;
    }
    else if(rate<2800){
        color=6;
    }
    else if(rate<3200){
        color=7;
    }
    else{
        color=8;
    }
    return color;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
int a;
map<int,int> rate;
rep(i,n){
    cin>>a;
    rate[calc_color(a)]++;
}
int ans=0;
int god=0;
for(auto v:rate){
    if(v.first==8){
        god+=v.second;
    }
    else{
        ans++;
    }
}
int o=god>0 ?1:0;
cout<<max(ans,o)<<" "<<ans+god<<endl;
return 0;
}

Measured memory_bytes: 256
n = int(input())
trumplist = []
for _ in range(n):
	trumplist.append(input())

mark_list = ["S","H","C","D"]

for mk in mark_list:
	for i in range(1,14):
		chk_trump = str.format("{0} {1}",mk,str(i))
		istrump = False
		for j in trumplist:
			if j == chk_trump:
				istrump = True
				break
		if istrump == False:
			print(chk_trump)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
#define FOR(i, n) for(ll i = 0; i < n; i++)
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);    
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll m = n/k;
    ll a = n - (m * k);
    cout << min(a, abs(a-k)) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	// freopen("settling.in", "r", stdin);
	// freopen("settling.out", "w", stdout);

	int n;
	cin >> n;

	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++)
		cin >> a[i] >> b[i];

	for(int i = 0; i + 2 < n; i++){
		if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  string answer = "Yes";
  if (x - r < 0 || y - r < 0 || x + r > W || y + r > H) {
    answer = "No";
  }
  cout << answer << endl;
  return 0;
}



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

int D;
int c[26];
int s[365][26];

long long calc(vector<int>& t, int d) {
  vector<int> last(26);
  long long ans = 0;
  rep(i, d) {
    int x = t[i];
    ans += s[i][x];
    ans -= c[x] * (i - last[x]) * ((i - last[x]) - 1) / 2;
    last[x] = i;
  }
  rep(i, 26) { ans -= c[i] * (25 - last[i]) * ((26 - last[i]) - 1) / 2; }
  return ans;
}

long long calc1(vector<int>& last, int n, int d) {
  long long ans = s[d][n];
  rep(i, 26) ans -= c[i] * (d - last[i]);
  return ans;
}

int main(){
  cin >> D;
  rep(i, 26) cin >> c[i];
  rep(i, D) rep(j, 26) cin >> s[i][j];

  vector<int> t(D); 
  rep(i, D) {
    cin >> t[i];
    t[i]--;
  }
  vector<int> last(26, -1);
  long long ans = 0;
  rep(i, D) {
    last[t[i]] = i;
    ans += calc1(last, t[i], i);
    cout << ans << endl;
  }
}


Measured memory_bytes: 3676
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def solve(N):

    yaku = np.zeros(N + 1, np.int32)

    for i in range(1, N + 1):
        for j in range(i, N + 1, i):
            yaku[j] += 1

    ans = 0
    for i in range(1, N + 1):
        ans += i * yaku[i]

    return ans


def main():

    N = in_n()
    print(solve(N))


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4,)')(solve)
    cc.compile()


if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import solve
    main()


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

#define LL long long
#define DD long double

#define M 1000000007
#define INF 1e18

void setIO(string s = "") { 
  cin.sync_with_stdio(0); cin.tie(0);
  if (s.size()) s += ".in", freopen(s.c_str(), "r", stdin);
}

int tt = 1;
void solve() {
  int a, b;
  cin >> a >> b;
  int tmp = a;
  a = max(a, b);
  b = min(tmp, b);
  string s = "";
  for (int i = 0; i < a; i++) {
    s += to_string(b);
  }
  cout << s << endl;
}

int main() {
  setIO();
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3704
def main():
    from itertools import accumulate

    n, *a = map(int, open(0).read().split())
    x = a[:n]
    y = a[n:]
    ans = 0
    for i in range(n):
        c = sum(x[:i + 1]) + sum(y[i:])
        ans = max(ans, c)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
ans = 0
for k in range(1,N+1):
    ans += k*(k+1)
ans = ans//2

for _ in range(N-1):
    u,v = list(map(int,input().strip().split()))
    u,v = sorted([u,v])
    ans -= u*(N-v+1)
print(ans)

Measured memory_bytes: 74636
s = list(str(input()))

s = list(map(int,s))

n = len(s)

l = []

for i in range(n-2):
	a = 100 * s[i] + 10 * s[i+1] + s[i+2]
	l.append(a)
    
for i in range(n-2):
	l[i] -= 753
	l[i] = abs(l[i])
    
print(min(l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b=0;
    scanf("%d %d",&a,&b);
    if(a+b>=a*b&&a+b>=a-b){
        printf("%d",a+b);
    }else if(a*b>=a+b&&a*b>=a-b){
        printf("%d",a*b);
    }else if(a-b>=a*b&&a-b>=a+b){
        printf("%d",a-b);
    }
    return 0;
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    long long sum = 0;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                sum += __gcd(__gcd(i, j), k) * 1LL;
            }
        }
    }
    cout << sum << '\n';
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>

using ll = unsigned long long;
using namespace std;

int main(void) {

    int* a = new int[5];
    for(int j =0; j < 5; ++j) {
        cin >> a[j];
    }

    int min_ix = -1;
    int min_val = 999;
    int min_check = 0;

    for(int s=0;s<5;++s){
        min_check = a[s]%10;
        // cout << "mc:" << min_check << endl;
        if(min_check != 0 && min_check < min_val) {
            // cout << "minix:chg" << min_ix << endl;
            min_ix = s;
            min_val = min_check;
            //  cout << "minix:chg:to" << min_ix << endl;

        } 
    }

    // cout << "minix:" << min_ix << endl;

    int total =0;
    for(int u = 0; u < 5; ++u) {
        if(min_ix!=u) {
            int c = a[u]%10;
            if(c == 0) {
                total+=a[u];
            }else { 
                total+= a[u] + (10-c);
            }
        } else {
            total+= a[u];
        }
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353

using namespace std;
typedef pair<llint, llint> P;

string s;
llint K;
llint dp[305][305][305];
llint sum[305][305], sum2[305][305];
vector<llint> vec;

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s >> K;
	llint n = s.size();
	s += '0';
	
	llint cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '1') cnt++;
		else{
			vec.push_back(cnt);
			cnt = 0;
		}
	}
	
	//for(int i = 0; i < vec.size(); i++) cout << vec[i] << " "; cout << endl;
	
	llint m = vec.size();
	K = min(K, n);
	dp[0][0][0] = 1;
	for(int i = 1; i <= m; i++){
		for(int k = 0; k <= K; k++){
			for(int j = 0; j <= n; j++){
				sum[j][k] = sum2[j][k] = 0;
			}
		}
		for(int k = 0; k <= K; k++){
			sum[0][k] = dp[i-1][0][k], sum2[0][k] = dp[i-1][0][k];
			for(int j = 1; j <= n; j++){
				if(j+k <= K) sum[j][k] = sum[j-1][k] + dp[i-1][j][j+k], sum[j][k] %= mod;
				sum2[j][k] = sum2[j-1][k] + dp[i-1][j][k], sum2[j][k] %= mod;
			}
		}
		llint a = vec[i-1];
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= K; k++){
				if(k-j >= 0){
					dp[i][j][k] = sum[j][k-j];
					dp[i][j][k] += sum2[min(n,j+a)][k] - sum2[j][k] + mod, dp[i][j][k] %= mod;
				}
			}
		}
		
		/*for(int j = 0; j <= n; j++){
			for(int k = 0; k <= K; k++){
				cout << dp[i][j][k] << " ";
			}
			cout << endl;
		}
		cout << endl;*/
	}
	
	llint ans = 0;
	for(int i = 0; i <= K; i++) ans += dp[m][0][i], ans %= mod;
	cout << ans << endl;
	
	return 0;
}

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

int main() {
    ll N,K;
    cin >> N >> K;
    vector<pair<ll,ll>> res;
    rep(i,N) {
        ll a,b; cin >> a >> b;
        res.push_back(make_pair(a,b));
    }
    sort(res.begin(),res.end());
    ll ans;
    ll sum = 0;
    ll i = 0;
    while(i < N && K > sum) {
        sum += res.at(i).second;
        i++;
    }
    ans = res.at(i-1).first;
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;

#define ll long long
#define ull unsigned long long

int main()
{
	long n, m;
	cin >> n >> m;
	long left = 0, right = n - 1;
	for (long i = 0; i < m; i++)
	{
		long l, r;
		cin >> l >> r;
		l--;
		r--;
		if (l > left)
			left = l;
		if (r < right)
			right = r;
	}

	printf("%ld", right >= left ? right - left + 1 : 0);

	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for i in range(m)]
bc.sort(key=lambda x:x[1], reverse=True)
flg=0
cnt=0
for i in range(n):
  if bc[flg][1] > a[i]:
    a[i] = bc[flg][1]
    cnt+=1
    if cnt==bc[flg][0]:
      flg+=1
      cnt=0
  else:
    flg+=1
    cnt=0
  if flg == m:
    break
print(sum(a))

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

using int64 = long long;

int64 Count(int64 n, int64 a, int64 b) {
  if (a > b)
    return 0;
  if (n == 1)
    return (a == b) ? 1 : 0;
  if (n == 2)
    return 1;

  int64 min = a * (n - 1) + b;
  int64 max = b * (n - 1) + a;
  return max - min + 1;
}

int main() {
  int64 n, a, b;
  cin >> n >> a >> b;
  cout << Count(n, a, b) << "\n";
  return 0;
}


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

int main(void) {
	int n, x, cnt = 0;
	
	cin >> n >> x;
	
	vector<int> a(n);
	
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	sort(a.begin(), a.end());
	
	for (int i = 0; i < n; i++) {
		x -= a[i];
		if (i == n-1 && x == 0) {
			cnt++;
		} else if (i == n-1 && x!=0) {
			break;
		} else if (x >= 0) {
			cnt++;
		} else {
			break;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

signed main() {
  ll H;
  cin >> H;

  ll n = 0;
  while (H > 0) {
    H /= 2;
    n++;
  }
  ll ans = pow(2, n) - 1;
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	while (scanf("%d", &n) == 1) {
		int total = 0;
		for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
		for (int k = 0; k < 10; k++) {
		for (int l = 0; l < 10; l++) {
			if (i+j+k+l == n)
				total++;
		}}}}
		printf("%d\n", total);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int n,k,q;
	cin>>n>>k>>q;
	map<int,int> p{};
	vector<int> a(q);
	for(int i=0;i<q;++i)
	{
		cin>>a[i];
		p[a[i]-1]+=1;
	}
	for(int i=0;i<n;++i)
	{
		if((k-(q-p[i]))>0)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;


int main() {
    int n,m,sum = 0;
    cin >> n >> m;
    double a[n];
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    double line = sum/(4*m);
    Sort(a,n)
    int ans = 0;
    rep(i,n) {
        if(a[i]>=sum/(4.0*m))ans++;
    }
    if(ans >=m) {
        cY
    }else {
        cN
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, A, B;
	cin >> N >> A >> B;
	int rsl1, rsl2;
	rsl1 = min(A, B);
	rsl2 = max(0, min(A, B) - (N - max(A, B)));
	cout << rsl1 << " " << rsl2 << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int N = 1e5;

int n,m,temp,connected;
int u[N] , v[N] , ans[N];
int parent[N],size[N];

void init(){
   for(int i = 1;i <= n;i++){ parent[i] = i; size[i] = 1 ; }
   connected = n;  
}

int getparent2(int k){
   while(k!=parent[k]){ parent[k] = parent[parent[k]]; k = parent[k]; }
   return k;
}

int getparent(int x){
   while(x!=parent[x]) x = parent[x];
   return x;
}

int getsize(int x){
   return size[getparent(x)];
}

void unite(int x , int y){

   int par1 = getparent(x);
   int par2 = getparent(y);
 if(par2==par1) return;
 connected--;
 if(size[par1] > size[par2])
      swap(par1,par2);
  temp-=size[par1]*size[par2];
  size[par2]+=size[par1];
  size[par1] = 0;
  parent[par1] = parent[par2]; 
}

int32_t main() {
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt","rb",stdin);
     // #endif   
 
  cin >> n >> m;
  temp = n*(n-1)/2;
  
init();  
for(int i = 1;i <= m; i++) cin >> u[i] >> v[i] ;
   for(int i = m; i >= 1; i--){
      ans[i] = temp;
      unite(u[i],v[i]); 
   }
 for(int i=1;i <=m;i++) cout << ans[i] << "\n";
return 0;
}

Measured memory_bytes: 5248