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

const int N = 26;

bool allEven(const int counts[N]) {
    for (int i = 0; i < N; ++i) {
        if (counts[i] % 2) {
            return false;
        }
    }
    return true;
}

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

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    std::string str;
    std::cin >> str;
    int counts[N] = { 0 };
    for (const char c : str) {
        ++counts[c - 'a'];
    }
    std::cout << (allEven(counts) ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N, T = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

AB.sort()

ans = 0
dp = [0] * T
dp = np.zeros(T, int)

for a, b in AB:
    ans = max(ans, dp[-1] + b)
    dp[a:] = np.maximum(dp[a:], dp[:-a] + b)
    # for j in reversed(range(a, T)):
    #     dp[j] = max(dp[j], dp[j-a] + b)

print(ans)


Measured memory_bytes: 21288
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char S[12][12];
char T[12][12];
char fr[12];
char to[12];
int toL;
char now[12][12];
int n;
int ans=999999;
int solve(int a){
	bool ok=true;
//	printf("%d %s\n",a,now[a]);
	for(int i=0;to[i]||now[a][i];i++){
		if(now[a][i]!=to[i]){ok=false;break;}
	}
	if(ok){
		ans=min(ans,a);
		return a;
	}
	if(a==9||strlen(now[a])>=toL){return 999999;}
	if(a==ans){return ans;}
	for(int i=0;i<n;i++){
		bool OK=false;
		int at=0;
		for(int j=0;now[a][j];j++){
			bool ok2=true;
			for(int k=0;S[i][k];k++){
				if(now[a][j+k]!=S[i][k]){
					ok2=false;break;
				}
			}
			if(ok2){
				for(int k=1;S[i][k];k++){
					j++;
				}
				for(int k=0;T[i][k];k++){
					now[a+1][at++]=T[i][k];
				}
				OK=true;
			}else{
				now[a+1][at++]=now[a][j];
			}
		}
		if(OK){
			solve(a+1);
		}
		for(int j=0;j<12;j++)now[a+1][j]=0;
	}
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		n=a;
		for(int i=0;i<a;i++){
			scanf("%s%s",S[i],T[i]);
		}
		scanf("%s%s",fr,to);
		toL=strlen(to);
		for(int i=0;i<12;i++)now[0][i]=fr[i];
		ans=999999;
		solve(0);
		if(ans>999)printf("-1\n");
		else printf("%d\n",ans);
	}
}

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

int main(){
      int maxx = 0;
      int curr = 0;
      string s;cin >> s;
      int n = s.length();
      for(int i = 0;i < n;i++){
            if(s[i] == 'A' || s[i] == 'T' ||
            s[i] == 'G' || s[i] == 'C'){
                  curr++;
            }
            else{
                  if(curr > maxx)maxx = curr;
                  curr = 0;
            }
      }
      cout << max(maxx, curr);
}

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

using namespace std;

string s;
int cnt0 = 0;
int cnt1 = 0;

int main()
{
	cin >> s;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] - 48 != (i % 2)) cnt0 += 1;
		if (s[i] - 48 != ((i + 1) % 2)) cnt1 += 1;
	}
	
	cout << min(cnt0, cnt1);
}

Measured memory_bytes: 512
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    string s;
    cin >> s;
    rep(i,0,s.size()) {
        cout << 'x';
    }
    cout << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,z,w,v=0,u,q;
  cin>>x>>y>>z;
  for(w=1;w<=x;w++){
    u=w;
    q=0;
    while(u>0){
      q+=u%10;
      u/=10;
    }
    if(y<=q&&q<=z) v+=w;
  }
  cout<<v<<endl;
}

Measured memory_bytes: 3576
N = int(input())
S = str(input())



if(N==1):
    print("No")
else:
    N2 = N/2
    i=(int(N2))
    i=N2-i
    N2=(int(N2))
    
    if(i==0):
        if(S[0:N2] == S[N2:N]):
            print("Yes")
        else:
            print("No")
    else:
        print("No")




Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    char s[5];
    scanf("%s", s);
    for(int i = 0; i < 3; i++){
        if(s[i] == s[i+1]){
            printf("%s\n", "Bad");
            return 0;
        }
    }
    printf("%s\n", "Good");
    return 0; 
}

