akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        List<String> s = new ArrayList<String>(Arrays.asList(br.readLine().split("")));
        List<String> t = new ArrayList<String>(Arrays.asList(br.readLine().split("")));
        int mins;
        int maxt;
        int sindex=0;
        int tindex=0;
        int minsize = Math.min(s.size(), t.size());
        for (int i = 0; i < minsize; i++) {
            mins = Integer.MAX_VALUE;
            maxt = Integer.MIN_VALUE;
            for (int j = 0; j < s.size(); j++) {
                if (s.get(j).charAt(0) < mins) {
                    mins = s.get(j).charAt(0);
                    sindex = j;
                }
            }
            for (int j = 0; j < t.size(); j++) {
                if (t.get(j).charAt(0) > maxt) {
                    maxt = t.get(j).charAt(0);
                    tindex = j;
                }
            }
            if (mins < maxt) {
                System.out.println("Yes");
                return;
            }else if(mins > maxt){
                System.out.println("No");
                return;
            }
            s.remove(sindex);
            t.remove(tindex);
        }
        if(s.size() < t.size()){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

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

long long N;
long long arr[500000];
long long head[500000];
long long tail[500000];

//first i], tail [i+1
long long cal(long long idx){
	return head[idx] - tail[idx+1];
}

int main(){
	cin >> N;
	for(long long i = 0; i < 3 * N; i++){
		cin >> arr[i];
	}

	long long cur = 0;
	priority_queue<long long,vector<long long>, greater<long long> > que;


	for(long long i = 0; i < N; i++){
		cur += arr[i];
		que.push(arr[i]);
	}

	head[N-1] = cur;
	for(long long i = N; i < 2 * N; i++){
		if(arr[i] > que.top()){
			cur += (arr[i] - que.top());
			que.pop();
			que.push(arr[i]);
			head[i] = cur;
		}else{
			head[i] = cur;
		}
	}

	priority_queue<long long> tailque;

	cur = 0;
	for(long long i = 3*N-1; i >= 2 * N; i--){
		cur += arr[i];
		tailque.push(arr[i]);
	}

	tail[2*N] = cur;
	for(long long i = 2*N - 1; i >= N; i--){
		if(arr[i] < tailque.top()){
			cur -= (tailque.top() - arr[i]);
			tailque.pop();
			tailque.push(arr[i]);
			tail[i] = cur;
		}else{
			tail[i] = cur;
		}
	}

	long long ret = LONG_MIN;
	for(long long i = N - 1; i < 2 * N; i++){
		ret = max(ret, cal(i));
	}
	cout << ret << endl;
}



Measured memory_bytes: 8820
#include<iostream>
using namespace std;
int main(){
    int X,Y;
    cin >> X >> Y;
    if(Y<2*X || 4*X<Y){
        cout << "No" << endl;
    }else if((Y-2*X)%2 == 0 && (4*X-Y)%2 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}   

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

#define ll long long

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define alll(it,A) for(it=A.begin();it!=A.end();it++)

#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define pii pair<int,int>
#define V vector<ll>
#define VP vector<pll>
#define SP set<pll>
#define VB vector<bool>
#define S set<ll>
#define MS multiset<ll>
#define VV vector<V>
#define VS vector<S>
#define PQi priority_queue< int >
#define PDQi priority_queue< int ,vector< int > ,greater< int > >
#define PQl priority_queue< ll >
#define PDQl priority_queue< ll ,V,greater< ll > >
//#define inf 1e5
#define mod 1000000007
bool isprime(ll n){
    ll i;
    if(n==2||n==3)return 1;
    ll flag=0;
    for(i=2;i<=sqrt(n)+1;i++){
        if(n%i==0){
            flag=1;
            break;
        }
    }
    if(flag)return 0;
    else return 1;
}
//ll cost[200001];
//V adj[200001];
//ll d[200001]={0};
//ll dam[200001]={0};
//V rdj[200001];
//ll visited[200001]={0};
//ll par[200001]={0},rnk[200001]={0};
//ll find(ll a){
//	if(par[a]==a)return par[a];
//	return find(par[a]);
//}
//void unionf(ll a,ll b){
//	a=find(a);
//	b=find(b);
//	//if(a==b)continue;
//	if(rnk[a]>rnk[b]){
//		par[b]=a;
//		rnk[a]+=rnk[b];
//	}
//	else{
//		par[a]=b;
//		rnk[b]+=rnk[a];
//	}
//}
ll kadane(ll a[],ll n){
    ll sumtill=0,maxtill=0,start=0,ending=0,start1=0;
    rep(i,0,n){
        sumtill+=a[i];
       // err1(sumtill);
        if(sumtill>maxtill){
            maxtill=sumtill;
            start=start1;
            ending=i;
        }
        if(sumtill<0){
            start1=i+1;
            sumtill=0;
        }
    }
    return maxtill;
}
ll pow1(ll a,ll b,ll mod1){
    int res=1;
    if(b<0) b+=mod1-1;
    while(b>0){
        if(b&1){
        	res=(res*a)%mod1;
		}
        a=(a*a)%mod1;
        b>>=1;
    }
    return res%mod1;
}
int main(){
	fast
    ll t;
    //cin>>t;
    t=1;
    while(t--){
            ll n,k;
            cin>>n>>k;
            ll a[n];
            rep(i,0,n)cin>>a[i];
            ll dp[k+1][2];
            rep(i,0,k+1)rep(j,0,2)dp[i][j]=!j;
            rep(j,0,n)dp[a[j]][0]=0,dp[a[j]][1]=1;
            rep(i,1,k+1){
                rep(j,0,n){
                    if(a[j]>i)continue;
                    dp[i][0]=min(dp[i][0],(ll)dp[i-a[j]][1]);
                    dp[i][1]=max(dp[i][1],(ll)dp[i-a[j]][0]);
                    //err3(dp[i][0],dp[i][1],i);
                }//cout<<"\n";
            }
            if(dp[k][0]==0)cout<<"First";
            else cout<<"Second";
    }
    return 0;
}



Measured memory_bytes: 5160
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define MAX_N (1<<18)
struct SegTree {
  set<int> seg[MAX_N*2-1];
  bool query(int a, int b, int xl, int xr, int k=0, int l=0, int r=MAX_N) {
    if (b <= l || r <= a) return false;
    if (seg[k].lower_bound(xl) != seg[k].upper_bound(xr)) return true;
    if (a <= l && r <= b) return false;
    return query(a, b, xl, xr, k*2+1, l, (l+r)/2)
        || query(a, b, xl, xr, k*2+2, (l+r)/2, r);
  }

  void insert(int a, int b, int x, int k=0, int l=0, int r=MAX_N) {
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      seg[k].insert(x);
      return;
    }
    insert(a, b, x, k*2+1, l, (l+r)/2);
    insert(a, b, x, k*2+2, (l+r)/2, r);
  }
};
SegTree seg[2];

int N;
int AX[100000], AY[100000], BX[100000], BY[100000];
set<P> V[2][200000];
bool S[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  vector<int> xs, ys;
  rep(i, N) {
    cin >> AX[i] >> AY[i] >> BX[i] >> BY[i];
    xs.pb(AX[i]), xs.pb(BX[i]);
    ys.pb(AY[i]), ys.pb(BY[i]);
  }
  sort(all(xs)); uniq(xs);
  sort(all(ys)); uniq(ys);
  rep(i, N) {
    AX[i] = index(xs, AX[i]), AY[i] = index(ys, AY[i]);
    BX[i] = index(xs, BX[i]), BY[i] = index(ys, BY[i]);
  }

  rep(i, N) {
    int t, l, r, y;
    if (AY[i] == BY[i]) {
      t = 0;
      l = AX[i], r = BX[i], y = AY[i];
    }
    else if (AX[i] == BX[i]) {
      t = 1;
      l = AY[i], r = BY[i], y = AX[i];
    }
    else assert(false);
    if (l > r) swap(l, r);

    set<P> &vs = V[t][y];

    auto nx = vs.lower_bound(P(l, INF));
    bool ok = (nx == vs.end() || r < nx->_1);
    if (nx != vs.begin()) {
      nx--;
      if (nx->_2 < l) {}
      else ok = false;
    }
    if (!ok) continue;

    if (seg[t^1].query(y, y+1, l, r)) continue;

    vs.insert(P(l, r));
    seg[t].insert(l, r+1, y);
    S[i] = true;
  }
  rep(i, N) cout << S[i] << "\n";
  return 0;
}

Measured memory_bytes: 93064
import collections

N = int(input())
S = list(input())

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)

