akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> A(H);  
  vector<char> sh(W+2,'#');
  
   for(int i=0 ; i < W+2 ; i++){      
  cout << sh.at(i);
   }  
  
  cout << endl;
  
  for(int i=0 ; i < H ; i++){
    cin >> A.at(i);
    
    cout << "#" << A.at(i) << "#" << endl;
    
  }
  
     for(int i=0 ; i < W+2 ; i++){   
  cout << sh.at(i);
   }  
  
  cout << endl;
  
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
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; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


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

	int D; cin >> D;
	vi c(26); vin(c);
	vvi s(D, vi(26));
	rep(i, D){
		rep(j, 26){
			cin >> s.at(i).at(j);
		}
	}
	long long int satisfaction = 0;

	vi last_day(26, 0);
	/*
	rep(i, D){
		vi temp_satisfaction(26, 0);
		rep(j, 26){
			auto temp_last_day = last_day;
			temp_satisfaction.at(j) += s.at(i).at(j);
			temp_last_day.at(j) = (i + 1);
			rep(k, 26){
				satisfaction -= c.at(k) * ((i+1) - temp_last_day.at(j));
			}
		}
		int max_index = max_element(temp_satisfaction.begin(),temp_satisfaction.end()) - temp_satisfaction.begin();
		satisfaction += temp_satisfaction.at(max_index);
		last_day.at(max_index) = (i + 1);
		cout << max_index + 1 << endl;
		//cout << "t " << t.at(i) << " s " <<  s.at(i).at(t.at(i) - 1)<< " i " << (i + 1) << endl;
		//last_day.at(j) = (i + 1);
	}
	*/
	rep(i, D){
		cout << 26 - (i%26) << endl;
	}
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/

int main() {
  char put;
  cin >> put;
  if(put<91) cout << "A";
  if(put>96) cout << "a";
  return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

int atari(int,int);
int n,h;
int X[2000],Y[2000];

main(){
  int i,j;
  

  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&X[i]);

  scanf("%d",&h);
  for(j = 0; j < h; j++)
    scanf("%d",&Y[j]);
    
  
  for(j = 0; j < h; j++)
    if(atari(n,Y[j]))
      printf("yes\n");
    else
      printf("no\n");
    
   
     

  return 0;
}

