akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <random>

using namespace std;



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

	long long n, i, j, k, ans, ans1, ans2, nn;
	cin >> n;
	vector<long long> a(n), aa;
	vector<pair<long long, long long>> even, odd;

	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i % 2 == 0) even.push_back({ a[i], i });
		else odd.push_back({ a[i], i });
	}

	sort(even.begin(), even.end());
	sort(odd.begin(), odd.end());

	if (even[even.size() - 1].first < 0) ans1 = even[even.size() - 1].first;
	else {
		ans1 = 0;
		for (auto p : even) {
			if (p.first >= 0) ans1 += p.first;
		}
	}
	if (odd[odd.size() - 1].first < 0) ans2 = odd[odd.size() - 1].first;
	else {
		ans2 = 0;
		for (auto p : odd) {
			if (p.first >= 0) ans2 += p.first;
		}
	}

	vector<bool> keep(n, false), keep2;
	if (ans1 > ans2) {
		// use ans1
		if (even[even.size() - 1].first < 0) keep[even[even.size() - 1].second] = true; 
		else {
			for (auto p : even) {
				if (p.first >= 0) keep[p.second] = true; 
			}
		}
	}
	else {
		// use ans1
		if (odd[odd.size() - 1].first < 0) keep[odd[odd.size() - 1].second] = true;
		else {
			for (auto p : odd) {
				if (p.first >= 0) keep[p.second] = true;
			}
		}
	}

	ans = max(ans1, ans2);
	vector<long long> plist;

	while (a.size() > 1) {
		n = a.size();
		aa.clear();
		keep2.clear();

		if (!keep[0]) {
			plist.push_back(1);
			for (i = 1; i < n; i++) {
				aa.push_back(a[i]);
				keep2.push_back(keep[i]);
			}
		}
		else if (!keep[n - 1]) {
			plist.push_back(n);
			for (i = 0; i < n - 1; i++) {
				aa.push_back(a[i]);
				keep2.push_back(keep[i]);
			}
		}
		else for (i = 1; i < n - 1; i++) {
			if (keep[i - 1] == keep[i + 1]) {
				plist.push_back(i + 1);
				for (j = 0; j < i - 1; j++) {
					aa.push_back(a[j]);
					keep2.push_back(keep[j]);
				}
				aa.push_back(a[i - 1] + a[i + 1]);
				keep2.push_back(keep[i - 1]);
				for (j = i + 2; j < n; j++) {
					aa.push_back(a[j]);
					keep2.push_back(keep[j]);
				}
				break;
			}
		}

		swap(a, aa);
		swap(keep, keep2);
	}


	cout << ans << "\n";
	cout << plist.size() << "\n";
	for (auto p : plist) cout << p << "\n";

	return 0;
}



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

namespace AtCoderIO
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            var len = str.Count();

            int zero = 0;
            int one = 0;

            for(int i = 0; i < len; i++)
            {
                if (str[i] == '0')
                {
                    zero++;
                }
                else
                {
                    one++;
                }
            }

            var result = 0;

            if (zero < one)
            {
                result = zero * 2;
            }
            else
            {
                result = one * 2;
            }

            Console.WriteLine(result);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11360
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
//const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

