akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

// 素因数を数列で返す。ソートされている。
// first が素因数で second が個数
template <class T> map<T, long long> factring(T N) {
    map<T, long long> ans;
    long long i = 2;
    while (i * i <= N) {
        if (N % i == 0) {
            ans[i]++;
            N /= i;
        } else {
            i++;
        }
    }
    if (N != 1)
        ans[N]++;
    return ans;
};

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

    int N;
    cin >> N;
    vector<int> a(N);
    for (auto &&i : a) {
        cin >> i;
    }
    ll ans = INF64;
    for (auto &&i : a) {
        auto fac = factring(i);
        chmin(ans, fac[2]);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int M = 1e9+7;
const int INF = 1<<30;

int _;
int a[105];

ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b) {ll s=1;while(b){if(b&1)s=(s*a)%M;b>>=1;a=(a*a)%M;}return s;}



int main()
{
    int n,m,tot=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++) {cin>>a[i];tot+=a[i];}
    int t = 4*m,k;
    if(tot%t==0) k = tot/t;
    else k = tot/t+1;
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(a[i]>=k) cnt++;
    }
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define ll long long int

using namespace std;

int main()
{
    ll s, n, d;
    vector<pair<ll, ll>>v;

    cin>>s;

    while(s!=0)
    {
        n=s%1000;
        s=s/10;
        d=fabs(753-n);

        v.push_back(make_pair(d, n));
    }

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

    cout<<v[0].first<<endl;


    return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    ll cur = 1;
    while(cur < B) {
        ans++;
        cur += A - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

int main()
{
	std::string card;
	while (std::cin >> card) {
		if (card == "-") {
			break;
		}
		std::queue<char> qc;
		for (auto c : card) {
			qc.push(c);
		}
		int m;
		std::cin >> m;
		while (m--) {
			int h;
			std::cin >> h;
			while (h--) {
				char t = qc.front();
				qc.pop();
				qc.push(t);
			}
		}
		while (!qc.empty()) {
			std::cout << qc.front();
			qc.pop();
		}
		std::cout << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	int a,b;
	cin >> a >> b;
	if(a < b)swap(a,b);
	cout << max(a + (a - 1), b + a) << endl;
}


Measured memory_bytes: 256
def main():
    n,q = map(int,raw_input().split())

    ds = DisjointSet(n)

    for i in xrange(q):
        com,x,y = map(int,raw_input().split())
        if com:
            ds.findSet(x)
            ds.findSet(y)
            if ds.parent[x] == ds.parent[y]:
                print 1
            else:
                print 0
        else:
            ds.findSet(x)
            ds.findSet(y)
            ds.unite(x,y)

class DisjointSet():
    def __init__(self,n):
        self.n = n
        self.parent = range(n)

    def findSet(self,x):
        if self.parent[x] == x:
            return x
        else:
            p = self.findSet(self.parent[x])
            self.parent[x] = p
            return p

    def unite(self,x,y):
        if self.parent[y] > self.parent[x]:
            self.parent[self.parent[y]] = self.parent[x]
        else:
            self.parent[self.parent[x]] = self.parent[y]

if __name__ == "__main__":
    main()

Measured memory_bytes: 6720
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>

    using namespace std;
    using namespace __gnu_pbds;

    typedef long long int ll;
    typedef long double ld;

    #define llset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
    #define en '\n'
    #define S second
    #define F first
    #define pll pair<ll,ll>
    #define PB push_back

    const ll N = 1e6+7;
    ll mod = 1e9+7;
    #define calncr for(int i=1  ;i<=1e6;i++) fac[i] = (fac[i-1]*i)%mod;
    ll fac[N] = {0};

    ll gen_base(const ll before, const ll after) {
        auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
        std::mt19937 mt_rand(seed);
        int base = std::uniform_int_distribution<ll>(before+1, after)(mt_rand);
        return base % 2 == 0 ? base-1 : base;
    }

    ll pow(ll a,ll b)
    {
        if(!b)
            return 1;
        ll p = pow(a,b/2);
        if(b%2)
            return (a*((p*p)%mod))%mod;
        else
            return (p*p)%mod;
    }

    ll modInv(ll a)
    {
        //cout<<a<<" "<<mod<<en;
        return pow(a%mod,mod-2);
    }

    ll nCr(ll n,ll r)
    {
        return (fac[n]*modInv((fac[r]*fac[n-r])%mod))%mod;
    }

    ll hashf(ll r,ll x,ll mod)
    {
        return (x+r)%mod;
    }


    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);cout.tie(0);
        fac[0] = 1;
        calncr;
        string s;
        cin>>s;
        ll ans=0;
        for(ll i=0;i<s.size();i++){
            ans = (ans+(s[i]-'0'))%9;
        }
        if(!ans)
            cout<<"Yes"<<en;
        else
            cout<<"No"<<en;
    }


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

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> points(n, vector<int>(3));
    for(int i = 0; i < n; i++)
        cin >> points[i][0] >> points[i][1] >> points[i][2];
    int firstmax = 0, secondmax = 0, id = -1;
    for(int j = 0; j < 3; j++)
    {
        if(firstmax < points[n - 1][j])
        {
            secondmax = firstmax;
            firstmax = points[n - 1][j];
            id = j;
        }
        else
            secondmax = max(secondmax, points[n - 1][j]);
    }
    for(int i = n - 2; i >= 0; i--)
    {
        int firstmax2 = 0, secondmax2 = 0, id2 = -1; 
        for(int j = 0; j < 3; j++)
        {
            int happyPoints = points[i][j] + (id == j ? secondmax : firstmax);
            if(firstmax2 < happyPoints)
            {
                secondmax2 = firstmax2;
                firstmax2 = happyPoints;
                id2 = j;
            }
            else
                secondmax2 = max(secondmax2, happyPoints);
        }
        firstmax = firstmax2;
        secondmax = secondmax2;
        id = id2;
    }
    cout << firstmax;
    return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a > b)
    {
        for(int i = 0;i < a;i ++)
            cout<<b;
    }else
    {
        for(int i = 0;i < b;i ++)
            cout<<a;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	char a,b;
	cin>>a>>b;
	if(a=='H'&&b=='H')cout<<"H";
	if(a=='H'&&b=='D')cout<<"D";
	if(a=='D'&&b=='H')cout<<"D";
	if(a=='D'&&b=='D')cout<<"H";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
# local only
# if not __debug__:
#     fin = open('in_1.txt', 'r')
#     sys.stdin = fin
# local only
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    N = ii()
    print(pow(N, 3))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
l, r = map(int, input().split())
ans = []
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        ans.append((i * j) % 2019)
        if (i * j) % 2019 == 0:
            print(0)
            exit()
print(min(ans))

Measured memory_bytes: 6888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

/*
 * 文字列sと文字列tの編集距離
 * 文字列sに対して、文字の「挿入」「削除」「置換」をコスト1で行い、文字列tに一致する最小コストを計算する
 *
 * Algorithn: 動的計画法
 *      定義
 *          dp[i][j] := s[0,i),t[0,j)の編集距離
 *      遷移
 *          挿入 dp[i][j] <- dp[i-1][j]+1
 *          削除 dp[i][j] <- dp[i][j-1]+1
 *          置換 dp[i][j] <- dp[i-1][j-1]+(s[i]!=t[j])
 */
int LevenshteinDistance(const std::string& s,const std::string& t){
    const int inf = (1<<29);
    int n = s.size();
    int m = t.size();
    vector<vector<int>> dp(n+1,vector<int>(m+1,inf));
    for(int i=0;i<n;i++) dp[i][0] = i;
    for(int i=0;i<m;i++) dp[0][i] = i;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j] = min({
                    dp[i-1][j]+1, // 追加
                    dp[i][j-1]+1,
                    dp[i-1][j-1]+(s[i-1]!=t[j-1]),
                    });
        }
    }
    return dp[n][m];
}

