akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int num =1;
        
        for(int i = 0;i<n;i++){
            num = Math.min(num*2,num+k);
            //System.out.println(num);
        }
        System.out.println(num);
    }
}




Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P, vector<P>, greater<P>> SPQ;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const ll inf = 1001001001001001;
const int INF = 1001001001;
const int mod = 1000000007;
const double pi = 3.14159265358979323846;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> void out(T a) { cout << a << endl; }
template<class T> void outp(T a) { cout << '(' << a.fi << ',' << a.se << ')' << endl; }
template<class T> void outvp(T v) { rep(i, v.size())outp(v[i]); }
template<class T> void outv(T v) { rep(i, v.size()) { if (i)cout << ' '; cout << v[i]; }cout << endl; }
template<class T> void outvv(T v) { rep(i, v.size()) { rep(j, v[i].size()) { if (j)cout << ' '; cout << v[i][j]; }cout << endl; } }
int main() {
  int a,b; cin>>a>>b;
  if(a>b){
    rep(i,a) cout<<b;
  }
  else{
    rep(i,b) cout<<a;
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
bool isOK(int c, int a, int b) {
  return !(c < a + b && a < c + b && b < a + c);
}

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int left = j;
      int right = N;
      while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (isOK(L[mid], L[i], L[j]))
          right = mid;
        else
          left = mid;
      }
      if (j < left) ans += left - j;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	int X;
	cin >> X;
	vector<int>A(M);
	vector<bool>Cost(N + 1, false);
	for (int i = 0; i < M; i++) {
		cin >> A.at(i);
		Cost.at(A.at(i)) = true;
	}
	int ans_to_zero = 0, ans_to_N = 0;
	for (int i = 0; i <= X; i++) {
		if (Cost.at(i)) ans_to_zero++;
	}
	for (int i = X; i <= N; i++) {
		if (Cost.at(i)) ans_to_N++;
	}
	cout << min(ans_to_N, ans_to_zero) << endl;
}

Measured memory_bytes: 256
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, n) {cin >> a[i];}
#define readmat(a, n, m) int a[(n) + 1][(m) + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    reads(s) reads(t)

    int l1 = sz(s); int l2 = sz(t);

    s = " " + s; t = " " + t;

    int dp[l1 + 1][l2 + 1] = {};

    fori (i, 1, l1)
    {
        fori (j, 1, l2) 
        {
            if(s[i] == t[j]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max (dp[i-1][j], dp[i][j-1]);
        }   
    }

    string ans = "";

    int i = l1, j = l2;

    while(sz(ans) != dp[l1][l2])
    {
        if(max(dp[i-1][j], dp[i][j-1]) == dp[i][j])
        {
            if(dp[i][j] == dp[i-1][j]) i--;
            else j--;
        }

        else
        {
            ans += s[i]; i--; j--;
        }

    }

    reverse(all(ans)); print(ans)

    return 0;
}


Measured memory_bytes: 73920
#include<stdio.h>

int main(void)
{
  int a, b, i;
  scanf("%d%d", &a, &b);
  if(a < b){
    for(i = 0; i < b; i++){
      printf("%d", a);
    }
    printf("\n");
  }else{
    for(i = 0; i < a; i++){
      printf("%d", b);
    }
    printf("\n");
  }
  return 0;
}

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



int main(){ 
    double pi = 3.141592653589793238462643383279;
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double angle, x, y, ans;
    angle = 11 * M / 720.0 - H / 12.0;
    angle *= pi * 2;

    x = A - B * cos(angle);
    y = B * sin(angle);

    ans = sqrt(x * x + y * y);

    cout << setprecision(21);
    cout << ans << endl;

}