int atari(int v,int m)
{
  int p;
  if(m == X[v])
    return 1;

  if(v == -1)
    return 0;

  if(m <= 0)
    return 0;

  if(atari(v-1,m))
    return 1;

  if(atari(v-1,m-X[v]))
    return 1;

  return 0;
  
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STR_EQ(s1,s2)       strcmp(s1,s2)==0
typedef long long ll;
 
int main(){
    ll N,A,B,C;
    scanf("%lld %lld %lld %lld",&N,&A,&B,&C);
    char S[N][3];
    char ans[N];
    for(ll i = 0;i<N;i++) scanf("%s",S[i]);
    for(ll i = 0;i<N;i++){
        if(A+B+C == 0) {printf("No\n");return 0;}
        else if(A+B+C==1){
            if(A==1&&STR_EQ(S[i],"BC")) {printf("No\n");return 0;}
            else if(A==1){
                A--;
                if(S[i][1]=='B'){B++;ans[i]='B';}
                else{C++;ans[i]='C';}
            }else if(B==1&&STR_EQ(S[i],"AC")) {printf("No\n");return 0;}
            else if(B==1){
                B--;
                if(S[i][0]=='A'){A++;ans[i]='A';}
                else{C++;ans[i]='C';}
            }else if(C==1&&STR_EQ(S[i],"AB")) {printf("No\n");return 0;}
            else if(C==1){
                C--;
                if(S[i][0]=='A'){A++;ans[i]='A';}
                else{B++;ans[i]='B';}
            }
        }else if(A+B+C>=2){
            if(STR_EQ(S[i],"BC")&&B==0&&C==0) {printf("No\n");return 0;}
            else if(STR_EQ(S[i],"AB")&&A==0&&B==0) {printf("No\n");return 0;}
            else if(STR_EQ(S[i],"AC")&&A==0&&C==0) {printf("No\n");return 0;}
            if(A==0){
                if(STR_EQ(S[i],"AB")){B--;A++;ans[i]='A';continue;}
                else if(STR_EQ(S[i],"AC")){C--;A++;ans[i]='A';continue;}
            }else if(B==0){
                if(STR_EQ(S[i],"AB")) {A--;B++;ans[i]='B';continue;}
                else if(STR_EQ(S[i],"BC")){C--;B++;ans[i]='B';continue;}
            }else if(C==0){
                if(STR_EQ(S[i],"AC")){A--;C++;ans[i]='C';continue;}
                else if(STR_EQ(S[i],"BC")){B--;C++;ans[i]='C';continue;}
            }
            if(A==1&&B==1&&C==0&&i!=N-1){
                if(STR_EQ(S[i+1],"BC")){B++;A--;ans[i]='B';continue;}
                else if(STR_EQ(S[i+1],"AC")){B--;A++;ans[i]='A';continue;}
            }else if(B==1&&C==1&&A==0&&i!=N-1){
                if(STR_EQ(S[i+1],"AB")){B++;C--;ans[i]='B';continue;}
                else if(STR_EQ(S[i+1],"AC")){B--;C++;ans[i]='C';continue;}
            }else if(A==1&&C==1&&B==0&&i!=N-1){
                if(STR_EQ(S[i+1],"AB")){A++;C--;ans[i]='A';continue;}
                else if(STR_EQ(S[i+1],"BC")){A--;C++;ans[i]='C';continue;}
            }
            if(STR_EQ(S[i],"AB")){
                if(A<B){A++;B--;ans[i]='A';}
                else{A--;B++;ans[i]='B';}
            }else if(STR_EQ(S[i],"BC")){
                if(B<C){B++;C--;ans[i]='B';}
                else{B--;C++;ans[i]='C';}
            }else if(STR_EQ(S[i],"AC")){
                if(C<A){C++;A--;ans[i]='C';}
                else{C--;A++;ans[i]='A';}
            }
        }
    }
    printf("Yes\n");
    for(ll i = 0;i<N;i++) printf("%c\n",ans[i]);
    return 0;
}

Measured memory_bytes: 2124
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define MODNUM (INT(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
void chmax(T& m, T x) {
	m = max(m, x);
}

template <typename T>
void chmin(T& m, T x) {
	m = min(m, x);
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	VI p(n);
	REP(i, n) { scanf("%d", &p[i]); }
	VI sum(1001);
	sum[0] = 0;
	REP(i, 1000) { sum[i + 1] += sum[i] + i + 1; }
	vector<double> a(n);
	REP(i, n) {
		a[i] = static_cast<double>(sum[p[i]]) / static_cast<double>(p[i]);
	}
	// REP(i, n) { printf("a[%d]: %f\n", i, a[i]); }
	vector<double> aa(n - k + 1);
	aa[0] = 0;
	REP(i, k) { aa[0] += a[i]; }
	REP(i, n - k) { aa[i + 1] = aa[i] - a[i] + a[i + k]; }
	// REP(i, n - k + 1) { printf("aa[%d]: %f\n", i, aa[i]); }
	double result = 0;
	REP(i, n - k + 1) { chmax(result, aa[i]); }
	printf("%.9f\n", result);
	return 0;
}

Measured memory_bytes: 4096
m[100],a[100],b[100],n;
broken(t){
	int i,M=0;
	for(i=0;i<n;i++){
		if(t>=a[i]&&t<b[i])
			M+=m[i];
	}
	return M>150;
}
main(){
	int i,br;
	for(;scanf("%d",&n),n;){
		for(i=0;i<n;i++){
			scanf("%d%d%d",m+i,a+i,b+i);
		}
		br=0;
		for(i=0;i<n;i++)
			br|=broken(a[i]);
		puts(br?"NG":"OK");
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, 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 n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
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;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * mod_pow(10, s.size() - i - 1, INF);
	}
	return cnt;
}
/*--------Library Zone!--------*/

int n, a[100005], b[100005], cnt, cnt2;
vector<int>vec;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		cnt += a[i];
	}
	rep(i, n) {
		cin >> b[i];
		cnt2 += b[i];
	}
	rep(i, n) {
		if (a[i] >= b[i]) {
			vec.push_back(a[i] - b[i]);
		}
	}
	if (cnt < cnt2) {
		cout << -1 << endl;
		endre;
	}
	int ma = cnt - cnt2;
	sort(vec.begin(), vec.end());
	int ans = 0;
	rep(i, vec.size()) {
		if (ma >= vec[i]) {
			ma -= vec[i];
			ans++;
		}
	}
	cout << n - ans << endl;
	endre;
}


Measured memory_bytes: 2936
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    b:String,
    }
    let a=a.chars().collect_vec();
    let b=b.chars().collect_vec();
    println!("{}",if a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]{"YES"}else{"NO"})
}

