akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

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

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll n;
    cin>>n;
    string s;
    string t = "ACL";
    rep(i,n){
        s += t;
    }
    out(s);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
//    ll T;
//    cin>>T;
//    while(T--)
    solve();
}


Measured memory_bytes: 3616
import java.util.Scanner;
public class Main {
 public static void main(String[] args){
     Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        if(T.startsWith(S)){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
 }   
}

Measured memory_bytes: 27008
#include<stdio.h>
#include<string.h>
int main(void)
{
	int A=0,B=0,d,length;
	char serve[101];
	for(;;)
	{
		scanf("%s",serve);
		if(strcmp(serve,"0")==NULL)
			break;
		length=strlen(serve);
		for(d=1;d<length;d++)
			if(serve[d]=='A')
				A++;
			else
				B++;
		if(A>B)
			A++;
		else if(B>A)
			B++;
		printf("%d %d\n",A,B);
		A=0;
		B=0;
	}
	return 0;
}

Measured memory_bytes: 532
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  val a = scala.io.StdIn.readLine.split(" ").map(_.toLong)

  val minus = a.count(_ < 0)
  val aa = a.map(_.abs)
  if (minus % 2 == 0) {
    println(aa.sum)
  } else {
    println(aa.sum - (aa.min * 2))
  }
}


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

int main()
{
  int num;
  int i;
  int odd=0;

  scanf("%d",&num);

  for(i=1;i<=num;i++)
  {
    if(i%2){odd++;}
  }
  printf("%.9lf\n",(double)odd/num);

  return 0;
}


Measured memory_bytes: 384
import heapq as h

N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
if N>=M:
    print(0)
else:
    data=[]
    h.heapify(data)
    for i in range(0,M-1):
        h.heappush(data,-X[i+1]+X[i])
    s=0
    for i in range(0,N-1):
        s+=(-1)*h.heappop(data)
    print(X[M-1]-X[0]-s)