Measured memory_bytes: 128
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
  //happy coding

  string s;
  string t;
  cin>>s>>t;
	vector<int>m[27];
  for(int i=0;s[i];i++){
  	m[s[i]-'a'].pb(i);
  }

  for(int i=0;t[i];i++){
  	if(m[t[i]-'a'].size()==0){
  		cout<<-1<<endl;
  		return 0;
  	}
  }
  int n = s.size();
  int idx = -2;
  int sum = 0;
  for(int i=0;t[i];i++){
  	auto x = upper_bound(all(m[t[i]-'a']),idx);
  	if(x != m[t[i]-'a'].end()){
  		idx = *x;
  	}else{
  		sum ++;
  		idx = m[t[i]-'a'][0];
  	}
  }

  cout<<sum*s.length()+idx+1<<endl;

  
  return 0;
}
int main(){
  int test = 1;
  //scanf("%d", &test);
  while (test--)solve();return 0;
} 


Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int m;
    cin >> m;
    int d[m];
    int c[m];
    int ketasuu = 0;
    int ketawa = 0;
    REP(i,m){
        cin >> d[i] >> c[i];
        ketawa += d[i] * c[i];
        ketasuu += c[i];
    }
    cout << ketasuu - 1 + (ketawa - 1) / 9 << endl;

}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

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

int main() {
    int n, k;
    cin >> n >> k;

    vector<int> p(n, 0);
    rep(i, n) {
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    long long ans = 0;
    rep(i, k) {
        ans += p[i];
    }

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

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

int main() {
	ll N,s=0;
	cin >> N;

	rep(i,N) {
		ll t=i+1;
		if(t%3 && t%5)
			s += t;
	}

	cout << s << endl;
}

Measured memory_bytes: 3636
A_1=list(map(int,input().split()))
A_2=list(map(int,input().split()))
A_3=list(map(int,input().split()))
N=int(input())
b=list(int(input()) for i in range(N))

for i in range(N):
    for j in range(3):
        if b[i] == A_1[j]:
            A_1[j]=0
        elif b[i] == A_2[j]:
            A_2[j]=0
        elif b[i] == A_3[j]:
            A_3[j]=0

A=A_1+A_2+A_3
if A[0]==A[1] and A[0]==A[2]:
    print('Yes')
elif A[3]==A[4] and A[3]==A[5]:
    print('Yes')
elif A[6]==A[7] and A[6]==A[8]:
    print('Yes')
elif A[0]==A[4] and A[0]==A[8]:
    print('Yes')
elif A[2]==A[4] and A[2]==A[6]:
    print('Yes')
elif A[0]==A[3] and A[0]==A[6]:
    print('Yes')
elif A[1]==A[4] and A[1]==A[7]:
    print('Yes')
elif A[2]==A[5] and A[2]==A[8]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(void){
	long long inf=10000000000;
	int N,K,H[101010],dp[101010];
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	for(int i=1;i<N;i++){
		dp[i]=inf;
	}
	dp[0]=0;
	for(int i=0;i<N;i++){
		for(int j=1;j<=K;j++){
			dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]));
		}
	}
	cout<<dp[N-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long
int main()
{
    string s;
    cin>>s;
    int n = s.size();
    if(s[n-1] == 's'){
        cout<<s+"es";
    }
    else{
        cout<<s+"s";
    }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
signed main(){
    for(int i=0;i<19;i++){
        char a;
        cin>>a;
        if(a==',')cout<<" ";
        else cout<<a;
    }
    cout<<endl;
    return 0;
}





Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N, K;
        cin >> N >> K;

        vector<Int> H(N + 1);
        for (int i = 1; i <= N; ++i) cin >> H[i];

        vector<vector<Int>> dp(N + 1, vector<Int>(N + 1, INFl));
        dp[0][0] = 0;

        for (int i = 0; i < N; ++i) {
            for (int j = 0; j <= N; ++j) {
                for (int k = 1; i + k <= N && j + k - 1 <= N; ++k) {
                    Int ni = i + k;
                    Int nj = j + k - 1;
                    Int nv = dp[i][j] + max(H[i + k] - H[i], 0ll);
                    chmin(dp[ni][nj], nv);
                }
            }
        }

//        Int ans = min(dp[N][K], dp[N - 1][K - 1]);
        Int ans = dp[N][K];
//        if (K > 0) chmin(ans, dp[N - 1][K - 1]);
        for (int i = 0; i <= N && i <= K; ++i) {
            Int tmp = dp[N - i][K - i];
            chmin(ans, tmp);
        }
        cout << ans << endl;


    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int n, a[100010];
int cnt;
int ans = 1;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		cnt += a[i];
	}
	sort(a, a + n);
	cnt -= a[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		if (cnt * 2 >= a[i + 1]) {
			ans++;
			cnt -= a[i];
		}
		else break;
	}
	cout << ans << endl;
}

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