Measured memory_bytes: 2160
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
using namespace std;
#define len(n) (int)n.length()
#define dump cout
#define pb push_back
#define ll long long
#define make_pair mkp
typedef pair<ll, ll> LLARR;

bool firstsort_less(const LLARR& left,const LLARR& right){
    return left.first > right.first;
}

bool secondsort_less(const LLARR& left,const LLARR& right){
    return left.second > right.second;
}

int main()
{
	ios::sync_with_stdio(false);
			
	int N;
	cin >> N;
	int sum = 0;
	int A[10000];
	
	int min = 10000;
	int max = -10000;
	for (int i = 0; i < N; i++) {
	    int tmp;
		cin >> tmp;
		A[i] = tmp;
		if (min > tmp)
			min = tmp;
		if (max < tmp)
			max = tmp;
	}

	ll ans = 0xffffffff;
	for (int i = min; i <= max; i++) {
		ll tmp = 0;
		for (int k = 0; k < N; k++) {
		    tmp += ((A[k] - i) * (A[k] - i));
		}
		if (ans > tmp)
			ans = tmp;
	}
	cout << ans << endl;
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  long long int a[N+2];
  for(int i=0; i<N+2;i++){
    if(i == 0 || i == N+1) a[i] = 0;
    else cin >> a[i];
  }
  long long int S_start[N+2];
  long long int S_end[N+2];

  for(int i=0; i<N+2;i++){
    if(i==0) S_start[i]=a[i];
    else S_start[i] = S_start[i-1] + abs(a[i] - a[i-1]);
  }
  for(int i=N+1; i>=0;i--){
    if(i==N+1) S_end[i]=a[i];
    else S_end[i]= S_end[i+1] + abs(a[i] - a[i+1]);
  }
  //  cout << a[0] << endl;
  for(int i=0; i<N;i++){
    //        cout << S_start[i] << endl;
    //        cout << S_end[i+2] << endl;
    //        cout << a[i] << endl;
    //	cout << a[i+2] << endl;
    cout << S_start[i] + S_end[i+2] + abs(a[i] - a[i+2]) << endl;
  }



}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 5, M = 13;
ll n,i;
string s;
ll dp[N][M], pw[N];
ll f(char c){
    return c - '0';
}
ll solve(ll i,ll j)
{
    ll &res = dp[i][j];
    if(res != -1) return res;
    
    if(i == 0) return res = (j == 0 ? 1 : 0);
    
    if(s[i] == '?'){
        res = 0;
        for(ll u = 0;u <= 9;u += 1) res = (res + solve(i - 1, (j - (u * pw[n - i]) % M + M) % M)) % mod;
    }
    else
        res = solve(i - 1, (j - (f(s[i]) * pw[n - i]) % M + M) % M);
    return res;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    pw[0] = 1;
    memset(dp, -1, sizeof(dp));
    cin>>s;
    n = s.length();
    rep(i,1,n) pw[i] = (pw[i - 1] * 10) % M;
    s = "$" + s;
    cout<<solve(n, 5);
    return 0;
}

Measured memory_bytes: 15980
N, K = map(int, input().split())
i = 1
lstA = []
while (i < K + 1):
  lstd = list(map(int, input().split()))
  lstA0 = list(map(int, input().split()))
  for a in lstA0:
    lstA.append(a)
  i += 1
 
j = 1
lst2 = []
while(j < N + 1):
  if(j not in lstA):
    lst2.append(j)
  j += 1
 
print(len(lst2))

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

  
// {{{ ModInt
template<int _MOD>
struct ModInt {
    static const auto MOD = _MOD;
    template<class T> using integral_only = typename enable_if<is_integral<T>::value>::type;
 
