akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtcoderTemplateForCSharp
{
    public class AtcoderTemplateForCSharp
    {
        public static void Main(string[] args)
        {
            var list = new List<int>();
            list.AddRange(
                Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                );

            if (list.Contains(1) && list.Contains(9) && list.Contains(7) && list.Contains(4))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 13276
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    while(--d >= 0){
        int x, y, w, h;
        cin >> x >> y >> w >> h;

        int n;
        cin >> n;

        int ret = 0;
        for(int i=0; i<n; ++i){
            int cx, cy;
            cin >> cx >> cy;

            if(x <= cx && cx <= x + w && y <= cy && cy <= y + h)
                ++ ret;
        }

        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

const ll INF = 1LL << 60;

template <typename T>
class SegmentTree{
private:
    int n;
    vector<T> dat;
public:
    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        dat.assign(2*n-1, INF);
    }
    void init(vector<T>& value){
        int n_ = value.size();
        n = 1;
        while(n < n_) n *= 2;
        dat.resize(2*n-1);
        for(int i=0;i<n_;i++){
            dat[i+n-1] = value[i];
        }
        for(int i=n_+n-1;i<2*n-1;i++){
            dat[i] = INF;
        }
        for(int k=n-2;k>=0;k--){
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // k: index(0-indexed), a: value
    void update(int k, int a){
        k += n-1;
        dat[k] = a;
        while(k>0){
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    // query(a, b) =>  minimum in [a,b]
    T query(int a, int b){
        return _query(a, b, 0, 0, n-1);
    }
    // dat[k] is minimum in [l,r]
    T _query(int a, int b, int k, int l, int r){
        if(r<a || b<l) return INF;
        if(a<=l&&r<=b){
            return dat[k];
        }else{
            T vl = _query(a, b, k*2+1, l, (l+r)/2);
            T vr = _query(a, b, k*2+2, (l+r)/2+1, r);
            return min(vl, vr);
        }
    }
    // k: index(0-indexed)
    T get(int k){
        return dat[k+n-1];
    }
};

int main(){
    ll N, x;
    cin >> N >> x;

    SegmentTree<ll> seg;
    vector<ll> a(2*N);
    for(int i=0;i<N;i++){
        cin >> a[i];
        a[N+i] = a[i];
    }
    seg.init(a);

    ll ans = INF;
    for(ll m=0;m<N;m++){
        ll ans_m = x * m;
        for(int i=0;i<N;i++){
            ans_m += seg.query(N+i-m, N+i);
        }
        ans = min(ans, ans_m);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-06 14:38:16
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int n, k, c; cin >> n >> k >> c;
  string s; cin >> s;

  vector<int> dp_left(k + 1, -1), dp_right(k + 1, -1);

  int cur = 0, last = -1e9;

  for (int i = 0; i < n; ++i) {
    if (s[i] == 'o') {
      if (i > last + c) {
        last = i;
        ++cur;
        dp_left[cur] = i;
        if (cur == k) break;
      }
    }
  }

  last = 1e9, cur = k + 1;

  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == 'o') {
      if (i < last - c) {
        last = i;
        --cur;
        dp_right[cur] = i;
        if (cur == 1) break;
      }
    }
  }

  debug(dp_left, dp_right);

  for (int i = 1; i <= k; ++i) {
    if (dp_left[i] != -1 && dp_left[i] == dp_right[i]) {
      cout << dp_left[i] + 1 << '\n';
    }
  }

  return 0;
}

Measured memory_bytes: 3348
#include <stdio.h>

int N,M,par[200500];

int find(int x)
{
	if (x != par[x]) par[x] = find(par[x]);
	return par[x];
}

int main()
{
	scanf ("%d %d",&N,&M);
	for (int i=0;i<N+M;i++) par[i] = i;
	for (int i=0;i<N;i++){
		int x;scanf ("%d",&x);
		while (x--){
			int y; scanf ("%d",&y);
			y = y - 1 + N;
			par[find(i)] = find(y);
		}
	}

	for (int i=0;i<N;i++) if (find(i) != find(0)){
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>
typedef long long LL;

LL f(LL x, LL n)
{
	if(n < x) return n;
	return f(x, n / x) + n % x; 
}

int main()
{		
	LL n, s, i, d, k, x, y;
	
	scanf("%lld%lld", &n, &s);
	if(s > n){
		puts("-1");
		return 0;
	}
	if(s == n){
		printf("%lld\n", n + 1);
		return 0;
	}
	for(i = 2; n / i >= i; i++){
		if(f(i, n) == s){
			printf("%lld\n", i);
			return 0;
		}
	}
	d = n - s;
	for(i = sqrt(d); i > 0; i--){
		if(d % i == 0){
			x = d / i + 1, y = s - i;
			if(y >= 0 && y < x && n / x < x){
				printf("%lld\n", x);
				return 0;
			}
		}
	}
	puts("-1");
				
	return 0;
}

Measured memory_bytes: 2160
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>

using std::string;
using std::vector;

string shuffle(const string& cards, int num) {
    string target = cards.substr(0 , num);
    string remain = cards.substr(num, cards.size() - num);
    // printf("\n %s: %d -> '%s' + '%s'\n", cards.c_str(), num,  remain.c_str(), target.c_str());
    return remain + target;
}

int main(){

    string buffer = {};
    vector<string> cardsList = {};

    while(true) {
        getline(std::cin, buffer);
        if (buffer == string("-")) break;

        string cards = buffer;

        getline(std::cin, buffer);
        int times = std::stoi(buffer);
        
        for (int i = 0; i < times; i++) {
            getline(std::cin, buffer);
            int num = std::stoi(buffer);
            cards = shuffle(cards, num);
        }
        printf("%s\n", cards.c_str());
    }

    // for (auto each: cardsList) {
    //     printf("%s\n", each.c_str());
    // }
}


Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    int q; cin >> q;
    REP(i, q){
        int b, e, t; cin >> b >> e >> t;
        swap_ranges(a.begin()+b, a.begin()+e, a.begin()+t);
    }
    REP(i, n){
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3100
import sys
input = sys.stdin.readline
def main():
   N,M = map(int,input().split())
   Set = set()
   for i in range(M):
      a,b = map(int,input().split())
      Set.add((a,b))
      Set.add((b,a))                        #condition
   for j in range(2,N):
      if (1,j) in Set and (j,N) in Set:
         print("POSSIBLE")
         return
   print("IMPOSSIBLE")

main()

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

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

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

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

	VI A(N), B(N), C(N - 1);
	rbf(a, A) cin >> a;
	rbf(b, B) cin >> b;
	rbf(c, C) cin >> c;

	int before = -1, ans = 0;
	rbf(a, A) {
		ans += B[a - 1];
		if (before == a - 1) ans += C[a - 2];
		before = a;
	}

	COL(ans);

	return 0;
}

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

void solve(){
    int n=0,m=0;
    string s;
    cin>>s;
    for (int i = 0; i < 3; ++i) {
        if (s[i]=='R') n++;
        else n=0;
        if (m<n)m=n;
    }
    cout<<m<<endl;
}
int main(){
    int _=1;
//    cin>>_;
    while(_--){
        solve();
    }
}


Measured memory_bytes: 3624
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define foreach(c, it) for(typeof(c) it = (c).begin(); it != (c).end(); it++)

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int A, B;

void rec(int a, int b, string now) {

    if(a == 5 && b < 4 && b != B) return;
    if(b == 5 && a < 4 && a != A) return;
    if(a > A || b > B) return;
    if(a == A && b == B) {
        cout << now << endl;
        return;
    }
    rec(a + 1, b, now + "A");
    rec(a, b + 1, now + "B");
}

int main() {
    
    cin >> A >> B;
    rec(0, 0, "");
}

Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <math.h>
 
using namespace std;
 
int main(){

  	string word;
  	
  	getline(cin, word);

  	for(int i=0; i< word.size(); i++){
      
    	if(word.at(i) >= 'A' && word.at(i) <= 'Z'){
        	word.at(i) += 0x20;
        }
      
        else if(word.at(i) >= 'a' && word.at(i) <= 'z'){
          word.at(i) -= 0x20;
        }
      
        cout << word.at(i);

    }
  	cout << endl;

  return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define gc getchar_unlocked
#define cases int t;  cin>>t;   while(t--)
ll mod =1e9+7;
//template<typename T> 
inline ll pwr(ll base,ll n){ll ans=1;while(n>0){ if(n%2==1)ans=ans*base;  base=base*base; n/=2;} return ans;}
struct range{int l,h;};
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;

    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n-1;i++)cin>>c[i];


    int ans=b[a[0]-1];
    for(int i=1;i<n;i++)
    {
      ans+=b[a[i]-1];
      if(a[i]-a[i-1]==1)
      ans+=c[a[i-1]-1];
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
B = [int(i) for i in input().split()]
A = [1e5+1] * N

while sum(B) != -1*(N-1):
    max_val = max(B)
    index = B.index(max_val)
    if A[index] > B[index]:
        A[index] = B[index]
    if A[index+1] > B[index]:
        A[index+1] = B[index]
    B[index] = -1
        
print(sum(A))

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
#define int long long

int N,M;
int H[100000];
vector<int> edge[100000];

bool not_good[100000];

signed main() {
  cin >> N >> M;
  for(int i=0; i<N; i++) cin >> H[i];
  for(int i=0; i<M; i++) {
    int a,b;
    cin >> a >> b; 
    a--; b--;
    //edge[a].push_back(b);
    //edge[b].push_back(a);
    if(H[a] < H[b]) {
      not_good[a] = true;
    }
    else if(H[b] < H[a]) {
      not_good[b] = true;
    }
    else {
      not_good[a] = true;
      not_good[b] = true;
    }
  }
  int ans = 0;
  for(int i=0; i<N; i++) {
    if(!not_good[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6856
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    string def=string(W+2,'#');
    vector<string> pic(H+2,def);
    for(int i=1;i<H+1;++i){
        for(int j=1;j<W+1;++j){
            char c;
            cin>>c;
            pic[i][j]=c;
        }
    }
    for(int i=0;i<H+2;++i){
        cout<<pic[i]<<endl;
    }
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll a,b ;
  cin >> a >> b;
  cout << max({a + b, a -b, a * b}) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
int main(void){
	double a,b,c,d,e,f,x,y;
	while(std::cin>>a>>b>>c>>d>>e>>f){
		x=(c*e-b*f)/(a*e-b*d);
		y=(c*d-a*f)/(b*d-a*e);
		if(x==0)x=0;
		if(y==0)y=0;
		printf("%.3f %.3f\n",x,y);
	}
}

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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int f;
	cin >> f;
	cout << (f-30)/2 << endl;
	return 0;
} 



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

using namespace std;

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define optimize_cin() \
	cin.tie(0);        \
	ios::sync_with_stdio(false)
using lint = long long;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (b < a)
	{
		a = b;
		return 1;
	}
	return 0;
}

#define M_DEBUG if (1)

/******************************************************************************
	Main
******************************************************************************/

#define L_N_MAX 3
#define L_M_MAX 5

bool check_constraints(const int pM, const int slist[], const int clist[], const string pNumStr)
{ 
	rep(i, pM) {
		if (pNumStr[slist[i]-1] != (char)(clist[i] + '0'))
		{
			// cout << "pNumStr[" << i << "], " << pNumStr << "i_val: " << i_val << endl;
			return false;
		}
	}
	// cout << "pNumStr, " << pNumStr << endl;
	return true;
}

int main()
{
	int n = 0, m = -1;
	cin >> n >> m;
	assert(n >= 1 && n <= 3);
	assert(m >= 0 && m <= 5);

	int clist[L_M_MAX] = {0, 0, 0, 0, 0};
	int slist[L_M_MAX] = {0, 0, 0, 0, 0};

	rep(i, m)
	{
		cin >> slist[i] >> clist[i];
		assert(slist[i] >= 1 && slist[i] <= n);
		assert(clist[i] >= 0 && clist[i] <= 9);
	}

	int answer = -1;
	rep(i, 1000) {
		stringstream iss; iss << i;
		string str = iss.str();
		if (str.size() != n) continue;
		if (check_constraints(m, slist, clist, str)) {
			answer = i;
			break;
		}
	}
	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc148/abc148_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  ll cnt = 0;
  int last = -1;
  vector<int> a(0);
  rep(i, N) {
    if (c[i] != i + 1 - cnt) {
      cnt++;
    } else {
      last = i;
    }
  }

  // printf("%d, %d", c[last], N - cnt + 1);
  if (cnt == c.size() || c[last] != N - cnt) cnt = -1;

  cout << cnt << endl;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))


four = 0
two = 0
els = 0

for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 0:
        two +=1
    else:
        els += 1

if two == 0:
    if four + 1 >= els:
        print('Yes')
    else:
        print('No')
else:
    if four >= els:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
#![allow(non_snake_case, unused_macros, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Main
fn main(){
    input!{
        N: usize
    }
    println!("{}", if N==7 || N==5 || N==3 {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
N,K = list(map(int,input().split()))
D = list(input().split())

ok = set(("0","1","2","3","4","5","6","7","8","9"))-set(D)

def solve(str_num):
    ans = 100000
    if str_num == "":
        for c in ok:
            if c == "0":
                continue
            ans = min(ans,solve(str_num+c))

    else:
        for c in ok:
            new_num = str_num+c
            if N <= int(new_num):
                ans = min(ans,int(new_num))
            else:
                ans = min(ans,solve(new_num))
    return ans

if N<10:
    ans = 100000
    for c in ok:
        if N <= int(c):
            ans = min(ans,int(c))
    if ans == 100000:
        print(solve(""))
    else:
        print(ans)
else:
    print(solve(""))

Measured memory_bytes: 3064
N  = int(input())

base = 10 ** 9 + 7
x = 10 ** N % base
A0 = 9 ** N % base
A9 = 9 ** N % base
A09 = 8 ** N % base
ans = (x - (A0 + A9 - A09))
print(ans % base)

Measured memory_bytes: 84800
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    A.sort()
    min_a = A.pop(0)
    while(len(A) > 0):
        x = A.pop(0)
        y = x % min_a
        if y != 0:
            A.append(y)
        if y != 0 and min_a > y:
            A.append(min_a)
            min_a = y
    print(min_a)



#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 14104
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
c = 0
for i in range(n):
    x = a.index(b[i])
    j = 0
    while x > i:
        j += 1
        y = a.index(b[x])
        c += a[y]
        a[x],a[y] = a[y],a[x]
        #print(" ".join(map(str,a)))
        #print(f"x:{x} y:{y}")
        x = y
    c += min(b[i]*j,b[i]*2+b[0]*(j+2))
print(c)


Measured memory_bytes: 5620
a, b, c = map(int, input().split())
d = 0
for i in range(1, a+1):
    e = 0
    f = i
    while True:
        e += f % 10
        f = f // 10
        if f == 0:
            if b <= e <= c:
                d += i
            break
print(d)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define mp make_pair

using namespace std;

typedef long long ll;


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

struct castle {
	int x, y;
	castle(int x, int y) :x(x), y(y) {}
};

int H, W;
string masu[1000];
int cnt[1000][1000] = {};
bool broken[1000][1000] = {};

queue<castle> que[2];

int main() {
	int t = 0;

	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> masu[i];
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (masu[i][j] == '.') continue;
			
			for (int k = 0; k < 8; k++) {
				if (masu[i + dx[k]][j + dy[k]] == '.') {
					cnt[i][j]++;
				}
			}

			if (masu[i][j] - '0' <= cnt[i][j]) {
				broken[i][j] = true;
				que[t].emplace(i, j);
			}
		}
	}

	int res = 0;
	while (!que[t].empty())
	{
		res++;
		while (!que[t].empty())
		{
			castle last = que[t].front();
			que[t].pop();

			for (int i = 0; i < 8; i++) {
				int x = last.x + dx[i], y = last.y + dy[i];
				if (masu[x][y] == '.' || broken[x][y]) continue;
				cnt[x][y]++;

				if (masu[x][y] - '0' <= cnt[x][y]) {
					broken[x][y] = true;
					que[!t].emplace(x, y);
				}
			}
		}
		t = !t;
	}
	

	cout << res << endl;


	return 0;
}



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

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

  int set[26] = {0};
  for (int i = 0; i < S.size(); i++) {
    int c = S[i];
    set[c-97]++;
  }

  string ans;
  for (int i = 0; i < 26; i++) {
    if (set[i] == 0) ans.push_back(i+97);
  }

  if (ans.size() == 0) cout << "None" << endl;
  else cout << ans[0] << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
vector<long long> da(7),ta(8);
int h, w, k;
void ch(vector<bool> ju) {
	bool gg = true;
	for (int i = 0;i < w - 2;i++) {
		if (ju[i] && ju[i + 1]) {
			gg = false;
			break;
		}
	}
	if (gg) {
		for (int i = 0;i < w - 1;i++) {
			if (ju[i]) {
				da[i]++;
			}
		}
		vector<bool> hu(w, false);
		for (int i = 0;i < w - 1;i++) {
			if (ju[i]) {
				hu[i] = true;
				hu[i + 1] = true;
			}
		}
		for (int i = 0;i < w;i++) {
			if (!hu[i])
				ta[i]++;
		}
	}
}

void dfs(int n, vector<bool> ju){
	if (n > 0) {
		ju[n] = true;
		dfs(n - 1,ju);
		ju[n] = false;
		dfs(n - 1,ju);
	}
	else {
		ju[n] = true;
		ch(ju);
		ju[n] = false;
		ch(ju);
	}
}

void gen(int n) {
	vector<bool> ju(n-1);
	dfs(n - 2,ju);
}

void deb(vector<vector<long long>> dp) {
	for (int i = 0;i < h + 1;i++) {
		for (int j = 0;j < w;j++) {
			if (j == w - 1)
				cout << dp[i][j] << endl;
			else
				cout << dp[i][j] << ' ';
		}
	}
}

void ag(vector<long long> da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size()-1)
			cout << da[i] << endl;
		else
			cout << da[i] << ' ';
	}
}

int main() {
	cin >> h >> w >> k;
	if (w == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<vector<long long>> dp(h+1, vector<long long>(w,0));
	dp[0][0] = 1;
	gen(w);
	for (int i = 1;i < h + 1;i++) {
		dp[i][0] = (dp[i - 1][1] * da[0]+dp[i-1][0]*ta[0])%1000000007;
		for (int j = 1;j < w - 1;j++) {
			dp[i][j] = (dp[i - 1][j - 1] * da[j - 1] + dp[i - 1][j + 1] * da[j]+dp[i-1][j]*ta[j]) % 1000000007;
		}
		dp[i][w - 1] = (dp[i - 1][w - 2] * da[w - 2]+dp[i-1][w-1]*ta[w-1]) % 1000000007;
	}
	cout << dp[h][k - 1] << endl;
	//deb(dp);ag(da);ag(ta);
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, faces = None):
        self.dice = {'N':2, 'E':4, 'S':5, 'W':3}
        self.faces = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6}
        self.currTop = 1
        if faces is not None:
            self.faces = faces

    def top(self):
        return self.currTop

    def topFace(self):
        return self.faces[self.currTop]

    def bottom(self):
        return 7 - self.currTop

    def bottomFace(self):
        return self.faces[self.bottom()]

    def rot(self, direction):
        newTop = self.dice[direction]
        currTop = self.currTop
        self.currTop = newTop
        if direction == 'N':
            self.dice['N'] = 7 - currTop
            self.dice['S'] = currTop
        elif direction == 'S':
            self.dice['N'] = currTop
            self.dice['S'] = 7 - currTop
        elif direction == 'E':
            self.dice['E'] = 7 - currTop
            self.dice['W'] = currTop
        elif direction == 'W':
            self.dice['E'] = currTop
            self.dice['W'] = 7 - currTop

    def yaw(self, direction):
        newDice = {}
        if direction == 'E':
            newDice['N'] = self.dice['E']
            newDice['E'] = self.dice['S']
            newDice['S'] = self.dice['W']
            newDice['W'] = self.dice['N']
        if direction == 'W':
            newDice['N'] = self.dice['W']
            newDice['E'] = self.dice['N']
            newDice['S'] = self.dice['E']
            newDice['W'] = self.dice['S']
        self.dice = newDice

dbg = False

faces1 = {k:v for k,v in zip(range(1,7), map(int, input().split()))}
faces2 = {k:v for k,v in zip(range(1,7), map(int, input().split()))}

d1 = Dice(faces1)
d2 = Dice(faces2)

d2indexes = [d2index for d2index,d2face in d2.faces.items() if d1.topFace() == d2face]

for d2topIndex in d2indexes:
    if dbg: print('d2topIndex:%d' % (d2topIndex) )

    # search d1.topFace() in d2 and rotate to make d2.topFace() equal to d1.topFace().
    key = [k for k,v in d2.dice.items() if d2topIndex == v]
    if len(key) == 0:
        d2.rot('N')
        key = [k for k,v in d2.dice.items() if d2topIndex == v]
    d2.rot(key[0])

    if d1.topFace() != d2.topFace() or d1.bottomFace() != d2.bottomFace():
        continue

    # rotate(yaw) to make frontIdx front.
    cnt = 0
    while True:
        if dbg: print('cnt:%d' % (cnt) )
        if cnt > 4:
            break
        d2.yaw('E')
        cnt += 1

        # compare two dices.
        d1State = {k:d1.faces[v] for k,v in d1.dice.items()}
        d2State = {k:d2.faces[v] for k,v in d2.dice.items()}
        if d1State == d2State:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 7968
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll cnt_n(ll n){
  ll cnt = 0;
  for(int i = 1; i <= n; i++){
    if(n%i==0) cnt++;
  }
  return cnt;
}

int main(){
  ll n;
  cin >> n;
  ll cnt = 0;
  for(int i = 1; i <= n; i+=2){
    if(cnt_n(i)==8){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rgt register
#define rint rgt int
#define LL long long
#define rll rgt LL
#define inf 0x7f7f7f7f
using namespace std;
template<class K>inline bool cmax(K&a,const K&b){return(a<b)?a=b,1:0;}
template<class K>inline bool cmin(K&a,const K&b){return(a>b)?a=b,1:0;}
inline int read() {
	rint s=0;
	rgt char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return s;
}
int n;
int main()
{
	rint i,j;
	n=read(),i=read();
	printf("%d",n/i+((n%i)?1:0));
	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

const int MOD = 100000;

int main() {
	int w, h;
	while (cin >> w >> h, w) {
		vector<vvi> dp(h, vvi(w, vi(4)));
		// 0:horizontal 1:vertical

		dp[0][0][0] = 1;
		FOR(i, 1, h-1) {
			dp[i][0][3] = 1;
		}
		FOR(i, 1, w-1) {
			dp[0][i][0] = 1;
		}

		FOR(i, 1, h - 1) {
			FOR(j, 1, w - 1) {
				dp[i][j][0] = (dp[i][j - 1][0] + dp[i][j - 1][2]) % MOD;
				dp[i][j][1] = dp[i - 1][j][0] % MOD;
				dp[i][j][2] = dp[i][j - 1][3] % MOD;
				dp[i][j][3] = (dp[i - 1][j][1] + dp[i - 1][j][3]) % MOD;
			}
		}

		int ans = 0;
		REP(i, 4) {
			ans += dp[h - 1][w - 1][i];
		}

		cout << ans%MOD << endl;
	}
}

Measured memory_bytes: 1772
def solve():
  N, K = map(int, input().split())
  _S = input()
  S = []
  b = _S[0]
  s = 0
  if b == '0': S.append(0)
  for _s in _S:
    if b == _s:
      s = s + 1
    else:
      b = _s
      S.append(s)
      s = 1
  S.append(s)
  if b == '0': S.append(0)
 
  num = min(len(S), 2 * K + 1)
  # n = sum(S[0:num if _S[0] == '1' else (num - 1)])
  n = sum(S[0:num])
  m = n
  # for i in range(0 if _S[0] == '1' else -1, len(S) - num, 2):
  for i in range(0, len(S) - num, 2):
    n = n - sum(S[i:i+2])
    n = n + sum(S[i + num:i + num + 2])
    m = max(m, n)
 
  return m
 
print(solve())

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))

int main() {
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  int yen;
  if (A + B > C * 2) {
    int num = MIN(X, Y); X -= num; Y -= num;
    yen = C * num * 2;
  } else {
    yen = 0;
  }
  yen += MIN(A, C * 2) * X;
  yen += MIN(B, C * 2) * Y;
  cout << yen << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while(N != 0)
  {
    ans++;
    N /= K;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict


def get_prime_factors(n):
    factors = []

    while n % 2 == 0:
        factors.append(2)
        n //= 2

    div = 3
    while n != 1:
        while n % div == 0:
            factors.append(div)
            n //= div
        div += 2

    return factors


N = int(input())
MOD = int(1e9 + 7)
primes = defaultdict(lambda: 0)
for i in range(1, 1 + N):
    for f in get_prime_factors(i):
        primes[f] += 1
ans = 1
for val in primes.values():
    ans *= val + 1
    ans %= MOD
print(ans)


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {
    public static void main(String[]args){
        Scanner in =new Scanner(System.in);
        int T=in.nextInt();
        int count=0;
        int[] arr=new int[T];
        for(int i=0;i<T;i++){
            arr[i]=in.nextInt();
        }
        for(int i=0;i<T;i++){
            if(arr[i]!=i+1)
                count++;
        }
        if(count==0 || count==2)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 21972
n=int(input())
s=list(input())
x=[]
y=[]

for i in range(n):
  if s[i]=='R':
    x+=[i]
  elif s[i]=='W':
    y+=[i]
    
ans=0


while True:
    if len(y)==0:
      print(ans)
      break
    elif len(x)==0:
      print(ans)
      break
    elif x[-1]>y[0]:
      x.pop()
      y.pop(0)
      ans+=1
      continue
    
    else:
      print(ans)
      break

Measured memory_bytes: 18772
#include<iostream>
#include<cstdio>
#include<algorithm>

#define MAX 100
static const int INFTY =(1<<21);

int n,M[MAX][MAX];
int unvisited=0,decide=1,comp_decide=2;

void dijkstra(){
	int d[MAX];
	int state[MAX];
	for(int i=0;i<n;i++){
		d[i]=INFTY;
		state[i]=unvisited;
	}
	d[0]=0;
	state[0]=0;
	while(1){
		int mincost=INFTY,u=-1;
		for(int i=0;i<n;i++){
			if(d[i]<mincost&&state[i]!=comp_decide){
				u=i;
				mincost=d[i];
			}
		}
		if(u==-1) break;
		state[u]=comp_decide;
		for(int v=0;v<n;v++){
			if(state[v]!=comp_decide&&M[u][v]!=INFTY){
				if(d[v]>d[u]+M[u][v]){
					d[v]=d[u]+M[u][v];
					state[v]=decide;
				}
			}
		}
	}
	for(int i=0;i<n;i++){
			printf("%d %d\n",i,(d[i]==INFTY ? -1:d[i]));
	}
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			M[i][j]=INFTY;
		}
	}
	int u,k,v,c;
	for(int i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(int j=0;j<k;j++){
			scanf("%d %d",&v,&c);
			M[u][v]=c;
		}
	}
	dijkstra();
}

Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main()
{
  uint64_t N, X;
  cin >> N >> X;
  vector<uint64_t> v;
  v.reserve(100001);
  v.push_back(X);
  for (auto i = 0; i < N; i++) {
    uint64_t x;
    scanf("%lu", &x);
    v.push_back(x);
  }
  sort(begin(v), end(v));
  vector<uint64_t> distance;
  distance.reserve(100000);
  for (auto i = 1; i < v.size(); i++) {
    distance.push_back(v[i] - v[i - 1]);
  }
  uint64_t n {distance[0]};
  for (auto i = 0; i < distance.size(); i++) {
    n = __gcd(n, distance[i]);
  }
  cout << n << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		sc.close();
		int con = 0;
		int ans = 0;
		for (int i = 0; i < line.length(); i++) {
			char cut = line.charAt(i);
			if (cut == 'A' || cut == 'C' || cut == 'G' || cut == 'T') {
				con++;
			}else {
				if (ans < con ) {
					ans = con;
					con = 0;
				}
			}
		}
		if (ans < con ) {
			ans = con;
			con = 0;
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <stdlib.h>
#define N 100000
  
int Partition(int [], int, int);
 
int main(void){
  int n,i,A[N],q;
 
  scanf("%d",&n);
  for(i = 1; i < n+1; i++){
    scanf("%d",&A[i]);
  }
 
  q = Partition(A,1,n);
 
  for(i = 1; i < n; i++){
    if(i == q){
      printf("[%d] ",A[i]);
    }else{
      printf("%d ",A[i]);
    }
  }
   
  printf("%d\n",A[i]);
 
  return 0;
}
 
int Partition(int A[], int b, int c){
  int x,i,j,tmp;
 
  x = A[c];
  i = b - 1;
 
  for(j = b; j <= c-1; j++){
    if(A[j] <=  x){
      i =  i + 1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[c];
  A[c] = tmp;
 
  return i+1; 
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 int D;
 cin>>D;
 if(D==25){cout<<"Christmas"<<endl;}
 if(D==24){cout<<"Christmas Eve"<<endl;}
 if(D==23){cout<<"Christmas Eve Eve"<<endl;}
 if(D==22){cout<<"Christmas Eve Eve Eve"<<endl;}
 return 0;}

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

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

    ll n, h;
    cin >> n >> h;

    vector<ll> a(n), b(n);

    ll a_mx = -1;
    rep(i, n){
        cin >> a[i] >> b[i];
        a_mx = max(a_mx, a[i]);
    }

    sort(b.begin(), b.end(), greater<ll>());

    ll res = 0;
    rep(i, n){
        if(b[i] < a_mx) break;
        h -= b[i];
        ++res;
        if(h <= 0){
            cout << res << endl;
            return 0;
        }
    }

    cout << res + (h + a_mx - 1) / a_mx << endl;



    return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr int inf = (1 << 30) - 1;

int main() {
  int N;
  std::cin >> N;
  std::vector<int> X(N);
  for (int &x: X) {
    std::cin >> x;
  }
  int ans = inf;
  for (int p: range(0, 101)) {
    int sum = 0;
    for (int x: X) {
      sum += (x - p) * (x - p);
    }
    chmin(ans, sum);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
// Problem : A - 9x9
// Contest : AtCoder Beginner Contest 144
// URL : https://atcoder.jp/contests/abc144/tasks/abc144_a
// Memory Limit : 1024,000000 MB 
// Time Limit : 2000,000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cout.precision(16);
  cout << fixed;
  
  int a;
  int b;
  cin >> a >> b;
  
  if (a > 9 || b > 9) {
    cout << -1;
    
    return 0;
  }
  
  cout << a * b;
}


Measured memory_bytes: 256
using System;

class ABC_141_A
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();

        if (S == "Sunny")
        {
            Console.WriteLine("Cloudy");
        }
        else if (S == "Cloudy")
        {
            Console.WriteLine("Rainy");
        }
        else if (S == "Rainy")
        {
            Console.WriteLine("Sunny");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
#define SIZE 1005
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, k, c;

int main() {
	io(); cin >> n >> k >> c;
	string s; cin >> s;
	int pos = -1, res = 0;
	set<int> st, st2;
	rep(i, 0, (s.length() - 1)) {
		if (pos >= i || s[i] == 'x') continue;
		if (st.size() == k) {
			++res;
			break;
		}
		pos = i + c;
		st.insert(i);
	}
	if (res) return 0;
	pos = s.length();
	for (int i = s.length() - 1; i >= 0; --i) {
		if (pos <= i || s[i] == 'x') continue;
		if (st2.size() == k) {
			++res;
			break;
		}
		pos = i - c;
		if (st.count(i)) st2.insert(i);
	}
	if (res) return 0;
	for (auto i : st2) cout << i + 1 << '\n';
}

Measured memory_bytes: 20500
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

struct Diameter {
    vector<int> prev;
    pair<int,int> DiameterDFS(const Graph &G, int v, int p) {
        pair<int,int> res(v, 0);
        for (int i = 0; i < (int)G[v].size(); ++i) {
            if (G[v][i] == p) continue;
            pair<int,int> tmp = DiameterDFS(G, G[v][i], v);
            tmp.second++;
            if (tmp.second > res.second) res = tmp, prev[G[v][i]] = v;
        }
        return res;
    }

    vector<int> solve(const vector<vector<int> > &G) {
        prev.assign((int)G.size(), -1);
        pair<int,int> leaf = DiameterDFS(G, 0, -1);
        prev.assign((int)G.size(), -1);
        pair<int,int> t = DiameterDFS(G, leaf.first, -1);
        vector<int> res;
        int cur = t.first;
        while (cur != -1) res.push_back(cur), cur = prev[cur];
        return res;
    }
};


int main(){
  int n;cin >> n;
  Graph G(n);
  for(int i = 0; i < n-1; ++i){
    int a,b;cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  Diameter di;
  auto v = di.solve(G);
  string ans = "First";
  if(v.size()%3 == 2){
    ans = "Second";
  }
  cout << ans << endl;
}


Measured memory_bytes: 21500
/*
 * src.cpp
 *
 *  Created on: 2016/08/08
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

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

int s[10];

int main(){
	REP(i,10)
		cin>>s[i];
	int sum=0;
	REP(i,10){
		sum+=s[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
	char x,y;
	int xa,ya;
	scanf("%c\n",&x);
	scanf("%c\n",&y);
	
	switch (x)
	{
		case 'A':
		xa=10;
		break;
		
		case 'B':
		xa=11;
		break;
		
		case 'C':
		xa=12;
		break;
		
		case 'D':
		xa=13 ;
		break;
		
		case 'E':
		xa=14;
		break;
		
		case 'F':
		xa=15;
		break;
		
		default :
		break;
	}
	
	switch (y)
	{
		case 'A':
		ya=10;
		break;
		
		case 'B':
		ya=11;
		break;
		
		case 'C':
		ya=12;
		break;
		
		case 'D':
		ya=13 ;
		break;
		
		case 'E':
		ya=14;
		break;
		
		case 'F':
		ya=15;
		break;
		
		default :
		break;
	}	
	
	if(xa==ya){printf("=");}
	if(xa>ya){printf(">");}
	if(xa<ya){printf("<");}	

	return 0;
}


Measured memory_bytes: 128
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define    rep(i,n)     for(int i=0;i<(n);++i)
#define    repA(i,a,n)  for(int i=a;i<=(n);++i)
#define    repD(i,a,n)  for(int i=a;i>=(n);--i)

using namespace std;

void solve()
{
    ll n;
    cin >> n;
    ll nsum = (n*(n+1))/2;
    ll f3 = floor(n/3);
    ll f5 = floor(n/5);
    ll f15 = floor(n/15);
    
    ll sf3 = (f3*(6+(f3-1)*3))/2;
    ll sf5 = (f5*(10+(f5-1)*5))/2;
    ll sf15 = (f15*(30+(f15-1)*15))/2;
    
    ll result = (nsum + sf15) - (sf3 + sf5);
    cout << result;
    
   
}

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

Measured memory_bytes: 3652
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()

acnt = s.count('a')
bcnt = s.count('b')
ccnt = s.count('c')

print("YES" if max(acnt, bcnt, ccnt) - min(acnt, bcnt, ccnt) <= 1 else "NO")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n,m;cin>>n>>m;
	ll p[m],y[m];
	rep(i,m) cin>>p[i]>>y[i];

	vector<ll> vec[n+1];
	rep(i,m) vec[p[i]].push_back(y[i]);
	rep(i,n) sort(vec[i+1].begin(),vec[i+1].end());
	
	ll ans[m];
	rep(i,m){
		ans[i]=p[i]*1000000+(lower_bound(vec[p[i]].begin(),vec[p[i]].end(),y[i])-vec[p[i]].begin())+1;
	}

	rep(i,m) printf("%012lld\n",ans[i]);
}

Measured memory_bytes: 9344