using namespace std;

int main(){

    int n;
    cin>>n;
    vector<int> height(n);
    for(auto &x : height) cin>>x;
    vector<int> ans(n, 0);

    for(int i = n-2; i >= 0; i--){

        ans[i] = abs(height[i] - height[i+1]) + ans[i+1];
        if(i+2 < n){
                    ans[i] = min(ans[i], abs(height[i] - height[i+2]) + ans[i+2]);

        }
    }

    cout<<ans[0];


}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    M = 10**9 + 7
    if N == 1:
        print(0)
        return
    ans = 0
    ans = 10**N - (9**N)*2 + 8**N 
    print(ans%M)    

if __name__ == '__main__':
    main()

Measured memory_bytes: 11056
import itertools
n, m, x = map(int, input().split())

c = []
d = []
for i in range(n):
	s = list(map(int, input().split()))
	d.append(s)
ans = 10**9
for i in range(1,n+1):
	for j in itertools.combinations(d,i):
		s = [0 for ii in range(m+1)]
		for k in j:
			for l in range(m+1):
				s[l] += k[l]
		y = min(s[1:])
		if y >= x:
			ans = min(ans,s[0])
if ans == 10**9:
	print (-1)
else:
	print (ans)


Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>

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

#define R(i, n) for(int i=0; i < 2; ++i) { val[n] = i;
#define START R(a, 0)R(b, 1)R(c, 2)R(d, 3)R(e, 4)R(f, 5)R(g, 6)R(h, 7)R(i, 8)R(j, 9)R(k, 10)
#define END }}}}}}}}}}}

#define T 'l'
#define F 'm'

using namespace std;

string gp( string str )
{
	int len = str.size();
	stack<char> st;
	string res = "";
	rep(i, len) {
		char c = str[i];
		switch(c) {
		case '(': case '+': case '*':
			st.push(c);
			break;
		case ')':
			while(1) {
				char cc = st.top(); st.pop();
				if(cc == '(') break;
				res += cc;
			}
			if(!st.empty() && st.top() == '-') {
				res += st.top();
				st.pop();
			}
			break;
		case '-': {
			switch(str[i+1]) {
			case '-': {
				int ii = 0;
				for(ii=0; str[i+ii] == '-'; ++ii);
				if(ii & 1)	i += ii - 2;
				else		i += ii - 1;
			}	break;
			case '>':
				st.push('/');
				++i;
				break;
			case '(':
				st.push(c);
				break;
			default:
				res += str[i+1];
				res += c;
				++i;
				break;
			}
		}	break;
		default:
			res += c;
			break;
		}
	}
	while(!st.empty()) {
		res += st.top(); st.pop();
	}
	return res;
}

bool val[13];

bool calc( string str )
{
	int len = str.size();
	stack<char> st;
	rep(i, len) {
		char c = str[i];
		char a, b;
		switch(c) {
		case '+':
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			if(val[a-'a'] | val[b-'a'])	st.push(T);
			else						st.push(F);
			break;
		case '-':
			a = st.top(); st.pop();
			if(val[a-'a'])	st.push(F);
			else			st.push(T);
			break;
		case '*':
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			if(val[a-'a'] & val[b-'a'])	st.push(T);
			else						st.push(F);
			break;
		case '/':
			b = st.top(); st.pop();
			a = st.top(); st.pop();
			if(val[a-'a'] & !val[b-'a']) st.push(F);
			else						 st.push(T);
			break;
		default:
			st.push(c);
			break;
		}
	}
	return val[st.top()-'a'];
}