int main(){
    string s,t; cin >> s >> t;
    cout << LevenshteinDistance(s,t) << endl;
}



Measured memory_bytes: 6920
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

vector<ll>prime_factorize(ll n){
    vector<ll>res;
    for(ll p = 2;p <= sqrt(n);p++){
      if (n%p != 0) continue;
      ll num = 0;
      while(n % p == 0){
        num++;
        n /= p;
      }
      res.push_back(num);
    }
    if (n != 1) res.push_back(1);
    return res;
}

int main(){
    ll n; cin>>n;
    ll ans=0;
    vector<ll>data=prime_factorize(n);
    for(auto i:data){
        ll a=i,t=1;
        while(a-t>=0){
            a-=t;
            t++;
            ans++;
        }
    }
    cout<<ans<<endl;
}






















Measured memory_bytes: 3724
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    int n; cin >> n;
    string s; cin >> s;
    int a = 0,b = 0;
    for(auto c : s){
        if(c == 'R')a++;
        else b++;
    }
    cout << (a > b ? "Yes":"No") << endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>
#include <deque>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

pair<double, double> add;
deque<pair<double, double>> en;

void PushBack(pair<double, double> x) {
	en.push_back(mp(x.fs - add.fs, x.sc - add.sc));
}

void PushFront(pair<double, double> x) {
	en.push_front(mp(x.fs - add.fs, x.sc - add.sc));
}


