akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>

constexpr int MAX_M=10000,MAX_N=500,INF=(int)1e9;

using P=std::pair<int,int>;

int m,n;
int ps[MAX_M];
P cs[MAX_N];

int dp[MAX_N][MAX_M];

int main(){
	std::cin>>m>>n;
	for(int i=0;i<m;++i)
		std::cin>>ps[i];
	std::sort(ps,ps+m,std::greater<int>());
	for(int i=1;i<m;++i)
		ps[i]+=ps[i-1];
	for(int i=0;i<n;++i)
		std::cin>>cs[i].first>>cs[i].second;

	for(int i=0;i<n;++i){
		for(int j=0;j<m;++j)
			dp[i][j]=INF;
	}

	for(int i=0;i<cs[0].first;++i)
		dp[0][i]=cs[0].second;

	for(int i=1;i<n;++i) {
		for(int j=0;j<cs[i].first;++j)
			dp[i][j]=std::min(cs[i].second,dp[i-1][j]);
		for(int j=cs[i].first;j<m;++j){
			dp[i][j]=std::min(dp[i-1][j-cs[i].first]+cs[i].second,dp[i-1][j]);
		}
	}
	int ans=0;

	for(int i=0;i<m;++i)
		ans=std::max(ans,ps[i]-dp[n-1][i]);
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 22744
import math
import collections
def primes(n):
    a = list(range(2, n+1))
    primes = [2]
    for i in a:
        flag = True
        m = math.sqrt(i)
        for j in primes:
            if j > m:
                break
            else:
                if i % j == 0:
                    flag = False
                    break
        if flag:
            primes.append(i)
            
    return primes
p = primes(10000)
dic = collections.defaultdict(int)
N = int(input())
mod = 10**9 +7
for i in range(1, N+1):
    for j in p:
        while i % j == 0:
            dic[j] += 1
            i = i // j
    ans = 1
for c in dic.values():
    ans *= (c+1)
    ans %= mod
print(ans)
                

Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define LL long long

LL N, h, n, w;

int main()
{
    while(cin >> N)
    {
        int flag = 0;
        for(h = 1;h <= 3500; ++h)
        {
            for(n = 1; n <= 3500; ++n)
            {
                LL a = N * h * n;
                LL b = 4 * h * n - N * n - N * h;
                if(b == 0) continue;
                if(a % b == 0 && a / b > 0)
                {
                    w = a / b;
                    flag = 1;
                    break;
                }
            }
            if(flag) break;
        }
        printf("%lld %lld %lld\n", h, n, w);
    }
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
bool f(char x) {
	string s = "ACGT";
  for ( char c: s) {
    if (c==x) return true;
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
	int ans = 0;
  string s; cin>>s;
  int n = s.size();
  for (int i=0; i<n; ) {
    int j=i;
    if (!f(s[i])) {
      i++; continue;
    }
    while (j<n && f(s[j])) j++;
    ans = max(ans, j-i);
    i = j;
  }
  cout<<ans;
  

  return 0;
}


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

int main() {
    int N;
    long int ans = 0;
    std::cin >> N;
    std::vector<long int> A(N);
    for(int i = 0; i < N; i++) {
        std::cin >> A.at(i);
    }

    for(int i = 1; i < N; i++) {
        if(A.at(i - 1) > A.at(i)) {
            ans += A.at(i - 1) - A.at(i);
            A.at(i) = A.at(i - 1);
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
#include<cmath>
#include<cstring>
#include<climits>
#define int long long
#define umitr unordered_map <int,int> :: iterator
#define usitr unordered_set <int> :: iterator
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define asc(a,n) sort(a,a+n);
#define dsc(a,n) sort(a,a+n,comp);
#define fo(i,x,y) for(int i=x;i<y;i++)
#define inarr(x) int n; cin>>n; int x[n]; fo(i,0,n){cin>>x[i];}
#define test int t; cin>>t; while(t--)
using namespace std;

int basic(){freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);return 0;}
bool comp(int a,int b){return a>b;}



int32_t main()
{ //basic(); 
  fast; 
  char s0[100]; char s1[100];
  cin>>s0; cin>>s1; int flag=0;
  for(int i=0;i<strlen(s0);i++)
  {
  	if(s0[i]!=s1[i]){ flag=1; break;}
  }
  if(flag==1){cout<<"No";}
  else {cout<<"Yes";}

 return 0;
}










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

using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;

#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
 
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#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;}

void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////



int main(){fastio
    ll n;cin>>n;
    ll a[n],b[n];rep(i,0,n-1)cin>>a[i];rep(i,0,n-1)cin>>b[i];
    ll dp[1<<n][n];rep(i,0,(1<<n)-1)rep(j,0,n-1)dp[i][j]=inf;
    rep(i,0,n-1){
        ll t=1<<i;
        dp[t][i]=i;
    }
    rep(i,0,(1<<n)-1){
        ll c=0;rep(j,0,n-1)if((i>>j)&1)c++;
        if(c==0)continue;
        rep(j,0,n-1){
            if(((i>>j)&1)==0)continue;
            ll nowo=0;
            if((c+j)%2==1){
                nowo=a[j];
            }else{
                nowo=b[j];
            }
            ll cou=-1;
            rep(k,0,n-1){
                if((i>>k)&1)continue;
                cou++;
                ll ni=i+(1<<k);
                ll nexo=0;
                if((c+1+k)%2==1)nexo=a[k];
                else nexo=b[k];
                if(nowo>nexo)continue;
                ll res=dp[i][j]+cou;
                
                Min(dp[ni][k],res);
            }
        }
    }
    ll ans=inf;
    rep(j,0,n-1){
        Min(ans,dp[(1<<n)-1][j]);
    }
    if(ans>=inf/2)ans=-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 37248
graph = 0
node_visited = 0
num_node = 0

def search_route(current_node):
    global node_visited
    node_visited[current_node] = True
    for next_node in range(num_node):
        if graph[current_node][next_node] == False:
            continue
        if node_visited[next_node] == True:
            continue
        search_route(next_node)
    
def main():
    global graph, node_visited, num_node
    num_node, num_edge = map(int, input().split())
    all_edges = [list(map(int, input().split())) for i in range(num_edge)]
    graph = [[False for j in range(num_node)] for i in range(num_node)]
    for edge_s, edge_g in all_edges:
        graph[edge_s - 1][edge_g - 1] = graph[edge_g - 1][edge_s - 1] = True
        
    num_bridge = 0
    for edge_s, edge_g in all_edges:
        graph[edge_s - 1][edge_g - 1] = graph[edge_g - 1][edge_s - 1] = False
        node_visited = [False for i in range(num_node)]
        search_route(current_node = 0)
        for node in node_visited:
            if node == False:
                num_bridge += 1
                break
        graph[edge_s - 1][edge_g - 1] = graph[edge_g - 1][edge_s - 1] = True
    print(num_bridge)

if __name__ == '__main__':
    main()

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

int main(){
	int c1, c2, c3;
	while(cin >> c1 >> c2 >> c3){
	    bool card[11];
        fill(card, card+11, false);
        card[c1] = card[c2] = card[c3] = true;

        int count = 0;
        for(int i=1; i <= 10; i++){
            if(!card[i] && c1+c2+i <= 20) count++;
        }
        if(4 <= count) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ull unsigned long long
using namespace std;
const ll mod=998244353;
string slast,s,t;
const ll p=623;
int n,m;
vector<ll> ts;
ll po[16000001];
ll has[16000001];
ll hast[16000001];
bool check(int len){
    if(len==0) return 1;
    if(len*m>s.size()) return 0;
    ll nowt=ts[len];
    ll cur=has[len*m-1];
    for(int i=1;i<=n-len*m;i++){
        if(cur==nowt) return 1;
        cur=(has[i+len*m-1]+mod-has[i-1]*po[len*m]%mod)%mod;
    }
    if(cur==nowt) return 1;
    return 0;
}
int solve(){
    int lb=-1,ub=ts.size()+1;
    while(lb<=ub){
        int mid=(lb+ub)/2;
        if(check(mid))
            lb=mid+1;
        else
            ub=mid-1;
    }
    return ub;
}
int main(){
    getline(cin,slast);
    getline(cin,t);
    n=slast.size(),m=t.size();
    while(s.size()<n+m)
        s+=slast;
    s+=slast;
    s+=slast;
    n=s.size();
    po[0]=1;
    for(int i=1;i<=2*n;i++)
        po[i]=po[i-1]*p%mod;
    for(int i=0;i<n;i++)
        has[i]=(has[i-1]*p%mod+(ll)s[i])%mod;
    for(int i=0;i<m;i++)
        hast[i]=(hast[i-1]*p%mod+(ll)t[i])%mod;
    ts.resize((n*2+m-1)/m+1);
    for(int i=1;i<ts.size();i++)
        ts[i]=(ts[i-1]*po[m]%mod+hast[m-1])%mod;
    int ans=solve();
    s+=s;
    n*=2;
    for(int i=0;i<n;i++)
        has[i]=(has[i-1]*p%mod+s[i])%mod;
    int ans2=solve();
    if(ans<ans2){
        puts("-1");
        return 0;
    }
    cout<<max(ans,0)<<endl;
    return 0;
}

Measured memory_bytes: 101536
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int num=scan.nextInt();
    String a=scan.next();
    String b=scan.next();
    String[] a1=new String[num];
    String[] b1=new String[num];
    a1=a.split("");
    b1=b.split("");
    for(int x=0; x<num; x++){
      System.out.print(a1[x]+b1[x]);
    }
  }
}

Measured memory_bytes: 21076
import math


X = int(input())


def is_prime(x):
    n = math.floor(math.sqrt(x))
    ret = True
    for i in range(n, 1, -1):
        if x % i == 0:
            ret = False
            break
    return ret


while not is_prime(X):
    X += 1
print(X)


Measured memory_bytes: 38384
calcRow :: [Int] -> [Int]
calcRow nums = nums ++ [foldl (+) 0 nums]

calcTotals :: [[Int]] -> [Int] -> [Int]
calcTotals [] t = t
calcTotals (x:xs) t = calcTotals xs $ sumEach t x
  where
    sumEach :: [Int] -> [Int] -> [Int]
    sumEach [] [] = []
    sumEach (x:xs) (y:ys) = (x+y):(sumEach xs ys)

printMatrix :: [[Int]] -> IO ()
printMatrix = mapM_ (\n -> putStrLn $ unwords [show x | x <- n])

main :: IO ()
main = do
    [r, c] <- getLine >>= return.(map $ \n -> read n :: Int).words
    matrix <- getMatrix r []
    let totals = calcTotals matrix [0 | _ <- [1..c+1]]
    printMatrix $ matrix ++ [totals]
  where
    getMatrix :: Int -> [[Int]] -> IO [[Int]]
    getMatrix 0 m = return m
    getMatrix n m = do
        nums <- getLine >>= return.(map $ \n -> read n :: Int).words
        getMatrix (n - 1) $ m ++ [calcRow nums]



Measured memory_bytes: 6572
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <string>
#include <algorithm>
#include <cassert>

using namespace std;
using ll = long long;

#define TBD cout << "TBD" << endl;

int main()
{
	string str;

	cin >> str;

	int year = stoi(str.substr(0, 4));
	if (year > 2019) {
		TBD;
		return 0;
	}
	int month = stoi(str.substr(5, 7));
	if (month > 4) {
		TBD;
		return 0;
	}
	int day = stoi(str.substr(8, 10));
	if (day > 31) {
		TBD;
		return 0;
	}

	cout << "Heisei" << endl;
}



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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

double kyori(pii x, pii y) {
  return sqrt(pow(x.first - y.first, 2) + pow(x.second - y.second, 2));
}

inline void Main() {
  // code
  long long n;
  cin>>n;
  for (long long m = sqrt(n); m >= 1; m--) {
    if(n % m == 0) {
      cout << m + n / m - 2 << endl;
      return;
    }
  }

}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i,i_len) for (ll i = 0, i##_len = (i_len); i < i##_len; i++)

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    while (cin >> n, n) {

        vector<ll> a(n);
        REP(i, n) cin >> a[i];
        
        ll sum = 0, ans = 0;
        REP(i, n) sum += a[i];
        REP(i, n) {
            if (sum >= a[i] * n) {
                ans++;
            }
        }
        cout << ans << endl;

    }

}


Measured memory_bytes: 3200
fun main(args: Array<String>) {
    val countN = readLine().orEmpty().toInt()
    val nameList = mutableListOf(0,0,0,0,0)
    var result = 0L
    for(i in 0 until countN){
        val name = readLine().orEmpty()
        when(name[0]){
            'M' -> nameList[0] += 1
            'A' -> nameList[1] += 1
            'R' -> nameList[2] += 1
            'C' -> nameList[3] += 1
            'H' -> nameList[4] += 1
        }
    }
    var nya = 1L
    val distinctList = nameList
    distinctList.removeAll{it == 0}

    if(distinctList.size < 3){
        result = 0
    }else if(distinctList.size == 3){
        result = 1L
        distinctList.forEach{
            result *= it
        }

    }else if(distinctList.size >= 4){
        for(i in 0 until distinctList.size){
            nya = distinctList[i].toLong()
            for(j in 0 until distinctList.size){
                if(j > i){
                    val prenya2 = nya
                    nya *= distinctList[j]
                    for(k in 0 until distinctList.size){
                        if(k > j){
                            val prenya3 = nya
                            nya *= distinctList[k]
                            result += nya
                            nya = prenya3
                        }
                    }
                    nya = prenya2
                }
            }
        }
    }

    println(result)
}



Measured memory_bytes: 39096
s = str(input())
di = []
k = 1
p = 0
for i in range(1,len(s)):
    if s[i-1] != s[i]:
        di.append(k)
        k = 1
        continue
    k += 1
di.append(k)
t = 1
p = 0
for l in range(1,len(s)):
    if s[l-1] == "<" and s[l] == ">":
        p += min(di[t-1],di[t])
        t += 1
    if s[l-1] == ">" and s[l] == "<":
        t += 1
ls = [e for e in range(max(di)+1)]
import numpy 
new_ls = numpy.cumsum(numpy.array(ls))
q = 0
for j in di:
    q += new_ls[j]
print(q-p)

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

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
    if b[i]>a[i]:
        cnt+=a[i]
        if b[i]>a[i]+a[i+1]:
            cnt+=a[i+1]
            a[i+1]=0
        else:
            cnt+=b[i]-a[i]
            a[i+1]-=b[i]-a[i]
    else:
        cnt+=b[i]
print(cnt)

Measured memory_bytes: 19376
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
# cから自分よりも小さいパーツの数を数えていく
a.sort()
b.sort()
c.sort()
from bisect import bisect_left
from bisect import bisect_right
ans = 0
for j in range(n):
    key = b[j]
    i = bisect_left(a, key)
    k = n - bisect_right(c, key)
    ans += i * k
print(ans)

Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
int main(){
    long l,r;
    cin >> l >> r;
    if(r-l >4038)cout << 0 << endl;
    else{
        int ans = 2018;
        for(long i=l;i<r;i++){
            for(long j=i+1;j<=r;j++){
                ans = min(ans,(int)((i*j)%2019));
                if(ans == 0)break;
            }
            if(ans == 0)break;
        }
        cout << ans << endl;
    }
}

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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  long long tmp = 0;
  for (auto ai: a) {
    tmp ^= ai;
  }
  if (tmp == 0) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

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

bool check(string &s, string pas){
    int p = 0;
    int k = 3 - pas.size();
    rep(i,k){
        pas = "0" + pas;
    }
    for(char c : s){
        if (c == pas[p]) {
            p++;
        }
        if (p == 3) return true;
    }
    return false;
}

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,1000){
        if(check(s, to_string(i))){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

template<typename T>
struct BIT {
	int n;
	vector<T>dat;
	void initialize(int temp) {
		n = temp;
		dat.resize(n);
		rep(i, 0, n)dat[i] = 0;
	}
	T sum(int i) {
		T s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}
	T sum_between(int i, int j) {
		if (i > j)return 0;
		return sum(j) - sum(i - 1);
	}
	void plus(int i, T x) {
		while (i < n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
	int lower_bound(T x) {
		if (sum(n - 1) < x)return -1;
		else if (sum(0) >= x)return 0;
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (sum(mid) >= x)ok = mid;
			else ng = mid;
		}
		return ok;
	}
};


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

	int N;
	cin >> N;
	string S;
	cin >> S;

	BIT<ll>bit[26];
	for (int j = 0; j < 26; j++)bit[j].initialize(N);

	for (int i = 0; i < N; i++)bit[S[i] - 'a'].plus(i,1);

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int q;
		cin >> q;
		if (q == 1) {
			int idx;
			char c;
			cin >> idx >> c;
			idx--;
			char pre = S[idx];
			bit[pre-'a'].plus(idx,-1);
			bit[c-'a'].plus(idx,1);
			S[idx] = c;
		}
		else {
			int l, r;
			cin >> l >> r;
			l--, r--;
			int cnt = 0;
			for (int j = 0; j < 26; j++) {
				cnt += (bit[j].sum_between(l,r) > 0);
			}
			puts(cnt);
		}
	}

	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;


  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;

  for (int h = 0; h < H; h++) {
    cout << "#";
    for (int w = 0; w < W; w++) {
      char c;
      cin >> c;
      cout << c;
    }
    cout << "#" << endl;
  }

  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;




  return 0;
}


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

int main()
{
	int ans = 0;
	int a, b;
	string s;

	cin >> a >> b >> s;

	int sz = s.size();
	if( sz != a + b + 1 ) {
		ans = 1;
	}
	else {
		for( int i = 0; i < sz; i++ ) {
			if( i == a ) {
				if( s[i] != '-' ) {
					ans = 1;
				}
			}
			else {
				if( s[i] < '0' || '9' < s[i] ) {
					ans = 1;
				}
			}
		}
	}

	if( ans == 0 ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
while true
  n,x = gets.chomp.split.map(&:to_i)
  if [n,x] == [0,0]
    break
  end
sum = 0
for i in 1..(n-2)
  for j in (i+1)..(n-1)
   for k in (j+1)..n
     if i + j + k == x
      sum += 1
     end
   end
  end
end
 puts sum
end

Measured memory_bytes: 8684
def input_ints():
    return list(map(int, input().split()))

def main():
    n = int(input())
    a = input_ints()
    b = input_ints()
    ans = 0
    for i in range(n):
        if a[i] > b[i]:
            ans += a[i] - b[i]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
//Intersection Determination
#include<bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;    // 許容誤差。問題によって変える
typedef complex<double> P;  // Point
#define X real()
#define Y imag()
double norm(P &p1, P &p2){
    return (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);
}
namespace std{
    bool operator<(const P p1, const P p2){
        return p1.X != p2.X ? p1.X < p2.X : p1.Y < p2.Y;
    }
    P operator+(const P p1, const P p2) { return P(p1.X + p2.X, p1.Y + p2.Y); }
    P operator-(const P p1, const P p2) { return P(p1.X - p2.X, p1.Y - p2.Y); }
    P operator*(const P p, double k) { return P(p.X * k, p.Y * k); }
    P operator/(const P p, double k) { return P(p.X / k, p.Y / k); }
} 

//Segment/Line
struct Segment{
    P p1, p2;
    Segment() {}
    Segment(P p1, P p2) : p1(p1), p2(p2) {}
};
typedef Segment Line;

//外積cross(a,b) = |a||b|sinθ=a1b2+a2b1
double cross(const P &a, const P &b){
    return (conj(a) * b).Y;
}
//内積dot(a,b) = |a||b|cosθ=a1b1+a2b2
double dot(const P &a, const P &b){
    return (conj(a) * b).X;
}

//位置関係判定(線分abを軸にcがどちら側にあるか)
int ccw(P a, P b, P c){
    b -= a;
    c -= a; //aからの向きを考える
    if (cross(b, c) > EPS)
        return +1; //clockwise
    else if (cross(b, c) < -EPS)
        return -1; //counter clockwise
    else if (dot(b, c) < -EPS)
        return +2; //c-a-b
    else if (norm(b) < norm(c))
        return -2; //a-b-c
    else
        return 0; //他
}

//Intersection Determination
bool intersectLL(const Line &l, const Line &m){
    return abs(cross(l.p2 - l.p1, m.p2 - m.p1)) > EPS || // non-parallel
        abs(cross(l.p2 - l.p1, m.p1 - l.p1))  < EPS;       // same line
                                                      
}
bool intersectLS(const Line &l, const Line &s){
    return cross(l.p2 - l.p1, s.p1 - l.p1) * // s.p1 is left of l
               cross(l.p2 - l.p1, s.p2 - l.p1) <EPS; // s.p2 is right of l
}
bool intersectLP(const Line &l, const P &p){
    return abs(cross(l.p2 - p, l.p1 - p)) < EPS;
}
bool intersectSS(const Line &s, const Line &t){
    return ccw(s.p1, s.p2, t.p1) * ccw(s.p1, s.p2, t.p2) <= 0 &&
           ccw(t.p1, t.p2, s.p1) * ccw(t.p1, t.p2, s.p2) <= 0;
}
bool intersectSP(const Line &s, const P &p){
    return abs(s.p1 - p) + abs(s.p2 - p) - abs(s.p2 - s.p1) < EPS; // triangle inequality
}

//Verify
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=jp
int main(){
    int q;
    cin>>q;
    for (int i = 0; i < q;i++){
        double x0,x1,x2,x3,y0,y1,y2,y3;
        cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
        P p0 = P(x0, y0), p1 = P(x1, y1), p2 = P(x2, y2), p3 = P(x3, y3);
        const Line l1 = Line(p0, p1), l2 = Line(p2, p3);
        if (intersectSS(l1, l2) )
            cout << "1" << endl;
        else
            cout << "0" << endl;
    }
    return 0;
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	cout << min(k, n)*x + max(0, n-k)*y << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 3010;
const int Mod = 1e9 + 7;

void add(int &x, int y){
	x += y;
	if(x >= Mod) x -= Mod;
}

int dp[N][N][2], n, m;

int main(){
	scanf("%d%d", &n, &m);

	For(i, 0, n) dp[0][i][i == 0] = 1;
	For(i, 0, m - 1) For(j, 0, n) For(v, 0, 1){
		int val = dp[i][j][v];
		if(j){
			add(dp[i + 1][j][v | (j == 1)], val);
			add(dp[i + 1][j - 1][v | (j == 1)], val);
		}
		if(n - j){
			add(dp[i + 1][j][v], val);
			add(dp[i + 1][j + 1][v], val);
		}
	}

	int ans = 0;
	For(i, 0, n) add(ans, dp[m][i][1]);

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

	return 0;
}

Measured memory_bytes: 70784
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int place[3] = {0};
	int moveint1,moveint2;
	char move1,move2;
	string hoge = "ABC";
	int dummy;
	
	place[0] = 1;
	while (~scanf("%c,%c",&move1,&move2)){
		moveint1 = hoge.find(move1);
		moveint2 = hoge.find(move2);
		if ( moveint1 != -1 && moveint2 != -1 ) {
			swap(place[moveint1],place[moveint2]);
		}
	}
	
	for ( int i = 0; i < 3; i++ ) {
		if ( place[i] == 1 ) {
			cout << hoge[i] << endl;
		}
	}
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m,c;
  cin>>n>>m>>c;
  vector<Int> l(c);
  for(Int i=0;i<c;i++) cin>>l[i];
  using P = pair<Int, Int>;
  vector<P> v;
  for(Int i=0;i<n;i++){
    Int a,b;
    cin>>a>>b;
    a--;
    v.emplace_back(b,a);
  }
  sort(v.rbegin(),v.rend());
  Int ans=0;
  for(Int i=0;i<n;i++){
    if(!l[v[i].second]) continue;
    ans+=v[i].first;
    l[v[i].second]--;
    if(!--m) break;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 5612
from collections import Counter

N = int(input())
s= input()

M = 0

for i in range(N):
    temp = 0
    l1,l2 = s[:i],s[i:]
    n1 , n2 = Counter(l1), Counter(l2)
    for c in n1.keys():
        if c in n2.keys():
            temp += 1
    if temp >= M:
        M = temp

print (M)

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var xa = Input.ar;
        if (xa[0] < xa[1])
            WriteLine(0);
        else WriteLine(10);
    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public static long numL => ToInt64(read);
    public static char[][] gred(int h)
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static string[] strs(int n)
        => Enumerable.Repeat(0, n).Select(_ => read).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public static string[] Make<T1, T2>(out T1 v1, out T2 v2)
    {
        var r = read.Split(' ');
        v1 = getValue<T1>(r[0]);
        v2 = getValue<T2>(r[1]);
        return r;
    }
    public static string[] Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3)
    {
        var r = Make(out v1, out v2);
        v3 = getValue<T3>(r[2]);
        return r;
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public const int MOD = 1000000007;
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  int k, s;
  cin >> k >> s;
  
  int ans = 0;
  rep(i, k+1){
    rep(j, k+1){
      int z = s - i - j;
      if(0 <= z && z <= k) ans++;
    }
  }

  cout << ans << endl;

}

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

const int N = 100005;
int head[N], tot;
struct edge { int to, nxt; } e[N << 1];
void link(int x, int y) {
	e[++tot] = (edge) { y, head[x] }, head[x] = tot;
	e[++tot] = (edge) { x, head[y] }, head[y] = tot;
}

bool dfs(int x, int f = 0) {
	int sum = 0;
	for (int i = head[x]; i; i = e[i].nxt)
		if (e[i].to != f) sum += dfs(e[i].to, x);
	if (sum > 1) std::cout << "First\n", std::exit(0);
	return !sum;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	int n; std::cin >> n;
	for (int i = 1, x, y; i < n; ++i)
		std::cin >> x >> y, link(x, y);
	std::cout << (dfs(1) ? "First" : "Second") << '\n';
	return 0;
}

Measured memory_bytes: 2304
use std::io::*;
use std::str::FromStr;
use std::cmp;

fn main() {
	let (n, k): (u64, u64) = (read(), read());
	let mo = n % k;
	let ans = cmp::min(mo, k-mo);
	println!("{}", ans);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 4352
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    for i in 1..10 {
        if n % i == 0 && n / i < 10 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int t, n;
    for(int i=1; i<=4; i++){
    cin >> t >> n;
    if(t==1)
        cout << n*6000 << endl;
    else if(t==2)
        cout << n*4000 << endl;
    else if(t==3)
        cout << n*3000 << endl;
    else
        cout << n*2000 << endl;
    }
        
}


Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int M;
    static int D;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        D = sc.nextInt();

        System.out.println( BigDecimal.valueOf(solve()).toPlainString() );
    }

    static double solve() {
        double x;
        if( D == 0 ) {
            x = 1.0 / N;

        } else if( N <= D ) {
            x = 0.0;

        } else if( N <= 2*D ) {
            // 各数値一つだけ美しい
            x = 1.0 / N;

        } else {
            // [1, D] までは X-Dが存在しない
            // [N-D, N] までは X+Dが存在しない
            // [D+1, N-D-1] までは両側に存在する
            x = (double)(2*N - 2*D) / N / N;
        }

        return x * (M-1);
    }

    @SuppressWarnings("unused")
    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

        int nextInt() {
            return Integer.parseInt(next());
        }

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 22996
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 1; i < (n - 1); ++i) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) {
			ans++;
		}
	}
	cout << ans << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
N = int(input())
arr = list(map(int, input().split()))
cnt = arr.count(0)
if cnt == N:
    print('Yes')
    exit()
if N % 3 != 0:
    print('No')
    exit()
if cnt == N//3 and len(set(arr)) == 2:
    print('Yes')
    exit()
from collections import defaultdict
d = defaultdict(int)
for i in arr:
    d[i] += 1
if len(d) != 3:
    print('No')
    exit()
check = []
for key in d.keys():
    check.append(key)
if d[check[0]] == d[check[1]] and d[check[1]] == d[check[2]] and d[check[2]] == d[check[0]] and check[0]^check[1]^check[2] == 0:
    print('Yes')
else:
    print('No')


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  if (B == 1) {
    cout << 0 << endl;
    return 0;
  }

  int sum = A;
  int answer = 1;
  while (sum < B) {
    sum += A;
    sum -= 1;
    answer++;
  }

  cout << answer << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
   int top1, top2;
    vector<int> vec_sorted;

    
    for (int i = 0; i < n; i++) {
        cin >> vec[i];
    }
    vec_sorted = vec;
    sort(vec_sorted.begin(), vec_sorted.end(), greater<int>());

    top1 = vec_sorted.at(0);
    top2 = vec_sorted.at(1);

    for(int i = 0; i < n; i++) {
        if (top1 == vec[i]) {
            cout << top2 << endl;
        } else {
            cout << top1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
N, W = map(int, input().split())
items = sorted([list(map(int, input().split())) for i in range(N)])
V = 10**5

dp = [[float("inf")]*(N + 1) for i in range(V + 1)]
dp[0] = [0]*(N + 1)
for i in range(V + 1):
    for j in range(N):
        k = i - items[j][1]
        dp[i][j + 1] = min(dp[i][j + 1], dp[i][j])
        if k < 0:
            break
        else:
            dp[i][j + 1] = min(dp[i][j + 1], dp[k][j] + items[j][0])

for i in range(V, -1, -1):
    for j in range(N + 1):
        if dp[i][j] <= W:
            print(i)
            exit()


Measured memory_bytes: 213384
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long a, b;
  cin >> a >> b;
  long long s = a + b;
  if (s % 2 == 0)
  {
    cout << s / 2 << endl;
  }
  else
  {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int count=0;
  
  while(B>0){
    if(B-A < 0 || count==C)
      break;
    B-=A;
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
// const int N = ;

int n, r, ans;
string s;

void solve() {
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'R') r++;
    }
    for(int i = r; i < s.size(); i++) {
        ans += s[i] == 'R';
    }
    cout << ans << '\n';
}

int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 3764
#include <stdio.h>

int main(){
	char w[8];
	scanf("%s", w);
    
    if(w[0]=='S') printf("Cloudy\n");
    else if(w[0]=='C') printf("Rainy\n");
    else if(w[0]=='R') printf("Sunny\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){

	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

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

	return 0;
}


Measured memory_bytes: 3104
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int MAXN = 1 << 13;

int dp[MAXN];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    for (int i = 0; i < MAXN; i++) {
        dp[i] = INF;
    }
    int n, m;
    cin >> n >> m;
    vector<int> mask(m), cost(m);
    int b, ind;
    for (int i = 0; i < m; i++) {
        cin >> cost[i] >> b;
        for (int j = 0; j < b; j++) {
            cin >> ind;
            ind--;
            mask[i] |= (1 << ind);
        }
        dp[mask[i]] = min(dp[mask[i]], cost[i]);
    }
    for (int i = 0; i < MAXN; i++) {
        if (dp[i] == INF) continue;
        for (int j = 0; j < m; j++) {
            dp[i | mask[j]] = min(dp[i | mask[j]], dp[i] + cost[j]);
        }
    }
    if (dp[(1 << n) - 1] == INF) cout << -1;
    else cout << dp[(1 << n) - 1];
}
/*
3 2
*/


Measured memory_bytes: 384
#include <stdio.h>

int t1,t2;

int a,b,c,d,e,f;

int dp[3005][3005];     // water, then sugar

int a1=0,a2=0;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&f);
    // fill table
    dp[0][0]=1;
    for (int i=0; i<f; i++) {
        for (int j=0; j<f; j++) {
            if (!dp[i][j]) continue;
            // put the 4 things
            if (i+j+100*a<=f) dp[i+100*a][j]=1;
            if (i+j+100*b<=f) dp[i+100*b][j]=1;
            if (i+j+c<=f) dp[i][j+c]=1;
            if (i+j+d<=f) dp[i][j+d]=1;
            // check
            if ((i/100)*e>=j) {
                // a2/(a1+a2) <= j/(i+j)
                // a2*(i+j) <= j*(a1+a2)
                // a2*i <= j*a1
                //printf("can %d %d\n",i,j);
                if (a2*i <= j*a1) {
                    a1=i;
                    a2=j;
                }
            }
        }
    }
    printf("%d %d\n",a1+a2,a2);
}


Measured memory_bytes: 28800
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;

int pc(int a) {
	int res = 0;
	while (a > 0) {
		res += a % 2;
		a /= 2;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N, 0);
	vector<vector<int> >B(N, vector<int>(11));
	int res = 0;
	int a;
	for (int i = 0; i < N; i++) {
		A[i] = 0;
		for (int j = 0; j < 10; j++) {
			cin >> a;
			A[i] += a;
			A[i] *= 2;
		}
		A[i] /= 2;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> B[i][j];
		}
	}
	res = -1000000005;
	int sum = 0;
	for (int i = 1; i < ((int)1 << 10); i++) {
		sum = 0;
		for (int j = 0; j < N; j++) {
			sum += B[j][pc(i & A[j])];
		}
		res = max(res, sum);
	}
	cout << res << endl;
}

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

using namespace std;

int N, K;

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

	int maxK = (N - 1)*(N - 2) / 2;

	if (K > maxK)
	{
		cout << "-1";
		return 0;
	}

	int diff = maxK - K;

	cout << N - 1 + diff << endl;

	for (int i = 2; i <= N; i++)
	{
		cout << 1 << " " << i << endl;
	}

	int cnt = 0;

	for (int i = 2; i <= N; i++)
	{
		for (int j = i + 1; j <= N; j++)
		{
          	if (cnt >= diff) return 0;
			cout << i << " " << j << endl;
			cnt++;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	int result = 0;
	int count = 0;
	for (int i = 0; i < 3; i++)
	{
		if (S[i] == 'S') count = 0;
		else
		{
			count++;
			result = max(result, count);
		}
	}

	cout << result;

	return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll solve(ll x){
    ll h = x / 11, r = x % 11;
    if (r == 0) return h*2;
    if (r <= 6) return h*2 + 1;
    else return h*2 + 2;
}

int main() {
    ll x; cin >> x;
    cout << solve(x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<long long> x(5);
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    if(s[0]=='M') x[0]++;
    else if(s[0]=='A') x[1]++;
    else if(s[0]=='R') x[2]++;
    else if(s[0]=='C') x[3]++;
    else if(s[0]=='H') x[4]++;
  }
  long long ans=0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int l=j+1;l<5;l++){
        ans+=x[i]*x[j]*x[l];
      }
    }
  }
  cout << ans << endl;
}

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

const int maxn=200009;

int n;
int a[maxn];
int sum;

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

Measured memory_bytes: 4484
n = int(input())
mod = 10**9 + 7
if n==1:
    print(0)
else:
    #0が入ってるいる個数
    a = pow(10,n,mod) - pow(9,n,mod)
    #9が入っている個数
    b = pow(10,n,mod) - pow(9,n,mod)
    #0か9が入っている
    c = pow(10,n,mod) - pow(8,n,mod)

    ans = (a + b - c)%mod
    print(ans)

Measured memory_bytes: 9216