    long long x;
    constexpr ModInt() : x() {}
    template<class T, integral_only<T>* = nullptr>
    ModInt(T _x) {
        x = _x % MOD;
        if (x < 0) x += MOD;
    }
    ModInt operator-() const { return {x == 0 ? 0 : MOD-x}; }
    ModInt& operator+=(ModInt rhs) {
        x += rhs.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        x -= rhs.x;
        if (x < 0) x += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (long long)x * rhs.x % MOD;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        return *this *= rhs.inv();
    }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    ModInt inv() const {
        // should work for non-prime MOD if gcd(x, MOD) = 1
        int a = x, b = MOD, u = 1, v = 0;
        while (b != 0) {
            int t = a / b;
            a -= t * b;
            u -= t * v;
            swap(a, b);
            swap(u, v);
        }
        return u;
    }
    template<class T, integral_only<T>* = nullptr>
    ModInt pow(T e) {
        ModInt r = 1, p = *this;
        while (e) {
            if (e & 1) r *= p;
            p *= p;
            e >>= 1;
        }
        return r;
    }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    bool operator<(ModInt rhs) const { return x < rhs.x; }
    bool operator<=(ModInt rhs) const { return x <= rhs.x; }
    bool operator>(ModInt rhs) const { return x > rhs.x; }
    bool operator>=(ModInt rhs) const { return x >= rhs.x; }
    friend string to_string(ModInt i) { return to_string(i.x); }
    friend ostream& operator<<(ostream &os, ModInt i) { return os << i.x; }
};
// }}}

const int MOD=1e9+7;
using mint=ModInt<MOD>;