pair<double, double> Get(int ind) {
	pair<double, double> res = en[ind];
	res.fs += add.fs;
	res.sc += add.sc;
	return res;
}

double Temp(int ind) {
	pair<double, double> cur = en[ind];
	cur.fs += add.fs;
	cur.sc += add.sc;
	return cur.sc / cur.fs;
}

int main () {
    ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	int n;
	double V;
	cin >> n >> V;

	vector<double> t(n);
	vector<double> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> t[i] >> v[i];
	}

	
	PushBack(mp(0, 0));
	PushBack(mp(V, t[0] * V));

	vector<double> res(n);
	res[0] = Temp(sz(en) - 1);

	for (int i = 1; i < n; ++i) {
		while (Get(sz(en) - 1).fs > V - v[i] + eps) {
			if (Get(sz(en) - 2).fs > V - v[i] - eps) {
				en.pop_back();
			} else {
				pair<double, double> last = Get(sz(en) - 1);
				en.pop_back();
				pair<double, double> prev = Get(sz(en) - 1);
				PushBack(mp(V - v[i], prev.sc + (last.sc - prev.sc) / (last.fs - prev.fs) * (V - v[i] - prev.fs)));
				break;
			}
		}

		add.fs += v[i];
		add.sc += v[i] * t[i];

		while (sz(en) > 1 && Temp(1) > Temp(0) - eps) {
			en.pop_front();
		}

	    PushFront(mp(0, 0));
	    res[i] = Temp(sz(en) - 1);		
	}

	cout.precision(20);
	for (int i = 0; i < n; ++i) {
		cout << res[i] << "\n";
	}



	return 0;
}


Measured memory_bytes: 30868
N, M = [int(x) for x in input().split(" ")]
lst = [int(x) for x in input().split(" ")]

cnt = 0

for x in range(0,N):
  if lst[x] >= sum(lst)/(4*M):
    cnt +=1

if cnt >=M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string S;
  cin>>S;
  int Cnt=0;
  for(int i=0;i<S.length();i++)
    if(S[i]=='W')
      Cnt++;
  int Ans=Cnt;
  for(int i=1;i<=Cnt;i++)
    if(S[S.length()-i]=='W')
      Ans--;
 	cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 3744
#include <stdio.h>

int min2(int a, int b)
{
  return (a > b) ? b : a;
}

