akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct P {
	int x, y;
};
struct Node {
	P p;
	int dir, cost;
};
bool operator >(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}
P operator +(const P& p1, const P& p2) {
	return (P){ p1.x + p2.x, p1.y + p2.y };
}

P Dir[4] = {
	(P){1, 0},
	(P){0, 1},
	(P){-1, 0},
	(P){0, -1},
};

#define INF 1e9

void AddQueue(priority_queue<Node, vector<Node>, greater<Node> >& Q, Node node, int op) {
	int dd = op;
	node.dir = (node.dir + dd) % 4;
	node.p = node.p + Dir[node.dir];
	Q.push(node);
}

int main() {
	int w, h;
	while ( cin >> w >> h, w || h ) {
		int s[30][30];
		for (int y = 0; y < h; ++y) for (int x = 0; x < w; ++x) {
			cin >> s[y][x];
		}
		int c[4];
		for (int i = 0; i < 4; ++i) cin >> c[i];

		int cost[30][30][4];
		fill(&cost[0][0][0], &cost[0][0][0]+30*30*4, -1);
		priority_queue<Node, vector<Node>, greater<Node> > Q;
		Q.push( (Node){ (P){0, 0}, 0, 0 } );
		while ( !Q.empty() ) {
			Node node = Q.top(); Q.pop();
			P p = node.p;
			if (p.x < 0 || p.x >= w || p.y < 0 || p.y >= h) continue;
			if (cost[p.y][p.x][node.dir] >= 0) continue;
			cost[p.y][p.x][node.dir] = node.cost;

			if (s[p.y][p.x] != 4) AddQueue(Q, node, s[p.y][p.x]);
			for (int i = 0; i < 4; ++i) {
				AddQueue(Q, (Node){ node.p, node.dir, node.cost + c[i] }, i);
			}
		}
		int ans = INF;
		for (int i = 0; i < 4; ++i) if (cost[h-1][w-1][i] >= 0) ans = min(ans, cost[h-1][w-1][i]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1616
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {

	int num = 1000000, tmp;

	string s;

	cin >> s;

	for (int i = 0; i < s.size()-2; i++) {

		tmp = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i+2] - '0');

		//cout << tmp << "\n";

		num = min(num, abs(753 - tmp));

		//printf("i=%d,num=%d\n", i, num);
	}

	cout << num << "\n";



	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/join.hpp>

using namespace std;

#if 0
// memo
abs()

start_with(str, "hoge");
ends_with(str, "hoge");

std::sort(d.begin(), d.end());
d.erase(std::unique(d.begin(), d.end()), d.end());


reverse(j.begin(), j.end());


// コンテナ連結出力
cout << join(r, " ") << "\n";
#endif

using namespace boost;
using namespace boost::algorithm;
using boost::lexical_cast;

static inline bool isOdd(int v)
{
    return v & 0x01;
}

int main()
{
    int A, B;
    scanf("%d%d", &A, &B);

    int c = 0;
    for (int i = A; i <= B; ++i) {
        string s = lexical_cast<string>(i);
        string j = s;
        reverse(j.begin(), j.end());
        if (s == j) {
            ++c;
        }
    }

    printf("%d\n", c);

    return 0;
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from functools import partial, reduce
from collections import Counter
#======================================================#
def f_chain(*args):
    return reduce(lambda x, f: f(x), args)
def is_odd(n):
    return n%2==1

def main():
    n = II()
    aa = [II() for _ in range(n)]
    c = Counter(aa)
    f_chain(c.values(),
            partial(filter, is_odd),
            list,
            len,
            print,
    )

if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n, m, k;
  while (cin >> n >> m >> k, n) {
    vector<vector<double>> dp(n + 1, vector<double>(n * m + 1, 0.));
    dp[0][0] = 1.;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= n * m; j++) {
        if (dp[i][j] == 0.) continue;
        for (int k = 1; k <= m && j + k <= n * m; k++) {
          dp[i + 1][j + k] += dp[i][j] * (1. / m);
        }
      }
    }
    
    double ans = 0.;
    for (int i = 0; i <= n * m; i++) {
      ans += dp[n][i] * max(1, i - k);
    }
    printf("%.10f\n", ans);
  }

  return 0;
}


Measured memory_bytes: 3364
N=int(input())
a=[int(i)-1 for i in input().split()]
M=0
for i in range(N-1):
  if a[i]==i:
    a[i],a[i+1]=a[i+1],a[i]
    M+=1