struct UnionFind {
    // UnionFind u(n) 宣言
    // u.unionSet(x,y) 併合
    // u.findSet(x,y) -> {true, false}
    // u.root(x) xのroot. data[x]を参照。併合前はxそのもの、併合後は同一union
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main() {
    int n;cin>>n;
    vector<ll> a(n);cin>>a;
    vector<int> cnt(21,0);
    int l = 0;
    
    ll ans = 0;
    rep(i,n){
        bool flag = false;
        for(auto j = l;j<n;j++){
            
            rep(k,21){cnt[k]+=(a[j]>>k)%2;if(cnt[k]>=2) flag = true;}
            
            
            if(flag){
            
                rep(k,21) cnt[k]-=(a[j]>>k)%2;
                
                l = j;
                ans +=(l-i);
                break;
            }
            
        }
        
        if(!flag){
            
            ans += (n-i);
            l=n;
        }
        
        rep(k,21)cnt[k]-=(a[i]>>k)%2;
        
        
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define mo 1000000007
ll comb(ll N_, ll C_) {
	const int NUM_ = 400001;
	static ll fact[400002], factr[400002], inv[400002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mo, factr[i] = factr[i - 1] * inv[i] % mo;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mo*factr[N_ - C_] % mo;
}
ll modpow(ll a, ll n = mo - 2) {
	ll r = 1;
	while (n) r = r * ((n % 2) ? a : 1) % mo, a = a * a%mo, n >>= 1;
	return r;
}

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

	int N, K;
	cin >> N >> K;
	VI A(N);
	REP(i, N)cin >> A[i];
	SORT(A);
	int ans = 0;

	if (K == 1) {
		cout << 0 << endl;
		return 0;
	}
	/*
	int comba[100010];
	int L = 1, R = N;
	int j = 1;
	int ksum = 0;

	for (int i = N - 2; i >= 0; i--) {
		comba[j] = comb(i, K - 2);
		ksum += comba[j];
		j++;
	}
	//cout << j << endl;
	while (j > L) {

		//cout << A[R - 1] << " " << A[L - 1] << " " << ksum << endl;

		ans += ((A[R - 1] * ksum)%mod);
		ans -= ((A[L - 1] * ksum)%mod);
		ans += mod;
		ans %= mod;
		ksum -= comba[L];
		L++;
		R--;
		//cout << ans << endl;
	}


	cout << ans << endl;

	*/

	int ma = 0, mi = 0;
	//int cnt = 0;
	FOR(i, 1, N) {
		int cnt = comb(i, K - 1);
		ma += A[i] * cnt;
		mi += A[N - 1 - i] * cnt;
		ma %= mod;
		mi %= mod;
		//cout << cnt << endl;
	}







	cout << ((ma + mod) - mi) % mod << endl;

	return 0;
}



Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define SORT(x) sort((x).begin(),(x).end())
int main(void){
    
    int N,M,C;
    cin >>N >>M >>C;
    vector<int> B(M);
    
    for(int i=0; i<M; i++){
        cin >>B[i];
    }
    
    int cnt =0;
    
    for(int j=0; j<N; j++){
        int sum=0;
        
        for(int k=0; k<M; k++){
            int A;
            cin >>A;
            
            sum+=A*B[k];
        }
        cnt +=(sum>(-C));
    }
    
    cout <<cnt <<endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s,t;
    ll c=0;
    cin>>s;
    cin>>t;
    for(ll i=0;i<3;i++)
    {
        if(s[i]==t[i])
        c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	string ans = "APPROVED";
	rep(i, N) {
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				ans = "DENIED";
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <sstream>
#include <algorithm>
#include <fstream>
#include <list>
#include <map>
#include <istream>
#include <bitset>
#include <sstream>
#include <unordered_map>
#include <stack>
#include <set>
#include <cmath>
#include <random>
#include <iostream>
#include <bitset>
#include <iomanip>
#include <queue>
#include <string>

#define int long long
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rr return 0
#define xx first
#define yy second
#define pii pair<int,int>

using namespace std;
typedef long long ll;
typedef long double ld;

int n, q;
vector<vector<int>> g;
vector<int> used;
vector<int> d;
vector<int> ans;

void dfs(int v, int sum = 0){
    used[v] = true;
    sum += d[v];
    ans[v] = sum;
    for(auto i : g[v]){
        if(!used[i]){
            dfs(i, sum);
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    g.resize(n);
    used.resize(n);
    d.resize(n);
    ans.resize(n);
    for(int i = 0;i < n - 1;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    while(q--){
        int p, x;
        cin >> p >> x;
        p--;
        d[p] += x;
    }
    dfs(0);
    for(int i = 0;i < n;i++){
        cout << ans[i] << " ";
    }
    rr;
}


Measured memory_bytes: 24320
from math import ceil
from collections import defaultdict
N=int(input())
Time=defaultdict(int)
for i in range(N-1):
    c,s,f=map(int,input().split())
    for j in range(N):
        if j<i:Time[j]=max(s,(ceil(Time[j]/f))*f)+c
        elif j==i:Time[j]=s+c
        else:pass
for k in range(N):print(Time[k])

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long

int mod = 1e9+7;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
};

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> ans(K);
  int R = N - K;
  if (R == 0) {
    rep(i, 0, K) {
      if (i == 0) cout << 1 << endl;
      else cout << 0 << endl;
    }
    return 0;
  } else {
    rep(i, 0, K) {
      if (i == 0) {
        cout << (R + 1) % mod << endl;
        continue;
      }
      int I = i + 1;
      if (R < I - 1) {
        cout << 0 << endl;
        continue;
      }
      if (R == I - 1) {
        ll ans = 1;
        rep(j, K - I + 1, K) {
          ans *= j;
          ans = (ans % mod);
        }
        rep(j, 1, I) {
          ans = ans * modinv(j, mod) % mod;
        }
        cout << ans << endl;
        continue;
      }
      ll ans = 1;
      rep(j, K - I + 1, K) {
        ans *= j;
        ans = (ans % mod);
      }
      rep(j, 1, I) {
        ans = ans * modinv(j, mod) % mod;
      }
      rep(j, I + 1, R + 2) {
        ans *= j;
        ans = (ans % mod);
      }
      rep(j, 1, R - I + 2) {
        ans = ans * modinv(j, mod) % mod;
      }
      cout << ans << endl;
    }
  }
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

using namespace std;

char a[101];
char b[101];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i) cout << a[i] << b[i];
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    int m,n,total=0;
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        total+=a[i];
    }
    double threshold=(double)total/4.0/(double)m;
    int counter=0;
    for(int i=0;i<n;i++){
        if(a[i]>=threshold) counter++;
    }
    if(counter>=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=600005;
const int MOD=1000000007;
int n,m,L,R;
long long fac[N],inv[N];
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
void init(int n=600000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int n,int m)
{
	if(m>n) return 0;
	else return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
long long calc(long long x,int p,int q)
{
	x-=1LL*m*p;
	if(x<0) return 0;
	long long res=0;
	for(int i=0;i<=n-m&&x-1LL*i*q>=0;i++)
		if(i&1) res=(res-C(n-m,i)*C(x-1LL*i*q+n,n)%MOD+MOD)%MOD;
		else res=(res+C(n-m,i)*C(x-1LL*i*q+n,n)%MOD)%MOD;
	res*=C(n,m);
	return res;
}
long long solve(int x)
{
	long long res=0;
	for(int p=1;p<=x;p++)
		res=(res+(calc(x,p,p)-calc(x,p+1,p)+MOD)%MOD)%MOD;
	res=(C(x+n,n)-res+MOD)%MOD;
	return res;
}
int main()
{
	init();
	scanf("%d%d%d%d",&n,&m,&L,&R);
	printf("%lld",(solve(R)-solve(L-1)+MOD)%MOD);
	return 0;
}


Measured memory_bytes: 13220
#include<bits/stdc++.h>
using namespace std;
#define int long long
double W,H,x,y;
signed main(){
  cin >> W >> H >> x >> y;
  printf("%.9f\n", W*H/2.0);
  if(x==W/2.0 && y==H/2.0) cout << "1" << endl;
  else cout << "0" << endl;

  /*if((x==0&& y==0) || (x==W && y==H) || (x==0 && y==H) || (x==W && y==0)){
    printf("%.9lf\n", (double)W*(double)H/2.0);
    cout << "1" << endl;
  }
  else{
    int s1=W*y,s2=W*(H-y),s3=H*x,s4=H*(W-x);
    if(s1>s2) s1=s2;
    if(s3>s4) s3=s4;
    printf("%.9lf\n", (double)max(s1,s3));
    if(s1==s3) cout << "1" << endl;
    else cout << "0" << endl;
  }*/
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n;

ll mod=1e9+7,a[200005],dp[200005],s[200005];

int32_t main(){
    /*seed_seq seq{
        (uint64_t) chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count(),
        (uint64_t) __builtin_ia32_rdtsc(),
        (uint64_t) (uintptr_t) make_unique<char>().get()
    };
    mt19937 rng(seq);*/
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();

    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    s[a[1]]=1;
    for(int i=1;i<=n;i++){
        if(a[i]!=a[i-1]){
            dp[i]=s[a[i]];
        }
        else dp[i]=dp[i-1];
        if(i<n && a[i]!=a[i+1]) s[a[i+1]]+=dp[i],s[a[i+1]]%=mod;
    }
    cout << dp[n];

}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vector<pii> t(n);
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    t[i].first = a-b;
    t[i].second = a+b;
  }

  sort(all(t), [](pii l, pii r) { return l.second < r.second; });

  ll p = -(1LL<<60);;
  ll ans = 0;
  rep(i, n) {
    if (p <= t[i].first) {
      ans++;
      p = t[i].second;
    }
  }
  cout << ans << endl;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll A,B,M,minA=1e10,minB=1e10;
  cin>>A>>B>>M;
  vector<ll> a(A),b(B);
  rep(i,A) {cin >> a[i]; chmin(minA, a[i]); }
  rep(i,B) {cin >> b[i]; chmin(minB, b[i]); }
  ll ans = minA + minB;
  rep(i,M) {
    ll x,y,c;
    cin>>x>>y>>c;
    chmin(ans, a[x-1]+b[y-1]-c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int m=sc.nextInt();
  int ans=0;
  for(ans=0;ans<10000;ans++){
  	if(((int)Math.floor(ans*0.08)==n)&&((int)Math.floor(ans*0.1)==m))break;
  }
  System.out.println(ans==10000?-1:ans);
}
}


Measured memory_bytes: 23764
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = [list(map(int,input().split())) for i in range(M)]
SUM = sum(T)

for i in range(M):
    p,x = PX[i]
    print(SUM - T[p-1] + x)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050];
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }

    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }
  ll invvf[1000500],fact[1000500];
  void pre()
  {
      ll i,j,n=1000050;
      fact[0]=1; fact[1]=1;
      rep(i,2,n) {fact[i]=fact[i-1]*i; fact[i]%=hell;}
      invvf[1]=1; invvf[0]=1;
      rep(i,2,n)
      {
          invvf[i]=inv(fact[i]);
      }

  }
 ll ncr(ll n , ll r)
 {
     ll y=fact[n];
     y*=invvf[r];
     y%=hell;
     y*=invvf[n-r];
     y%=hell;
     return y;
 }


int phi(int n) {
    int result = n;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}
    void solve()
    {
    long long  i,j=0,r=200,p,q,k=0,d,y=0,n,h=100000000000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
      string s;
      cin>>s;
      if(s[1]=='R') s[1]='B';
      else s[1]='R';
      cout<<s;
    }
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //sieve();
        //pre();
         // cin>>t;
        solve();
    }


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

int main(void)
{
   string s, t;
   cin >> s >> t;
   rep(i, s.size())
   {
       bool flag = true;
       rep(j, s.size())
       {
           if(s[(i + j)%s.size()] != t[j]) flag = false;
       }
       if(flag)
       {
           puts("Yes");
           return 0;
       }
   }
   puts("No");
    return 0;
}

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

int main() {
  long long int n,m,d;
  cin >> n >> m >> d;
  double res;
  if(d == 0){
    res = (double)n / (n*n) * (m - 1);
  }
  else {
    res = ((double)(n-d) * 2) / (n*n) * (m - 1);
  }
  printf("%.12f",res);
  cout << endl;
  return 0;
}


Measured memory_bytes: 3760
chars = gets.chomp.split ""

idx_a = 0
idx_z = 0

chars.each_with_index do |char, idx|
  if char == "A" 
    idx_a = idx
    break
  end
end

chars.reverse.each_with_index do |char, idx|
  if char == "Z"
    idx_z = chars.size - idx - 1
    break
  end
end

puts idx_z - idx_a + 1

Measured memory_bytes: 18300
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)
template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}

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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................
int printNonDivisible(int A[], int n) 
{ 
    // Find maximum element in B[] 
    sort(A,A+n);
    int maxA = A[n-1]; 
    
  
    // Initialize all multiples as marked 
    int mark[maxA+5]; 
    memset(mark, 0, sizeof(mark)); 
  
    // Marking the multiples of all the 
    // elements of the array. 
    for (int i = 0; i < n; i++) 
        for (int x = A[i]; x <= maxA; x += A[i]) 
            mark[x]++; 
  
    // Print not marked elements 
    int cnt=0;
    for (int i = 0; i < n; i++) 
        if (mark[A[i]]<=1) 
            cnt++;
            return cnt;
} 

int main()
{   
     auto start = chrono::high_resolution_clock::now();
    fast
    int n;
    cin>>n; 
    int a[n];
    rep(i,n)cin>>a[i];
    cout<<printNonDivisible(a,n)<<"\n";
    auto end = chrono::high_resolution_clock::now();
    TIME(start, end);
    return 0;
}

Measured memory_bytes: 8340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
int main(){
  vector<int> Product(5);
  for (int  i = 0; i < 5; i++)
  {
    cin >> Product[i];
  }
  int min_time = 20021003;

  do{
    int ans = 0;
    for (int  i = 0; i < 5; i++)
    {
      while (ans % 10 != 0)
      {
        ans++;
      }
      ans += Product[i];
    }
    min_time = min(min_time, ans);
  } while(next_permutation(Product.begin(), Product.end()));
  cout << min_time << endl;
}

Measured memory_bytes: 256
// Problem : C - Multiple Gift
// Contest : AtCoder Regular Contest 088
// URL : https://atcoder.jp/contests/arc088/tasks/arc088_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

ll x, y;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> x >> y;
	y /= x;
	int z = log2(y);
	if ((1ll << z) > y) z--;
	cout << z + 1;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    else {
        return gcd(b, a % b);
    }
}

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

int main() {
    int n;
    cin >> n;
    ll result = 1;
    
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        result = lcm(result, a);
    }
    cout << result << endl;
    return 0;
}

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