int main(void)
{
  int n, a, b;
  int max, min;

  scanf("%d %d %d", &n, &a, &b);

  max = min2(a, b);
  if ((a + b) <= n)
    min = 0;
  else
    min = a + b - n;

  printf("%d %d\n", max, min);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{string s,t;
 cin>>s>>t;
 fo(i,0,max(s.size(),t.size())){
 if(i<s.size())cout<<s[i];
 if(i<t.size())cout<<t[i];
 }
 return 0;
}

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


int main() {
    int N;
    int plan[300000];
    bool can = true;

    cin >> N;
    plan[0] = 0;
    plan[1] = 0;
    plan[2] = 0;
    for (int i = 0; i < N; ++i){
        cin >> plan[3*(i+1)] >> plan[3*(i+1)+1] >> plan[3*(i+1)+2];
    }

    for (int i = 0; i < N; ++i){

        int time = plan[3*(i+1)] - plan[3*i];
        int distance = abs(plan[3*(i+1)+1] - plan[3*i+1]) + abs(plan[3*(i+1)+2] - plan[3*i+2]);

        if (distance > time || time % 2 != distance % 2){
            can = false;
        }
    }

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


}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main()
{

   string s;
   cin >> s;

    if(s[0] == s[1] && s[1] == s[2]){
        cout<<"Yes"<<endl;

    }else if(s[1] ==s[2] && s[2] == s[3]) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static Random rnd = new Random(42);
  static int qc = 0;
  static int A, B, N;

  public static void main(String[] args) {
    A = sc.nextInt();
    B = sc.nextInt();
    N = A + B;
    if (A <= B) {
      System.out.println("Impossible");
      return;
    }
    int start = 0;
    int restA = A;
    int honest = -1;
    OUT:while (true){
      if (start == N - 1) {
        honest = start;
        break;
      }
      int cur = start;
      int next = cur + 1;
      int count = 1;
      while (true){
        boolean res = query(cur, next);
        if (res){
          ++count;
          if (count == restA) {
            honest = next;
            break OUT;
          } else {
            cur = next;
            next = cur + 1;
          }
        } else {
          if (next - start + 1 >= count * 2) {
            start = next + 1;
            restA -= count;
            break;
          }
          next++;
        }
      }
    }
    int[] result = new int[N];
    for (int i = 0; i < N; i++) {
      result[i] = query(honest, i) ? 1 : 0;
    }
    System.out.print("! ");
    for (int i = 0; i < N; i++) {
      System.out.print(result[i]);
    }
    System.out.println();
  }

  static boolean query(int a, int b) {
    ++qc;
    System.out.println("? " + a + " " + b);
    String ret = sc.next();
    return ret.charAt(0) == 'Y';
  }

}


Measured memory_bytes: 44892
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,0,sz(s) - 1) ans += s[i] != s[i+1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);

