akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa

using namespace std;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  string s; cin >> s;
  int i, j, z, ans = 0;
  i = 0; j = n-1;
  while (i < j) {
    while (i < j && s[i] != 'W') i++;
    while (j > i && s[j] != 'R') j--;
    if (i < j && s[i] == 'W' && s[j] == 'R') {
      ans++;
      swap(s[i], s[j]);
      i++;
      j--;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3768
import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
        int n = sc.nextInt();
        double a = 1;
        double b = 0;
        for(int i = 0; i < n; i++) {
            int k = sc.nextInt();
           b += 1.0 / k;
        }
        

        System.out.println(a / b);


    } 
}

Measured memory_bytes: 23124
#include<stdio.h>

int main(void)
{
	int i,x;
	
	for(i=1;i<=10000;i++){
		scanf("%d",&x);
		if(x==0){
			break;
		}
		printf("Case %d: %d\n",i,x);
		
	}
	
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define MAX_V 100000
using namespace std;
int m,w[100001];
vector<int> vv[100001];
unordered_set<int> st[100001];
int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V];
int C[100001],F[100001],U[100001],ans;
bool UU[100001];


void DFS(int p){
  for(int i=0;i<vv[p].size();i++){
    int mn=min(vv[p][i],p),mx=max(vv[p][i],p);
    if(st[mn].find(mx)==st[mn].end()){
      st[mn].insert(mx);
      G[p].push_back(vv[p][i]);
      rG[vv[p][i]].push_back(p);
      DFS(vv[p][i]);
    }
  }
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++)if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++)if(!used[rG[v][i]])rdfs(rG[v][i],k);
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++)if(!used[v])dfs(v);
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]])rdfs(vs[i],k++);
  return k;
}

bool DFS1(int p){
  if(U[p])return 0;
  U[p]=1;
  bool f=F[cmp[p]]>=2;
  for(int i=0;i<G[p].size();i++)
    f|=DFS1(G[p][i]);
  ans+=w[p]*f;
  return UU[p]=f;
}
bool UUU[100001];
int DFS2(int p){
  if(UUU[p])return 0;
  UUU[p]=1;
  int res=0;
  
  for(int i=0;i<G[p].size();i++)
    res=max(res,DFS2(G[p][i]));  
  return res+(UU[p]?0:w[p]);
}

int main(){
  cin>>V>>m;
  for(int i=0;i<V;i++)cin>>w[i];
  for(int j=0,a,b;j<m;j++){
    cin>>a>>b;a--,b--;
    vv[a].push_back(b),vv[b].push_back(a);
  }
  DFS(0);
  int t=0;
  for(int i=0;i<V;i++)t+=w[i];
  scc();
  for(int i=0;i<V;i++)F[cmp[i]]++;
  DFS1(0);
  cout<<ans+DFS2(0)<<endl;
  return 0;
}

Measured memory_bytes: 42756
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

int mod_pow(int x,int n,int mod){
  if(n==0)return 1;
  int res=mod_pow( x*x%mod , n/2 ,mod);
  if( n & 1 )res = res*x%mod;
  return res;
}

int fact[1000003],ifact[1000003];

signed main(){
  int q,p=1000003;
  cin>>q;
  fact[0]=ifact[0]=1;
  FOR(i,1,1000003){
    fact[i]=(fact[i-1]*i)%p;
    ifact[i]=mod_pow(fact[i],p-2,p);
  }
  
  rep(cn,q){
    int x,d,n;
    cin>>x>>d>>n;
    
    if(d==0){
	 cout<<mod_pow(x,n,p)<<endl;
	 continue;
    }
    
    if(d>1){
	 x*=mod_pow(d,p-2,p);
	 x%=p;
    }
    
    if(n>=p||x==0||x>(x+(n-1))%p){
	 cout<<0<<endl;
	 continue;
    }

    int ans = (fact[(x+n-1)%p]*ifact[x-1])%p;
    if(d>1){
	 ans*=mod_pow(d,n,p);
	 ans%=p;
    }

    cout<<ans<<endl;
    
  }
  return 0;
}


Measured memory_bytes: 16512
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
minans = inf ;ans = 0 ;count = 0 ;pro = 1