Measured memory_bytes: 68640
N, K = map(int, input().split())
MOD = 10**9 + 7
memo = {}


def a(n):
    if n in memo:
        return memo[n]
    else:
        ret = pow(n, N, MOD)
        for i in range(2, n+1):
            ret -= a(n//i)
        memo[n] = ret
        return ret


ans = 0
for i in range(1, K+1):
    ans += i*a(K//i)
    ans %= MOD
print(ans)


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	int n; cin >> n;
	vector<int> a(n + 1, 0);
	for (int i = 1; i < n; ++i)
	{
		cin >> a[i];
	}
	a[0] = a[1];
	ll res = 0;
	for (int i = 1; i < n; ++i)
	{
		res += (min(a[i], a[i - 1]));
	}
	cout << res + a[n - 1];
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3608
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int cou = 1;
    int n = sc.nextInt();
    int[] p = new int[n];
    for(int i = 0; i < n; i++){
      p[i] = sc.nextInt();
    }
    int min = 999999999;
    for(int i = 1; i < n; i++){
      min = Math.min(min,p[i-1]);
      if(p[i] < min){
        cou++;
      }
    }
    System.out.print(cou);
  }
}


Measured memory_bytes: 65016
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <cstdlib>
#include <set>
#include <algorithm>
using namespace std;
#define N (1<<18)