void solv()
{
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    printf("%d\n", (r / d) - ((l - 1) / d));
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


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

using namespace std;

int main() {

    long long N, D;
    cin >> N >> D;

    long long X[N + 1], Y[N + 1];
    for(int i = 1; i <= N; i++) {
        cin >> X[i] >> Y[i];
    }

    int ans = 0;

    for(int i = 1; i <= N; i++) {
        long long length = (X[i] * X[i]) + (Y[i] * Y[i]);

        if(length <= D * D) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6740
# -*- coding: utf-8 -*-
from fractions import gcd

def inpl(): return map(int, input().split())
N = int(input())
A = []
B = []

for _ in range(N):
    a, b = inpl()
    A.append(a)
    B.append(b)

ans = 0
for a, b in zip(A[::-1], B[::-1]):
    a += ans
    x = (b - a%b)%b
    ans += x

print(ans)

Measured memory_bytes: 14848
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    string s,ss;
    cin>>s>>ss;
    if(s.length()<ss.length()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=s.length()-ss.length()+1;i>=0;i--){
        bool f=true;
        rep(j,0,ss.length()){
            if(ss[j]==s[i+j] || s[i+j]=='?'){}
            else {
                f=false;
            }
        }
        if(f){
            rep(j,0,s.length()){
                if(j<i || i+ss.length()-1<j){
                    if(s[j]=='?')cout<<"a";
                    else cout<<s[j];
                }else {
                    cout<<ss[j-i];
                }
            }
            cout<<endl;
            return 0;
        }
    }
    
    cout<<"UNRESTORABLE"<<endl;
    return 0;
}


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

int main(){
	ios::sync_with_stdio(0);
	
	string str;
	while(cin>>str){
		if(str[str.size()-1]=='s')
			cout<<str+"es\n";
		else
			cout<<str+"s\n";
	}
}


Measured memory_bytes: 3664
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M = i_l()
a = i_l()


if len([x for x in a if x >= sum(a) / (4*M)]) >= M:
    print('Yes')
else:
    print('No')

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

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    ll X;
    cin >> X;

    ll ans = 0;
    ll t = 100;
    while(t < X){
        ans++;
        t = t+ (ll)(t * 0.01);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
// include
// ----------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>

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

// memory clear
// ----------------------------------------------------------------------------
#define CLRNUM(a) memset((a), 0, sizeof(a))
#define CLRBOOL(a, flag) memset((a), flag, sizeof(a))
#define CLRCHAR(a) memset((a), '\0', sizeof(a))

// debug
// ----------------------------------------------------------------------------
#define DEBUGNUM(x) printf("%d\n", x);
#define DEBUGCHAR(x) printf("%c\n", x);
#define DEBUGSTR(x) printf("%s\n", x);
#define DEBUGFORNUM(i, a, b, x) FOR(i, a, b){ printf("%d ", x[i]); }
#define DEBUGFORCHAR(i, a, b, x) FOR(i, a, b){ printf("%c ", x[i]); }
#define DEBUGREPNUM(i, n, x) REP(i, n){ printf("%d ", x[i]); }
#define DEBUGREPCHAR(i, n, x) REP(i, n){ printf("%c ", x[i]); }

// other
// ----------------------------------------------------------------------------
#define PUTNL printf("\n")

// constant
// ----------------------------------------------------------------------------
#define INF 1000000000

int main(void)
{
    int n, len;
    int i, j;
    char str[1024];

    scanf("%d", &n);

    getchar();
    for (i = 0; i < n; ++i){
        fgets(str, sizeof(str), stdin);
        
        len = strlen(str);

        for (j = 0; j < len; ++j){
            if (strncmp(&str[j], "Hoshino", 7) == 0){
                strncpy(&str[j], "Hoshina", 7);
            }
        }

        printf("%s", str);

    }

    return 0;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    ll n, a, b; cin>>n>>a>>b;
    ll ans=(b-a)*(n-2)+1;
    cout << (ans>0 ? ans : 0) << endl;
}

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

int main() {
  int num;
  int a,b;
  int cntA,cntB;
  cin >> num;
  
  vector<int> vecP(num);
  vector<int> vecQ(num);
  vector<int> tmp(num);
  
  for(int i = 0; i < num; i++) cin >> vecP.at(i);
  for(int i = 0; i < num; i++) cin >> vecQ.at(i);
  for(int i = 0; i < num; i++) tmp.at(i) = i+1;
  
  int index = 0;
  bool chk = true;
  do{
    index++;
    
    chk = true;
    for(int i = 0; i < num; i++){
      if(vecP.at(i) != tmp.at(i)){
        chk = false;
      }
    }
    if(chk == true) cntA = index;
    
    chk = true;
    for(int i = 0; i < num; i++){
      if(vecQ.at(i) != tmp.at(i)){
        chk = false;
      }
    }
    if(chk == true) cntB = index;
  } while(next_permutation(tmp.begin(), tmp.end()));

  cout << abs(cntA - cntB);  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		
		int A=sc.nextInt();
		//int B=sc.nextInt();
		//int K=sc.nextInt();
		
		if(A>=1000){
			System.out.println("ABD");
		}else{
			System.out.println("ABC");
		}
	}
}

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

typedef long long ll;

int a_to_if(vector<ll> a, vector<ll> &i, vector<ll> &f, ll n){
  ll ind = 0LL;
  for ( auto x : a ){
    i[ind] = max(0LL, ind - x);
    f[ind] = min(n, ind + x);
    ++ind;
  }
  
  sort(i.begin(), i.end());
  sort(f.begin(), f.end());
  
  return 0;
}

int if_to_a(vector<ll> &a, vector<ll> i, vector<ll> f, ll n){
  vector<ll> b(n, 0LL);
  for(ll ind = 0LL; ind < n; ind++ ){
    b[ind] = (upper_bound(i.begin(), i.end(), ind) - i.begin()) 
      - (upper_bound(f.begin(), f.end(), ind-1) - f.begin());
  }
  a = b;
  return 0; 
}

int update(vector<ll> &a, vector<ll> &i, vector<ll> &f, ll n){
  
  a_to_if(a, i, f, n);  
  if_to_a(a, i, f, n);
  return 0;
}

int check(vector<ll> q, ll n){
  for (auto a: q ){
    if (a != n )
      return 0;
  }
  return 1;
}

int print_vec(vector<ll> v){
  for ( auto a : v )
    cout << a << " ";
  cout << endl;
  
  return 0;
}  

int main(int argc, const char * argv[]) {
    
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
  ll n, k;
  cin >> n >> k;
  
  vector<ll> a(n, 0LL);
  for (ll i = 0; i < n; i++ )
    cin >> a[i];
  
  vector<ll> i(n,0LL);
  vector<ll> f(n,0LL);

  for ( ll j = 0LL; j < k; j++){
    if(check(a, n))
      break;
    else
      update(a, i, f, n);
  }
  
  print_vec(a);
  
    return 0;
}



Measured memory_bytes: 12160
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Calculate(long a, long b, long c)
        {
            var s = new[] { a, b, c };
            long min = s.Min();
            long max = s.Max();
            return (min > 0) ? max - min : long.MaxValue;
        }
        static long Solve(long H, long W)
        {
            long min = long.MaxValue;
            long h1 = (H + 0) / 3;
            long h2 = (H + 1) / 3;
            long h3 = (H + 2) / 3;
            long ha = (H + 0) / 2;
            long hb = (H + 1) / 2;
            long w1 = (W + 0) / 3;
            long w2 = (W + 1) / 3;
            long w3 = (W + 2) / 3;
            long wa = (W + 0) / 2;
            long wb = (W + 1) / 2;
            min = Math.Min(Calculate(h1 * W, h2 * W, h3 * W), min);
            min = Math.Min(Calculate(w1 * H, w2 * H, w3 * H), min);
            min = Math.Min(Calculate(h1 * W, (H - h1) * wa, (H - h1) * wb), min);
            min = Math.Min(Calculate(h2 * W, (H - h2) * wa, (H - h2) * wb), min);
            min = Math.Min(Calculate(h3 * W, (H - h3) * wa, (H - h3) * wb), min);
            min = Math.Min(Calculate(w1 * H, (W - w1) * ha, (W - w1) * hb), min);
            min = Math.Min(Calculate(w2 * H, (W - w2) * ha, (W - w2) * hb), min);
            min = Math.Min(Calculate(w3 * H, (W - w3) * ha, (W - w3) * hb), min);
            return min;
        }
        static void Main(string[] args)
        {
            long[] values = ReadLongs();
            Console.WriteLine(Solve(values[0], values[1]));
        }
    }
}


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