int main( void )
{
	val[11] = true;
	val[12] = false;
	string input, sa, sb;
	while(cin >> input, input[0] != '#') {
		sa = ""; sb = "";
		int len = input.size();
		rep(i, len) {
			if		(input[i] == 'T') input[i] = T;
			else if	(input[i] == 'F') input[i] = F;
		}
		bool hit = true;
		rep(i, len) {
			if(input[i] == '=') { hit = !hit; continue; }
			if(hit) sa += input[i];
			else    sb += input[i];
		}
		sa = gp(sa);
		sb = gp(sb);
		bool ans = true;
		START
			if(calc(sa) != calc(sb)) {
				ans = false;
				goto ANSWER;
			}
		END
ANSWER:;
		if(ans)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 908
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << ""; print(ts...); }

int main(){
  int k,a,b; cin >>k >>a >>b;
  print((b/k-(a-1)/k>=1)?"OK":"NG");
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    long double a,b,x;
    cin>>a>>b>>x;

    long double ans;

    if (2 * x >= a * a * b)
    {
       long double d;
       d = 2*(a*a*b-x)/a/a;
       ans = atan(d / a) / M_PI * 180;
       //cout<<atan(d / a) / M_PI * 180;
    }
    else
    {
        long double h = x * 2	/ a / b ;
        ans = 90 - atan(h/ b) * 180 / M_PI; 
        //cout << 90 - atan(h/ b) * 180 / M_PI << endl;
    }


    printf("%.30Lf\n",ans);


    return 0;
}

Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
vector<vector<int>> vec;
vector<vector<int>> dp;
int h, w;
void rec(int y, int x){
    if (vec[y][x] == '#')return; //壁だったら考えるまでもないです
    if (y >= 1){
        if (vec[y][x] == '.'){
            dp[y][x] += dp[y - 1][x];
            dp[y][x] %= MOD;
        }
    }
    if (x >= 1){
        if (vec[y][x] == '.'){
            dp[y][x] += dp[y][x - 1];
            dp[y][x] %= MOD;
        }
    }
}
int main()
{
    int n;
    cin >> n;
    vector<double> P(n);//今回は小数がでてくるのでdouble型を取っておきましょう
    for (int i = 0; i < n; i++)cin >> P[i];
    double dp[n + 1][n + 2];
    dp[1][0] = 1 - P[0];//初期化をしていきましょう
    dp[1][1] = P[0];
    for (int i = 2; i <= n; i++){
        for (int j = 0; j <= i; j++){
            if (j == 0){
                dp[i][0] = dp[i - 1][0] * (1 - P[i - 1]);
            }else{
                dp[i][j] = dp[i - 1][j - 1] * P[i - 1] + dp[i - 1][j] * (1.0 - P[i - 1]);
            }
        }
    }
    double res = 0;
    for (int i = n / 2 + 1; i <= n; i++)
    {
        res += dp[n][i];
        
    }
    cout << setprecision(10) << res << endl;
}


Measured memory_bytes: 70400
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
int a[maxn];
int n,mx,cnt;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 1;i <= n;++i){
        cin >> a[i];
    }
    sort(a+1,a+n+1);
    if(a[1] == a[n]){
        if(a[1] == n-1)
            cout << "Yes\n";
        else{
            if(2 * a[1] <= n)
                cout << "Yes\n";
            else cout << "No\n";
        }
    }
    else{
        if(a[n] - a[1] > 1){
            cout << "No\n";
            return 0;
        }
        else{
            cnt = 0;
            mx = a[n];
            for(int i = 1;i <= n;++i){
                if(a[i] == a[1])
                    cnt++;
            }
            if(cnt < mx && 2 * (mx - cnt) <= n - cnt)
                cout << "Yes\n";
            else cout << "No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int n;
char s[100005];
ll dp[100005][13];

int main () {
  int i, j, ki;
  ll res = 0;

  scanf("%s", s);
  n = strlen(s);

  dp[0][0] = 1;
  rep(i,n) {
    int c;
    if (s[i] == '?') c = -1;
    else c = s[i] - '0';

    rep(j,10) {
      if (c != -1 && c != j) continue;
      rep(ki,13) {
        dp[i+1][(ki*10+j)%13] += dp[i][ki];
      }
    }
    rep(j,13) dp[i+1][j] %= mod;
  }
  res = dp[n][5];

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 10496
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,x,ans;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=9;i++)
	{
		x=i;
		if(x<=n)
			ans++;
	}
	for(int i=1;i<=9;i++)
		for(int j=0;j<=9;j++)
			for(int k=0;k<=9;k++)
			{
				x=100*i+10*j+k;
				if(x<=n)
					ans++;
				if(x>n)
					break;
			}
	for(int i=1;i<=9;i++)
		for(int j=0;j<=9;j++)
			for(int k=0;k<=9;k++)
				for(int l=0;l<=9;l++)
					for(int t=0;t<=9;t++)
					{
						x=10000*i+1000*j+100*k+10*l+t;
						if(x<=n)
							ans++;
						if(x>n)
							break;
					}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
str = gets.split
a = []
answer = 0

for x in 0...n
  a[x] = str[x].to_i
end

d = 2
f = 0
loop do
  for x in 0...n
    if a[x] % d != 0
      f = 1
      break
    end
  end
  if f == 1
    break
  end
  d *= 2
  answer += 1
end

puts(answer)

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N,H;
  cin >> N >> H;
  int a[N],b[N];
  for(int i=0;i<N;i++) cin >> a[i] >> b[i];
  sort(a,a+N);
  sort(b,b+N);
  reverse(b,b+N);

  int amax = a[N-1];
  int dmg = 0;
  int cnt = 0;
  for(int i=0;i<N;i++){
    if(dmg<H && b[i]>amax){
      dmg += b[i];
      cnt++;
    }
    else break;
  }

  if(dmg >= H){
    cout << cnt << endl;
    return 0;
  }

  int res = H - dmg;
  cnt += (res + amax - 1) / amax;

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;
    int l = s.size();
    int cnt = 0;
    rep(i, l) {
        if (0 == i % 2) {
            if (s[i] == 'L') {
                ++cnt;
            }
        } else {
            if (s[i] == 'R') {
                ++cnt;
            }
        }
    }
    if (cnt == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[]$){
        Scanner s=new Scanner(System.in);
        char[] c=s.next().toCharArray();
        int k=c.length;
        for(int i=0,w=0;i<c.length;++i){
            if(c[i++]!=w){
                w=c[--i];
            } else{
                w=0;
                --k;
            }
        }
        System.out.println(k);
    }
}


Measured memory_bytes: 26552
#import <stdio.h>
int main(){
    char s[250] = {'\0'};
    scanf("%s",s);
    unsigned long n = strlen(s);
    for(int i=n/2-1;i>=1;i--) {
        char a[250] = {'\0'};
        char b[250] = {'\0'};
        strncpy(a, s, i);
        strncpy(b, s+i, i);
        if(strcmp(a,b)==0){
            printf("%d",2*i);
            return 0;
        }
    }
}


Measured memory_bytes: 2164
import sys
from io import StringIO
import unittest


def resolve():
    s = input()
    t = input()

    num = len(t)
    ans = 1000

    for i in range(0, len(s) - num + 1):
        tmp = 0
        for a, b in zip(s[i:(i + num)], t):
            if a != b:
                tmp += 1

        if tmp < ans:
            ans = tmp

    print(ans)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """cabacc
abc"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """codeforces
atcoder"""
        output = """6"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16200
#include <iostream>
using namespace std;
int n;
int a[100010];
main() {
    cin>>n;
    for(int i=0;i<n;++i)cin>>a[i+1];
    int ans=0,p=0;
    for(p=1;ans<n&&p!=2;p=a[p],++ans);
    cout<<(p!=2?-1:ans)<<endl;
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(a) (a).begin(),(a).end();

string s;
int id;
map<char,int>M;
char f()
{
  char a,b;
  if(s[id]=='[')
  {
    id++;
    a=f();
  }
  else
  {
    a=s[id];
   }
  id+=2;
  if(s[id]=='[')
  {
id++;
b=f();
  }
  else
  {
    b=s[id];
  }
  id++;
  if(M[a]>M[b])
  {
    M[a]--;
    return a;
  }
  else
  {
    M[b]--;
    return b;
  }
}


int main(){

  cin>>s;
  char c;
  int v;
  while(cin>>c>>v)
  {
    M[c]=v;
  }
  id=1;
  f();
  for(pair<char,int>p:M)
  {
    if(p.second!=0)
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

}




Measured memory_bytes: 3208
class Dice:
    def __init__(self, label):
        self.d = label

    def roll(self, direction):
        if direction == "N":
            self.d[0], self.d[1], self.d[5], self.d[4] = self.d[1], self.d[5], self.d[4], self.d[0]
        elif direction == "S":
            self.d[0], self.d[1], self.d[5], self.d[4] = self.d[4], self.d[0], self.d[1], self.d[5]
        elif direction == "E":
            self.d[0], self.d[2], self.d[5], self.d[3] = self.d[3], self.d[0], self.d[2], self.d[5]
        else:
            self.d[0], self.d[2], self.d[5], self.d[3] = self.d[2], self.d[5], self.d[3], self.d[0]

label = [int(i) for i in input().split()]
cmd = input()

dice1 = Dice(label)

for i in cmd:
    dice1.roll(i)

print(dice1.d[0])

Measured memory_bytes: 7800
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
string s;
long long dp[100001][13];
int surplus[100001];
int main(){
    cin >> s;
    reverse(s.begin(),s.end());
    for(int j=0;j<=s.size();j++){
        for(int i=0;i<13;i++){
            dp[j][i] = 0;
        }
    }
    surplus[0] = 1;
    if(s[0] == '?'){
        for(int i=0;i<10;i++){
            dp[0][i] = 1;
        }
    }
    else{
        string s2(1,'a');
        s2[0] = s[0];
        const char *line = s2.c_str();
        int tmp = atoi(line);
        //cout << "s[" << "0" << "]" << "=" << tmp << endl;
        dp[0][tmp] = 1;
    }
    for(int i=1;i<s.size();i++){
        surplus[i] = (surplus[i-1]*10)%13;
        //cout << "surplus" << "[" << i << "]=" << surplus[i] << endl;
        if(s[i] == '?'){
            for(int k=0;k<10;k++){
                for(int j=0;j<13;j++){
                    dp[i][(j+surplus[i]*k)%13] = (dp[i][(j+surplus[i]*k)%13]+dp[i-1][j])%(1000000007);
                }
            }
        }
        else{
            string s2(1,'a');
                s2[0] = s[i];
                const char *line = s2.c_str();
                int tmp = atoi(line);
                //cout << "s[" << i << "]" << "=" << tmp << endl;
            
            for(int j=0;j<13;j++){
                dp[i][(j+surplus[i]*tmp)%13] = (dp[i][(j+surplus[i]*tmp)%13]+dp[i-1][j])%(1000000007); 
            }
        }
    }
    int ans = dp[s.size()-1][5];
    cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
int compar(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

int main(){
    int N,K;
int ans=0;
    cin>>N>>K;
    int l[51];
    for(int i=0;i<N;i++){
        scanf("%d",&l[i]);
    }
    qsort(l,N,sizeof(int),(int (*)(const void *, const void *))compar);
//for(int i=0;i<N;i++) printf("%d ",l[i]);
    for(int i=N;i>N-K;i--){
        ans+=l[i-1];
    }
   printf("%d",ans);
    return 0;
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(vector<vector<T>> x){cerr<<"\n{"; int f=x.size();for(int i=0;i<f;i++){cerr<<"("; int g=x[i].size(); for(auto j:x[i]){cerr<<j; (--g!=0)?cerr<<",":cerr<<"";}cerr<<")\n";}cerr<<"}";}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void __print(vector<bool> x){cerr<<"{";int f=x.size();for(auto i:x){cerr<<i;(--f !=0)?cerr<<",":cerr<<"";}cerr<<"}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define trace(x...)
#endif
 
template<typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}
 
template<typename... T>
void writ(T&&... args) {
    ((cout << args << " "), ...);
}
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define IINF (int)1e9
#define EPS 1e-9
/*
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    In the blazing sun I saw you
    In the shadows hiding from yourself
    When the lights are on I know you
    See you're grey from all the lies you tell 
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //It feels awkward coming back to coding after the break but here we go
    int x; cin>>x;
    if(x<30) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 3620
def main():
  h, w, k = map(int, input().split())

  table = [[0] * w for _ in range(h)]
  total = 0

  for i in range(h):
    for j, c in enumerate(input()):
      if c == "#":
        table[i][j] = 1
        total += 1


  ans = 0
  cols = [sum([table[i][j] for i in range(h)]) for j in range(w)]

  for i in range(2 ** h):
    cols_minus = [0] * w
    tmp_total1 = total

    for row in range(i):
      if i >> row & 1:
        for col in range(w):
          c = table[row][col]
          if c == 1:
            cols_minus[col] -= 1
            tmp_total1 -= 1

    for j in range(2 ** w):
      tmp_total2 = tmp_total1
      for col in range(j):
        if j >> col & 1:
          tmp_total2 -= cols[col] + cols_minus[col]

      if tmp_total2 == k:
        ans += 1




  print(ans)


main()


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		stringstream ss;
		ss<<i;
		if(ss.str().size()&1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int N, A, B;
	char s;

	cin >> N >> A >> B;

	int num = 0;
	int num_B = 0;

	for (int i = 0; i < N; i++) {
		cin >> s;
		if (s == 'a') {
			if (num < A + B) {
				cout << "Yes" << endl;
				num++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (s == 'b') {
			if (num < A + B && num_B < B) {
				cout << "Yes" << endl;
				num++;
			}
			else {
				cout << "No" << endl;
			}
			num_B++;
		}
		else if (s == 'c') {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main() {
	int a,b,c;
	scanf ("%d %d %d",&a,&b,&c);
	if(a==b+c) {
		printf("Yes\n");} 
	else if(b==a+c) {
		printf("Yes\n");
	} else if(c==a+b) {
		printf("Yes\n");
	} else { 
	    printf ("No\n"); 
	}
	    return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int N;
vector<LL> line;

bool check(int x){
	LL sum = line[x];
	REP(i, N){
		if(x==i)continue;
		if(sum*2 < line[i])return false;
		sum += line[i];
	}
	return true;
}

int main(){
	string str;
	cin >> str;
	vector<int> ans(str.size(), 0);
	LL K;
	cin >> K;
	REP(i, str.size()-1){
		int need = 'z' - str[i] + 1;
		need %= 26;
		if(need <= K){
			ans[i] = need;
			K -= need;
		}
	}
	ans.back() = K;
	REP(i, str.size()){
		str[i] = 'a' + ((int)ans[i] + str[i] - 'a') % 26;
	}
	cout << str << endl;

	return 0;
}


Measured memory_bytes: 1024
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    return dfs(i + 1, f + s[i + 1]) +  dfs(i + 1, f + "+" + s[i + 1])


s = input()
n = len(s)

print(dfs(0, s[0]))


Measured memory_bytes: 3060
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

A, B, M = map(int, input().split())
List_A = list(map(int, input().split()))
List_B = list(map(int, input().split()))
List_discount = [list(map(int, input().split())) for i in range(M)]

# print(List_discount)
ans = 2 * 10**5
for d in List_discount:
    # print(d)
    p = List_A[d[0]-1] + List_B[d[1]-1] - d[2]
    ans = min(ans, p)
no_discount = min(List_A) + min(List_B)
ans = min(ans, no_discount)
print(ans)


Measured memory_bytes: 39380
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define ll long long

ll A,B;

ll sub_solve(ll n){
	// compute xor from 0 to n;
	ll ans=0;
	for(int i=0;i<(n+1)%4;i++){
		ans ^= n-i;
	}
	return ans;

}


int solve(){
	ll ans = sub_solve(B)^sub_solve(A-1);
	cout << ans << endl;
	return 0;
}



int main(){
	cin >> A >> B;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int n;
	cin >> n;
	vs s(n);
	REP(i, n) cin >> s[i];
	vector<pii> v;
	REP(i, n)
	{
		int l = 0, r = 0;
		REP(j, s[i].size())
		{
			if (s[i][j] == '(') r++;
			else
			{
				if (r > 0) r--;
				else l++;
			}
		}
		v.emplace_back(l, r);
	}
	bool f = true;
	REP(i, n)
	{
		if (v[i].first != 0 || v[i].second != 0) f = false;
	}
	if (f)
	{
		puts("Yes");
		return 0;
	}
	int lmax = 0, l = -1, rmax = 0, r = -1;
	REP(i, n)
	{
		if (v[i].first == 0 && v[i].second == 0) continue;
		if (v[i].first == 0)
		{
			if (v[i].second > rmax)
			{
				rmax = v[i].second;
				r = i;
			}
		}
		else if (v[i].second == 0)
		{
			if (v[i].first > lmax)
			{
				lmax = v[i].first;
				l = i;
			}
		}
	}

	if (l == -1 || r == -1)
	{
		puts("No");
		return 0;
	}
	vector<bool> flag(n);
	flag[l] = flag[r] = true;
	int tmp = rmax;
	while (1)
	{
		int ti = -1, tmax = -INF;
		REP(i, n)
		{
			if (flag[i] || v[i].first > tmp) continue;
			if (v[i].second - v[i].first > tmax ||
			   (v[i].second - v[i].first == tmax  && v[i].first > v[ti].first))
			{
				ti = i;
				tmax = v[ti].second - v[ti].first;
			}
		}
		if (ti == -1 || tmax < 0) break;
		tmp += tmax;
		flag[ti] = true;
	}
	while (1)
	{
		int ti = -1, tmax = -INF;
		REP(i, n)
		{
			if (flag[i] || v[i].first > tmp) continue;
			if (tmax < v[i].first)
			{
				ti = i;
				tmax = v[i].first;
			}
		}
		if (ti == -1) break;
		tmp += v[ti].second- v[ti].first;
		flag[ti] = true;		
	}

	f = true;
	REP(i, n) if (!flag[i]) f = false;
	if (tmp != lmax) f = false;
	if (f) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
 
int main() {
  int k, x;
  cin >> k >> x;
  if (500 * k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
	int n;
	scanf("%d", &n);
	if (n == 3 || n == 5 || n == 7) {
		puts("YES");
	}
	else {
		puts("NO");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <random>
#include <ctime>
using namespace std;

void printlist(int lst[], size_t len){
	for(int i = 0; i < len - 1; i ++){
		cout << lst[i] << " ";
	}
	cout << lst[len - 1] << endl;
}

void inserSort(int lst[], size_t len){
	int select, j;

	for(size_t i = 1; i < len; i ++){
		select = lst[i];
		j = i - 1;

		while(j >= 0 && lst[j] > select){
			swap(lst[j], lst[j + 1]);
			j --;
		}
		printlist(lst, len);
	}
}

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	int st[N];
	for (auto& i : st){
		cin >> i;
	}
	printlist(st, sizeof(st) / sizeof(int));
	inserSort(st, sizeof(st) / sizeof(int));
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
using namespace std;
int main (){
    int x[10],a;
    a=0;
    for(int i=0;i<10;i++){
        cin>>x[i];
    }
    sort(x,x+10);
    cout<<x[9]<<endl<<x[8]<<endl<<x[7]<<endl;
    return 0;
}

Measured memory_bytes: 3124
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXVAL=30000;
const int MAXN=20000;

int n;
int ret[MAXN],nret;
ll sum;

void run() {
	scanf("%d",&n);
	nret=0; sum=0;
	ret[nret++]=3; sum+=3; ret[nret++]=5; sum+=5;
	{ int a=-1; FORE(i,6,MAXVAL) if(i%2!=0&&i%3==0) if(a==-1) a=i; else if(nret<n-2) { ret[nret++]=a; sum+=a; ret[nret++]=i; sum+=i; a=-1; } }
	{ int a=-1; FORE(i,6,MAXVAL) if(i%2!=0&&i%3!=0&&i%5==0) if(a==-1) a=i; else if(nret<n-2) { ret[nret++]=a; sum+=a; ret[nret++]=i; sum+=i; a=-1; } }
	FORE(i,2,MAXVAL) if(i%2==0) if(nret<n-1||nret==n-1&&(sum+i)%30==0) { ret[nret++]=i; sum+=i; }
	assert(nret==n&&sum%30==0); REP(i,nret) assert(gcd(ret[i],sum)!=1);
	REP(i,nret) { if(i!=0) printf(" "); printf("%d",ret[i]); } puts("");
}

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


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
int main(int argc, const char * argv[]) {
    int n,i,j;
    double m=0,p,g;
    double x[101],y[101];
    double max=-1.0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lf",&x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%lf",&y[i]);
    }
    for(j=0;j<=3;j++){
        for(i=0;i<n;i++){
            if(j==3){
                p= fabs(x[i]-y[i]);
                if(p>max){
                    max=p;
                }

            }
            else{
                p= fabs(x[i]-y[i]);
                m+=pow(p,j+1);
            }
        }
        if(j==3){
        printf("%f\n",max);

    }else{
        g=1.000000/(j+1);
        printf("%f\n",pow(m,g));
        m=0;
    }
    }
    
    return 0;
}

Measured memory_bytes: 1984
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n,m,i,c,cc;
	bool f[1010]={};

	while(1){
		cin>>n>>m;
		if(n==0&&m==0) break;
		rep(j,0,1000) f[j]=1;
		c=0; cc=n; i=n;
		while(1){
			i++;
			if(i==n+1) i=1;
			if(f[i]==1&&cc==1) break;
			if(f[i]==1) c++;
			if(c==m){
				f[i]=0; cc--; c=0;
			}
		}
		o(i);
	}
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  int cnt = 0;
  bool flg = false;
  for(int i = 0; i < N; i++){
    int tmp1,tmp2; cin >> tmp1 >> tmp2;
    if(tmp1 == tmp2){
      cnt++;
    } else { 
      cnt = 0;
    }

    if(cnt == 3){
      flg = true;
    }
  }

  if(flg){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())

	for i := 0; i < n; i++ {
		stdin.Scan()
		fmt.Println(strings.Replace(stdin.Text(), "Hoshino", "Hoshina", -1))
	}
}



Measured memory_bytes: 1076
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cmath>
using namespace std;
int main(void)
{
	double r,syu,s;
	scanf("%lf",&r);
	syu=2.0*r*M_PI;
	s=r*r*M_PI;
	printf("%lf %lf\n",s,syu);
	return 0;
}


Measured memory_bytes: 2748