struct Query{
	int t,a,b,y;
};
int Q;
Query que[50000];

set<int> next;

int dead[50000];
vector< pair<int,int> > event[200010];

struct Node{
	int minimum;
	int lazy;
	Node(){ minimum = lazy = 0; }
};

Node seg[2*N];


vector<int> u;
int n;

void update(int l,int r,int v,int k=1,int a=1,int b=N){
	if( seg[k].lazy && k < N ){
		seg[k*2].minimum = seg[k].lazy;
		seg[k*2+1].minimum = seg[k].lazy;
		seg[k*2].lazy = seg[k].lazy;
		seg[k*2+1].lazy = seg[k].lazy;
	}
	seg[k].lazy = 0;
	if( b < l || r < a ) return;
	
	if( l <= a && b <= r ){
		seg[k].minimum = v;
		seg[k].lazy = v;
		return;
	}
	int m = (a+b)>>1;
	update(l,r,v,k*2,a,m);
	update(l,r,v,k*2+1,m+1,b);
	seg[k].minimum = min( seg[k*2].minimum , seg[k*2+1].minimum );
}

int get(int l,int r,int k=1,int a=1,int b=N){
	if( seg[k].lazy && k < N ){
		seg[k*2].minimum = seg[k].lazy;
		seg[k*2+1].minimum = seg[k].lazy;
		seg[k*2].lazy = seg[k].lazy;
		seg[k*2+1].lazy = seg[k].lazy;
	}
	seg[k].lazy = 0;
	if( b < l || r < a ) return 2e9;
	
	if( l <= a && b <= r ){
		return seg[k].minimum;
	}
	int m = (a+b)>>1;
	int vl = get(l,r,k*2,a,m);
	int vr = get(l,r,k*2+1,m+1,b);
	seg[k].minimum = min( seg[k*2].minimum , seg[k*2+1].minimum );
	return min(vl,vr);
}

int seg2[2*N];


void update2(int l,int r,int v,int k=1,int a=1,int b=N){
	if( b < l || r < a ) return;
	
	if( l <= a && b <= r ){
		seg2[k] = max(seg2[k],v);
		return;
	}
	int m = (a+b)>>1;
	update2(l,r,v,k*2,a,m);
	update2(l,r,v,k*2+1,m+1,b);
}


int get2(int i){
	i += N - 1;
	int ans = 0;
	while(i){
		ans = max( ans , seg2[i]);
		i /= 2;
	}
	return ans;
}