const int N=1e5+5;
int n, A[N], mp[N];
mint ans = 1;

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

    cin >> n;
    REP(i,n) cin >> A[i];

    REP(i,n) {
    	int x = 3;
    	if(A[i] > 0) {
    		x = mp[A[i]-1];
    	}
		x -= mp[A[i]];
		mp[A[i]]++;
		ans *= x;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[5];
	cin>>n;
	a[1]=n/1000;
	a[2]=n/100%10;
	a[3]=n/10%10;
	a[4]=n%10; 
	if(a[1]==a[2]&&a[2]==a[3]||a[2]==a[3]&&a[3]==a[4]) {
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():

    # 割引時の最小値と個別購入の最小値を比較する必要あり

    a_num, b_num, m = map(int, input().split())

    a_val = list(map(int, input().split()))
    b_val = list(map(int, input().split()))

    values = []
    for i in range(m):
        values.append(list(map(int, input().split())))

    set_value = []
    for i in range(len(values)):
        set_value.append(a_val[values[i][0]-1] +
                         b_val[values[i][1]-1] - values[i][2])
    min_set_value = min(set_value)

    solo_value = min(a_val) + min(b_val)

    answer = min_set_value if min_set_value <= solo_value else solo_value

    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106000
#include<bits/stdc++.h>
using namespace std;
int a,b,c,k=1000;
int main( ){
	cin>>a>>b>>c;
	while(k--)
		if(k*a%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int maxn=5e5+7;

int root[maxn],tot;
int m;
int a[maxn],b[maxn];

void quchong(int n){
    sort(b+1,b+1+n);
    m=unique(b+1,b+1+n)-b-1;
}
 
int getid(int x){
    return lower_bound(b+1,b+1+m,x)-b;
}
 
struct Tree {
    int lc, rc;
    int sum;
} tree[maxn * 80];
 
void pushup(int k){
    tree[k].sum=tree[tree[k].lc].sum+tree[tree[k].rc].sum;
}
 
int build(int l,int r){
    int k=++tot;
    tree[k].sum=0;
    if(l==r) return k;
    int mid=(l+r)>>1;
    tree[k].lc=build(l,mid);
    tree[k].rc=build(mid+1,r);
    return k;
}
 
int updata(int p,int id,int v,int l,int r){
    int k=++tot;
    tree[k]=tree[p];
    if(l==r){
        tree[k].sum+=v;
        return k;
    }
    int mid=(l+r)>>1;
    if(id<=mid) tree[k].lc=updata(tree[p].lc,id,v,l,mid);
    else tree[k].rc=updata(tree[p].rc,id,v,mid+1,r);
    pushup(k);
    return k;
}
 
int myfind(int p,int id,int l,int r){
    if(l==r) return tree[p].sum;
    int mid=(l+r)>>1;
    if(id<=mid) return tree[tree[p].rc].sum+myfind(tree[p].lc,id,l,mid);
    return myfind(tree[p].rc,id,mid+1,r);
 
}
 
int belong[maxn];
 
int main(){
 
    int n;
    scanf("%d",&n);
    int q;
    scanf("%d",&q);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    int l,r;
    quchong(n);
    root[0]=build(1,n);
    for(int i=1;i<=n;++i){
        int id=getid(a[i]);
        if(belong[id]){
            int t=updata(root[i-1],belong[id],-1,1,n);
            root[i]=updata(t,i,1,1,n);
        }
        else{
            root[i]=updata(root[i-1],i,1,1,n);
        }
        belong[id]=i;
    }
 
    while(q--){
        scanf("%d%d",&l,&r);
        printf("%d\n",myfind(root[r],l,1,n));
    }
 
    return 0;
}

Measured memory_bytes: 254732
N = int(input())
kokuban = list(map(int, input().split()))

counter = 0
roop_checker = True
while roop_checker == True:
    for i in range(N):
        if kokuban[i] % 2 == 1:
            roop_checker = False
        else:
            kokuban[i] = kokuban[i] / 2
    if roop_checker == True:
        counter += 1
    else:
        next

print(counter)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n;
    int tmp;
    int count;
    vector<int> h;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        h.emplace_back(tmp);
    }
    tmp = h[0];
    count = 1;
    for (int i = 1; i < n; i++)
    {
        if (h[i] >= tmp)
        {
            count++;
            tmp = h[i];
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect

A, B, Q = map(int, input().split())
INF = 10 ** 12
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b,d = bisect.bisect_right(s,x) , bisect.bisect_right(t,x)
    res = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1 = abs(x-T) + abs(T-S) #t -> s
            d2 = abs(x-S) + abs(S-T) #s -> t
            res = min(res,d1,d2)
    print(res)

Measured memory_bytes: 12804
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include<iostream>
#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,P) scanf("%d %d %d %d",&n,&m,&o,&P)
#define SINT5(n,m,o,P,q) scanf("%d %d %d %d %d",&n,&m,&o,&P,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1010000000; // 0x3C33'6080
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second


int in[102][3];
/*
4 4 6

14/3 = 4.666
123/10 = 12.333

*/
int main() {
	int n, m;
	cin >> n >> m;

	for (int x = m / n; x > 0; --x) {
		if (m%x == 0) {
			cout << x << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int B[] = new int[M];
		int A[][] = new int[N][M];
		int answer = 0;
		int sum = 0;

		for (int i = 0; i < M; i++) {
			B[i] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			sum = 0;
			for (int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
				sum += A[i][j] * B[j];
			}
			if (sum + C > 0) answer++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

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


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
class Solution {
    int  M = 3e9 + 7;
public:    
    Solution() {
        
    }
    void solve() {
        int n; cin>>n;
        int mx1 = 0, mn1 = M, mx2 = -M, mn2 = M;
        FOR(i, 0, n) {
            int x, y; cin>>x>>y;
            mx1 = max(mx1, x+y);
            mn1 = min(mn1, x+y);
            mx2 = max(mx2, x-y);
            mn2 = min(mn2, x-y);
        }
        cout<<max(abs(mx1-mn1), abs(mx2-mn2));
    }
};
// abs(x1 - x2) + abs(y1 - y2)   
// (x1 - x2) + (y1-y2)       -- both +ve
// (x1 + y1) - ( x2 + y2)    -- (1) 
// OR 
// -(x1 - x2) - (y1 - y2)    -- both -ve
// -x1 + x2 - y1 + y2        -- Same as (1) (?)
// OR
// x1 - x2 - y1 + y2         -- second -ve
// (x1 - y1) - (x2 - y2)     -- (2) 
// OR
// -x1 + x2 + y1 - y2
// -(x1 - y1) + (x2 - y2)    -- Same as (2) ()

void solve(){
    Solution sol;
    sol.solve();
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}

Measured memory_bytes: 3632
#include<map>
#include<algorithm>
#include<queue>
#include<iostream>
#include<deque>
#include<vector>
using namespace std;
#define _rep(n, a, b) for (int n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (int n = (a); n >= (b); --n)
#define _for(n, a, b) for (int n = (a); n < (b); ++n)
#define _rof(n, a, b) for (int n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pdd pair<db, db>
#define endl "\n"
const int mod = 1e9 + 7;
const int maxn = 10;
vector<int> a, sub, r, c;
vector<vector<int>> G(maxn, vector<int>(maxn, 0));
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    ll cur = 0;
    r.resize(n + 1), c.resize(m + 1);
    _rep(i, 0, n-1) {
        string s;
        cin >> s;
        _for(j, 0, s.size()) {
            if (s[j] == '#') {
                cur++;
                G[i][j] = 1;
            }
            else {
                r[i]++;
                c[j]++;
            }

        }
    }
    ll res = 0;
    _rep(row, 0, (1 << n) - 1) {
        _rep(col, 0, (1 << m) - 1) {
            int rem = 0;
            _for(i, 0, n) {
                _for(j, 0, m) {
                    if (G[i][j] == 1 && !((row >> i) & 1) && !((col >> j) & 1)) {
                        rem++;
                    }
                }
            }
            if (rem == k)res++;

        }
    }
    
    cout << res << endl;

}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll A, B, C, K; cin >> A >> B >> C >> K;
    ll ans = 0;
    if (A < K) {
        ans = A;
        if (K - A > B) ans -= (K - A - B);
    }
    else {
        ans = K;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt","w",stdout);
  // #endif
  
ll a,l;
cin>>a>>l;
vec q(a);

	f(i,0,a)
	{
		q[i]=l+i;
		
	}
	ll q1=accumulate(all(q),0);
	
	

	if(l<0)
	{
		sort(all(q));

	if(count(all(q),0)!=0)
	cout<<q1;
	else
	cout<<q1-q[a-1];	
	}
	else if(l>-1)
	{

	cout<<q1-q[0];
    
    }
	
	

  


    




    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;


} 


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

using namespace std;

typedef long long ll;

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

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

vector<vector<int>> obs_row;
vector<vector<int>> obs_col;
vector<string> grid;

int solve(const int H, const int W) {
    int maximum = 0;
    for (int h = 1; h <= H; h++) {
        for (int w = 1; w <= W; w++) {
            if (grid[h - 1][w - 1] == '#') continue;

            auto row = obs_row[h];
            auto col = obs_col[w];

            int left = *(upper_bound(row.begin(), row.end(), w) - 1); // the position of the nearest obstracle in left
            int right = *(lower_bound(row.begin(), row.end(), w)); // in right
            int up = *(upper_bound(col.begin(), col.end(), h) - 1); // in up
            int down = *(lower_bound(col.begin(), col.end(), h)); // in down
            // printf("(%d, %d) left: %d, right: %d, up: %d, down: %d\n", w, h, left, right, up, down);

            int res = (right - left - 1) + (down - up - 1) - 1;
            chmax(maximum, res);
        }
    }

    return maximum;
}

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

    grid.resize(H);
    obs_row.resize(H + 1);
    obs_col.resize(W + 1);
    for (int i = 1; i <= W; i++) {
        obs_col[i].push_back(0);
    }
    for (int i = 1; i <= H; i++) {
        string S;
        cin >> S;
        grid[i - 1] = S;
        obs_row[i].push_back(0);
        for (int j = 1; j <= W; j++) {
            if (S[j - 1] == '#') {
                obs_row[i].push_back(j);
                obs_col[j].push_back(i);
            }
        }
        obs_row[i].push_back(W + 1);
    }
    for (int i = 1; i <= W; i++) {
        obs_col[i].push_back(H + 1);
    }

    // cout << "obs_row: " << endl;
    // for (int i = 0; i < (int) obs_row.size(); i++) {
    //     for (int j = 0; j < (int) obs_row[i].size(); j++) {
    //         cout << obs_row[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    // cout << "obs_col: " << endl;
    // for (int i = 0; i < (int) obs_col.size(); i++) {
    //     for (int j = 0; j < (int) obs_col[i].size(); j++) {
    //         cout << obs_col[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;

    cout << solve(H, W) << endl;

    return 0;
}


Measured memory_bytes: 42240
using System;
using System.Linq;

namespace Number
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string s = Console.ReadLine().Trim('\n');
                if(s == "0 0") break;
                int[] i = s.Split(' ')
                           .Select(e => int.Parse(e))
                           .ToArray();
                int a = i[0];
                int b = i[1];
                for(int j = 0; j < a; j++)
                {
                    string _c = (j % 2) == 0 ? "#." : ".#";
                    string _t = "";
                    for(int k = 0; k < b; k++)
                        _t = _t + ((k % 2) == 0 ? _c[0] : _c[1]);
                    Console.WriteLine(_t);
                }      
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9556
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int a, b, c, d;
int all[200];

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen(fname".in", "r", stdin);
	// freopen(fname".out", "w", stdout);
	scanf("%d%d%d%d", &a, &b, &c, &d);
	for(int i = a; i < b; ++i)
		all[i]++;
	for(int i = c; i < d; ++i)
		all[i]++;
	int cnt = 0;
	for(int i = 0; i <= 100; ++i){
		if (all[i] == 2)
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
       int x = in.nextInt();

       if(x==3 || x==5 || x==7){
           System.out.println("YES");
       }
       else System.out.println("NO");
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int a,b,c,k; cin>>a>>b>>c>>k;

    int ans = 0;
    int A = min(k,a);
    ans += A;
    k-=a;
    k-=b;
    if (k>0) ans -= k;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
MOD = 10**9 + 7
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = [[0] * (m+1) for _ in range(n+1)]
cs = [[0] * (m+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, m+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = 1 + cs[i-1][j-1]
            dp[i][j] %= MOD

        cs[i][j] = cs[i-1][j] + cs[i][j-1] - cs[i-1][j-1] + dp[i][j]
        cs[i][j] %= MOD

print((cs[n][m] + 1) % MOD)


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

void dfs(ll x, int digit, vector<ll> &list) {
  list.push_back(x);
  if (digit == 10) {
    return;
  }
  vector<int> next;
  int digit0 = x % 10;
  for (int i = -1; i <= 1; i++) {
    int next = digit0 + i;
    if (next >= 0 && next <= 9) {
      dfs(x * 10 + next, digit + 1, list);
    }
  }
}

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

  vector<ll> list;
  for (int i = 1; i <= 9; i++) {
    dfs(i, 1, list);
  }
  sort(list.begin(), list.end());
  cout << list[k - 1] << endl;

  return 0;
}


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

int main() {
string S,T;
  cin >> S;
  cin >> T;
  int i;
  i=0;
    while (i < S.size()){
  if ( S.at(i) == T.at(i)){
    i++;
  }
  else{
    cout << "No" << endl;
    break;
  }
    }
 if (i >= S.size())
   cout << "Yes" << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
int min(int a,int b){
  if(a>b) return b;
  return a;
}
int main(void){
  int p,q,r;
  scanf("%d %d %d",&p,&q,&r);
  int ans;
  ans = min(p+q,min(q+r,r+p));
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string ans="Yes";
  vector<int> a(26,0);
  for(int i=0;i<4;i++){
    a[(int)(s.at(i)-'A')]++;
  }
  for(int i=0;i<26;i++){
    if(a[i]==1||a[i]==3||a[i]==4){ans="No";}
  }
  cout<<ans;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
#define rep(i,j,n) for(int i=(j);i<=((int)n);++i)
#define rev(i,n,j) for(int i=(n);i>=((int)j);--i)
typedef long long int ll;
#define int long long int
const ll INFL=0x3f3f3f3f3f3f3f3fLL;
const int INF=0x3f3f3f3f;
const int mod=1000000007;
#define endl "\n"
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define readmat(a, n, m) int a[n + 5][m + 5] = {}; rep(i, 1, n) {rep(j, 1, m) cin >> a[i][j];}
#define printmat(a, n, m) rep (i, 1, n) {rep (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define printarr(a, n) rep(i, 1, n) cout << a[i] << " "; cout << endl;
typedef std::map< int,int> mii;
typedef std::vector< int > vi;
typedef std::vector< vi > vvi;
typedef std::pair< int,int > ii;
using namespace std;
#define cerr cout
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);}
const int N = 1e6+5, M = N;
vector <int>g[N];

void solve()
{
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;
  

}



signed main()
{
  FAST;
#ifdef LOCAL
    freopen("C:\\Users\\hp\\Documents\\input.txt", "r", stdin);
    freopen("C:\\Users\\hp\\Documents\\output.txt", "w", stdout);
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
#endif

solve();

#ifdef LOCAL
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cout<<endl;
    cout << "\nElapsed Time: " << elapsed_time << "ms\n";
#endif

return 0;

}

// vector string set map first second continue break return upper_bound lower_bound length void sort
// stack queue pop size erase empty insert
// #Hala BBCF



Measured memory_bytes: 27080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

int modPow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

vector<long long> fact_inv, inv;

/*  init_nCk :二項係数のための前処理
    計算量:O(k)
*/
void init_nCk(int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
 
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(k)
*/
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    long long ans = 1;
    for (int i = n; i >= n - k + 1; i--) {
        ans *= i;
        ans %= MOD;
    }
    return ans * fact_inv[k] % MOD;
}

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

    int N, A, B; cin >> N >> A >> B;
    ll ans = modPow(2, N, MOD) - 1;

    init_nCk(200000);
    ll a = nCk(N, A);
    ll b = nCk(N, B);

    ans = (ans+MOD - a) % MOD;
    ans = (ans+MOD - b) % MOD;
    cout << ans << endl;
}

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

int main(int argc, char const *argv[])
{
	int a,b,q;
	cin>>a>>b>>q;
	multiset<long long> s,t;
	long long c;
	for (int i = 0; i < a; ++i)
	{
		cin>>c;
		s.insert(c);
	}
	for (int i = 0; i < b; ++i)
	{
		cin>>c;
		t.insert(c);
	}
	s.insert(-1000000000000LL);
	s.insert(1000000000000LL);
	t.insert(-1000000000000LL);
	t.insert(1000000000000LL);
	long long x;
	for (int i = 0; i < q; ++i)
	{
		cin>>x;
		long long ans=1000000000000LL;
		auto itrs=s.lower_bound(x);
		auto itrt=t.lower_bound(*itrs);
		ans=min(ans,abs(x-*itrs)+abs(*itrs-*itrt));
		--itrt;
		ans=min(ans,abs(x-*itrs)+abs(*itrs-*itrt));
		--itrs;
		itrt=t.lower_bound(*itrs);
		ans=min(ans,abs(x-*itrs)+abs(*itrs-*itrt));
		--itrt;
		ans=min(ans,abs(x-*itrs)+abs(*itrs-*itrt));
		itrt=t.lower_bound(x);
		itrs=s.lower_bound(*itrt);
		ans=min(ans,abs(x-*itrt)+abs(*itrt-*itrs));
		--itrs;
		ans=min(ans,abs(x-*itrt)+abs(*itrt-*itrs));
		--itrt;
		itrs=s.lower_bound(*itrt);
		ans=min(ans,abs(x-*itrt)+abs(*itrt-*itrs));
		--itrs;
		ans=min(ans,abs(x-*itrt)+abs(*itrt-*itrs));
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int n;
vector<int>E[N];
#define pb push_back
void input()
{
	int x,y;
	n=read<int>();
	For(i,2,n)
	{
		x=read<int>(),y=read<int>();
		E[x].pb(y),E[y].pb(x);
	}
}
int Max[N],ans[N];
void dfs(int u,int pre,int fir,int sec,int pos)
{
	Max[u]=max(Max[pre],pre);
	cmax(sec,u);
	if(fir<u)fir=u,sec=0;
	if(Max[fir]>sec)ans[fir]++;
	else ans[pos]++;
	for(int v:E[u])if(v^pre)dfs(v,u,fir,sec,fir==u?v:pos);
}
void dfs2(int u,int pre)
{
	ans[u]+=ans[pre];
	for(int v:E[u])if(v^pre)dfs2(v,u);
}
void work()
{
	dfs(1,0,0,0,0);			
	ans[0]=ans[1]=0;
	dfs2(1,0);
	For(i,2,n)write(ans[i],' ');
}
int main()
{

	input();
	work();
	return 0;
}



Measured memory_bytes: 29696
# -*- coding: utf-8 -*-

import sys
import os
from math import sin, cos
import math

def rotate_vector(v, rad):
    x = v[0]
    y = v[1]

    new_x = cos(rad) * x - sin(rad) * y
    new_y = sin(rad) * x + cos(rad) * y
    return (new_x, new_y)

pos = [0, 0]
dir = [0, 1]
for s in sys.stdin:
    length, degree = map(int, s.split(','))

    # move
    pos[0] += dir[0] * length
    pos[1] += dir[1] * length

    # rotate
    rad = math.radians(degree)
    rad *= -1

    # rotated dir
    dir = rotate_vector(dir, rad)
print(int(pos[0]))
print(int(pos[1]))

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

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
	//freopen("input.txt", "r", stdin);
	string s;
	cin >> s;
	long long sum = 0LL;
	for (int i = 0; i < s.length(); ++i) {
		sum = (sum + s[i] - '0') % 9;
	}

	sum = sum % 9;
	if(!sum)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3752