#define WORDS_LIMIT 1024000

typedef struct {
	char word[24];
	int num;
} words_array_t;

int qsort_comp_str(const void* x,const void* y) {
	return strcmp((const char*)x,(const char*)y);
}

int qsort_comp_warr(const void* x,const void* y) {
	const words_array_t* a=(const words_array_t*)x;
	const words_array_t* b=(const words_array_t*)y;
	if((a->num)<(b->num))return 1;
	if((a->num)>(b->num))return -1;
	return strcmp(a->word,b->word);
}


int words_num;
char words[WORDS_LIMIT][24];
char buffer[1028];
words_array_t warr[WORDS_LIMIT];
int warr_num;

int main(void) {
	int n;
	int i;
	char* cp;
	char k[4];
	int left,right,mid;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		while(getchar()!='\n');
		words_num=0;
		for(i=0;i<n;i++) {
			fgets(buffer,sizeof(buffer),stdin);
			cp=strchr(buffer,'\n');
			if(cp)*cp=0;
			cp=strtok(buffer," ");
			if(cp)strcpy(words[words_num++],cp);
			while(cp=strtok(NULL," ")) {
				strcpy(words[words_num++],cp);
			}
		}
		scanf("%s",k);
		qsort(words,words_num,sizeof(words[0]),qsort_comp_str);
		left=0;right=words_num-1;
		while(left<=right) {
			mid=(left+right)/2;
			if(words[mid][0]>=k[0])right=mid-1;
			else left=mid+1;
		}
		if(words[right+1][0]==k[0]) {
			strcpy(warr[0].word,words[right+1]);
			warr[0].num=1;
			warr_num=0;
			for(i=right+2;i<words_num && words[i][0]==k[0];i++) {
				if(strcmp(warr[warr_num].word,words[i])==0) {
					warr[warr_num].num++;
				} else {
					warr_num++;
					strcpy(warr[warr_num].word,words[i]);
					warr[warr_num].num=1;
				}
			}
			warr_num++;
			qsort(warr,warr_num,sizeof(words_array_t),qsort_comp_warr);
			if(warr_num>5)warr_num=5;
			printf("%s",warr[0].word);
			for(i=1;i<warr_num;i++)printf(" %s",warr[i].word);
			putchar('\n');
		} else puts("NA");
	}
	return 0;
}

Measured memory_bytes: 0
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;