#define inf 1000000000
#define infmx 1e18
#define ff first
#define ss second
#define ll long long
#define pb push_back
typedef pair<int,int>pi;
typedef pair<long long,long long>pll;
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const int N=300000;
int mark[33];
bool check(int num)
{
    while(num>0)
    {
        int dig=num%10;
        num/=10;
//        cout<<"dig = "<<dig<<endl;
        if(mark[dig])return 0;
    }
    return 1;
}

int main()
{
    IOS;
    int n,k;
    cin>>n>>k;
    for(int i=0;i<k;i++)
    {
        int a;cin>>a;
        mark[a]=1;
    }
    int res=n;
    for(int i=n;;i++)
    {
        if(check(i)){
            res=i;
            break;
        }
    }
    cout<<res<<endl;
}


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

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  long long n, s;
  scanf("%lld %lld", &n, &s);
  if (n < s) {
    puts("-1");
    return 0;
  }
  if (n == s) {
    printf("%lld\n", n + 1);
    return 0;
  }
  auto check = [&](long long b) {
    long long ret = 0;
    long long x = n;
    while (x > 0) {
      ret += x % b;
      x /= b;
    }
    return ret == s;
  };
  long long ans = LLONG_MAX;
  for (int b1 = 1; b1 * 1LL * b1 <= n - s; ++b1) {
    if ((n - s) % b1 != 0) {
      continue;
    }
    {
      int b = b1 + 1;
      if (check(b)) {
        ans = min(ans, b * 1LL);
      }
    }
    {
      long long b = (n - s) / b1 + 1;
      if (check(b)) {
        ans = min(ans, b);
      }
    }
  }
  printf("%lld\n", ans == LLONG_MAX ? -1 : ans);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