if a[N-1]==N-1:
  a[N-2],a[N-1]=a[N-1],a[N-2]
  M+=1
print(M)


Measured memory_bytes: 13880
#include<iostream>
using namespace std;
int V, E, R, S[500010], T[500010], D[500010]; // ????????§?????????????????\???
int C[100010]; // ??????????????§??????????????¢?????????
// ???????????¨????????°?????¨???????????????????????§?¶?????¨????
const int Inf = 10000*100000+100;

int main() {
  cin >> V >> E >> R;
  for (int i=0; i<E; ++i)
    cin >> S[i] >> T[i] >> D[i]; // ???????????\??? 
  for(int i=0;i<V;i++)
    C[i]=Inf;
  C[R]=0;// C????????????: C[R]???0???,??????Inf???
  for (int t=0; t<V; ++t)
    {                           // V?????°?????????
      bool update = false;
      for (int i=0; i<E; ++i)
      {
	int s = S[i], t = T[i], d = D[i]; // i???????????????s,t,d????????????
	if (C[s] < Inf && C[t]>d+C[s])
	  { // ???s,t??§????????§????????????
	    C[t] =d+C[s]; // C[t]?????´??°;
	    update = true; // ??´??°???????????£????????¨????¨????
	  }
      }
      if (!update) break; // ????????????????????´??°??????????????°???????????£?????????
    }
  for(int i=0;i<V;i++)
    {
      if(C[i]==Inf)
	cout<<"INF"<<endl;
      else
	cout<<C[i]<<endl;
    }
}

Measured memory_bytes: 9128
#include <stdio.h>
int main(void) {
    int H, W;
    char c;
    scanf("%d%d", &H, &W);
    for (int i = 0; i < H; i++) {
        int k = -1;
        for (int j = 0; j < W; j++) {
            scanf("%c", &c);
            if (c != 'c' && c != '.') {
                j--;
                continue;
            }
            if (k >= 0) {
                k++;
            }
            if (c == 'c') {
                k = 0;
            }
            printf("%d%c", k, (j == W - 1) ? '\n' : ' ');
        }
    }
}

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

ll f(ll x) {
  ll a;
  while (x) {
    x /= 2;
    a++;
  }
  return a;
}

int main() {
  ll h; cin >> h;
  cout << (ll)(pow(2, f(h)) - 1);
  return 0;
}

Measured memory_bytes: 384
#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,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010
#define MAX_V 		102
#define MAX_E 		1005