Measured memory_bytes: 4164
//0506-String
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)	for(int i=0;i<n;i++)
string to_string(int a){
	stringstream ss;
	ss<<a;
	return ss.str();
}
int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)	return 0;
		string s;
		cin>>s;
		int cnt;
		string temp;
		rep(i,n){
			string safter;
			cnt=0;
			temp=s[0];
			int t=(int)s.size();
			rep(j,t){
				if(s[j]==temp[0]){
					cnt++;
				}
				else{
					safter+=to_string(cnt);
					safter+=temp;
					cnt=1;
					temp=s[j];
				}
			}
			safter+=to_string(cnt);
			safter+=temp;
			s=safter;
		}
		cout<<s<<endl;
	}
}
			
			

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

int main(){
  int A;
  int B;
  int C;
  cin >> A;
  cin >> B;
  cin>> C;
  vector <int> seged_vector;
  seged_vector.push_back(A+B);
  seged_vector.push_back(A+C);
  seged_vector.push_back(B+A);
  seged_vector.push_back(B+C);
  seged_vector.push_back(C+A);
  seged_vector.push_back(C+B);
  int seged=seged_vector[0];
  for(int i=1;i<seged_vector.size();i++){
    if(seged>seged_vector[i]){
      seged=seged_vector[i];
    }
  }
  cout << seged;
	return 0;
}


Measured memory_bytes: 3604
import math
n = int(input())
a = list(map(int, input().split()))
f = [0]*10**7
def fctr_d(n):
    c = 0
    r = int(n**0.5)
    for i in range(2, r+2):
        while n % i == 0:
            c += 1
            n = n//i
        if c != 0:
            if f[i] != 0:
                return False
            else:
                f[i] = True
                c = 0
    if n != 1:
        if f[n] != 0:
            return False
        else:
            f[n] = True
    return True


pairwise_flag = True
for i in range(n):
    m = a[i]
    if not fctr_d(m):
        pairwise_flag = False
        break

setwise_flag = True
gcd = a[0]
for i in range(1, n):
    gcd = math.gcd(gcd, a[i])
if gcd != 1:
    setwise_flag = False

if pairwise_flag:
    print("pairwise coprime")
else:
    if setwise_flag:
        print("setwise coprime")
    else:
        print("not coprime")