#include <map>

/*
\cap_{u,v} \cup_{i\in (u,v) path} E_i

g(N) = |{E | {u,v\in M | \cup_{i\in (u,v) path} E_i} = N}|
G(N) = |{E | {u,v\in M | \cup_{i\in (u,v) path} E_i} \subseteq N}|
     = |{E | {u,v\in M-N | \cap_{i\in (u,v) path} !E_i}}|
*/

int n, m;
std::vector<int> E[50];
int D[50][50];

long long int M[20];
long long int A[1<<20];
std::map<std::pair<int, int>, int> edges;

long long int dfs(int u, int v, int p){
  if(u == v) return 0;
  for(int x: E[u]){
    if(x == p) continue;
    long long int b = dfs(x, v, u);
    if(b != -1) return (1LL << edges[{u, x}]) | b;
  }
  return -1;
}

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n-1; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    E[a-1].push_back(b-1);
    E[b-1].push_back(a-1);
    edges[{a-1,b-1}] = i;
    edges[{b-1,a-1}] = i;
  }
  scanf("%d", &m);
  for(int i = 0; i < m; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    M[i] = dfs(a-1, b-1, -1);   
  }
  long long int ans = 0;
  for(int i = 0; i < (1<<m); i++){
    A[i] = A[i&(i-1)] | M[__builtin_ctzll(i)];
    long long int x = 1LL << (n-1-__builtin_popcountll(A[i]));
    if(__builtin_parity(i)) x = -x;
    ans += x;
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 8448
n=input()
li=list(n)
if len(n)==1:
  print(0)
elif len(n)%2==0:
  counta=0 
  countb=0
  a=list("10"*int((int(len(n))/2)))
  b=list("01"*int((int(len(n))/2)))
  for i in range(len(n)):
    counta+= abs(int(li[i])-int(a[i]))
    countb+=abs(int(li[i])-int(b[i]))
  print(min(counta,countb))

elif len(n)%2==1 and len(n) != 1:
  countaa=0 
  countbb=0
  aa=list("10"*int(((int(len(n))-1)/2))+"1")
  bb=list("01"*int(((int(len(n))-1)/2))+"0")
  for i in range(len(n)):
    countaa+=abs(int(li[i])-int(aa[i]))
    countbb+=abs(int(li[i])-int(bb[i]))
  print(min(countaa,countbb))


Measured memory_bytes: 5748
//【ライブラリここから】
// 1. 入力の容易化（https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8）
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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//【ライブラリここまで】

fn main() {
    input! {d:i32, t:i32, s:i32};
    println!("{}", if d > t * s { "No" } else { "Yes" });
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int solve(int n) {
  int ret = 0;
  for (int i=1; i<=n; ++i) {
    if (n%i==0) ret++;
  }
  return ret;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  int ans = 0;
  for (int i=1; i<=n; i+=2) {
    if (solve(i)==8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

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

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	int n;
	cin >> n;
	VI h(n);
	rep(i, n) cin >> h[i];

	int ans = n;
	bool flag = 0;
	for (int i = 1; i<n; i++) {
		flag = 1;
		for (int j = 0; j < i; j++) {
			if (h[i] < h[j]) {
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
t, a = map(int, input().split())
h = np.array(list(map(int, input().split())))

A = [abs(a-(t-x*0.006)) for x in h]
[idx] = [i for i, x in enumerate(A) if x == min(A)]

print(idx+1)

Measured memory_bytes: 12388
import itertools
A,B,C=map(int,input().split())
L=[str(A),str(B),str(C),"+"]
S=list(itertools.permutations(L,4))
ans=0
for seq in S:
    if seq[0]=="+" or seq[3]=="+":
        continue
    eq="".join(seq)
    tmp=eval(eq)
    if ans<tmp:
        ans=tmp
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,m;
int a[55][55];
int v[55];
int h[55],g[55];
void dfs(int u,int fa)
{
    if(v[u])return ;
    v[u]=1;
    for(int i=0; i<n; i++)
        if(a[u][i]==1)
        {
            dfs(i,u);
        }
}
int main()
{
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>h[i]>>g[i];
        h[i]--;
        g[i]--;
        a[h[i]][g[i]]=a[g[i]][h[i]]=1;

    }
    int ans=0;
    for(int i=0; i<m; i++)
    {
        a[h[i]][g[i]]=a[g[i]][h[i]]=0;
        memset(v,0,sizeof v);
        dfs(0,-1);
        for(int j=0; j<n; j++)
            if(v[j]==0)
            {
                ans++;
                break;
            }
        a[h[i]][g[i]]=a[g[i]][h[i]]=1;
    }
    cout<<ans<<endl;
}


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

int main() {
  string s;
  int count = 0;
  
  cin >> s;
  for (char c: s) {
    if (c == 'o')
      count++;
  }
  cout << count * 100 + 700 << endl;
  return 0;
}

Measured memory_bytes: 256
import scala.io.Source

object Main extends App {
  val input = Source.stdin.getLines.map(_.split(" ").toList.map(_.toInt)).toList

  val matrixA: List[List[Int]] = input.tail.dropRight(input(0)(1))
  val vectorB: List[Int] = input.drop(input(0)(0)+1).flatten

  println((for {
    line <- matrixA
    i <- 0 to input(0)(1)-1
  } yield { line(i) * vectorB(i) }).sliding(input(0)(1), input(0)(1)).toList.map(_.sum).mkString("\n"))
}

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

using namespace std;

void mySwap(int* a, int* b) {

	int tmp = *a;

	*a = *b;

	*b = tmp;

}

int main(void) {

	int n; cin >> n;
	int sw = 0;
	
	int* a = new int[n + 1];

	a[0] = 0;

	for (int i = 1; i <= n; ++i) {

		int num; cin >> num;

		if (num == i) {

			a[i] = 1;

		}
		else {

			a[i] = 0;

		}

	}

	for (int i = 1; i <= n;) {

		if (a[i]) {

			if (a[i + 1]) {

				a[i] = 0;
				a[i + 1] = 0;

				i += 2;

			}
			else {

				a[i] = 0;

				++i;

			}

			++sw;

		}
		else {

			++i;

		}

	}

	cout << sw << endl;

	return 0;

}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
	int i;
	int counter[26]={0};
	char ch;
	
	while(scanf("%c",&ch)!=EOF){
		if(ch==EOF) break;
		int num=ch-'a';
		if(0<=num && num<26){
			counter[num]++;
		}else if(-32<=num && num<-6){
			counter[num+32]++;
		}
	//	printf("%c %d\n",ch,ch);
	}
	
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,counter[i]);
	}
	return 0;
}

Measured memory_bytes: 540
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int i,j,k,N;
char S[200001],T[200001];

int main()
{
  cin>>S>>T;
  N=strlen(S);
  k=0;
  for(i=0;i<N;i++)
  {
    if(S[i]!=T[i]) k++;
  }
  cout<<k;
}

Measured memory_bytes: 4008
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int x[100],i=0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x[i-2]=x[i-2]+x[i-1];
      i--;  
    } else if ( s[0] == '-' ){
      x[i-2]=x[i-2]-x[i-1];
      i--;
    } else if ( s[0] == '*' ){
      x[i-2]=x[i-2]*x[i-1];
      i--;
    } else {
      x[i] = atoi(s);
      i++;
    }
  }
  printf("%d\n",x[0]);
  return 0;
}

Measured memory_bytes: 548
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

constexpr int NA {10000};

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

  int c,t;
  int ans{NA};
  for (int i = 0; i < N; i++) {
    cin >> c >> t;
    if (t <= T) {
      ans = min(ans,c);
    }
  }

  cout << (ans == NA ? "TLE" : to_string(ans)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
typedef long long ll;
const int maxn = 40;
pii _1[100010];
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif // LOCAL
    ios::sync_with_stdio(0);
    int n, tmp;
    scanf("%d", &n);
    map<int, int> cnt1, cnt2;
    for (int i = 0; i < n; i++) {
        scanf("%d", &tmp);
        if (i&1)cnt1[tmp] ++;
        else cnt2[tmp] ++;
    }
    cnt1[-1000] = 0;
    cnt2[-1000] = 0;
    tmp = 0;
    for (auto a:cnt1) _1[tmp++] = make_pair(a.second, a.first);
    sort(_1, _1+tmp);
    int maxn = 0;
    for (auto a:cnt2) {
        for (int i = tmp-1; i >= 0; i--) {
            if (_1[i].second != a.first) {
                maxn = max(maxn, _1[i].first + a.second);
                break;
            }
        }
    }
    printf("%d", n - maxn);
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
int main(){
	int n,m;
	cin>>n>>m;
	vl a(n);
	priority_queue<int> que;
	rep(i,n){
		cin>>a[i];
		que.push(a[i]);
	}
	int x;
	ll ans=0;
	rep(i,m){
		x=que.top()/2;
		que.pop();
		que.push(x);
	}
	while(!que.empty()){
		ans+=que.top();
		que.pop();
	}
	cout<<ans<<endl;
}















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

signed main(){
  int N;
  cin >> N;
  vector<unsigned long long int>A(N);
  unsigned long long int ans=0;
  for(int K=1;K<=N;K++){
    for(int i=1;i<=N/K;i++){
      A[K*i]++;
    }
  }
  for(int i=1;i<=N;i++){
    ans+=A[i]*i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 81396
#include<stdio.h>

int main()
{
    int a, b, c, count = 0;
    scanf("%d %d %d", &a, &b, &c);

    for(int i = a; i <= b; ++i){
        if(c%i == 0)  ++count;
    }

    printf("%d\n", count);
    
    return 0;
}



Measured memory_bytes: 2104
#include<stdio.h>

int main(){
	
	char s[7];          //0 1 2 3 4 5 6
	scanf("%s",&s);    // a b c d e f g
	
	s[2] == s[3] && s[4] == s[5]? printf("Yes") : printf("No");
	
	return 0;
}

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

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

using namespace std;

ll gcd(ll a, ll b){
  if(a==1 || b==1)return 1;
  if (a < b)swap(a,b);
  
  return b ? gcd(b, a % b) : a;
}

int main(){
  int n;cin>>n;
  map<ll, ll>a;
  rep(i, n){
    ll t;cin>>t;
    a[t]++;
  }
  bool f=true;
  for(auto p:a)if(p.second>1){f=false;break;}
  if(f) cout<<"YES";
  else cout<<"NO";

  return 0;
}

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

const int MOD = (int)1e9+7;

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++)  cin >> a.at(i);

  long long count1=0;
  long long sum=0;
  for(int i=0;i<n;i++){
    sum+=a.at(i);
    if(i%2==0 && sum<=0){
      count1=count1-sum+1;
      sum=1;
    }
    else if(i%2==1 && sum>=0){
      count1=count1+sum+1;
      sum=-1;
    }
  }

  long long count2=0;
  sum=0;
  for(int i=0;i<n;i++){
    sum+=a.at(i);
    if(i%2==0 && sum>=0){
      count2=count2+sum+1;
      sum=-1;
    }
    else if(i%2==1 && sum<=0){
      count2=count2-sum+1;
      sum=1;
    }
  }
  cout << min(count1,count2) << endl;

  return 0;
}


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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;

main(){
	int n;
	cin >> n;
	int a[n];
	
	for(int i=0;i<n;i++){
		a[i] = 0;
	} 
	for(int i=0;i<n-1;i++){
		int t;
		cin >> t;
		t--;
		a[t]++;
	} 

	for(int i=0;i<n;i++){
		cout << a[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 5036
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
#include<vector>
struct da
{
	long long s,t;
};
bool operator <(const da &x,const da &y)
{
	if(x.s!=y.s)return x.s<y.s;
	return x.t<y.t;
}
bool operator ==(const da &x,const da &y)
{
	return x.s==y.s&&x.t==y.t;
}
int fa[133333],siz[133333],lea[133333],lc[133333],rc[133333];
long long dep[133333];
std::vector<da> f[133333];
int n;
da a[133333],b[133333],c[133333];
int pa,pb,pc;
bool chk(long long m)
{
	for(register int i=n;i;--i)f[i].clear();
	for(register int i=n;i;--i)
		if(lea[i])f[i].push_back((da){dep[i],dep[i]});
		else
		{
			if(siz[i[lc]]>siz[i[rc]])std::swap(i[lc],i[rc]);
			int ls=f[i[lc]].size();
			int rs=f[i[rc]].size();
			pa=pb=0;
			for(register int j=0;j<ls;++j)
			{
				long long t1=f[i[lc]][j].t;
				int ret=-1;
				for(register int l=0,r=rs-1,mid=l+r>>1;l<=r;mid=l+r>>1)
					if(f[i[rc]][mid].s+t1-2*dep[i]<=m)ret=mid,l=mid+1;
						else r=mid-1;
				if(ret!=-1)a[++pa]=(da){f[i[lc]][j].s,f[i[rc]][ret].t};
			}
			for(register int j=0;j<ls;++j)
			{
				long long s1=f[i[lc]][j].s;
				int ret=-1;
				for(register int l=0,r=rs-1,mid=l+r>>1;l<=r;mid=l+r>>1)
					if(f[i[rc]][mid].t+s1-2*dep[i]<=m)ret=mid,r=mid-1;
						else l=mid+1;
				if(ret!=-1)b[++pb]=(da){f[i[rc]][ret].s,f[i[lc]][j].t};
			}
			int P=1,Q=1;
			pc=0;
			while(P<=pa&&Q<=pb)
			{
				da min=dmin(a[P],b[Q]);
				if(a[P]==min)
				{
					c[++pc]=a[P];
					if(a[P]==b[Q])Q++;
					P++;
				}
				else c[++pc]=b[Q],Q++;
			}
			while(P<=pa)c[++pc]=a[P++];
			while(Q<=pb)c[++pc]=b[Q++];
			for(register int j=1;j<=pa;++j)a[j]=a[0];
			for(register int j=1;j<=pb;++j)b[j]=b[0];
			int now=0;
			for(register int j=1;j<=pc;++j)
				if(!now||c[now].t>c[j].t)c[++now]=c[j];
			for(register int j=1;j<=now;++j)
				f[i].push_back(c[j]);
			if(f[i].size()==0)return 0;
		}
	return 1;
}
int main()
{
	n=io::F();
	for(register int i=2;i<=n;++i)
	{
		fa[i]=io::F(),dep[i]=dep[fa[i]]+io::F(),lea[i]=1;
		if(!fa[i][lc])fa[i][lc]=i,lea[fa[i]]=0;
			else fa[i][rc]=i;
	}
	for(register int i=n;i;--i)
		++siz[i],siz[fa[i]]+=siz[i];
	long long ans=1ll<<34;
	for(register long long l=0,r=ans,mid=l+r>>1;l<=r;mid=l+r>>1)
		if(chk(mid))ans=mid,r=mid-1;
			else l=mid+1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 34292