const ll LINF = (ll)1e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];

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

	double ans = 0;

	int odd = 0;
	REPS(i,1,N+1)if(i%2==1)odd++;

	printf("%0.7lf\n",(double)odd/N);

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = std::vector<int>;
using Vlli = std::vector<lli>;
using Wint = std::vector<Vint>;
using Wlli = std::vector<Vlli>;
using Vbool = std::vector<bool>;
using pii = std::pair<int, int>;
using pll = std::pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {std::make_pair(1, 0), std::make_pair(-1, 0), std::make_pair(0, 1), std::make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

std::deque<int> A;

int main(void){
  int n, a; scanf("%d\n", &n);
  REP(i, n){scanf("%d", &a); if(i % 2 == 0) A.push_front(a); else A.push_back(a);}
  if(n % 2 != 0){
    REP(i, n-1){
      printf("%d ", A.front());
      A.pop_front();
    }
    printf("%d\n", A.front());
    A.pop_front();
  }
  else{
    REP(i, n-1){
      printf("%d ", A.back());
      A.pop_back();
    }
    printf("%d\n", A.back());
    A.pop_back();
  }
  return 0;
}

Measured memory_bytes: 2944
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(x);
    ll s = x;
    ll i = 1;
    while(true) {
        s += x;
        ++i;
        if (s % 360 == 0) {
            cout << i << endl;
            return;
        }
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3644
#!/usr/bin/env python3

a = []

a = list(map(int, input().split()))

coin = 0
for i in range(2):
    if a[0] >= a[1]:
        coin += a[0]
        a[0] = a[0] - 1
    else:
        coin += a[1]
        a[1] = a[1] - 1

print(coin)

Measured memory_bytes: 3060
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in); 
	String a = sc.next();
	String b = sc.next();
	if(a.equals(b)){
	    System.out.println("H");
	}else{
	    System.out.println("D");
	}
    }
}
      


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> A(X), B(Y), C(Z);
	for (ll i=0; i<X; ++i) cin >> A[i]; sort(A.begin(), A.end(), greater<ll>()); 
	for (ll i=0; i<Y; ++i) cin >> B[i]; sort(B.begin(), B.end(), greater<ll>()); 
	for (ll i=0; i<Z; ++i) cin >> C[i]; sort(C.begin(), C.end(), greater<ll>()); 
	vector<ll> vec;
	ll idx=0;
	for (ll i=0; i<X; ++i) {
		for (ll j=0; j<Y; ++j) {
			for (ll k=0; k<Z; ++k) {
				if ((i+1) * (j+1) * (k+1) <= K) {
					vec.push_back(A[i]+B[j]+C[k]);
				} else {
					break;
				}
			}
		}
	}
	//cout << "idx: " << idx << endl;
	sort(vec.begin(), vec.end(), greater<ll>());	
	for (ll i=0; i<K; ++i) {
		cout << vec[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 1404
#include <stdio.h>
#include <string.h>

int input[1001];
    
int q_sort(int start, int end){
	if(end == start) return 0; 
	else{ 
		int p = start;
		for(int i = (start + 1); i < end + 1; i++){ 
			if(input[i] < input[p]){ 
				int temp = input[i]; 
				memmove(input + start + 1, input + start, (i - start)*sizeof(int));
				input[start] = temp;
				p++; 
			}
		}
		if(start != p) q_sort(start,p-1);
		if(end != p) q_sort(p+1,end); 
		return 0;
	}
}
int main(){
	int a, b, c, d;
	scanf("%d%d", &a, &b);
	c = 0;
	for(int i = 0; i < a; i++){
		scanf("%d", &input[i]);
	}
	q_sort(0,a-1);
	for(int i = 0; i < b; i++){
		c = c + input[i];
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 1720
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

#参加者のポイント
p = [k - q] * n
for i in a:
    p[i - 1] += 1

for i in p:
    if i > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 10508
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  double edge;
  double area;
  
  lll l;

  cin >> l;

  edge = l/3.0d;

  area = edge * edge * edge;

  printf("%0.7lf\n",area);

  return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
long long n,m,dp[1007][1007];
char array1[1007][1007];
bool isvalid(int i,int j){
    return i>=0&&i<=n&&j>=0&&j<=m;
}
long long solve(int i,int j){
   if(i>n)
        return 0;
    if(j>m)
        return 0;
    if(array1[i][j]=='#')
        return 0;
    if(i==n-1&&j==m-1)
        return 1;
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    return dp[i][j]=((solve(i+1,j)%MOD)+(solve(i,j+1)%MOD))%MOD;
}
int main()
{
int i,j;
memset(dp,-1,sizeof(dp));
cin>>n>>m;
for(i=0;i<n;i++){
    for(j=0;j<m;++j){
        cin>>array1[i][j];
    }
}
printf("%I64d",solve(0,0));





    return 0;
}


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

typedef long long ll;

string s;
stack<char> q;
ll res;
 
int main() {
	cin >> s;
	for (char& v: s) {
		if (q.empty() || q.top() == v) q.push(v);
		else {
			q.pop();
			res += 2;
		}
	}
	cout << res;
	
	return 0;
}


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

typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<int> check(n);

    for (int i = 0; i < n; i++){
        check[i] = 0;
    }
    for (int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        check[a[i]]++;
        check[b[i]]++;
    }

    bool flag = true;

    for (int i = 0; i < n; i++){
        if (check[i] % 2 == 1){
            flag = false;
        }
    }

    if (flag){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Hitachi2020
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string s = Read();
            if(s=="hi"|| s == "hihi"|| s == "hihihi"|| s == "hihihihi"|| s == "hihihihihi")
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        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); }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
    
#define rep(i, n) for (int i = 0; i < (int)n; i++)
    
int N, X;
multiset<int, greater<int>> s;
queue<int> aux1;
vector<int> cur;
    
int main()
{
    cin >> N;
    
    rep(i, 1 << N)
    {
        cin >> X;
        s.insert(X);
    }
    
    cur.push_back(*(s.begin()));
    s.erase(s.begin());
    
    rep(i, N)
    {
        for (int c : cur)
        {
            auto it = s.upper_bound(c);

            if (it != s.end())
            {
                aux1.push(*it);
                s.erase(it);
                goto next;
            }
    
            cout << "No\n";
            return 0;
    
            next:
            continue;
        }
    
        while (!aux1.empty())
        {
            cur.push_back(aux1.front());
            aux1.pop();
        }
    }
    
    cout << "Yes\n";
}

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

int main(){
    int c;
    cin>>c;
    if(c==25)
        cout<<"Christmas"<<endl;
    else if(c==24)
        cout<<"Christmas Eve"<<endl;
    else if(c==23)
        cout<<"Christmas Eve Eve"<<endl;
    else if(c==22)
        cout<<"Christmas Eve Eve Eve"<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
using namespace std;


int main() {

    int A, B, C;
    cin >> A >> B >> C;

    string answer = "No";
    if( A == B && B != C ){
        answer = "Yes";
    } 
    if( B == C && C != A ){
        answer = "Yes";
    } 
    if( C == A && A != B ){
        answer = "Yes";
    } 

    cout << answer << endl;

    return 0;
}


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

using namespace std;

int main(){
  long long count = 0;
  string s,t;
  cin >> s >> t;
  for(long long i = 0; i < (long long)s.size();i++){
    if(s[i] != t[i]){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3768
#include "bits/stdc++.h"

using namespace std;

void Main() {
    string S;
    cin >> S;

    string dream = "dream";
    string dreamer = "dreamer";
    string erase = "erase";
    string eraser = "eraser";

    bool ans = true;
    while (!S.empty()) {
        int n = S.size();
        if (n < 5) {
            ans = false;
            break;
        }
        if (n >= 5 && S.substr(n - 5, 5) == dream) {
            S = S.substr(0, n - 5);
            continue;
        }
        else if (n >= 5 && S.substr(n - 5, 5) == erase) {
            S = S.substr(0, n - 5);
            continue;
        }
        else if (n >= 6 && S.substr(n - 6, 6) == eraser) {
            S = S.substr(0, n - 6);
            continue;
        }
        else if (n >= 7 && S.substr(n - 7, 7) == dreamer) {
            S = S.substr(0, n - 7);
            continue;
        }
        else {
            ans = false;
            break;
        }
    }
    cout << (ans ? "YES" : "NO") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DD;
const int inf = 1e9;
const int mo= 1e9+7;
const int N = 9e5+10;
int n, m, k, fac[N], inv[N], tmp[N], mi[N];


int C(int n, int m){
	return 1ll * fac[n] * inv[m] % mo * inv[n - m] % mo;
}

int pow(int a, int k){
	int ans=1;
	for(; k; k =k >> 1, a = 1ll * a * a % mo)
		if(k & 1)
			ans = 1ll * ans * a % mo;
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(false);
	cout.tie(false);
	cin >> n >> m >> k;
	fac[0] = 1;
	for(int i = 1; i <= 900000; i++){
		fac[i] = 1ll * fac[i-1] * i % mo;
	}
	inv[900000] = pow(fac[900000], mo - 2);
	inv[0] = 1;
	int sz = m + k;
	for(int i = 899999; i ; i--)
		inv[i] = 1ll * inv[i + 1] * (i + 1) % mo;
	mi[0] = 1;
	for(int i = 1; i <= sz; i++)
		mi[i] = mi[i - 1] * 3ll % mo;
	
	LL ans = 0,sum = 1;
	for(int i = 0; i <= sz; i++){
		ans = (ans + 1ll * sum * C(i + n -1, n - 1) % mo * mi[sz - i] )% mo;
		sum=(sum<<1)%mo;
		if(i >= m)
			sum = (sum - C(i, m) + mo) % mo;
		if(i >= k)
			sum = (sum - C(i, i - k) + mo) % mo;
			
	}
	cout << ans << endl;
	return 0;
}




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

int main()
{
    int w,h,x,y,r;
    cin >> w >> h >> x >> y>> r;
    
    if (0 <= (x-r) && 0 <= (y-r) && (x+r) <= w && (y+r) <= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    while(a%2 == 0){
      ++ans;
      a /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
/* 
 Author:N_o_o_B 
 Created:September 28 2019 17:07:54
*/
#include <bits/stdc++.h>
using namespace std;

#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const ll mod=1e9+7;
const ll INF=1e18;

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

    int n;
    cin >> n;
    int o=0;
    for(int i=1;i<=n;i+=2){
        o++;
    }
    double ans=o*1.00/n;
    cout << ans << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#include <boost/functional/hash.hpp>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using namespace tr1;
using namespace boost;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define EPS 1e-8
#define mod 100000
#define DEB 0

/*
struct state{
  int s,c;
  state(int _s, int _c){
    s=_s; c=_c;
  }
};
struct state_eq{
  bool operator()(const state &a, const state &b)const{
    return a.s==b.s && a.c==b.c;
  }
};
struct ihash{
  size_t operator()(const state &a)const{
    size_t seed = 0;
    hash_combine(seed, a.s);
    return seed;
  }
};
*/

typedef unsigned short int usint;
int h,w;
char field[20][21];
int dp[20][20][17712];
int mask;
//unordered_map<state, bool, ihash, state_eq> hii;
unordered_map<int,usint> hii;

int solve(int c, int S){
  if( c==w*h ) return 1;
  int x = c%w;
  int y = c/w;
  int ret = 0;
  
  //unordered_map<state, int, ihash, state_eq>::iterator it;
  unordered_map<int,usint>::iterator it;
  it = hii.find(S);
  int idx;
  int sz = hii.size();
  if( it==hii.end() ){
    hii.insert(mp(S,sz));
    idx = sz;
  }else{
    idx = it->second;
  }
  
  if( dp[y][x][idx]!=-1 ){
    ret = dp[y][x][it->second];
  }else{
    if( field[y][x]=='?' || field[y][x]=='J' ){
      int next;
      if( S&1 ){
	next = ((S-1)<<1)|1;
      }else{
	next = (S<<1)|1;
      }
      ret = (ret + solve(c+1, next&mask)) % mod;
    }
    if( field[y][x]=='?' || field[y][x]=='O' ){
      ret = (ret + solve(c+1, (S<<1)&mask)) % mod;
    }
    if( field[y][x]=='?' || field[y][x]=='I' ){
      if( x==w-1 || !((1<<(w-1))&S) ){
	int next;
	if( S&1 ){
	  next = (S-1)<<1;
	}else{
	  next = S<<1;
	}
	ret = (ret + solve(c+1, next&mask)) % mod;
      }
    }
    dp[y][x][idx] = ret;
  }

  return ret;
}

int main(){
  
  while(~scanf("%d%d",&h,&w)){
    hii.clear();
    memset(dp,-1,sizeof(dp));
    int all = 1;
    rep(i,h)scanf("%s",field[i]);
    rep(i,h)rep(j,w)if( field[i][j]=='?' ){
      all = (all*3) % mod;
    }
    mask = (1<<w)-1;

    int wr = solve(0,0);
    printf("%d\n",(all-wr+mod)%mod);

#if DEB
    cout << hii.size() << endl;
#endif
  }
  return 0;
}

Measured memory_bytes: 28000
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String t = sc.nextLine();
        sc.close();

        int ans = 0;
        for(int i=0; i<=s.length()-t.length(); i++) {
            int match = 0;
            for(int j=0; j<t.length(); j++) {
                if(s.charAt(i+j) == t.charAt(j)) {
                    match++;
                }
            }
            ans = Math.max(ans,match);
        }
        if(ans != 0) System.out.println(t.length()-ans);
        else System.out.println(t.length());

    }
}


Measured memory_bytes: 36168
#include <bits/stdc++.h>
using namespace  std;
int const N=1e5;

set <char> st;
int main() {
int n;
string s;
cin>>n;
map <string,long long > mp;
for(int i=0;i<n;i++)
{
    s.clear();
    st.clear();
    string str;
    cin>>str;
   sort(str.begin(),str.end());
    mp[str]++;

}
long long sum=0;
for(auto it=mp.begin();it!=mp.end();it++)
{
    long long  x=it->second;

    sum+=(x*(x-1))/2;
}
cout<<sum;

}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        
        int[] code = new int[m];
        for (int i = 0; i < m; i++) {
            code[i] = sc.nextInt();
        }
        int count = 0;

        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += code[j] * sc.nextInt();
            }

            if (sum + c > 0) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) 1e9
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
int main(){
	fast;
	ll n;
	cin>>n;
	vector <pair <ll, ll>> a;
	pair<ll ,ll> p;
	ll t;
	p = {0,0};
	a.pb(p);
	for(ll i=1; i<=n; i++){
		cin>>t;
		p = mp(t, i);
		a.pb(p);
	}
	sort(a.begin()+1, a.end());
	ll ans=0;
	ll dp[n+1][n+1]={};
	for(ll len = n; len>=1; len--){
		for(ll st=1; st <= n-len+1; st++){
			if(len==1){
				ans = max(ans, dp[st][st] + a[len].ff*abs(a[len].ss - st));
			}
			else{
				dp[st+1][st + len - 1] = max(dp[st+1][st+len-1], dp[st][st+len-1] + a[len].ff*abs(a[len].ss - st));
				dp[st][st + len - 2] = max(dp[st][st + len-2], dp[st][st+len-1] + a[len].ff*abs(a[len].ss-(st+len-1)));

			}
		}
	}
	cout<<ans<<endl;
	// for(ll i=1; i<=n; i++){
	// 	for(ll j=1; j<=n; j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
}

Measured memory_bytes: 34996
#include <bits/stdc++.h>
using namespace std; 
void insertionSort(vector<int> &A, int &N){
    int v = A.at(N);
    int j = N - 1;
    while (j >= 0 && A.at(j) > v){
        A.at(j+1) = A.at(j);
        j -= 1;
        A.at(j+1) = v;
    }
    N += 1;
    return;
}

int main(){
    int N;
    cin >> N;
    vector<int> Ai(N);
    for (int i=0; i<N; i++){
        cin >> Ai.at(i);
        if (i != N-1) cout << Ai.at(i) << " ";
        else cout << Ai.at(i) << endl;
    }
    for (int k=1; k<N;){
        insertionSort(Ai, k);
        for (int m=0; m<N; m++){
            if (m == N-1) cout << Ai.at(m) << endl;
            else cout << Ai.at(m) << " ";
        }
    }
    return 0;

}


Measured memory_bytes: 3048
#include<cstdio>
void solve(int n){
	if(n==1){printf("deficient number\n"); return;}
	int sum=1;
	for(int i=2;n>=i*i;i++){
		if(n%i==0&&n!=i*i)
 	 	sum+=i+(n/i);
     	if(sum>n){printf("abundant number\n"); return;}
 	}
	if(sum==n)printf("perfect number\n");
	else printf("deficient number\n");
}

int main(){
	int n,ans;
	while(scanf("%d",&n)){
	if(n==0)break;
	solve(n);
	}
  return 0;	
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    long long int a, b, n, v, i, max, tmp;
    scanf("%lld %lld %lld", &a, &b, &n);
    max=0;
    if (n<b) {
        max=floor(a*n*1.00/b);
    }
    else {
        max=floor(a*(b-1)*1.00/b);

    }
    printf("%lld\n", max);
    return 0;
}

Measured memory_bytes: 2212
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, p;
int one, zero;
signed main() {
	cin >> n >> p;
	rep(i, n) {
		int a; cin >> a;
		if (a % 2)one++;
		else zero++;
	}
	if (!one && p)cout << 0 << endl;
	else if (!one)cout << ((int)1 << zero) << endl;
	else cout << ((int)1 << (n - 1)) << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main(void)
{
  const int minNum = 1;
  const int maxNum = 9;

  for (int i = minNum; i <= maxNum; i++) {
    for (int j = minNum; j <= maxNum; j++) {
      std::cout << i << "x" << j << "=" << i * j << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1116
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<numeric>
using namespace std;
int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i <= k)
			ans += x;
		else
			ans += y;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,m,inf=INF;
  cin >> n >> m;
  ll xsum = 0,ysum = 0,x,y;
  FOR(i,0,n){
    cin >> x;
    xsum += (2*i+1-n)*x;
    xsum %= inf;
  }
  FOR(i,0,m){
    cin >> y;
    ysum += (2*i+1-m)*y;
    ysum %= inf;
  }
  cout << xsum*ysum%inf << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define SIZE 1000111
#define BC 50
#define BS 5000
#define MOD 1000000007LL
#define MAXV 555
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<vector<long long> > mat;

ll n,m, w[111], v[111];
ll d[111][333][111];

ll dp(ll idx, ll sum, ll cnt) {
	// printf("idx %lld sum %lld cnt %lld\n",idx,sum,cnt);
	if(cnt * w[0] + sum > m)	return -INFL;
	if(idx == n)				return 0;
	if(d[idx][sum][cnt] != -1)	return d[idx][sum][cnt];
	ll ret = 0;
	ret = max(ret, v[idx] + dp(idx+1, sum + w[idx]-w[0], cnt+1));
	ret = max(ret, dp(idx+1, sum, cnt));
	return d[idx][sum][cnt] = ret;
}

int main () {
	memset(d,-1,sizeof(d));
	scanf("%lld%lld",&n,&m);
	for(int i=0;i<n;i++)	scanf("%lld%lld",w+i,v+i);
	printf("%lld\n",dp(0,0,0));
}

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

#define ll long long
#define ld long double

void solve() {
	char s[3];
	int num = 0, max = 0;
	cin >> s;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == 'R') {
			num++;
			if (max < num) 
				max = num;
		} else {
			num = 0;
		}
	}
	cout << max << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

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

            int ans = a;
            if (b < a) {
                ans--;
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 23764
#include <iostream>
#include <utility>
#include<cmath>
#include<cstdio>
using namespace std;

int main() {
        pair<double, double> p1, p2;
        cin >> p1.first >> p1.second >> p2.first >> p2.second;
        printf("%.8f\n", sqrt(pow(p2.first - p1.first, 2) + pow(p2.second - p1.second, 2)));
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}



//ll a[]={6,8,4,2,6};

//ll tb=100;
void solve(){
	ll x,y;
	cin>>x>>y;
	ll maxl=x*4;
	ll minl=x*2;
	if(y>=minl&&y<=maxl&&y%2==0){
		cout<<"Yes"<<endl;

	}
	else{
		cout<<"No"<<endl;
	}



		
}



int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
   // cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int K, A, B;
    cin >> K >> A >> B;

    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<int> d(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> d[i];
        sum += d[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += d[i] * (sum - d[i]);
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll = long long;
#define what(x) cerr << #x << " is " << x << endl;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    ll ret = 0;
    for(int i = 0; i < 1<<(n-1); ++i) {
        vector<int> plus;
        for(int j = 0; j < n-1; ++j) {
            if(i & (1<<j))
                plus.push_back(j);
        }
        plus.push_back(n-1);
        int pos = 0;
        for(auto p : plus) {
            ret += stoll(s.substr(pos, p-pos+1));
            pos = p+1;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import groupby
n = int(input())
h = list(map(int,input().split()))
max_h = max(h)
for i in range(n):
    h[i] = [h[i],0]
ans = 0
for i in range(max_h):
    for is_more,group in groupby(h, key=lambda a:bool(a[0] > a[1])):
        group = list(group)
        if is_more:
            ans += 1
    for hs in h:
        hs[1] += 1
print(ans)

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

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
ios_base::sync_with_stdio(false); \
cin.tie(0);                       \
cout.tie(0);
#define test  \
int t;    \
cin >> t; \
while (t--)
#define debug(a)          \
	cerr << #a << ": ";   \
for (auto i : a)      \
	cerr << i << " "; \
cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
for (int u = 0; u < n; u++) \
	{                           \
		cout << ar[u] << " ";   \
	}                           \
	cout << endl;
#define int long long
#define M 1000000007
	signed main()
	{
		rootdada;
// #ifndef ONLINE_JUDGE
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 		freopen("error.txt", "w", stderr);
// #endif
		int k,a,b;
		cin>>k>>a>>b;
		rep(i,a,b+1)
		{
			if(i%k==0)
			{
				cout<<"OK\n";
				return 0;
			}
		}
		cout<<"NG\n";
	} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

static const int N=101;
static const int W=10010;
int dp[N+1][W+1];

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(a+b+c+d)/60<<endl;
    cout<<(a+b+c+d)%60<<endl;

  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const ll p=998244353ll,pp=p*p;
const int N=2500000;
ll fac[N+5],ifa[N+5];
inline ll expo(ll a,int b=998244351){
	ll c=1ll;
	while(b){
		if(b&1)c=c*a%p;
		b>>=1; a=a*a%p;
	}
	return c;
}
inline ll C(int a,int b){return fac[a]*(ifa[a-b]*ifa[b]%p)%p;}
inline ll f(int a,int b){return b?C(a+b-1,a):(!a);}
inline void app(ll &a){if(a> pp)a-=pp;}
inline void spp(ll &a){if(a<0ll)a+=pp;}
int main(){
	int n,m,i,t,b;ll ans;
	scanf("%d%d",&n,&m);t=m+(m<<1);
	fac[0]=1ll;
	for(i=1;i<=N;++i)fac[i  ]=fac[i-1]*i%p;
	ifa[N]=expo(fac[N]);
	for(i=N;i   ;--i)ifa[i-1]=ifa[i  ]*i%p;
	ans=f(t,n)-n*f(m-1,n);
	b=min(t,n);
//	printf("ans=%lld b=%d n=%d m=%d t=%d\n",ans,b,n,m,t);
/*	for(i=++m;i<=b;++i){
//		if((i^m)&1)printf("+%lld %lld %lld\n",C(i,m),C(n,i),f(t-i,n-i));
//		else       printf("-%lld %lld %lld\n",C(i,m),C(n,i),f(t-i,n-i));
		if((i^m)&1)app(ans+=(C(i-1,i-m)*C(n,i)%p)*f(t-i,n-i));
		else       spp(ans-=(C(i-1,i-m)*C(n,i)%p)*f(t-i,n-i));
	}*/
	for(i=m+2;i<=b;i+=2){
		spp(ans-=C(n,i)*f((t-i)>>1,n));
	}
	printf("%lld",(ans+pp)%p);
	return 0;
}

Measured memory_bytes: 39424
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


n, *A = map(int, open(0).read().split())
f = partition(A, 0, n-1)
ans = ''
for i in range(n):
    if i == f:
        ans += f'[{A[i]}] '
    else:
        ans += f'{A[i]} '
print(ans[:len(ans) - 1])



Measured memory_bytes: 16368
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    #include<algorithm>

    using namespace std ;

    int gcd(int a, int b){
      if(a%b==0)return b;
      else return gcd(b,a%b);
    }
    int main(){
      int N,ans=0;
      cin>>N;
      int d[100000];
      for(int i=0;i<N;i++){
        cin>>d[i];
      }
      sort(d,d+N);
      //for(int i=0;i<N;i++){
        //cout<<d[i]<<endl;
      //}
      ans=d[N/2]-d[(N/2)-1];
      cout<<ans<<endl;
      return 0;
    }

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

int gcd(int a,int b){
  if(b%a==0){
    return a;
  }else{
    return gcd(b%a,a);
  }
}

int main(){
  int k,sum=0;
  cin>>k;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      int d=gcd(a,b);
      for(int c=1;c<=k;c++){
        int e=gcd(d,c);
        sum+=e;
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
const int inf = 1e9;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int mincost[101][101][4][11][11];
void initcost(){
    REP(y,101) REP(x,101) REP(d,4) REP(p,11) REP(q,11){
        mincost[y][x][d][p][q] = inf;
    }
}


struct info{
    int y,x,d,p,q,c;
    info(int y, int x, int d, int p, int q, int c)
        :y(y),x(x),d(d),p(p),q(q),c(c){}
    info(){}
    bool operator<(const info &a) const{
        return c > a.c;
    }
};

int main(){
    int h,w,a;
    cin >> h >> w >> a;
    vector<vector<char> > field(h+2, vector<char>(w+2, '#'));
    int sy,sx, gy,gx;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> field[i][j];
            if(field[i][j]=='S'){
                sy = i;
                sx = j;
            }
            if(field[i][j]=='G'){
                gy = i;
                gx = j;
            }
        }
    }
    
    priority_queue<info> wait;
    if(field[sy+1][sx]!='#'){
        wait.push(info(sy+1, sx, 1, a, a, 0));
    }
    initcost();
    mincost[sy+1][sx][1][a][a] = 0;

    while(!wait.empty()){
        info top = wait.top();
        int y = top.y;
        int x = top.x;
        int d = top.d;
        int p = top.p;
        int q = top.q;
        int c = top.c;
        wait.pop();
        if(field[y][x]=='G') continue;
        if(c > mincost[y][x][d][p][q]) continue;

        for(int i=0; i<4; i++){
            int ny = y+dy[i];
            int nx = x+dx[i];
            int np = p;
            int nq = q;
            if(field[ny][nx] == '#') continue;
            if(field[ny][nx] == 'S' && i==3) continue;
            if(field[y][x] == 'S' && (i!=d)) continue;
            if((i+2)%4 == d) continue;
            if((d+i)%4 == 1) np--;
            if((d+i)%4 == 3) nq--;
            if(np<0 || nq<0) continue;
            if(c+1 < mincost[ny][nx][i][np][nq]){
                wait.push(info(ny, nx, i, np, nq, c+1));
                mincost[ny][nx][i][np][nq] = c+1;
            }
        }
    }

    int ans = inf;
    for(int d=0; d<4; d++){
        for(int p=0; p<=10; p++){
            for(int q=0; q<=10; q++){
                if(mincost[gy][gx][d][p][q] != inf){
                    ans = min(ans, a-p +a-q);
                }
            }
        }
    }
    if(ans == inf){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 22564