Measured memory_bytes: 56360
#include<stdio.h>
int main(){
  int high[100];
  int width[100];
  int i;
  int j;
  int count=0;
  int z;

  
  while(1){
  scanf("%d %d",&high[count],&width[count]);
  if(high[count] == 0 && width[count]==0) break;
  count++;
  }

  for(z=0;z<count;z++){
    for(i=0;i<high[z];i++){
      for(j=0;j<width[z];j++){
	if(i%2==0){
	  if(j %2 != 0){
	    printf(".");
	  }
	  else printf("#");
	}
	else{
	  if(j%2==0){
	    printf(".");
	  }
	  else printf("#");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;


int N,M;
char img[50][50];
char tmp[50][50];
bool contain(int M,int x, int y){
	for(int i=0;i<M;i++){
		for(int j=0;j<M;j++){
			if(img[x+i][y+j] != tmp[i][j])return false;
		}
	}
	return true;
}

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

	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin >> img[i][j];
		}
	}

	for(int i=0;i<M;i++){
		for(int j=0;j<M;j++){
			cin >> tmp[i][j];
		}
	}
	for(int x=0;x<N-M+1;x++){
		for(int y=0;y<N-M+1;y++){
			if(contain(M,x,y)){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main(){
  int A[5][4][11], n;
  for ( int i = 1; i <= 4; i++ )
   for ( int j = 1; j <= 3; j++ )
    for ( int k = 1; k <= 10; k++) A[i][j][k] = 0;

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
  int b, f, r, v;
  cin >> b >> f >> r >> v ;
  A[b][f][r] += v;
 }

 for ( int f = 1; f <= 4; f++ ){
 if ( f > 1) cout << "####################\n";
 for ( int b = 1; b <=3; b++ ){
  for ( int r = 1; r <= 10; r++ ){
 cout << " " << A[f][b][r];
}
cout << endl;
}
}

return 0;
}  


Measured memory_bytes: 3100
'use strict'

const Main = (input) => {
  const tmp = input.trim().split('\n')
  const N = parseInt(tmp[3])

  const men = [
    tmp[0].split(' ').map(Number),
    tmp[1].split(' ').map(Number),
    tmp[2].split(' ').map(Number)
  ]

  for (let i = 4; i < 4 + N; i++) {
    const number = parseInt(tmp[i])
    for (let j = 0; j < men.length; j++) {
      if (men[j].indexOf(number) != -1) {
        men[j][men[j].indexOf(number)] = 0
      }
    }
  }

  let result = 'No'

  for (let k = 0; k < men.length; k++) {
    if (men[k][0] === 0 && men[k][1] === 0 && men[k][2] === 0) {
      result = 'Yes'
    } else if (men[0][k] === 0 && men[1][k] === 0 && men[2][k] === 0) {
      result = 'Yes'
    }
  }

  if (men[0][0] === 0 && men[1][1] === 0 && men[2][2] === 0) {
    result = 'Yes'
  } else if (men[2][0] === 0 && men[1][1] === 0 && men[0][2] === 0) {
    result = 'Yes'
  }

  console.log(result)
  return result
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 21576
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x;
	int cnt=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
	    for(int j=0;j<=b;j++)
	        for(int k=0;k<=c;k++)
	        	if(i*500+j*100+k*50==x)
	        	     cnt++;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <utility>
#include <functional>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
void pow(int p[100001], int k, int ret[100001]){
    int pp[31][100001];
    for(int i=1; i<=n; i++){
        pp[0][i]=p[i];
    }
    for(int j=1; (1<<j)<=k; j++){
        for(int i=1; i<=n; i++){
            pp[j][i]=pp[j-1][pp[j-1][i]];
        }
    }
    for(int i=1; i<=n; i++) ret[i]=i;
    for(int j=0; (1<<j)<=k; j++){
        if(k&(1<<j)){
            int ret2[100001];
            for(int i=1; i<=n; i++){
                ret2[i]=ret[pp[j][i]];
            }
            for(int i=1; i<=n; i++) ret[i]=ret2[i];
        }
    }
}
void mul(int p[100001], int q[100001], int ret[100001]){
    for(int i=1; i<=n; i++){
        ret[i]=p[q[i]];
    }
}
int main()
{
    int k; cin>>n>>k;
    int p[100001], q[100001], pi[100001], qi[100001];
    for(int i=1; i<=n; i++){
        cin>>p[i]; pi[p[i]]=i;
    }
    for(int i=1; i<=n; i++){
        cin>>q[i]; qi[q[i]]=i;
    }
    int r[100001], rp[100001], r1[100001], r2[100001];
    mul(q, pi, r1);
    mul(qi, p, r2);
    mul(r1, r2, r);
    pow(r, (k-1)/6, rp);
    if((k-1)%6>=3){
        int rp2[100001];
        mul(rp, r1, rp2);
        for(int i=1; i<=n; i++) rp[i]=rp2[i];
    }
    int rpi[100001];
    for(int i=1; i<=n; i++){
        rpi[rp[i]]=i;
    }
    int s[100001];
    if((k-1)%6==0){
        for(int i=1; i<=n; i++) s[i]=p[i];
    }else if((k-1)%6==1){
        for(int i=1; i<=n; i++) s[i]=q[i];
    }else if((k-1)%6==2){
        for(int i=1; i<=n; i++) s[i]=r1[i];
    }else if((k-1)%6==3){
        for(int i=1; i<=n; i++) s[i]=pi[i];
    }else if((k-1)%6==4){
        for(int i=1; i<=n; i++) s[i]=qi[i];
    }else{
        for(int i=1; i<=n; i++) s[i]=r2[i];
    }
    int ans2[100001];
    mul(rp, s, ans2);
    int ans[100001];
    mul(ans2, rpi, ans);
    for(int i=1; i<=n; i++){
        if(i<n) cout<<ans[i]<<" ";
        else cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;


ll n;
string s;
int main()
{
        cin >> s;
        n = s.length();
        s = "#" + s;
        if(s[n] != '0' || s[1] != '1') {
                cout << "-1\n"; return 0;
        }
        for(ll i=1; i <= n-i; i++) {

                if(s[i] != s[n-i]){
                        cout << "-1\n"; return 0;
                }
        }
        vector< pll > ans;
        ll curv = 1;
        ll pt = 1;
        for(ll i=1; i <= n-i; i++) {

                if(s[i] == '1') {

                        ans.pb(make_pair(++pt, curv));
                        curv = pt;
                        continue;
                }else {
                        ans.pb(make_pair(curv, ++pt));
                }
        }
        //cout << ans.size() << endl;
        ll st = (n/2)+1;
        //cout << st << endl;
        for(ll i=st;i<n;i++) {
                if(s[i] == '0') {
                        ans.pb(make_pair(curv, ++pt));
                }else {
                        ans.pb(make_pair(curv, ++pt));
                        curv = pt;
                }
        }
        assert(ans.size() == n-1);
        for(auto &i : ans) cout << i.first << " " << i.second << endl;
        return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define double long double
typedef pair<double, int> P;

struct edge {
	int to;
	double cost;
};

double x[1010];
double y[1010];
double r[1010];
double d[1010];

vector<edge> G[1010];

double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	double d = sqrt(dx * dx + dy * dy);
	if(d < r[i] + r[j]) return 0;
	return d - (r[i] + r[j]);
}

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

	double xs, ys, xt, yt;
	int N;
	cin >> xs >> ys >> xt >> yt >> N;

	for(int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[N] = xs, y[N] = ys, r[N] = 1e-9;
	x[N + 1] = xt, y[N + 1] = yt, r[N + 1] = 1e-20;

	for(int i = 0; i < N + 2; i++) {
		for(int j = 0; j < N + 2; j++) {
			if(i == j) continue;
			G[i].push_back(edge{ j, dist(i, j) });
		}
	}

	fill(d, d + N + 2, 1e20);
	d[N] = 0;
	priority_queue <P, vector<P>, greater<P>> q;
	q.push(P(0, N));
	while(q.size()) {
		int v = q.top().second;
		double c = q.top().first;
		q.pop();
		if(d[v] < c) continue;
		for(auto e : G[v]) {
			if(d[e.to] >  c + e.cost) {
				d[e.to] = c + e.cost;
				q.push(P(d[e.to], e.to));
			}
		}
	}
	cout << fixed << setprecision(15) << d[N + 1] << endl;
}

Measured memory_bytes: 40812
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);


		int n = sc.nextInt();

		HashSet<String> set = new HashSet<String>();

		for(int i = 0; i < n; i++){
			set.add(sc.next());
		}

		System.out.println(set.size());
	}

}


Measured memory_bytes: 66348
blood = [0] * 4

while True:
    try:
        b = input().split(',')[1]
        if b == 'A':
            blood[0] += 1
        elif b == 'B':
            blood[1] += 1
        elif b == 'AB':
            blood[2] += 1
        else:
            blood[3] += 1
    except:
        for b in blood: print(b)
        break

Measured memory_bytes: 6720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD=1000000007;
//scanf("%d", &a); '\n';
bool IsPrime(int x) {
	if (x < 2) return false;
	for (int i = 2; i <= sqrt(x); ++i) {
		if (x%i == 0) return false;
	}
	return true;
}


int main() {
	int x;
	cin >> x;
	rep2(i, x, MOD) {
		if (IsPrime(i)) {
			cout << i; return 0;
		}
	}
	}

	

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main() {
    // freopen("input.txt","r",stdin);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    set<pair<int,int>> s;
    for (int i = 0; i < n; i++) {
        s.insert(make_pair(a[i],i));
    }
    long long ans=0;
    for(int j=0;j<n;j++){
        for(int i=0;i<j;i++){
            int x = a[i]+a[j];
            auto it =s.lower_bound(make_pair(x,0));
            if(it!=s.begin()) {
                it--;
                if(it->second>j){
                    ans+=it->second-j;
                }
            }
        }
    }
    cout<<ans;
    return 0;
}



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

int N;
int main(void){
  cin >> N;
  vector<int> L(N);
  int i,sum=0;
  for(i=0;i<N;i++) cin >> L[i];
  sort(L.begin(),L.end());
  for(i=0;i<N-1;i++){
    sum += L[i];
  }
  if(sum > L[N-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#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 itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
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 n_max int(1e5+5)
#define MOD llong(1e9+7)

int main(){
    int n;
    cin >> n;
    int A[n_max]={};
    int tmp;
    REP(i,n){
        scanf("%d",&tmp);
        A[tmp]+=1;
    }
    int sa = n-1;
    while(1){
        if(sa <1) break;
        if(A[sa] !=2){
            cout << 0 << endl;
            return 0;
        }
        sa-=2;
    }
    if( sa ==0){
        if(A[sa]!=1){
            cout << 0 << endl;
            return 0;
        }
    }
    llong ans=1;
    REP(i,n/2){
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int fa[101000],n,k,ans,f[101000];
vector<int> e[101000];
void dfs(int x){
	int mx=0;
	for(int v:e[x]) dfs(v),mx=max(mx,f[v]+1);
	if(x==1||fa[x]==1) return;
	if(mx==k-1) ans++,f[x]=-1;
	else f[x]=mx;
}
int main(){
	read(n);read(k);
	for(int i=1;i<=n;i++) read(fa[i]);
	if(fa[1]!=1) fa[1]=1,ans=1;
	for(int i=2;i<=n;i++) e[fa[i]].push_back(i);
	dfs(1);
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 12800
// ABC046
// A - AtCoDeerくんとペンキ / AtCoDeer and Paint Cans
#include<bits/stdc++.h>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    set<int> s{a,b,c};
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    int a, b, m;
    cin >> a >> b >> m;

    vi x(a), y(b);
    rep (i, a) cin >> x[i];
    rep (i, b) cin >> y[i];

    ll mi = INF;
    rep (i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        chmin(mi, x[a] + y[b] - c);
    }
    sort(all(x));
    sort(all(y));
    chmin(mi, x[0] + y[0]);
    cout << mi << endl;
}

Measured memory_bytes: 1792
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> getLine >>= print . solve

solve :: String -> Int
solve s = minimum $ calc cs 0
    where
        calc (y : ys) z = (wr + bl) : calc ys (z + 1)
            where
                wr = wn - y
                bl = z - y
        calc _ _ = []

        bs = map (== '.') s 
        wn = length $ filter id bs
        bn = length $ filter not bs
        cs = scanl sf 0 bs
        sf acc x 
            | x = acc + 1
            | otherwise = acc

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

int factrial(long long n){
  while(n>1){
    return (n*factrial(n-1))%(1000000007);
  }
  return 1;
}

int main()
{
  long long n;
  cin >>n;
  long long ans=factrial(n);

  cout <<ans<<endl;

}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int dp[MAX_N][3];
int a[MAX_N], b[MAX_N], c[MAX_N];

int main() {
    int n;
    cin >> n;
    repeat(i, 1, n + 1) {
        cin >> a[i] >> b[i] >> c[i];
    }
    repeat(i, 1, n + 1) {
        dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
        dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
        dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
        // if (pre != 0 && dp[i] < dp[i - 1] + a[i]) {
        //     dp[i] = dp[i - 1] + a[i];
        //     temp = 0;
        // }
        // if (pre != 1 && dp[i] < dp[i - 1] + b[i]) {
        //     dp[i] = dp[i - 1] + b[i];
        //     temp = 1;
        // }
        // if (pre != 2 && dp[i] < dp[i - 1] + c[i]) {
        //     dp[i] = dp[i - 1] + c[i];
        //     temp = 2;
        // }
        // pre = temp;
    }

    out(max(dp[n][0], max(dp[n][1], dp[n][2])));
    return 0;
}


Measured memory_bytes: 2560
H,W = map(int,input().split())
C = [list(map(int,input().split())) for i in range(10)]
A = [list(map(int,input().split())) for i in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])
ans = 0
for row in A:
    for a in row:
        if a == -1: continue
        ans += C[a][1]
print(ans)

Measured memory_bytes: 9464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    int l[n];
    rep (i, n) cin >> l[i];
    int pos = 0;
    bool f = false;
    rep (i, n) {
        pos += l[i];
        if (pos > x) {
            cout << i + 1 << endl;
            f = true;
            break;
        }
    }
    if (!f) cout << n+1 << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n;
long long num[100];
long long gcd(long long a, long long b){
    if(b==0)return a;
    else return gcd(b, a%b);
}
long long lcm(long long a, long long b){
    long long tmp = gcd(a,b);
    return a / tmp * b; 
}
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> num[i];
    }
    long long res = 1;
    for(int i = 0; i < n; i++){
        res = lcm(res,num[i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Comparator

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    (0 until n)
            .map {
                val (s, p) = readLine()!!.split(' ')
                Triple(it + 1, s, p.toInt())
            }
            .sortedWith(Comparator { o1, o2 ->
                if (o1.second != o2.second)
                    o1.second.compareTo(o2.second)
                else
                    -o1.third.compareTo(o2.third)
            })
            .forEach { println(it.first) }
}


Measured memory_bytes: 36320
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

void transpose(vector<vector<char>> &b)
{
    if (b.size() == 0)
        return;

    vector<vector<char>> trans_vec(b[0].size(), vector<char>());

    for (int i = 0; i < b.size(); i++)
    {
        for (int j = 0; j < b[i].size(); j++)
        {
            trans_vec[j].push_back(b[i][j]);
        }
    }

    b = trans_vec; // <--- reassign here
}

// C++ゆるさねえリスト
// accumulate(all(a), 0LL);
// 二分探索

int main()
{

    ll a, b, k, ans1, ans2;
    cin >> a >> b >> k;
    if (k <= a)
    {
        ans1 = a - k;
        ans2 = b;
    }
    else if (k <= a + b)
    {
        ans1 = 0;
        ans2 = a + b - k;
    }
    else
    {
        ans1 = 0;
        ans2 = 0;
    }
    cout << ans1 << ' ' << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
    val (w,h,n) = readLine()!!.split(" ").map { it.toInt() }
    val paintList = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }

    val x1 = paintList.filter { it[2] == 1 }.map { it[0] }.max()
    val x2 = paintList.filter { it[2] == 2 }.map { it[0] }.min()
    val y1 = paintList.filter { it[2] == 3 }.map { it[1] }.max()
    val y2 = paintList.filter { it[2] == 4 }.map { it[1] }.min()

    val map = (1..h).map { (1..w).map { 0 }.toMutableList() }

    x1?.let {
        for(i in map.indices) {
            for(j in map[i].indices) {
                if(j < it) {
                    map[i][j] = 1
                }
            }
        }
    }
    x2?.let {
        for(i in map.indices) {
            for(j in map[i].indices) {
                if(j > it - 1) {
                    map[i][j] = 1
                }
            }
        }
    }
    y1?.let {
        for(i in map.indices) {
            if(i < it) {
                for(j in map[i].indices) {
                    map[i][j] = 1
                }
            }
        }
    }
    y2?.let {
        for(i in map.indices) {
            if(i > it - 1) {
                for(j in map[i].indices) {
                    map[i][j] = 1
                }
            }
        }
    }
    val ans = map.map { it.count { it == 0 } }.sum()
    println(ans)
}


Measured memory_bytes: 36200
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++)cin>>d[i];
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++)ans += d[i]*d[j];

    }
    cout << ans <<endl;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
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<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head


struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }


ll n;

Mod dp[1000010];
Mod sum[1000010];

int main(){

  n = in();

  dp[0] = 1;
  sum[1] = 1;
  Mod ans = 0;
  FOR( i , 1 , n ){
    dp[i] = sum[i];
    if( i >= 2 ){
      dp[i] -= dp[i-2];
    }
    sum[i+1] = sum[i] + dp[i];
  }

  REP( i , n-1 ){
    ll c = i + 2;
    if( i >= n - 2 ){
      c--;
    }
    ans += dp[i] * c * n;
    // cout << ( dp[i] * c * n ).n << endl;
    if( n - c >= 2 ){
      ans += dp[i] * ( n - c - 1 ) * ( n - 1 );
    }
  }
  ans += dp[n-1] * n;

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

  return 0;
}


Measured memory_bytes: 8448
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<algorithm>
#define ll long long
#define re register
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int dep[2010],front[2010],cnt,k,n;
struct node{
	int to,nxt;
}e[500010];
void Add(int u,int v){
	e[++cnt]=(node){v,front[u]};front[u]=cnt;
}
void dfs(int u,int fa,int depth){
	dep[u]=depth;
	for(re int i=front[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa)continue;
		dfs(v,u,depth+1);
	}
}
int main(){
	n=gi();k=gi();
	int ans=n;
	for(re int i=1;i<n;i++){
		int u=gi(),v=gi();Add(u,v);Add(v,u);
	}
	if(k%2){
		for(re int u=1;u<=n;u++){
			for(re int i=front[u];i;i=e[i].nxt){
				int v=e[i].to;
				if(v<u)continue;
				dfs(u,v,0);
				dfs(v,u,0);
				int cnt=0;
				for(re int j=1;j<=n;j++)
					if(dep[j]>k/2)cnt++;
				ans=min(ans,cnt);
			}
		}
		printf("%d\n",ans);
	}
	else{
		for(re int u=1;u<=n;u++){
			for(re int i=front[u];i;i=e[i].nxt){
				dfs(u,0,0);
				int cnt=0;
				for(re int j=1;j<=n;j++)
					if(dep[j]>k/2)cnt++;
				ans=min(ans,cnt);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int dfs(int p, int q, int a, int n, int pi, int prev){
  if(p == 0 && pi <= a){
    return 1;
  }else if(n == 0){
    return 0;
  }
  
  int sum = 0;
  int div = a / pi + 1;
  while(p * div >= q){
    if(n * q < p * div){
      div--;
      continue;
    }else if(div < prev){
      break;
    }
    
    sum += dfs(p * div - q, q * div, a, n - 1, pi * div, div);
    div--;
  }
  
  return sum;
}

int main(int argc,char* argv[]){
  for(;;){
    int p, q, a, n;
    scanf("%d %d %d %d", &p, &q, &a, &n);
    
    if(p == 0 && q == 0 && a == 0 && n == 0){
      break;
    }

    printf("%d\n", dfs(p, q, a, n, 1, 0));
  }

  return 0;  
}

Measured memory_bytes: 600
if __name__ == "__main__":
    h, w = map(int, input().split())

    if h == 1 or w == 1:
        print(1)
    elif h % 2 == 0 or w % 2 == 0:
        print(h * w // 2)
    else:
        print((h*w+1) // 2)


Measured memory_bytes: 2940
char*s,T['   '],*r=T;U[1<<27];i;k;main(n){for(;gets(r+1);k=0)for(--n;*++r&=31;)U[r-T]=k|=!!n<<*r;for(;s>T||(s=r,i++-2);k=U[k]=U[k-=~-~*s<<21]?:*s?s-T:0)n+=__builtin_popcount(U[--s-T]&(U[k+'   ']^=!s[-1]<<*s));printf("%d",n);}

Measured memory_bytes: 135100
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;

int GetGCD(int m, int n){
	if(n == 0){
		return m;
	}

	return GetGCD(n, m%n);
}

int GetLCM(int a, int b, int gcd){
	return (int)((double)a/gcd*b);
}

int main(){
	int a, b;
	int g, l;

	while(cin >> a >> b){

		if(a > b){
			g = GetGCD(a, b);
		}else{
			g = GetGCD(b, a);
		}

		l = GetLCM(a, b, g);
		cout << g << ' ' << l << endl;
	}

	return 0;
}

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

using namespace std;

class WeightedDisjointSet{
public:
    vector<int> p,rank,depth;
    
    WeightedDisjointSet();
    WeightedDisjointSet(int size){
        // サイズをセットし直す
        rank.resize(size,0);
        p.resize(size,0);
        depth.resize(size,0);
        for(int i = 0;i < size;++i){
            makeSet(i);
        }
    }
    
    // 要素xがただ一つである集合を作る
    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
        depth[x] = 0;
    }
    
    // 同じ集合にいるか
    bool same(int x,int y){
        return findSet(x) == findSet(y);
    }
    
    void relate(int x, int y, int z){
        int px = findSet(x);
        int py = findSet(y);
        link(px,py,depth[y] + z - depth[x]);
    }
    
    // 要素xが属する集合の代表の要素を求める
    int findSet(int x){
        // 自身がルートでない場合
        if(x != p[x]){
            // 自身の親をさかのぼる
            int tmp = findSet(p[x]);
            depth[x] += depth[p[x]];
            p[x] = tmp;
        }
        return p[x];
    }
    
    void link(int x, int y, int z){
        if(rank[x] > rank[y]){
            p[y] = x;
            depth[y] = -z;
        }else{
            p[x] = y;
            depth[x] = z;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }

    int diff(int x, int y){
        return sumDepth(x) - sumDepth(y);
    }
    
    int sumDepth(int x){
        int sum = 0;
        int index = x;
        while(index != p[index]){
            sum += depth[index];
            index = p[index];
        }
        return sum;
    }
};

int main(void){
    int n,q,c,x,y,z;
    cin >> n >> q;
    WeightedDisjointSet wds = WeightedDisjointSet(n);
    
    for(int i = 0;i < q;++i){
        cin >> c >> x >> y;
        switch(c){
                // relate
            case 0:{
                cin >> z;
                wds.relate(x, y, z);
                break;
            }
                // diff
            case 1:{
                if(!wds.same(x, y)){
                    cout << "?" << endl;
                }
                else{
                    cout << wds.diff(x, y) << endl;
                }
                break;
            }
        }
    }
}



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

int main()
{
    string S;
    cin >> S;
    int use[26] = {0};

    for (int i = 0; i < S.size(); i++)
    {
        use[S[i] - 'a']++;
        if (use[S[i] - 'a'] >= 2)
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 256
// olaf_surgut
//        _        __                             _   
//   ___ | | __ _ / _|  ___ _   _ _ __ __ _ _   _| |_ 
//  / _ \| |/ _` | |_  / __| | | | '__/ _` | | | | __|
// | (_) | | (_| |  _| \__ \ |_| | | | (_| | |_| | |_ 
//  \___/|_|\__,_|_|___|___/\__,_|_|  \__, |\__,_|\__|
//                |_____|             |___/           
//
// #pragma optimize ("Ofast")
#include <bits/stdc++.h>
#define st  first
#define nd  second
#define ll  long long
#define INF 1000000005LL
using namespace std;

void solve(){
  int a, b;
  cin >> a >> b;
  cout << a * b << '\n';  
}

int main(){
#ifndef LOCAL
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
#endif
  int _ = 1;
  // cin >> _;
  while(_--)solve();
}

Measured memory_bytes: 3652
import math

Q = int(input())
lr =  [list(map(int, input().split())) for _ in range(Q)]

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime

sosu_list = primes(10**5+7)

like2017 = [0] * (10**5+7)
for i in range(len(sosu_list)-1):
    if i % 2 == 1 and sosu_list[i]:
        if sosu_list[(i+1)//2]:
            like2017[i] = like2017[i-1] + 1
            continue
    like2017[i] = like2017[i-1]

for l, r in lr:
    print(like2017[r]-like2017[l-1])



Measured memory_bytes: 29828
#include <iostream>

using namespace std;

int main(){
	int h[2], k[2];
	int iwana, yamame, iwapo, yamapo;
	int hiroshi, kenji;

	cin >> h[0] >> h[1] >> k[0] >> k[1] >> iwana >> yamame >> iwapo >> yamapo;

	hiroshi = (h[0] * iwana) + (h[1] * yamame);
	kenji = (k[0] * iwana) + (k[1] * yamame);

	hiroshi += ((h[0] / 10) * iwapo) + ((h[1] / 20) * yamapo);
	kenji += ((k[0] / 10) * iwapo) + ((k[1] / 20) * yamapo);

	if (kenji > hiroshi){
		cout << "kenjiro" << endl;
	}
	else if (hiroshi > kenji){
		cout << "hiroshi" << endl;
	}
	else {
		cout << "even" << endl;
	}

}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
#include <memory.h>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;

int N, A, B;

int main()
{
	string s;
	while(cin>>N>>A>>B)
	{
		cin>>s;
		int total=0, oc=0;
		for(int i=0; i<s.size(); i++)
		{
			if(s[i] == 'a')
			{
				if(total < A+B) 
				{
					cout<<"Yes"<<endl;
					total++;
				}
				else cout<<"No"<<endl;
			}
			else if(s[i] == 'b')
			{
				if(total < A+B && oc < B) 
					{
						cout<<"Yes"<<endl;
						total++;
					}
				else cout<<"No"<<endl;
				oc++;
			}
			else cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 896
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))




int main(){
	int N;
	cin>>N;
	int res[10000];
	string str;
	int in=0,out=0,runner=0;
	CLR(res);
	while(in<N){
		cin>>str;
		if(str=="OUT"){
			out++;
		}else if(str=="HIT"){
			if(runner==3)res[in]++;
			else runner++;
		}else if(str=="HOMERUN"){
			res[in]+=runner+1;
			runner=0;
		}
		if(out==3){
			runner=0;out=0;
			in++;
		}
	}
	REP(i,N)cout<<res[i]<<endl;
	return 0;
}

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

int col[100000];
struct edge{int to; ll w;};
vector<edge> G[100000];

void dfs(int u,bool c){
    
    col[u] = c;

    for(int i = 0;i < G[u].size();i ++){
        if(col[G[u][i].to]!=-1) continue;

        ll dif;
        dif = G[u][i].w;

        if(dif%2) dfs(G[u][i].to,!c);
        else dfs(G[u][i].to,c);
    }
}

int main(){
    fill(col,col+100000,-1);
    int n;
    cin >> n;
    for(int i = 0;i < n-1;i ++){
        int u,v;
        ll w;
        cin >> u >> v >> w;
        u --,v --;
        G[u].push_back({v,w});
        G[v].push_back({u,w});
    }
    dfs(0,0);
    for(int i = 0;i < n;i ++){
        cout << col[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 9856
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int N;
	cin >> N;
	ll dig[111] = {};
	for (int i = 2; i <=N ; ++i) {
		int t = i;
		for (int j = 2; t!=1; ++j) {
			while (t%j == 0) {
				dig[j]++;
				t /= j;
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i < 111; ++i) {
		if (dig[i] >= 74)ans++;
	}
	for (int i = 1; i < 111; ++i) {
		for (int j = 1; j < 111; ++j) {
			for (int k = j + 1; k < 111; ++k) {
				if (i != j && i != k) {
					if (dig[i] >= 2 && dig[j] >= 4 && dig[k] >= 4) {
						ans++;
					}
				}
			}
		}
	}
	for (int i = 1; i < 111; ++i) {
		for (int j = 1; j < 111; ++j) {
			if (i!=j&&dig[i] >= 4 && dig[j] >= 14) {
				ans++;
			}
			if (i!=j&&dig[i] >= 24 && dig[j] >= 2)ans++;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main(){
    int e;
    while(1){
        cin>>e;
        if(e==0)return 0;
        set<int>S[3];
        int a=0,b=0;
        int mi=1e9;
        while(a*a*a<=e)a++;
        while(b*b<=e)b++;
        a--;b--;
        for(int i=a;i>=0;i--){
            for(int j=b;j>=0;j--){
                if(e-(i*i*i)-(j*j)<0)continue;
                mi=min(mi,i+j+(e-(i*i*i)-(j*j)));
                break;
            }
        }
        cout<<mi<<endl;
    }
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define INF 1 << 28
typedef pair<int, int> Pi;
#define pb push_back
#define fi first
#define se second

inline void chmin(int &a, int b) { a = min(a, b); }
inline void chmax(int &a, int b) { a = max(a, b); }
inline int llabs(int n) { if(n < 0) n *= -1; return n; }

int N, L;
int A[100005];
int memo[100005];

int dfs(int v) {
  if(~memo[v])return memo[v];
  int ret = 0;
  
  if(v > 0 && A[v - 1] > A[v]) ret = dfs(v - 1);
  if(v <= N && A[v + 1] > A[v]) ret = max(ret, dfs(v + 1));
  
  return memo[v] = (ret + L - A[v]);
} 
  
signed main()
{
  memset(memo, -1, sizeof(memo));

  cin >> N >> L;

  Rep(i, N) cin >> A[i + 1];
  A[0] = A[N + 1] = 0;
  int maxv = 0;
  for(int i = 1; i <= N; i++) {
    maxv = max(maxv, dfs(i));
  }
  
  cout << maxv << endl;
  return 0;
}

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

int main(){

    int N,K;cin >> N >> K;
    int H[N];for(int i = 0; i < N; i++){cin >> H[i];}sort(H, H+N, greater<int>());
    for(int i = 0; i < min(N,K); i++){H[i] = 0;}

    long long ans = 0;
    for(int i = 0; i < N; i++){ans += H[i];}

    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import product
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        book = tuple(map(int, input().split()))
        books.append(book)
    pro = product((1, 0),repeat=n)
    costs = []

    for proe in pro:
        cost = 0
        algo = [0] * m
        for i1, proee in enumerate(proe):
            if proee:
                cost += books[i1][0]
                for al in range(1, m + 1):
                    algo[al-1] += books[i1][al]
            if all([i >= x for i in algo]):
                costs.append(cost)
    if not costs:
        print(-1)
    else:
        print(min(costs))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10036
N = int(input())
ans = float("inf")
a = 1
b = 1

def F(a,b):
    return max(len(str(a)), len(str(b)))

for i in range(1, int(N**0.5)+1):
    a = i
    b = N//i
    if N%i==0:
        ans = min(ans, F(a,b))
print(ans)

Measured memory_bytes: 65656
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> data(n);
    int point;
    rep(i,0,n){
        cin >> data[i];
        if(data[i]==1){
            point = i;
        }
        
    }
    
    int ans = (n-1)/(k-1);
    if( (n-1)%(k-1)!=0&&k-1!=1){
        ans++;
    }
    //cout<<point<<endl;
    cout<<ans<<endl;

  return 0;
}

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

int main()
{
  ll X;
  cin >> X;
  
  ll money = 100;
  ll year = 0;
  while (1)
  {
    year++;
    money = money + money * 0.01;
    
    if (X <= money)
    {
      break;
    }
  }
  
  cout << year << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#define MAX 100

int main(){
    int BY[MAX][MAX];
    int i,j,n,u,k,v;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++) BY[i][j]=0;
    }
    for(i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        u--;
        for(j=0;j<k;j++){
            scanf("%d",&v);
            v--;
            BY[u][v]=1;
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(j) printf(" ");
            printf("%d",BY[i][j]);
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2108
def is_prime(n):
    if n == 1:
        return True
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            return False
    return True

x = int(input())
while True:
  if is_prime(x) == True:
    ans = x
    break
  x += 1

print(ans)

Measured memory_bytes: 2940