Measured memory_bytes: 470380
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int a[200000];
int b[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    for (int i = 0; i < n; i++)
        a[i] = gi();
    memcpy(b, a, sizeof(a));
    sort(a, a+n);
    if (a[n-1] == a[n-2])
        for (int i = 0; i < n; i++)
            printf("%d\n", a[n-1]);
    else
        for (int i = 0; i < n; i++)
            printf("%d\n", b[i] == a[n-1] ? a[n-2] : a[n-1]);

    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define N 200009
using namespace std;

int n,rt,last,a[N],fa[N],fst[N],nxt[N],tg[N],f[N],g[N],bo[N];
void dfs(int x){
	int y;
	for (y=fst[x]; y; y=nxt[y]) if (!bo[y]) dfs(y);
	for (y=fst[x]; y; y=nxt[y]) if (!bo[y]) tg[f[y]]=x;
	for (y=0; tg[y]==x; y++);
	f[x]=y;
	for (y++; tg[y]==x; y++);
	g[x]=y;
}
int main(){
	scanf("%d",&n);
	int i;
	for (i=1; i<=n; i++){
		scanf("%d",&fa[i]);
		nxt[i]=fst[fa[i]]; fst[fa[i]]=i;
	}
	for (i=1; !bo[i]; i=fa[i]) bo[i]=1;
	memset(bo,0,sizeof(bo));
	for (; !bo[i]; i=fa[i]) bo[i]=1;
	rt=last=i;
	for (; bo[i]==1; last=i,i=fa[i]){ dfs(i); bo[i]=2; }
	for (a[rt]=f[rt],i=rt; fa[i]!=rt; i=fa[i])
		a[fa[i]]=(a[i]==f[fa[i]]?g[fa[i]]:f[fa[i]]);
	if (a[last]!=a[rt]){
		puts("POSSIBLE"); return 0;
	}
	for (a[rt]=g[rt],i=rt; fa[i]!=rt; i=fa[i])
		a[fa[i]]=(a[i]==f[fa[i]]?g[fa[i]]:f[fa[i]]);
	puts(a[last]==f[rt]?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define iter(i,a,b) for(i=a;i<b;i++)
bool f(int [],int,int);
int abs(int);
bool f(int arr[],int g,int h)
{
  int j;
  for(j=0;j<g;j++)
  {
    if(h==arr[j])
       {
         return true;
       }
       
  }
   
       return false;
}


int abs(int a)
{
  if(a>0)
    return a;
  else return -a;
}


int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
{
int n,m,i;
      cin>>n>>m;
      int a[m];
      iter(i,0,m)
        cin>>a[i];
      sort(a,a+m);
      int mn=100000;
      if(m==0)
        cout<<n;
      else
      {
        for(i=-1000;i<=1000;i++)
        {
          if((f(a,m,i)==false)&&(abs(n-i)<mn))
            mn=abs(n-i);
        }
        
        for(i=-1000;i<=1000;i++)
        {
          if((f(a,m,i)==false)&&(abs(n-i)==mn))
          {
            cout<<i;
            break;
          }
        }
      }    

    
   

}

return 0;
}






Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;
int main() {
  int h, w, m;
  cin >> h >> w >> m;
  vector<int> hc(h + 1), wc(w + 1);
  vector<pair<int, int>> p(m);
  for (int i = 0; i < m; ++i)
    cin >> p[i].first >> p[i].second, hc[p[i].first]++, wc[p[i].second]++;
  set<pair<int, int>> s(p.begin(), p.end());
  int hm = *max_element(hc.begin(), hc.end());
  int wm = *max_element(wc.begin(), wc.end());
  vector<int> vh, vw;
  for (int i = 1; i <= h; ++i)
    if (hc[i] == hm)
      vh.emplace_back(i);
  for (int i = 1; i <= w; ++i)
    if (wc[i] == wm)
      vw.emplace_back(i);
  int sh = vh.size(), sw = vw.size();
  if (sh * sw > m) {
    cout << hm + wm;
    return 0;
  }
  for (int i : vh)
    for (int j : vw)
      if (!s.count({i, j})) {
        cout << hm + wm;
        return 0;
      }
  cout << hm + wm - 1;
}

Measured memory_bytes: 26092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto 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; }

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

    map<ll, ll> prime;
    eFOR1(j,n){
        ll N = j;
        for (ll i = 2; i * i <= N; i++) {
            while (N % i == 0) {
                prime[i]++;
                N /= i;
            }
        }
        if (N != 1) prime[N]++;
    }
    ll ans = 1;
    for (auto p : prime) {
        ans *= p.second + 1LL;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<iostream>
using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  for (int i=0 ; i<S.size() ; i++) {
    bool flag = true;
    for (int j=0 ; j<S.size() ; j++) {
      if (S[(j+i)%S.size()] != T[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = list(map(int,input().split()))
Network = UnionFind(N)

AB = []
for i in range(M):
    AB.append(list(map(int,input().split())))

out = [0]*(M+1)
cnt = N*(N-1)//2
out[-1]=cnt
for i in range(M):
    A,B = AB[M-1-i]
    if Network.same(A-1, B-1):
        out[M-1-i] = cnt
        Network.union(A-1, B-1)
    else:
        cnt += -1*Network.size(A-1)*Network.size(B-1)
        out[M-1-i] = cnt
        Network.union(A-1, B-1)
for i in range(1,M+1):
    print(out[i])

Measured memory_bytes: 97840
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
#define all(x) (x).begin(), (x).end()


int main() {
	ifstream fin("Text.txt");
	DT i, j, q;
	DT n, m;
	cin >> n;
	vector<char> vec(n + 2);
	vector<int> ans(n + 2),ans2(n+2),ans3(n+2),ans4(n+2);
	forn (i, n) 
		cin >> vec[i + 1];

	ans[1] = 1;
	ans[2] = 1;

	ans[0] = (vec[1] == 'o' ? 1 : 2);

	forc(i,2,n) {
		if (vec[i] == 'o') {
			if (ans[i] == 1) {
				ans[i + 1] = ans[i - 1];
			}
			else {
				ans[i + 1] = 3 - ans[i - 1];
			}
		}
		else {
			if (ans[i] == 2) {
				ans[i + 1] = ans[i - 1];
			}
			else {
				ans[i + 1] = 3 - ans[i - 1];
			}
		}
	}
	if (ans[1] == ans[n + 1] && ans[0]==ans[n]) {
		forc(i, 1, n) {
			if (ans[i] == 1)
				cout << "S" ;
			else
				cout << "W" ;
		}

		cout << endl;
		return 0;
	}

	ans2[1] = 1;
	ans2[2] = 2;
	
	ans2[0] = (vec[1] == 'o' ? 2 : 1);

	forc(i, 2, n) {
		if (vec[i] == 'o') {
			if (ans2[i] == 1) {
				ans2[i + 1] = ans2[i - 1];
			}
			else {
				ans2[i + 1] = 3 - ans2[i - 1];
			}
		}
		else {
			if (ans2[i] == 2) {
				ans2[i + 1] = ans2[i - 1];
			}
			else {
				ans2[i + 1] = 3 - ans2[i - 1];
			}
		}
	}

	if (ans2[1] == ans2[n + 1] && ans2[0] == ans2[n]) {
		forc(i, 1, n) {
			if (ans2[i] == 1)
				cout << "S";
			else
				cout << "W";
		}

		cout << endl;
		return 0;
	}

	ans3[1] = 2;
	ans3[2] = 1;
	
	ans3[0] = (vec[1] == 'o' ? 2 : 1);

	forc(i, 2, n) {
		if (vec[i] == 'o') {
			if (ans3[i] == 1) {
				ans3[i + 1] = ans3[i - 1];
			}
			else {
				ans3[i + 1] = 3 - ans3[i - 1];
			}
		}
		else {
			if (ans3[i] == 2) {
				ans3[i + 1] = ans3[i - 1];
			}
			else {
				ans3[i + 1] = 3 - ans3[i - 1];
			}
		}
	}
	if (ans3[1] == ans3[n + 1] && ans3[0] == ans3[n]) {
		forc(i, 1, n) {
			if (ans3[i] == 1)
				cout << "S";
			else
				cout << "W";
		}
		cout << endl;
		return 0;
	}

	ans4[1] = 2;
	ans4[2] = 2;

	ans4[0] = (vec[1] == 'o' ? 1 : 2);
	
	forc(i, 2, n) {
		if (vec[i] == 'o') {
			if (ans4[i] == 1) {
				ans4[i + 1] = ans4[i - 1];
			}
			else {
				ans4[i + 1] = 3 - ans4[i - 1];
			}
		}
		else {
			if (ans4[i] == 2) {
				ans4[i + 1] = ans4[i - 1];
			}
			else {
				ans4[i + 1] = 3 - ans4[i - 1];
			}
		}
	}
	if (ans4[1] == ans4[n + 1] && ans4[0] == ans4[n]) {
		forc(i, 1, n) {
			if (ans4[i] == 1)
				cout << "S";
			else
				cout << "W";
		}

		cout << endl;
		return 0;
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
    int n,k; cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans=1e18;
    for(int i=0;i<(1<<n);i++){
        if(__builtin_popcount(i)>=k){
            ll cnt=0;
            ll ma=0;
            for(int j=0;j<n;j++){
                if(i&(1<<j)){
                    if(ma<a[j])ma=a[j];
                    else{
                        cnt+=ma+1-a[j];
                        ma++;
                    }
                }
                else{
                    ma=max(ma,a[j]);
                }
            }
            ans=min(ans,cnt);
        }
    }
    cout << ans << endl;
}

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

int n;
vector<int> a;
int s[2];

int main() {
  cin >> n;
  for (int i = 0, j; i < n; ++i) {
    cin >> j;
    a.push_back(j);
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < n; ++i) {
    s[i % 2] += a[i];
  }
  cout << s[0] - s[1] << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){

    int N;
    cin >> N;
    vector<string> S(N);

    for(int i=0; i<N; i++){
        cin >> S.at(i);
    }

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    for(int i=0; i < N; i++){
        if(S.at(i) == "AC"){
            ac++;
        }

        else if (S.at(i) == "WA"){
            wa++;
        }

        else if (S.at(i) == "TLE"){
            tle++;
        }

        else{
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

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

int main() {
  int n; cin >> n;
  map<int, int> vals;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    vals[x] += 1;
  }
  cout << vals.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int main() {

  int n;
  map<ll, ll> M;
  cin >> n;
  std::vector<ll> v(n + 1);
  for(int i = 1; i <= n; i++)cin >> v[i];

  ll ans = 0;
  // j - i = v[j] + v[i]
  // i + v[i] = j - v[j]
  for(int i = n; i >= 1; i--){
    if(M.find(i + v[i]) != M.end())ans += M[i + v[i]];
    M[i - v[i]]++;
  }
  cout << ans << '\n';

  return 0;
}

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



int main(){
    int l;
    cin >> l;
    double x,y,z;
    x = (double)l / 3;
    y = x;
    z = (double)(l - x - y);
    double vol = x*y*z;
    printf("%f",vol);
    // cout << x*y*z << endl;
    return 0;
}


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

    int i, n;
    int a[1000];
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf(" %d", &a[i]);
    }
    for(i=0;i<n;i++){
        if(i)
         printf(" ");
         printf("%d", a[n-i-1]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2128
public class Main {


  private static void solve() {
    double n = ni();
    double m = ni();
    double d = ni();

    double ret = (d == 0 ? n : ((n - d) * 2)) / (n * n) * (m - 1);
    System.out.printf("%.12f\n", ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23380
N=int(input())
A=list(map(int, input().split()))
B=[A[0]]
for i in range(1,N):
    B.append(B[i-1]+A[i])
p=10**9+7
ans=0
for i in range(1,N):
    ans+=A[i]*B[i-1]
ans%=p
print(ans)


Measured memory_bytes: 31628
def main():
    import sys
    input = lambda : sys.stdin.readline().rstrip()

    n, q = map(int, input().split())
    stx = []
    for _ in range(n):
        s, t, x = map(int, input().split())
        stx.append([x, s - x, t - x])
    stx.sort(reverse=True)
    d = [int(input()) for _ in range(q)]

    N = q
    N0 = 2**(N-1).bit_length()
    data = [None]*(2*N0)
    INF = (-1, 10**9 + 1)
    def update(l, r, v):
        L = l + N0; R = r + N0
        while L < R:
            if R & 1:
                R -= 1
                data[R-1] = v

            if L & 1:
                data[L-1] = v
                L += 1
            L >>= 1; R >>= 1
    def _query(k):
        k += N0-1
        s = INF
        while k >= 0:
            if data[k]:
                s = max(s, data[k])
            k = (k - 1) // 2
        return s
    def query(k):
        return _query(k)[1]



    import bisect

    for i, (x, start, last) in enumerate(stx):
        l = bisect.bisect_left(d, start)
        r = bisect.bisect_left(d, last)
        update(l, r, (i, x))

    for i in range(q):
        res = query(i)
        if res == 10**9 + 1:
            print(-1)
        else:
            print(res)
if __name__ == '__main__':
    main()
    



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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (c <= a + b) {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int k, s;
    cin >> k >> s;
    int cnt=0;
    for(int x=0; x<=k; x++){
        for(int y=0; y<=k; y++){
            int z = s-(x+y);
            if(0<=z && z<=k) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;

#define fin(ans) cout << (ans) << endl;

void Main()
{
    ll W, a, b;
    cin >> W >> a >> b;
    if (a < b)
    {
        if (a + W < b)
            fin(b - a - W) else fin(0)
    }
    else
    {
        if (b + W < a)
            fin(a - b - W) else fin(0)
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  int N = S.size(), cnt = 0;
  REP(i, N/2){
    if(S.at(i) != S.at(N-i-1)){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,e,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    cin>>n>>m ;
    vector<pll>v ;
    for(i=0 ; i<n ; i=i+1)
    {
        cin>>a>>b ;
        pll p1 ;
        p1.first = a ;
        p1.second = b ;
        v.pb(p1) ;
    }
    sort(all(v)) ;
    c = 0 ;
    ll money = 0 ;
    for(i=0 ; i<n ; i=i+1)
    {
        a = v[i].first ;
        b = v[i].second ;
        if(m<c+b)
        {
            money+=(m-c)*a ;
            break;
        }
        else
        {
            money+=b*a ;
            c+=b ;
        }
    }
    cout<<money ;
}

Measured memory_bytes: 2420
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 21:03:36 2020

@author: Kanaru Sato
"""

x = int(input())

countone = 0
counttwo = 0

while x >= 500:
    x = x-500
    countone += 1
while x >= 5:
    x = x-5
    counttwo += 1

ans = countone*1000 + counttwo*5

print(ans)

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

#define fio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i >= b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb push_back
#define sz(v) v.size()
#define pln(a)  cout<<a;
#define rr return 0;
#define rr1 return 1;
#define vr return;
#define int long long 

void solve()
{
  int h1, m1, h2, m2, k;
  cin>>h1>>m1>>h2>>m2>>k;
  
  int total_minutes = (h2*60 + m2) - (h1*60 + m1);
  cout<<(total_minutes >= k ? total_minutes - k : 0);
}

signed main() {

  fio;
  
  
  //tc(t) {
    solve();
    pln("\n");
  //}
  
  rr;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cmath>
using namespace std ;
int main(){
  int a[5] ;
  for (int i=0 ;i<5;i++){
    cin >>a[i];
  }
  for (int i=0 ;i<5 ;i++){
    if (a[i]==0){
        cout << i+1 ;
        break ;
    }
  }
}


Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  v(double) a(n);
  rep(i,n) cin>>a[i];
  double ans=0;
  rep(i,n){
    ans+=1/a[i];
  }
  ans=1/ans;
  cout<<ans<<endl;
}

Measured memory_bytes: 3676
#include<iostream>
using namespace std;
int main(){
   long long int n,i,sum=0;
   cin>>n;
   int a[n];
   for(i=0;i<n;i++){
    cin>>a[i];
   }
   for(i=0;i<n-1;i++){
   if(a[i+1]<a[i]){
sum=sum-a[i+1]+a[i];
    a[i+1]=a[i+1]-a[i+1]+a[i];
   }
   }
   cout<<sum<<endl;
   
}


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


int main()
{
    string s;
    cin>>s;
    int c[2]={0};
    for(int i=0;i<3;i++)
    {
        int co=s[i]-'A';
        c[co]++;
    }
    if(c[0]>0 && c[1]>0) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int cp(int,int);

int main(){
  int n,cnt=0;
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    //printf("%d\n",x);
    cnt+=cp(x,sqrt(x)+1);
  }
  printf("%d\n",cnt);
  return 0;
}

int cp(int x,int y){
  int i;
  for(i=2;i<y;i++){
    if(x%i==0)return 0;
  }
  return 1;
}



Measured memory_bytes: 2688
while 1:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(int(a / b))
        

Measured memory_bytes: 7640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int a, b, count;
	cin >> a >> b;
	count = 0;
	for (int i = a; i <= b; i++) {
		if (i % 10 == i / 10000 && (i / 10) % 10 == (i / 1000) % 10) count++;
	}
	cout << count << endl;
}

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

int main(){
  int a, b, min;
  scanf("%d %d",&a,&b);

  min=b*10;
  for(int i = min; i/10<=b; i++){
    if(i*8/100==a){
      printf("%d",i);
      return 0;
    }
  }
  printf("%d",-1);
}

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
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a, x;
  cin >> x >> a;
  if (x < a) cout << "0" << endl;
  else cout << 10 << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

/////////////////////////////////////////////////////

const ll MAX_N=1<<20;
//セグメント木を持つグローバル配列
ll n,dat[2*MAX_N-1];
//初期化
void init(ll n_){
    //簡単のため要素数を2のべき乗に
    n=1;
    while(n<n_)n*=2;
    //全ての値をinfに
    for(ll i=0;i<2*n-1;i++)dat[i]=(1<<31)-1;
}
//k番目の値(0-indexed)をaに変更
void update(ll k,ll a){
    //葉の節点
    k+=n-1;
    dat[k]=a;
    //登りながら更新
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}
//[a,b)の最小値を求める
//後ろの方の引数は、計算の簡単のための引数
//kは節点の番号、l,rはその節点が[l,r)に対応づいていることを表す。
//従って、[a,b)の最小値を求めたい時はquery(a,b,0,0,n)として呼ぶ
ll query(ll a,ll b,ll k,ll l,ll r){
    //[a,b)と[l,r)が交差しなければinf
    if(r<=a||b<=l)return inf;
    //[a,b)が[l,r)を完全に含んでいれば、この節点の値
    if(a<=l&&r<=b)return dat[k];
    else{
        //そうでなければ、2つの子の最小値
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}
/////////////////////////////////////////////////////

int main(){
    ll N,Q;cin>>N>>Q;
    init(N);
    while(Q--){
        int a,b,c;cin>>a>>b>>c;
        if(a==0){
            update(b,c);
        }else{
            cout<<query(b,c+1,0,0,n)<<endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 5156
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Long, Long> map = new HashMap<>();
		Long sum = 0L;
		for (int i = 0; i < n; i++) {
			Long key = sc.nextLong();
			Long count = map.getOrDefault(key, 0L);
			count++;
			map.put(key, count);
			sum+=key;
		}
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			Long b = sc.nextLong();
			Long c = sc.nextLong();
			Long diff = c - b;
			Long bValue = map.getOrDefault(b, 0L);
			map.remove(b);
			Long cValue = map.getOrDefault(c, 0L);
			map.put(c, cValue + bValue);
			sum = sum + diff * bValue;
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 66900
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

//#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

const ll MOD = 1e9 + 7;

VV<ll> calc_pows() {
    V<ll> pows(410, 1);
    VV<ll> pows_sum(410, V<ll>(410, 0));
    for(ll c = 0; c < 410; c++) {
        ll sum = 0;
        for(ll i = 0; i < 410 - 1; i++) {
            (sum += pows[i]) %= MOD;
            (pows[i] *= max<ll>(i, 1)) %= MOD;
            pows_sum[c][i + 1] = sum;
        }
    }
    return move(pows_sum);
}

ll calc_pows_value(ll a, ll b, ll c, const VV<ll> &pows_sum) { return (pows_sum[c][b + 1] - pows_sum[c][a] + MOD) % MOD; }

int main() {
    init_io();
    auto pows_sum = calc_pows();
    ll N, C;
    cin >> N >> C;
    V<ll> A(N), B(N);
    for(ll &e : A) cin >> e;
    for(ll &e : B) cin >> e;
    V<ll> dp(C + 1);
    for(ll i = 0; i <= C; i++) dp[i] = (pows_sum[i][B[0] + 1] - pows_sum[i][A[0]] + MOD) % MOD;
    for(ll i = 1; i < N; i++) {
        auto ndp = V<ll>(C + 1);
        for(ll prec = 0; prec <= C; prec++) {
            for(ll nowc = 0; nowc + prec <= C; nowc++) {
                (ndp[prec + nowc] += calc_pows_value(A[i], B[i], nowc, pows_sum) * dp[prec]) %= MOD;
            }
        }
        dp = move(ndp);
    }
    cout << dp[C] << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef long long int lli;
typedef long double float64;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define tr(container, it) \
    for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 

// #define sz(a) int((a).size())
// #define pb push_back
// #define fill(a,v) memset(a,v,sizeof a)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

#define trace3(x,y,z) cout<< '>' << #x << ':' << x \
        << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;

#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x \
    << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;


inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);

/////////////////////////////////////////////////////////////////////

/*bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/

template<class T> inline T gcd(T a,T b) //NOTES:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}



const int MAX_N = 123;

int arr[MAX_N][11];
ll P[MAX_N][11];
int A[MAX_N];

int main() {
    int N;
    ll ans=INT_MIN;
    ll temp;
    scanf("%d",&N);
    for(int i=1;i<N+1;i++){
        for(int j=1;j<11;j++){
            scanf("%d",&arr[i][j]);
        }
    }
    for(int i=1;i<N+1;i++){
        for(int j=0;j<11;j++){
            scanf("%lld",&P[i][j]);
        }
    }
    for(int i=1;i<(1<<10);i++){
        memset(A,0,sizeof A);
        temp=0;
        bool flag=false;
        if(flag)
            continue;
        for(int j=0;j<10;j++){
            if(i&(1<<j)){
                for(int k=1;k<N+1;k++){
                    if(arr[k][j+1]==1){
                        //printf("her ");
                        A[k]++;
                    }
                }
            }
        }
        //printf("%d ",A[0]);
        for(int j=1;j<N+1;j++){
            temp+=P[j][A[j]];
        }
        /*if(temp>ans){
            trace3(ans,temp,A[1]);
        }*/
        ans=max(ans,temp);
    }
    printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
int n;
int a[50];
int solve(int i, int x){
    if(x == 0){
        return 1;
    }
    if(i >= n){
        return 0;
    }else{
        int res = solve(i+1, x) || solve(i+1, x-a[i]);
        return res;
    }
    
}
int main(){
    //std::stack<int> stack;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int x;
        cin >> x;
    if(solve(0, x)){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }
    }
    
    return 0;
}






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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...)
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, k;
	string s;
	cin >> n >> k >> s;

	int g = 1;
	for (int i = 1; i < n; ++i)
		g += s[i] != s[i-1];

	g -= 2*k;
	g = max(g, 1);

	cout << n - g << "\n";

	return 0;
}


Measured memory_bytes: 512
function main(input) {
  input = input.trim().split("\n");
  const [n, m] = input[0].split(" ").map(n => Number(n));
  const ab = input.slice(1).map(l => l.split(" ").map(m => Number(m));
  ab.sort((l, m) => {
  	const [la, lb] = l;
    const [ma, mb] = m;
    return la-ma;
  });
  let cnt = 0;
  let result = 0;
  for (let i = 0; i < n; i++) {
    const [a, b] = ab[i];
    const min = Math.min(m-cnt, b);
    cnt += min;
    result += a*min;
    if (cnt === m) break;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 52892
#include<cstdio>
typedef long long lolo;
lolo gcd(lolo a, lolo b){
  if(b == 0)
    return a;
  else
    return gcd(b,a%b);
}
void solve(lolo a, lolo b){
  lolo ans = gcd(a,b);
  printf("%lld %lld\n",ans,a / ans * b);
}
int main(){
  lolo a;
  lolo b;
  while(scanf("%lld %lld",&a,&b) != EOF)
    solve(a,b);
}



Measured memory_bytes: 2580