n=int(input())
A=list(map(int,input().split()))
for i in range(n-1):
    A[i+1]+=A[i]
C=collections.Counter(A)
C[0]+=1
# print(C)
for ci in C.values():
    count+=(ci*(ci-1))//2
print(count)

Measured memory_bytes: 94960
#include <bits/stdc++.h>
#define REP(i, n, s) for (int i = (s); i < (n); i++)
using namespace std;
typedef long long int LL;
typedef long double LD;

const int MAXN = 1e5 + 1;
const int LOGV = 17;

int dp[LOGV][MAXN], X[MAXN];

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

	int N, L, Q, logV;

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> X[i];
	}
	for (logV = 1; (1 << (logV + 1)) <= N; logV++);
	cin >> L;
	for (int i = 1, j = 1; i <= N; i++) {
		while (j <= N && X[j] - X[i] <= L) j++;
		dp[0][i] = j - 1;
	}
	for (int i = 1; i <= logV; i++) {
		for (int j = 1; j + (1<<i)-1 <= N; j++) {
			dp[i][j] = dp[i-1][dp[i-1][j]];
		}
	}
	cin >> Q;
	int a, b;
	while (Q--) {
		cin >> a >> b;
		if (a > b) a ^= b ^= a ^= b;
		int step = 0;
			for (int i = logV; i >= 0; i--) {
			if (dp[i][a] && dp[i][a] < b) {
				step += 1 << i;
				a = dp[i][a];
			}
		}
		cout << step + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 7424
import java.util.Scanner;
    class Main{
    public static void main (String[] args){
    Scanner scanner =new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    int d = scanner.nextInt();
    if(a+b>c+d)
    System.out.println("Left");
    else if(a+b<c+d)
    System.out.println("Right");
    else
    System.out.println("Balanced");
    scanner.close();
    }
    }

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

int main(){
    int t[5];
    int a=0;
    for(int i=0;i<5;i++){
        cin>>t[i];
        if(t[i]%10!=0){
            if(10-(t[i]%10)>a)a=10-(t[i]%10);
            t[i]+=10-(t[i]%10);
        }
    }
    int ans=0;
    for(int i=0;i<5;i++){
        ans+=t[i];
    }
    cout<<ans-a<<endl;
    return 0;
}

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

int main(void) {
    int a, b, c;

    cin >> a >> b >> c;

    if ((a == 5 && b == 5 && c == 7) || (a == 5 && b == 7 && c == 5) || (a == 7 && b == 5 && c == 5)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//
//  Created by Vijay Bhati on 19/02/20.
//  Copyright © 2019 Vijay Bhati. All rights reserved.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <map>
#include <sstream>
#include <set>
#include <iomanip>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cassert>
#include <memory>
#define ll long long
#define ull unsigned long long
#define pi acos(-1.0)
#define rf freopen("in.txt", "r", stdin);
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define P pair<ll, ll>
#define ff first
#define ss second
#define F first
#define S second
#define MOD 1000000007
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)

using namespace std;

ll max(ll a, ll b) {
    return a > b ? a : b;
}

ll min(ll a, ll b) {
    return a > b ? b : a;
}

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

ll find_power(ll a, ll b) {
    ll ans = 1;
    while (b > 0) {
        if (b & 1) {
            ans = (ans * a) % 1000000007;
        }
        b = b >> 1;
        a = (a * a) % 1000000007;
    }
    return ans;
}


int main() {
#ifdef __APPLE__
    const clock_t begin_time = clock();
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    
    ll n, k;
    cin >> n >> k;
    int h[100005];
    ll dp[100005];
    
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    
    dp[1] = 0;
    
    for (int i = 2; i <= n; i++) {
        dp[i] = 1e18;
        for (int x = 1; x <= k; x++) {
            if (i - x <= 0) break;
            dp[i] = min(dp[i], dp[i-x] + abs(h[i] - h[i-x]));
        }
    }
    cout << dp[n] << endl;
    
    
#ifdef __APPLE__
    cout << endl;
    cout << "Time : ";
    cout << float( clock () - begin_time ) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> l[i];
    sum += l[i];
  }
  if(*max_element(l.begin(),l.end()) < sum - *max_element(l.begin(), l.end())){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
n = int(input())
a = list(map(int,input().split()))
x = [0 for _ in range(10**5+1)]
for ai in a:
  x[ai] += 1
p = 0
q = 0
for xi in x:
  if xi%2 == 1:
    p += 1
  elif xi > 0:
    q += 1
if q%2 == 0:
  print(p+q)
else:
  print(p+q-1)
    

Measured memory_bytes: 90072
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a,b,c,d;
    string s,t;

    cin >> a >> b>> c;// >> d;
    //cin >> s >> t;
    if (b-c>=0) cout << "delicious";
    else if (a+b-c>=0) cout <<"safe";
    else cout << "dangerous";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n, k;
	cin >> n >> k;
	
	if(k > (n + 1) / 2) { cout << -1 << endl; return 0; }
	
	vector<int> a(n), b(n), c(n);
	inc(i, n) { a[i] = i; }
	inc(i, n) { b[(i + n / 2) % n] = n + i; }
	inc(i, n) { c[i] = a[i] + b[i] + (n + 1) / 2 +  (n % 2 == 0 && i < n / 2 ? 1 : 0); }
	
	inc(i, n) {
		cout << a[i] + k << " " << b[i] + k << " " << c[i] + k << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int red =0;
      int blue =0;
      for(int i=0;i<s.length();i++){
        if(s.charAt(i)=='0'){
          red++;
        }else{
          blue++;
        }
      }
      System.out.println(Math.min(red,blue)*2);
    }
}

Measured memory_bytes: 39228
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {


    ll n; cin >> n;
    vector<ll> c(n-1),s(n-1),f(n-1);
    ll time = 0;

    rep(i,n-1){
        cin >> c[i]  >> s[i] >> f[i];
    }

    rep(i,n-1){
        for(int j = i; j < n-1; j ++){
            if(j == i) time = s[j] + c[j];
            else{
                if(s[j] >= time) time = s[j] + c[j];
                else {
                    time = c[j] + (time/f[j])*f[j] + ((time%f[j] == 0)?0:f[j]);
                }
            }
        }
        cout << time << endl;
    }
    cout << 0 << endl;


    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int root;
int t[2][100000],hight[100000];
int dfs(int p){
  if(p==-1)return -1;
  return hight[p]=max(dfs(t[0][p]),dfs(t[1][p]))+1;
}

int main(){
  int root;
  int n,par[100000],sib[100000];
  cin>>n;
  for(int i=0;i<n;i++)sib[i]=par[i]=-1;
  for(int i=0;i<n;i++){
    int a,b,c;
    cin>>a>>b>>c;
    t[0][a]=b;
    t[1][a]=c;
    if(b!=-1)sib[b]=c,par[b]=a;
    if(c!=-1)sib[c]=b,par[c]=a;
    }
  for(int i=0;i<n;i++)if(par[i]==-1)root=i;
  dfs(root);
  for(int i=0;i<n;i++){
    int dep=0,deg=(int)(t[0][i]!=-1)+(int)(t[1][i]!=-1);
    for(int j=par[i];j!=-1;j=par[j])dep++;
    cout<<"node "<<i<<": parent = "<<par[i]<<", sibling = "<<sib[i]<<", degree = "<<deg<<", depth = "<<dep<<", height = "<<hight[i]<<", ";
    if(!dep)cout<<"root";
    else if(t[0][i]==t[1][i])cout<<"leaf";
    else cout<<"internal node";
    cout<<endl;
    }
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int hund, ten, one;
  vector<int> x(s.size()-2);
  for (int i=0 ; i<s.size()-2 ; i++){
    hund = s.at(i) - '0';
    ten = s.at(i+1) - '0';
    one = s.at(i+2) - '0';
    x.at(i) = hund*100 + ten*10 + one;
  }
  
  int min = abs(x.at(0)-753);
  for (int i=1 ; i<x.size() ; i++){
    if (abs(x.at(i)-753) < min)
      min = abs(x.at(i)-753);
  }
  
  cout << min << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 101;
const LL INF = 1e18;
vector<vector<vector<vector<LL> > > > dp;

vector<LL> cnt[4];
LL prefix[4][1000];
int n;
LL wt[MAXN], val[MAXN], W;

int main() {
  ios_base::sync_with_stdio(false);
	cin >> n >> W;
	for(int i = 1; i <= n; i++) {
		cin >> wt[i] >> val[i];
		cnt[wt[i] - wt[1]].push_back(val[i]);
	}
	vector<int> sizes;
	for(int i = 0; i < 4; i++) {
		sizes.push_back(cnt[i].size());
		sort(cnt[i].begin(), cnt[i].end(), std::greater<LL>());
		for(int j = 1; j <= cnt[i].size(); j++) {
			prefix[i][j] = prefix[i][j-1] + cnt[i][j-1];
		}
	}
	LL res = 0;
	for(LL i = 0; i <= sizes[0]; i++) {
		for(LL j = 0; j <= sizes[1]; j++) {
			for(LL k = 0; k <= sizes[2]; k++) {
				for(LL p = 0; p <= sizes[3]; p++) {
					if(i * (wt[1]) + j * (wt[1] + 1) + k * (wt[1] + 2) + p * (wt[1] + 3) <= W) {
						LL temp = prefix[0][i] + prefix[1][j] + prefix[2][k] + prefix[3][p];
						res = max(res, temp);
					}
				}
			}
		}
	}
	cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    map<string,ll> blue,red;
    cin >> N;
    string S;
    rep(i,N){
        cin >> S;
        blue[S]++;
    }
    cin >> M;
    rep(i,M){
        cin >> S;
        red[S]++;
    }
    ll ans = 0;
    for(auto x : blue){
        chmax(ans,x.second - red[x.first]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
s = input()
p = input()

f = False

for i in range(len(s)):
        if s[i] == p[0]:
                f = True
                for j in range(len(p)):
                        if s[(i+j)%len(s)] != p[j]:
                                f = False
                                break

                if f == True:
                        break

if f == True:
        print("Yes")
else:
        print("No") 


Measured memory_bytes: 5560
#include <stdio.h>
#define MAX 100
#define INFTY 2097152
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(void)
{
  int minv,i,v,u;
  int d[MAX],color[MAX];
  for(i=0;i<n;i++)
  {
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  while(1)
  {
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++)
    {
      if(minv>d[i] && color[i]!=BLACK)
      {
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)
    {
      break;
    }
    color[u]=BLACK;
    for(v=0;v<n;v++)
    {
      if(color[v]!=BLACK && M[u][v]!=INFTY)
      {
        if(d[v]>d[u]+M[u][v])
        {
          d[v]=d[u]+M[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
for(i=0;i<n;i++)
{
      printf("%d ",i);
    if(d[i]==INFTY)
    {
      printf("-1\n");
    }
    else
    {
      printf("%d\n",d[i]);
    }
}

}

int main()
{
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      M[i][j]=INFTY;
    }
  }

  int u,k,c,v;
  for(i=0;i<n;i++)
  {
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++)
    {
      scanf("%d %d",&v,&c);
      M[u][v]=c;
    }
  }
dijkstra();
return 0;
}



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

int main(){
    long long N, sum=0;
    cin >> N;

    for(int i=1; i<=N; i++){
        if((i%3!=0) && (i%5!=0)){
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	float ans=0;
	int N=sc.nextInt();
	int v[]=new int[N];
	for(int i=0;i<v.length;i++) {
		v[i]=sc.nextInt();
	}
	Arrays.sort(v);
	ans=v[0];
	for(int i=1;i<N;i++) {
		ans=(ans+v[i])/2;
	}
	System.out.println(ans);
}
}


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

int main(){
  int i,j,cnt=0;
  ll a,b,c;
  cin>>a>>b>>c;
  if(a%2==0 || b%2==0 || c%2==0)cout<<0;
  else cout<<min(a*b,min(b*c,c*a));
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
const double eps = 1e-7;
int N, M, K, Q, T;

int main()
{
	int i, j;
	set<string> st;
	cin >> N;
	string s;
	for (i = 1; i <= N; ++i) {
		cin >> s;
		st.insert(s);
	}
	printf("%d", st.size());
	return 0;
}

Measured memory_bytes: 19184
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <limits>
#include <utility>
#define EPS (1e-10)
#define REP(i,n) for(int i=0;i<n;i++)
#define equals(a,b) (fabs((a) - (b)) < EPS)
#define ll long long
using namespace std;

//typedef pair<int,int> P;
//const ll MOD = 1000000007;
//const ll INF = 100000000;

const int max_N = 100000;
const int max_M = 100000;
int N, M, H[max_N+1], A[max_M], B[max_M];

//stack<int> stack;
//queue<int> que;
//priority_queue<int> pque;
//set<int> s; set<int>::iterator ite;
//multiset<int> ms; multiset<int>::iterator ite;
//map<int, int> m; map<int, int>::iterator ite;
//multimap<int, int> mm; multimap<int, int>::iterator ite;

//int dp[][];
//int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1};
//int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve() {
  int ans[max_N], ret=0;

  REP(i,N) ans[i] = 1;

  REP(i,M) {
    if(H[A[i]-1] < H[B[i]-1]) ans[A[i]-1] = 0;
    else if(H[A[i]-1] > H[B[i]-1]) ans[B[i]-1] = 0;
    else {ans[A[i]-1] = 0; ans[B[i]-1] = 0;}
  }

  REP(i,N) {
    //printf("%d\n", ans[i]);
    if(ans[i] == 1) ret++;
  }

  printf("%d\n", ret);
}

int main(int argc, char const *argv[]) {

  scanf("%d %d", &N, &M);

  REP(i,N) scanf("%d", &H[i]);
  REP(i,M) scanf("%d %d", &A[i], &B[i]);

  solve();
  return 0;
}



Measured memory_bytes: 5380
#include<bits/stdc++.h>
using namespace std;
int i,j;
char c[101];
int main()
{
	cin>>c;
	for (i=0;i<strlen(c);i++)
	{
		if ((j==0)&&(c[i]=='C'))
	   	 j++;
	   	if ((j==1)&&(c[i]=='F'))
	   	 {
	   	 	cout<<"Yes"<<endl;
	   	 	return 0;
	   	 }	
	}
	cout<<"No"<<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 s = a + b + c;
    int m = max(a, max(b, c));
    if ((m + s) & 1) {
        m++;
    }
    cout << ((3 * m - s) >> 1) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import random

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
#t = [int(input()) for i in range(D)]
#M = int(input())
#Q = [list(map(int,input().split())) for i in range(M)]

def content(t):
    cont = 0
    last = [0]*26
    for i in range(D):
        cont += s[i][t[i]-1]
        last[t[i]-1] = i+1
        for j in range(26):
            cont -= c[j]*(i+1-last[j])
    return cont

def main():
    t = [random.randint(1,26) for i in range(D)]
    #prev = content(t)
    #for i in range(100):
    #    d,q = random.randint(0,D-1), random.randint(1,26)
    #    prev_t = t[d]
    #    t[d] = q
    #    now = content(t)
    #    if prev>content(t):
    #        t[d] = prev_t
    #    else:
    #        prev=now
    for a in t:
        print(a)


if __name__ == '__main__':
    main()





Measured memory_bytes: 78020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, K;
  cin >> N >> K;
  int ans = 1;
  rep(i, N)
  {
    if (ans < K)
      ans += ans;
    else
      ans += K;
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int rem = n % 10;
    //cout << rem << endl;
    if(rem == 2 || rem ==4 || rem == 5 || rem==7 || rem == 9){
        cout << "hon" <<endl;
    }
    else if(rem==0 || rem == 1|| rem == 6|| rem==8){
        cout << "pon" <<endl;
    }
    else if(rem == 3){
        cout << "bon" <<endl;
    }
    return 0;
}

Measured memory_bytes: 3096
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto X = RDA;

	auto pos = X.MIN_POS();

	writeln(pos+1);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 2720
#include <stdio.h>
int main(void)
{
  int K,X;
  int i,j;

  scanf("%d %d",&K,&X);

  j = 0;
  for ( i = X - K + 1; j < 2 * K - 2; i++){
      j++;
      printf("%d ", i);
  }
  printf("%d\n", i);
  
  return 0;
}

Measured memory_bytes: 128
function main(input = "") {
    const lines = input.split("\n");
    const arr = lines[0].split(" ").map((v) => (0 | v));
    const H = arr[0], W = arr[1], K = arr[2];
    const GRID = lines.slice(1).join("").split("").map((v) => (v === "#" ? 1 : 0));

    let res = 0;
    for (let i = 0; i < 2 ** H; i++) {
        for (let k = 0; k < 2 ** W; k++) {
            let grid = GRID.slice();
            for (let r = 0; r < H; r++) {
                if (i & (1 << r)) {
                    for (let ir = 0; ir < W; ir++) {
                        grid[ir + r * W] = 0;
                    }
                }
            }
            for (let c = 0; c < W; c++) {
                if (k & (1 << c)) {
                    for (let ic = c; ic < grid.length; ic += W) {
                        grid[ic] = 0;
                    }
                }
            }
            let cnt = grid.reduce((p,c)=>(p+c));
            if(cnt === K){
                res++;
            }
        }
    }
    return res;
}

//******************************
exports.main = main;

function Main(input) {
    console.log(main(input.trim()));
}

if (process.argv[2] !== "test") {
    Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}

Measured memory_bytes: 32656
def cnt(n):
    ret = 0
    while n % 2 == 0:
        ret += 1
        n /= 2
    return ret

##  NG
##  すべて3倍
##  2で割ってよいのは偶数だけ
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))

print(sum(list(map(cnt, a))))

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

const int N = 2e5 + 10;
typedef long long ll;
ll n, K, a[N], x[N], tx, y[N], ty;

bool chk(ll lim) {
    ll num = 0;
    if (lim < 0) {
        lim *= -1;
        num = tx * ty;
        rep(i, 1, tx)
            num -= (upper_bound(y + 1, y + ty + 1, lim / x[i]) - y - 1);
    } else if (!lim) {
        num = tx * ty;
    } else {
        num += tx * ty + (n - tx - ty) * (tx + ty) + (n - tx - ty) * (n - tx - ty - 1) / 2;
        rep(i, 1, tx) {
            int j = upper_bound(x + 1, x + i, lim / x[i]) - x - 1;
            if (x[i] * x[j] >= lim) --j;
            num += j;
        }
        rep(i, 1, ty) {
            int j = upper_bound(y + 1, y + i, lim / y[i]) - y - 1;
            if (y[i] * y[j] >= lim) --j;
            num += j;
        }
    }
    return num < K;
}

int main() {
    cin >> n >> K;
    rep(i, 1, n) scanf("%lld", &a[i]);

    sort(a + 1, a + n + 1);
    rep(i, 1, n) if (a[i] < 0) x[++tx] = -a[i];
    reverse(x + 1, x + tx + 1);
    rep(i, 1, n) if (a[i] > 0) y[++ty] = a[i];

    ll ans = 0, l = -1e18, r = 1e18;
    while (l <= r) {
        ll mid = (l + r) >> 1;
        if (chk(mid)) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int n;
std::vector<i64> a;
i64 ff(i64 x) {
	i64 ret = 0;
	for(int i = 0; i < n; i++) ret += (x ^ a[i]);
	return ret;
}

i64 calc(int j, bool f) {
	i64 ret = 0;
	for(int i = 0; i < n; i++) ret += (a[i] >> j & 1);
	if(!f) return ret;
	return n - ret;
}

int main() {
	i64 k; scanf("%d%lld", &n, &k); a.resize(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(begin(a), end(a));
	
	i64 x = 0;
	bool f = false;
	for(int i = 60; i >= 0; i--) {
		if((1 << i) > k) continue;
		if(k >> i & 1) {
			if(calc(i, 0) < calc(i, 1)) {
				x |= (1LL << i);
			} else {
				f = true;
			}
		} else {
			if(f) {
				if(calc(i, 0) < calc(i, 1)) {
					x |= (1LL << i);
				}
			}
		}
	}
	printf("%lld\n", ff(x));
	return 0;
}


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

int top, S[1000];

void push(int x) {
    S[++top] = x;	
} 

int pop() {
	top--;
	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];
	
	while(scanf("%s", s) != EOF) {
		if (s[0] == '+') {
		    a = pop();
			b = pop();
			push(a + b); 
		} else if (s[0] == '-') {
		    b = pop();
			a = pop();
			push(a - b); 
		} else if (s[0] == '*') {
		    a = pop();
			b = pop();
			push(a * b); 
		} else {
			push (atoi(s));
		}
	}
		printf("%d\n", pop());
		return 0;	
} 

Measured memory_bytes: 2656
N, W = map(int, input().split())

weights = [None for i in range(N)]
values = [None for i in range(N)]

# dp[i][j] = maximum value using at most i weight and using elements 1,...,j

dp = [[0 for i in range(N+1)] for j in range(W+1)]

for i in range(N):
    w, v = map(int, input().split())
    weights[i] = w
    values[i] = v
    
for weight in range(W+1):
    for item in range(1,N+1):

        # Case: dont include item
        dp[weight][item] = max(dp[weight][item],
                               dp[weight][item-1])

        # Case: include item
        dp[weight][item] = max(dp[weight][item],
                               dp[weight-1][item])
        
        if weights[item-1] > weight: continue
 
        # Case: include item
        dp[weight][item] = max(dp[weight][item],
                               values[item-1] + dp[weight - weights[item-1]][item - 1])
    
print(max(dp[-1]))


Measured memory_bytes: 130248
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <map>
using namespace std;

long long n, w, refW, refV;

long long nr[4];
long long values[4][101];

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

  cin >> refW >> refV;

  values[0][1] = refV;
  nr[0]++;


  for (int obj = 2; obj <= n; ++obj) {
    long long weight, value;
    cin >> weight >> value;
    int poz = weight - refW;
    ++nr[poz];
    values[poz][nr[poz]] = value;
  }

  long long sumVal0, sumVal1, sumVal2, sumVal3;
  long long bestVal = 0;

  for (int type = 0; type <= 3; ++type) {
    sort(values[type] + 1, values[type] + nr[type] + 1, greater<long long>());
  }

  sumVal0 = sumVal1 = sumVal2 = sumVal3 = 0;

  for (int nr0 = 0; nr0 <= nr[0]; ++nr0) {
    sumVal0 += values[0][nr0];
    sumVal1 = sumVal2 = sumVal3 = 0;
    for (int nr1 = 0; nr1 <= nr[1]; ++nr1) {
      sumVal1 += values[1][nr1];
      sumVal2 = sumVal3 = 0;
      for (int nr2 = 0; nr2 <= nr[2]; ++nr2) {
        sumVal2 += values[2][nr2];
        sumVal3 = 0;
        for (int nr3 = 0; nr3 <= nr[3]; ++ nr3) {
          sumVal3 += values[3][nr3];
          long long sumW = 0;
          sumW = (nr0 + nr1 + nr2 + nr3) * refW + nr1 + nr2 * 2 + nr3 * 3;

          if (sumW > w) continue;

          if (sumVal0 + sumVal1 + sumVal2 + sumVal3 > bestVal)
            bestVal = sumVal0 + sumVal1 + sumVal2 + sumVal3;
        }
      }
    }
  }

  cout << bestVal;

}


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

int main(void) {

	int mm = 0;
	int i;
	int ii = 0;
	int iii = 0;
	int s[1000];
	double n = 0;
	double m = 0;
	double aa = 0;
	double a;
	double A[100];

	while (1) {
		scanf("%lf", &n);
		if (0 == n) break;
		while (ii != n) {
			scanf("%d", &s[ii]);
			mm += s[ii];
			ii++;
		}
		m = mm / n;

		for (i = 0; i < n; i++) {
			aa += (s[i] - m)*(s[i] - m) / n;
		}
		a = sqrt(aa);
		A[iii] = a;
		iii++;
		ii = 0;
		mm = 0;
		aa = 0;
	}
	for (i = 0; i < iii; i++) {
		printf("%f\n", A[i]);
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, a, free = 0;
  cin >> n;
  unordered_map<string, int> um;
  rep(i, n) {
    cin >> a;
    if (1 <= a && a <= 399) {
      um["gray"]++;
    } else if (400 <= a && a <= 799) {
      um["brown"]++;
    } else if (800 <= a && a <= 1199) {
      um["green"]++;
    } else if (1200 <= a && a <= 1599) {
      um["sky"]++;
    } else if (1600 <= a && a <= 1999) {
      um["blue"]++;
    } else if (2000 <= a && a <= 2399) {
      um["yellow"]++;
    } else if (2400 <= a && a <= 2799) {
      um["orange"]++;
    } else if (2800 <= a && a <= 3199) {
      um["red"]++;
    } else {
      free++;
    }
  }
  int minc = um.size();
  int aminc = max(minc, 1);
  int maxc = minc + free;
  cout << aminc << " " << maxc << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a;
    int b;
    cin >> a;
    cin >> b;
    if ( a > b ) {
          cout << "a > b" << endl;
    }
    else if ( a < b ) {
          cout << "a < b" << endl;
    }
    else { 
          cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
A,B,M = map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
lis = []
ans = min(a)+min(b)
for i in range(M):
    x,y,c = map(int, input().split())
    if a[x-1]+b[y-1]-c < ans:
        ans = a[x-1]+b[y-1]-c
print(ans)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

class Knapsack {
    typedef long long LL;
    struct item { 
        LL v, w; 
    };

    LL W;
    vector<item> items;
    LL lv;

    LL solve_rec(size_t k, LL v, LL w) {
        if (w + items[k].w > W) return solve_rec(k+1, v, w);
        LL cv = v, cw = w;
        for (size_t i = k; i < items.size(); ++i) {
            if (cw + items[i].w <= W) {
                cw += items[i].w;
                cv += items[i].v;
            }
        }
        if (lv < cv) lv = cv;
        double fv = v, fw = w;
        for (size_t i = k; i < items.size(); ++i) {
            if (fw + items[i].w <= W) {
                fw += items[i].w;
                fv += items[i].v;
            } else {
                fv += items[i].v * (W - fw) / items[i].w;
                break;
            }
        }
        if (fv - lv < 1 || fv < lv) return lv;
        solve_rec(k+1, v+items[k].v, w+items[k].w);
        return solve_rec(k+1, v, w);
    }

    public:
    // 価値v, 重みwのアイテムを追加
    void add_item(LL v, LL w) {
        items.push_back({v, w});
    }

    // 重みの合計がW以下になるようにアイテムを選んだときの価値の和の最大値を返す．
    LL solve(LL W_) {
        if(items.empty()) return 0;
        W = W_;
        sort(items.begin(), items.end(), [](const item &a, const item &b) { 
                return a.v * b.w > a.w * b.v;
                });
        lv = 0;
        return solve_rec(0, 0, 0);
    };
};



int main(){
    int D;
    cin >> D;
    Knapsack solver;
    for(int d = 1; d <= 2; d++){
        int T;
        cin >> T;
        while(T--){
            string a;
            int p;
            cin >> a >> p;
            if(a == string(d, 'D')){
                solver.add_item(p, d);
            }
        }
    }
    long long ans = solver.solve(D);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
int main()
{
  int A,B,C,D;
  scanf("%d %d %d",&A,&B,&C);
  D=C-(A-B);
  if(D<0)
  {
    printf("0");
  }
  else
  {
    printf("%d",D);
  }
} 

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

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

    int N;
    int K;
    cin >> N >> K;
    vector<int>D(K);
    cin >> D;

    auto exist = [&](int n) {
        for (auto&& d : D) {
            if (d == n)return true;
        }
        return false;
    };

    int ans = -1;
    FOR(i, N, 100001) {
        int m = i;
        ans = i;
        while (m != 0) {
            if (exist(m % 10)) {
                ans = -1;
                break;

            }
            m /= 10;
        }
        if (ans != -1) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
int main()
{
	string s;
	cin >> s;

	int l = s.size();

	int i = s.find('A');
	int f = s.rfind('Z');
	int Ans = f-i+1;

	cout << Ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

std::string S;

int main() {
  std::cin >> S;

  bool fl = true;

  rep( i, S.size() ) {
    if( i&1 ) {
      fl &= S[i]=='L' || S[i]=='U' || S[i]=='D';
    } else {
      fl &= S[i]=='R' || S[i]=='U' || S[i]=='D';
    }
  }

  puts(fl ? "Yes" : "No" );

  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("input.txt","r",stdin);freopen("ans.txt","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    lli n;
    cin>>n;
    string s;
    cin>>s;
    lli a=0,b=0;
    for (int i=0;i<n;i++)
    {
        if (s[i]=='R')
        a++;
    }
    for (int i=0;i<a;i++)
    {
        if (s[i]=='R')
        b++;
    }
    cout<<a-b;
    return 0;
}

Measured memory_bytes: 3736