int main(){
	string s;
	cin>>s;
	int64_t n=s.length();
	vector<vector<int64_t> > alphabet_place;
	alphabet_place.resize(26);
	for(int i=0;i<26;i++){
		alphabet_place[i].reserve(n);
	}
	for(int64_t i1=0;i1<n;i1++){
		alphabet_place[s[i1]-'a'].push_back(i1);
	}
	int64_t ans=0;
	for(int64_t i1=0;i1<26;i1++){
		reverse(alphabet_place[i1].begin(),alphabet_place[i1].end());
		for(int64_t i2=0;i2<alphabet_place[i1].size();i2++){
			ans+=n-alphabet_place[i1][i2]-1-i2;
		}
	}
	++ans;
	cout<<ans<<endl;





}

Measured memory_bytes: 2180
from collections import deque

N = int(input())
closings = list(input())
r_cnt = l_cnt = 0
for closing in closings:
  if closing == ')':
    if l_cnt > 0:
      l_cnt -= 1
    else:
      r_cnt += 1
  else:
    l_cnt += 1
answer = ['(' for _ in range(r_cnt)] + closings + [')' for _ in range(l_cnt)] 
print(''.join(answer))

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

int main() {
    ll N;
    cin >> N;
    ll H[N];
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    ll MAX = 0;
    ll count = 0;
    for (int i = 1; i < N; i++) {
        if (H[i-1] >= H[i]) count ++;
        if (H[i-1] < H[i]) {
            MAX = max(MAX, count);
            count = 0;
        }
    }

    MAX = max(MAX, count);

    cout << MAX << endl;
    return 0;
}

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

using namespace std;

int main() {
    
    long long int i,j,n,k;
    cin>>n>>k;
    long long a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    vector<int> cycle;
    cycle.push_back(1);
    map<int,int> mp;
    i=0;
    while(mp.find(cycle[i])==mp.end())
    {
        mp[cycle[i]]=i;
        if(mp.find(a[cycle[i]])!=mp.end()) break;
        cycle.push_back(a[cycle[i]]);
        i++;
    }
    int m=cycle.size();
    if(k<m)
    {
        cout<<cycle[k];
        return 0;
    }
    int t=mp[a[cycle[i]]];
    k++;
    k-=t;
    int diff=m-t;
    if(k%diff==0)
        cout<<cycle[diff+t-1];
    else    
        cout<<cycle[k%diff+t-1];
    
}

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

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int count = n/x;
    int ans;
    if (n%x != 0){
        ans = (count+1)*t;
    }else{
        ans = count*t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        System.out.println((int)(Math.min(b / a, c)));
        scan.close();
    }
}

Measured memory_bytes: 26992
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int n, m;
vi to[MX];

int ans;
int dfs(int v, int p=0) {
  int res = 0;
  for (int u : to[v]) {
    int r = dfs(u,v);
    maxs(res,r);
  }
  res++;
  if (res >= m && p) {
    ans++;
    res = 0;
  }
  return res;
}

int main() {
  scanf("%d%d",&n,&m);
  vi a(n);
  rep(i,n) {
    scanf("%d",&a[i]);
    --a[i];
  }
  if (a[0] != 0) {
    ans++;
    a[0] = 0;
  }
  rep(i,n) if (i) {
    to[a[i]].pb(i);
  }
  dfs(0);
  cout<<ans<<endl;
  return 0;
}







Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, n, a) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, n, 0)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    bool ff = false;
    rep(i, n) if (a[i] == 1)
    {
        cout << "first" << endl;
        return 0;
    }
    int cnt = 0;
    rep(i, n) if (a[i] % 2 == 0) cnt++;
    if (cnt != n)
        cout << "first" << endl;
    else
        cout << "second" << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, k, f[N], c[N];