int main(){
	scanf("%d",&Q);
	for(int i = 0 ; i < Q ; i++){
		scanf("%d%d%d%d",&que[i].t,&que[i].a,&que[i].b,&que[i].y);
	}
	
	for(int i = 0 ; i < Q ; i++){
		u.push_back(que[i].a);
		u.push_back(que[i].a+1);
		
		u.push_back(que[i].b);
		u.push_back(que[i].b+1);
	}
	u.push_back(0);
	sort(u.begin(),u.end());
	u.erase(unique(u.begin(),u.end()),u.end());
	n = u.size();
	for(int i = 0 ; i < Q ; i++){
		que[i].a = lower_bound(u.begin(),u.end(),que[i].a) - u.begin();
		que[i].b = lower_bound(u.begin(),u.end(),que[i].b) - u.begin();
	}
	
	for(int i = 1 ; i < n ; i++) next.insert(i);
	
	vector<int> arr(n);
	for(int i = 0 ; i < Q ; i++){
		if( que[i].t == 0 ){
			update2(que[i].a,que[i].b,que[i].y);
		}else{
			set<int>::iterator it = next.lower_bound(que[i].a);
			while(it != next.end()){
				if( *it > que[i].b ) break;
				arr[*it] = get2(*it);
				next.erase(it++);
			}
		}
	}
	for(set<int>::iterator it = next.begin(); it != next.end(); ++it){
		arr[*it] = get2(*it);
	}
	
	
	for(int i = 1 ; i < n ; i++) update(i,i,arr[i]);
	//for(int i = 1 ; i < n ; i++) cout << arr[i] << " "; cout << endl;
	for(int i = 0 ; i < Q ; i++){
		if( que[i].t == 0 ){
			if( que[i].y != get(que[i].a,que[i].b) ){	
				cout << "NO" << endl;
				return 0;
			}
		}else{
			update(que[i].a,que[i].b,que[i].y);
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 22740
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, W; cin >> N >> W;

    vector<intmax_t> w(N), v(N);
    for (size_t i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    constexpr int MAX = int(1e5);

    auto dp = make_v(LINF, N + 1, MAX + 1);
    dp[0][0] = 0;
    for (size_t i = 0; i < N; ++i) {
        for (size_t value = 0; value <= MAX; ++value) {
            chmin(dp[i + 1][value], dp[i][value]);
            if (value >= v[i]) {
                chmin(dp[i + 1][value], dp[i][value - v[i]] + w[i]);
            }
        }
    }

    intmax_t res = 0;
    for (size_t value = 0; value <= MAX; ++value) {
        if (dp[N][value] <= W) res = value;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

priority_queue<int> q1;
int num[20];
int aft[20];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	bool flag=true;
	cin>>n;
	for(i=0;i<(1<<n);i++){
		cin>>a;
		q1.push(a);
	}
	a=q1.top(),q1.pop(),aft[n]=1;
	while(!q1.empty()){
		b=q1.top(),q1.pop();
		if(a!=b){
			a=b;
			for(i=0;i<=n;i++){
				num[i]+=aft[i];
			}
			memset(aft,0,sizeof(aft));
		}
		for(i=n;i>0;i--){
			if(num[i]>0){
				num[i]--,num[i-1]++,aft[i-1]++;
				break;
			}
		}
		if(i==0){
			flag=false;
			break;
		}
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main() {
  string s;
  cin >> s;

  int ans;
  if (s == "SUN") ans = 7;
  else if (s == "MON") ans = 6;
  else if (s == "TUE") ans = 5;
  else if (s == "WED") ans = 4;
  else if (s == "THU") ans = 3;
  else if (s == "FRI") ans = 2;
  else if (s == "SAT") ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int ufr[225816],ufp[225816];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufr[i] = 1;
		ufp[i] = i;
	}
}

int ufind(int x){
	if(ufp[x] == x){
		return x;
	}
	return ufp[x] = ufind(ufp[x]);
}

void ufinit(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return;
	}
	if(ufr[x]<ufr[y]){
		std::swap(x,y);
	}
	ufr[x] += ufr[y];
	ufp[y] = x;
}

int main(void){
	int n,m,i,j,k,l;
	std::cin >> n >> m;
	ufinit(n+m);
	for(i=0; i<n; ++i){
		std::cin >> k;
		for(j=0; j<k; ++j){
			std::cin >> l; --l;
			ufinit(i,n+l);
		}
	}
	for(i=0; i<n; ++i){
		if(ufind(0)!=ufind(i)){
			std::cout << "NO" << std::endl;
			return 0;
		}
	}
	std::cout << "YES" << std::endl;
	return 0;
}


Measured memory_bytes: 4984
import bisect

n = int(input())
s = input()
r = []
b = []
g = []
for i,c in enumerate(s):
    if c == 'R':
        r.append(i)
    elif c == 'B':
        b.append(i)
    else:
        g.append(i)
g_leng = len(g)
r_leng = len(r)
b_leng = len(b)
ans = g_leng*r_leng*b_leng
subans = 0
for j in b:
    for i in r:
        g_ind = bisect.bisect_left(g, 2*j-i)
        if g_ind != g_leng and g[g_ind] == 2*j-i:
            subans+=1
        g_ind = bisect.bisect_left(g, 2*i-j)
        if g_ind != g_leng and g[g_ind] == 2*i-j:
            subans+=1
        g_ind = bisect.bisect_left(g, (i + j) // 2)
        if g_ind != g_leng and g[g_ind] == (i + j) / 2:
            subans += 1
print(ans-subans)

Measured memory_bytes: 74628
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)

// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string s; cin >> s;
    bool flag=0;
    rep(i,3){
        if(s[i-1]==s[i]&&s[i]==s[i+1]) flag=1;
    }
    if(flag) pr("Yes");
    else pr("No");
}



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

using namespace std;
int main() {
    int n;
    string s;
    cin >> n >> s;
    //n = 7;
    //s = "DDIDDII";
    if(n < 1 || 100 < n) {
        return 0;
    }
    if(s.length() != n) {
        return 0;
    }

    int cur = 0;
    int max = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'I') {
            cur++;
        } else if(s[i] == 'D') {
            cur--;
        }

        if(max < cur) max = cur;
    }
    cout << max;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
using namespace std;

int main(){
  int N,D;
  cin >> N >> D;
  int X[N],Y[N];
  long D2 = pow(D,2);
  for(int i=0;i<N;i++){
    cin >> X[i] >> Y[i];
  }
  int count = 0;
  long X2[N],Y2[N];
  for(int i=0;i<N;i++){
    X2[i] = pow(X[i],2);
    Y2[i] = pow(Y[i],2);
    if(X2[i]+Y2[i]<=D2) count++;
  }
  
  printf("%d\n",count);
  
  return 0;
}

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

int main(){
	const unsigned long long md=1000000007;
	unsigned long long n,ans,a=1,b=1,c=1;
	cin >> n;
	for(unsigned long long i=0; i<n-1; ++i){
		a = (a*10)%md;
		b = (b*9)%md;
		c = (c*8)%md;
	}
	a = (a*10);
	b = (b*9);
	c = (c*8)%md;
	ans = ((a + c) - (b*2)%md)%md;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
package main

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

func lib_CountInt(values []int) map[int]int {
	m := map[int]int{}
	for _, value := range values {
		m[value]++
	}
	return m
}
func lib_PowInt(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}
func lib_PrimeFactorsInt(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}
	if n > 2 {
		pfs = append(pfs, n)
	}
	return
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	var P int
	scanner.Scan()
	P, _ = strconv.Atoi(scanner.Text())
	fmt.Println(solve(N, P))
}
func solve(N int, P int) int {
	pfs := lib_CountInt(lib_PrimeFactorsInt(P))
	if len(pfs) == 0 {
		return 1
	}
	res := 1
	for pf, cnt := range pfs {
		n := cnt / N
		if n > 0 {
			res *= lib_PowInt(pf, n)
		}
	}
	return res
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5 + 100;

ll n;
int x, m;
set<int> st;
ll acu[N];
int pos_st[N];

int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

	cin >> n >> x >> m;
	ll ans = 0;
	int qnt = 0;
	for(int i = 1; pos_st[x] == 0; i++) {
		pos_st[x] = i;
		ans = ans + x;
		acu[i] = ans;
		qnt++;
		st.insert(x%m);
		x = (x*1ll*x)%m;
	}

	int start_cycle = pos_st[x];
	int end_cycle = qnt;
	// cout << "cycle = " << start_cycle << ' ' << end_cycle << '\n';
	qnt = end_cycle-start_cycle+1;
	ll cycled = ans-acu[start_cycle-1];
	// cout << "cycled = " << cycled << " | " << cycled*1LL*((n-start_cycle+1)/qnt) << '\n';
	// cout << "pre-cycle: " << acu[(int)min(n, (ll)start_cycle-1)] << '\n';
	ll beforeCycle = acu[(int)min(n, (ll)start_cycle-1)];
	ll inCycle = cycled*1LL*((n-start_cycle+1)/qnt);
	int lSt = (start_cycle-1);
	ll afterCycle = 0;
	if(n >= start_cycle)
		afterCycle = (acu[lSt + (n-start_cycle+1)%qnt]-acu[lSt]);
	// cout << "in: " << inCycle << '\n';
	// cout << "after: " << afterCycle << '\n';
	ans = beforeCycle + inCycle + afterCycle;
			
	cout << ans << '\n';



	return 0;
}


Measured memory_bytes: 6744
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

ll solve()
{
    const ll inf = 1LL << 60;
    ll N;
    cin >> N;
    ll a,b,c;
    //ll ans = 0;
    vector<vector<pair<ll,ll>>> node(N);
    for1(i,N-1) {
        cin >> a >> b >> c;
        a -= 1;
        b -= 1;
        node[a].push_back(make_pair(b,c));
        node[b].push_back(make_pair(a,c));
    }

    ll Q,K;
    cin >> Q >> K;
    K -= 1;

    vector<ll> sc(N, inf);
    sc[K] = 0;
    priority_queue<pair<ll,ll>> q;
    q.push(make_pair(0,K));
    while (!q.empty()) {
        pair<ll,ll> item = q.top();
        q.pop();
        ll cost = -item.first;
        ll src = item.second;
        for (auto road : node[src]) {
            ll dest = road.first;
            ll cost1 = road.second;
            if (sc[dest] > cost + cost1) {
                sc[dest] = cost + cost1;
                q.push(make_pair(-sc[dest],dest));
            }
        }
    }

    vector<ll> ans(Q);
    for1(i,Q) {
        ll x,y;
        cin >> x >> y;
        x -= 1;
        y -= 1;
        ans[i] = sc[x] + sc[y];
    }
    for1(i,Q) {
        cout << ans[i] << endl;
    }

    return 0;//ans;
}

int main()
{
    do {
        solve();
        //cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 11504
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) {
        cout << ":(";
    } else {
        cout << "Yay!";
    }   
}


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

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

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        ans += a - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import collections


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def solve():
    N = int(input())
    if N == 1:
        return 0
    D = factorization(N)
    R = primes()

    result = 0
    for d in D:
        result += R[d[1]]

    return result


def primes():
    R = [0 for i in range(41)]
    for i in range(40, 0, -1):
        tmp_R = R[:]
        for j in range(i, 41):
            tmp_R[j] = max(R[j], R[j - i] + 1)
        R = tmp_R

    return R


if __name__ == "__main__":
    print(solve())


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

using namespace std;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define z cout<<"\n";


int main()
{
    optimize();

    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";

    z;

    return 0;

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,i,data;
	cin >> n;
	int arr[n+1];
	for(i=0;i<=n;++i)
		arr[i]=0;
	for(i=0;i<n-1;++i)
	{
		
		cin >> data;
		arr[data]++;
	}
	for(i=1;i<=n;++i)
	{
		cout<<arr[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4352
def list_divisors(pd)
  return [1] if pd.size == 0
  q,d = pd[0]
  ds = list_divisors(pd[1..-1])
  x = 1
  (0..d).map{
    ds.map{ |d| d * x }.tap{ x *= q }
  }.flatten
end

require "prime"
N,K,*A = `dd`.split.map &:to_i
SA = A.inject(:+)

ds = list_divisors(SA.prime_division).sort
p ds.reverse_each.find{ |d|
  as = A.map{ |a| a % d }.select{ |a| a > 0 }.sort
  dd = as.inject(0,:+)
  next true if dd == 0
  n = dd / d
  as[0...(as.size - n)].inject(0,:+) <= K
}



Measured memory_bytes: 15492
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

bool solve(string &s){
    stack<char> S;
    for (auto &&i : s) {
        if(i == '(' || i == '[') S.emplace(i);
        else if(i == ')' || i == ']'){
            if(S.empty()) return false;
            char c = S.top(); S.pop();
            if(i == ')' && c == '[') return false;
            if(i == ']' && c == '(') return false;
        }
    }
    return S.empty();
}

int main() {
    string s;
    while(getline(cin, s), s != "."){
        puts(solve(s) ? "yes" : "no");
    }
    return 0;
}



Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int f(int b[][102],int c[][102],int x,int y,int w){
  if(c[x][y])
    return 0;
  else if(b[x][y]!=w)
    return 0;
  else{
    c[x][y]=1;
    f(b,c,x-1,y,w);
    f(b,c,x,y-1,w);
    f(b,c,x+1,y,w);
    f(b,c,x,y+1,w);
    return 1;
  }
}
int main(){
  int i,j;
  int b[102][102],c[102][102],cnt,h,w;
  string s;
  for(;;){
    cin>>h>>w;
    if(h+w==0)
      break;
    memset(b,0,sizeof(b));
    for(i=0;i<h;i++){
      cin>>s;
      for(j=0;j<w;j++){
	if(s[j]=='@')
	  b[j+1][i+1]=1;
	else if(s[j]=='#')
	  b[j+1][i+1]=2;
	else if(s[j]=='*')
	  b[j+1][i+1]=3;
      }
    }
    memset(c,0,sizeof(c));
    cnt=0;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(f(b,c,j+1,i+1,b[j+1][i+1]))
	  cnt++;
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  string ans = "Three";
  
  for (int i = 0; i < N; i++) {
    string c;
    cin >> c;
    
    if (c == "Y") {
      ans = "Four";
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;

int main()
{
	int n, x, ans = 0;
	while (true) {
		cin >> n >> x;
		if (n == 0 && x == 0)
			break;
		ans = 0;
		n = min(n,  x - 3);
		for (int i = n; i > 2; --i) {
		    if ((i - 1)*3 < x) break;
			int r = x - i;
			int y = min(r - 1, i - 1);
			int z = max(1, r - y);
			ans+= (y - z + 1) / 2;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3120
import sys

a=sys.stdin.read()

alpha="abcdefghijklmnopqrstuvwxyz"
counter=[0]*26

for i in a:
    for j in alpha:
        if i==j or i==j.upper():
            counter[alpha.index(j)]+=1
            break

for i in alpha:
    print(i,":",counter[alpha.index(i)])


Measured memory_bytes: 5568
list1=[6**i for i in range(1,7)]
list2=[9**i for i in range(1,6)]
data=[1]
data+=list1+list2
data.sort()
N=int(input())
count=0
dp=[10**7 for i in range(0,N+1)]
dp[0]=0
dp[1]=1
for i in range(2,N+1):
    max=0
    start=0
    end=11
    while end-start>1:
        test=(start+end)//2
        if N>=data[test]:
            start=test
        else:
            end=test
    if N>=data[end]:
        max=end
    else:
        max=start
    dp[i]=1+min(dp[i-data[j]] for j in range(0,max+1))
print(dp[N])


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
const ll mod = 1e9 + 7;

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

    int n,m;
    cin >> n >> m;
    VLL a(m);
    vector<bool> b(n+3,false);
    rep(i,m){
      cin >> a[i];
      b[a[i]] = true;
    }
    ll dp[n+3];
    memset(dp,0,sizeof(dp));
    //cerr << "e" << endl;
    dp[0] = 1;
    rep(i,n){
      if(i >= 1){
        if(b[i+1]) continue;
        else if(b[i] == true && b[i-1]== true){
          //cerr<< 1 << endl;
          continue;

        }
        else if(b[i] == true){
          dp[i+1] += dp[i-1];
          //cerr << 2 << endl;
        }
        else if(b[i-1] == true){
          dp[i+1] += dp[i];
          //cout << 3<< endl;
        }else{
          dp[i+1] += dp[i] + dp[i-1];
        }
      } else {
        if(b[i+1] == false && b[i] == false ){
          dp[i+1] += dp[i];
          //cout << "hi" << endl;
        }
      }
      dp[i+1] %= mod;
    }
    
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1792
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

W, H, x, y = LI()

if (W==2*x and H==2*y):
    print(W*H/2, 1)
else:
    print(W*H/2, 0)



Measured memory_bytes: 38512
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;

int island;
char field[16][16];

void search(int y, int x)
{
	field[y][x] = '2';
	int dy[] = {0, 1, 0, -1};
	int dx[] = {-1, 0, 1, 0};

	rep(i, 4) rep(j, 4){
		int py = dy[i] + y;
		int px = dx[i] + x;
		if(py<0 || px<0 || 12<=py || 12<=px)
			continue;
		if(field[py][px] != '1')
			continue;
		search(py, px);
	}
}

int main()
{
	while(1){
		island = 0;
		rep(i, 12){
			if(scanf("%s", field[i]) == EOF)
				return 0;
		}
		rep(i, 12){
			rep(j, 12){
				if(field[i][j] == '1'){
					search(i, j);
					++island;
				}
			}
		}
		printf("%d\n", island);
	}
}

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

int main(){
    int N, D; cin >> N >> D;
    vector<vector<int>> v(N, vector<int>(D));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> v[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1 ; j < N; j++){
            int dist = 0;
            for(int k = 0; k < D; k++){
                dist += powf(v[i][k] - v[j][k], 2);
            }
            if(powf((int)sqrt(dist), 2) == dist) ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int,int>>> evi(N);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    for (int j = 0; j < A; j++) {
      int x, y;
      cin >> x >> y;
      evi[i].push_back({x-1,y});
    }
  }
  int ans = 0;
  vector<int> fact(N,0);
  for (int tmp = 1; tmp < (1 << N); tmp++) {
    int honest = 0;
    bool b = false;
    bitset<15> s(tmp);
    for (int i = 0; i < N; i++) {
      if (s.test(i)) fact[i] = 1;
    }
    for (int i = 0; i < N; i++) {
      if (s.test(i)) {
        honest += 1;
        for (auto p : evi[i]) {
          if (fact[p.first] != -1 && fact[p.first] != p.second) {
            b = true;
            break;
          }
        }
        if (b) break;
      }
    }
    fact.assign(N,0);
    if (b) continue;
    ans = max(honest,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3552
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
ad={}
for i in range(len(a)):ad[i]=a[i]
b=list(map(int,input().split()))
bd={}
for i in range(len(b)):bd[i]=b[i]
m=min(a)+min(b)
for _ in range(M):
    x,y,c=map(int,input().split())
    s=ad[x-1]+bd[y-1]-c
    m=min(m,s)
print(m)




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

bool judgeOfMagic(int A, int B, int C)
{
	return (A < B) && (B < C);
}

bool trialAndError(int K, int A, int B, int C)
{
	if (judgeOfMagic(A, B, C)) return true;

	if (K == 0) return false;

	if (trialAndError(K - 1, 2 * A, B, C)) return true;
	if (trialAndError(K - 1, A, 2 * B, C)) return true;
	if (trialAndError(K - 1, A, B, 2 * C)) return true;

	return false;
}

int main()
{
	int A, B, C; cin >> A >> B >> C;
	int K; cin >> K;

	if (trialAndError(K, A, B, C))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3588
def main():
    MOD = int(10**9+7)
    N = int(input())
    total = 1
    not0 = 1
    not9 = 1
    not09 = 1
    for _ in range(N):
        total *= 10
        total %= MOD
        not0 *= 9
        not0 %= MOD
        not9 *= 9
        not9 %= MOD
        not09 *= 8
        not09 %= MOD
    
    ans = total - not0 - not9 + not09
    while ans < 0:
        ans += MOD
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 63324
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

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 ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  a = a * b;
  if (a % 2) cout << "Odd";
  else cout << "Even";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = n; i <= 999; i++){
        if(i % 10 == i / 100 && (i / 10) % 10 == i % 10){
            cout << i << "\n";
            return 0;
        }
    }
}

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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int find_min(const vector<long long> &A, int pos) {
  while (pos + 1 < A.size() && A[pos] >= A[pos + 1]) {
    pos++;
  }
  return pos;
}

int find_max(const vector<long long> &A, int pos) {
  while (pos + 1 < A.size() && A[pos] <= A[pos + 1]) {
    pos++;
  }
  return pos;
}

int main() {
  _upgrade;
  int n;
  cin >> n;
  vector<long long> A(n);
  for (auto &a : A) {
    cin >> a;
  }

  vector<pair<int, int>> intervals;
  for (int i = 0; i < n; i++) {
    int beg = find_min(A, i);
    if (beg == n - 1) {
      break;
    }
    int end = find_max(A, beg + 1);
    intervals.emplace_back(beg, end);

    i = end;
  }

  long long money = 1000;
  for (const auto &p : intervals) {
    int beg = A[p.first];
    int end = A[p.second];

    long long nb_stocks = money / beg;
    money -= nb_stocks * beg;
    money += nb_stocks * end;
  }
  cout << money << "\n";
  return 0;
}

Measured memory_bytes: 3664
let list_of_str s = let rec f i = if i >= String.length s then [] else s.[i] :: f (i+1) in f 0
let rec solve = function
  | [] -> "YES"
  | ('r'::'e'::('m'::'a'::'e'::'r'::'d'::xs | 's'::'a'::'r'::'e'::xs))
  | ('m'::'a'::'e'::'r'::'d'::xs) | ('e'::'s'::'a'::'r'::'e'::xs)  -> solve xs
  | _ -> "NO"
let () = Scanf.scanf "%s" list_of_str |> List.rev |> solve |> print_endline

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll mod=1e9+7;
int main() {
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    //cout << std::fixed;
    // cout << std::setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s; ll m; cin>>s>>m;
    int n=s.size();
    ll dp[n-1][m];
    for(int i=0;i<n-1;i++){
        for(int j=0;j<m;j++){
            dp[i][j]=0;
        }
    }
    for(int r=1;r<=9;r++){
        dp[0][r%m]++;
    }
    for(int i=1;i<n-1;i++){
        for(int j=0;j<m;j++){
            for(int r=0;r<=9;r++){
                ll k=(j+r%m)%m;
                dp[i][k]=(dp[i][k]+dp[i-1][j])%mod;
            }
        }
    }
    ll ans=0;
    for(int i=0;i<=n-2;i++){
        ans=(ans+dp[i][0])%mod;
    }
    ll dp1[n][m][2];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<2;k++){
                dp1[i][j][k]=0;
            }
        }
    }
    for(int r=1;r<(int)s[0]-48;r++){
        dp1[0][r%m][0]++;
    }
    dp1[0][((int)(s[0]-48))%m][1]++;
    for(int i=1;i<n;i++){
        for(int j=0;j<m;j++){ 
            int r=0;
            for(;r<(s[i]-48);r++){
                ll k=( j+r%m )%m;
                dp1[i][k][0]=(dp1[i][k][0]+(dp1[i-1][j][0]+dp1[i-1][j][1])%mod )%mod;
            }
            for(;r<=9;r++){
                ll k=( j + r%m )%m;
                dp1[i][k][0]=(dp1[i][k][0]+dp1[i-1][j][0])%mod;
                if(r==(s[i]-48) )
                dp1[i][k][1]=(dp1[i][k][1]+dp1[i-1][j][1])%mod;
            }
        }
    }
    ans=(ans+(dp1[n-1][0][0]+dp1[n-1][0][1])%mod )%mod;
    cout<<ans;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
int main(void)

{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    map<char, char> mp;
    mp.insert({'A', 'T'});
    mp.insert({'C', 'G'});
    mp.insert({'T', 'A'});
    mp.insert({'G', 'C'});
    cout << mp[c] << endl;
}


Measured memory_bytes: 3560