vector <int> G[N];
auto mul = [](int &a, int b) { a = 1ll*a*b%mod; }; 
void dfs(int u, int fa)
{
	int pre = 0;
	f[u] = fa;
	for(int v : G[u])
	{
		if(v==fa) continue;
		dfs(v, u);
		c[v] = c[pre] + 1;
		pre = v;
	}
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	for(int i=1; i<n; i++) 
 	{
 		int u, v;
 		cin >> u >> v;
 		G[u].pb(v); G[v].pb(u);
 	}
 	c[0] = -1;
 	dfs(1, 0);
 	int ans = 1;
 	for(int i=1; i<=n; i++)
 	{
 		if(f[i]) c[i]++;
 		if(f[f[i]]) c[i]++;
 		if(k-c[i]<0) ans = 0;
 		mul(ans, k-c[i]);
 	}
 	cout << ans;
	return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
  i32 N;
  cin >> N;
  vector<i32> a(N);
  for(auto& a_ : a) {
    cin >> a_;
  }
  
  i32 ans = 0;
  i32 num = 1;
  for(i32 i = 0; i < N; ++i) {
    if(a[i] == num) {
      ans++;
      num++;
    }
  }
  if(N-ans < N) {
    cout << N-ans << endl;
  } else {
  	cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
N += 1
dp = []
for l in range(N):
  L = []
  for i in range(4):
    I = []
    for j in range(4):
      J = [0,0,0,0]
      I.append(J)
    L.append(I)
  dp.append(L)
dp[0][0][0][0] = 1
NGLIST_JKL = [[1,0,2],[1,1,2],[1,2,2],[1,3,2],[1,2,0],[1,2,1],[1,2,2],[1,2,3]]
NGLIST_KLM = [[1,2,3],[2,1,3],[1,3,2]]
for i in range(N-1):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        if not [j,k,l] in NGLIST_JKL:
          for m in range(4):
            if not [k,l,m] in NGLIST_KLM:
              dp[i+1][k][l][m] += dp[i][j][k][l]
              dp[i+1][k][l][m] = dp[i+1][k][l][m]%(10**9+7)
        else:
          if j == 1 and l == 2:
            for m in range(4):
              if m != 3:
                dp[i+1][k][l][m] += dp[i][j][k][l]
                dp[i+1][k][l][m] = dp[i+1][k][l][m]%(10**9+7)
          elif j == 1 and k == 2:
            for m in range(4):
              if m != 3:
                dp[i+1][k][l][m] += dp[i][j][k][l]
                dp[i+1][k][l][m] = dp[i+1][k][l][m]%(10**9+7)
ans = 0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans += dp[N-1][i][j][k]%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 3444
#include <stdio.h>

int main()
{
	int n,k,i;
	char s[60];
	scanf("%d %d",&n,&k);
	scanf("%s",s);
	switch(s[k-1])
	{
		case 'A' : s[k-1]='a'; break;
		case 'B' : s[k-1]='b'; break;
		case 'C' : s[k-1]='c'; break;
	}
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    map<int,int> mp;
    while(1){
        string s; getline(cin,s);
        bool ok=0;
        for(char c:s){
            if(c>='a'&&c<='z'){
                mp[c-'a']++;
                ok=1;
            }
            else if(c>='A'&&c<='Z'){
                mp[c-'A']++;
                ok=1;
            }
        }
        if(!ok)break;
    }
    for(int i=0;i<26;i++){
        cout << (char)('a'+i) << " : " << mp[i] << endl;
    }
}


Measured memory_bytes: 3204
#include <vector>
#include <cstdio>
#include <queue>
 
class Edge{
public:
    int start, to, weight;
    Edge(const int s = 0, const int t = 0, const int w = 0):start(s), to(t), weight(w){};
};
int main(){
    int n;
    std::scanf("%d", &n);
    std::vector<std::vector<Edge>> edge(n);
    for(auto i = 1; i < n; ++i){
        int s, t, w;
        std::scanf("%d %d %d", &s, &t, &w);
        edge.at(s).push_back(Edge(s, t, w));
        edge.at(t).push_back(Edge(t, s, w));
    }
    int max;
    auto func = [&](int start){
        std::queue<Edge> queue;
        std::vector<int> node(n, -1);
        node.at(start) = -1;
        queue.push(Edge(start, start, 1));
        for (auto i = 0; i < n; ++i){
            while (node.at(queue.front().to) >= 0){queue.pop();}
            node.at(queue.front().to) = node.at(queue.front().start) + queue.front().weight;
            for (auto e : edge.at(queue.front().to)){
                queue.push(e);
            }
        }
        max = 0;
        int minn;
        for (auto i = 0; i < n; ++i){
            if (max < node.at(i)){
                max = node.at(i);
                minn = i;
            }
        }
        return minn;
    };
    func(func(0));
    std::printf("%d\n", max);
}

Measured memory_bytes: 10500
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main () {

    int N, M;
    cin >> N >> M;

    vector<int> A(N);
    int total_vote = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        total_vote += A[i];
    }

    sort(A.begin(), A.end(), greater<int>());
    cout << ((4*M*A[M-1] >= total_vote)? "Yes": "No") << endl;

    return 0;
}

Measured memory_bytes: 256