akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <stdio.h>
using namespace std;

int main(){
    int A,i;
    cin>>A;
    for(i=1;i<10;i++){
        if((A%i==0)&&(A/i<10)){
            break;
        }
    }
    if(i==10){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
    return 0;
}

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


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }
ll find_greater_equal(ll a[], ll N, ll x){ int q = lower_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }
ll find_greater(ll a[], ll N, ll x){ int q = upper_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }
string s;
int main(){
    ios::sync_with_stdio(0);
    cin >> s;
    if(s.size() == 2){
    	cout << s; return 0;
	}
	for (int i = s.size() - 1; i >= 0; i--){
		cout << s[i];
	}
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ld long double
#define clr(x) memset((x),0,sizeof(x))

const int MX = 1e5 + 10, MD = 1e9 + 7;
ll n, m, a, b, c, ans, tmp;
int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ;
    cin >> a >> b >> c;
    ans = b;
    ans += min(b + a + 1, c);
    cout << ans;

}



Measured memory_bytes: 256
//AOJ How many islands?
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)//repをdefineした際は=でつながないようにね
#define rep2(i,a,n) for(int i=a;i<=n;i++)
int H,W;
vector<vector<int>> area;

void dfs(int i,int j){
    area[i][j]=0; //0にしておくことで隣接したマス目の探索をしているときに再度探索されることを防ぐ
    rep2(di,-1,1) rep2(dj,-1,1) {
        int ni=i+di,nj=j+dj;
        if(ni<0||nj<0||ni>=H||nj>=W) continue;
        if(area[ni][nj]==0) continue;
       // cout<<ni<<" "<<nj<<endl;
        dfs(ni,nj);
    }    
    //帰りがけの処理をするならここで
    return;
}

int main() {

while(cin>>W>>H,H!=0&&W!=0){
    area.assign(H,vector<int>(W,0));//area 2次元配列の初期化はassignを使うとforを使った代入の必要がない 
    rep(i,0,H) rep(j,0,W) cin>>area[i][j]; 
    //探索開始
    int c=0;
    rep(i,0,H) rep(j,0,W) {
        if(area[i][j]==0) continue;
        dfs(i,j);
        c++;
    }
    cout<<c<<endl;
}
return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

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

  int n;
  cin >> n;
  cout << n*n*n << endl;

  return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [a, b] <- map strToInt . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ solve s a b

numJudge :: Char -> Bool
numJudge c = ord c >= ord '0' && ord c <= ord '9'


solve :: String -> Int -> Int -> String
solve s a b = if s!!a == '-' && all numJudge (delete '-' s) then "Yes" else "No"


Measured memory_bytes: 508
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int out_table[50][3];
map<int,bool> MAP;
bool FLG;


int makeCode(int code[3]){
	return 100*code[0]+10*code[1]+code[2];
}


void recursive(int code[3],bool used[50]){
	if(FLG)return;
	int tmp_code;

	int next_code[3];

	for(int i = 0; i < N; i++){
		if(used[i] == false){

			for(int k = 0; k < 3; k++){
				next_code[out_table[i][k]] = code[k];
			}

			tmp_code = makeCode(next_code);

			if(tmp_code == 12){
				FLG = true;
				return;
			}
			auto at = MAP.find(tmp_code);
			if(at != MAP.end())continue;
			MAP[tmp_code] = true;

			bool next_used[50];
			for(int k = 0; k < N; k++)next_used[k] = used[k];
			next_used[i] = true;
			recursive(next_code,next_used);
		}
	}

}

int main(){

	scanf("%d",&N);

	int yoko_num,work[3],tmp;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&yoko_num);

		for(int i = 0; i < 3; i++)work[i] = i;

		for(int i = 0; i < yoko_num; i++){
			scanf("%d",&tmp);
			if(tmp == 0){
				swap(work[0],work[1]);
			}else{
				swap(work[1],work[2]);
			}
		}

		for(int i = 0; i < 3; i++){
			out_table[loop][work[i]] = i;
		}
	}

	FLG = false;
	int first_code[3] = {0,1,2};
	bool first_used[50];
	for(int i = 0; i < N; i++)first_used[i] = false;

	recursive(first_code,first_used);

	if(FLG){
		printf("yes\n");
	}else{
		printf("no\n");
	}

	return 0;
}



Measured memory_bytes: 3172
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <limits>
#include <type_traits>

using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
    double N,D;
    cin >> N >> D;
    cout << ceil(N/(2*D+1))<< endl;
 }


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np

N,K = map(int, input().split())
A = np.array([int(i) for i in input().split()], np.int64)

INF = 10**18 + 1

A = np.sort(A)
# []内の条件文を満たす値の配列
zero = A[A == 0]
pos = A[A > 0]
neg = A[A < 0]

# 積がX以下となる個数がK未満 -> True
def is_under_K(X:int):
    cnt = 0

    # A[i] == 0
    if X >= 0:
        cnt += len(zero) * N
    
    # A[i] > 0
    tmp = X // pos
    cnt += np.searchsorted(A, tmp, "right").sum()

    # A[i] < 0
    tmp = (-X-1) // (-neg)
    cnt += (N - np.searchsorted(A, tmp, "right")).sum()

    # A[i] * A[i] <= X
    cnt -= np.count_nonzero(A * A <= X)

    assert cnt % 2 == 0
    return cnt // 2 < K

def main():
    # 二分探索 O(log(INF))
    ok, ng = -INF, INF
    while ng - ok > 1:
        mid = (ng + ok) // 2
        if is_under_K(mid):
            ok = mid
        else:
            ng = mid

    """
    is_under_K(X) = Flaseとなる最小値X
    -> X = ng
    """
    print(ng)

if __name__ == "__main__":
    main()

Measured memory_bytes: 32316
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=[0]+A
tmp=1
flist=[0 for i in range(N+1)]
blist=[]
for i in range(1,N+1):
  if flist[tmp]==0:
    flist[tmp]=i
    blist+=[tmp]
  else:
    ls=flist[tmp]
    le=i
    T=le-ls
    break
  tmp=A[tmp]
else:
  ls=1
  le=N+1
  T=N
Tlis=[]
for i in range(T):
  Tlis+=[tmp]
  tmp=A[tmp]
if K<=ls-1:
  print(blist[K])
else:
  K2=K-(ls-1)
  K2=K2%T
  print(blist[ls+K2-1])

Measured memory_bytes: 32300
#include<stdio.h>
int main()
{
    int n, k, i, count = 0, max = 0;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++)
    {
        b[i]=-1;
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[a[i]] = i;
        if(max < a[i] )
        max = a[i];
    }
    for(i=0;i<max+1;i++)
    {
        if(b[i]!=-1)
        printf("%d ",b[i]+1);
    }
    return 0;
}


Measured memory_bytes: 1536
/**
*    created: 01.07.2020 21:21:59
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int MOD = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int INF = 1LL << 60;

signed main() {

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

    int n;
    cin >> n;
    map<char,int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
            mp[s[0]]++;
        }
    }
    if (mp.size() < 3) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> v;
    for (auto p : mp) {
        v.push_back(p.second);
    }
    int ans = 0;
    rep(i,v.size()) rep(j,i) rep(k,j) {
        ans += v[i] * v[j] * v[k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

set<char> st({'A', 'T', 'C', 'G'});

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

    int ans = 0;
    for(int i=0;i<s.length();++i) {
        int j = i;
        while(j < s.length()) {
            if(st.find(s[j]) != st.end()) {
                ++j;
            } else {
                break;
            }
        }
        ans = max(ans, j-i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
constexpr ll INF = 1LL<<60;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif

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

    REP(i, n) {
        if(s[i]=='R') s[i] = 'A';
        else if(s[i]=='G') s[i] = 'B';
        else s[i] = 'C';
    }
    dump(s);

    vector<vector<ll>> cnt(n+1, vector<ll>(3));    
    for(ll i=n-1; i>=0; --i) {
        cnt[i] = cnt[i+1];
        cnt[i][s[i]-'A']++;
    }
    dump(cnt);

    ll ans = 0;
    REP(i, n) FOR(j, i+1, n) {
        if(s[i] != s[j]) {
            ll plus = n-j-1 - cnt[j+1][s[i]-'A'] - cnt[j+1][s[j]-'A'];
            if(j-i <= n-j-1 && s[i]!=s[2*j-i] && s[j]!=s[2*j-i]) plus--;
            ans += plus;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3868
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>

int e = 0;

int solve(){
    int x,y,z;

    int z_max;
    int res = INT_MAX;
    for(y=0; y<=e; ++y){
        if((e-y*y) < 0){
            break;
        }
        z_max = pow(e-y*y, 1.0/3.0) + 1;
        for(z=0;z<=z_max;++z){
            x = e - y*y - z*z*z;
            if(x >= 0){
               res = std::min(res, x+y+z);
            }else{
                break;
            }
        }
    }
    return res;
}

int main(void){
    while(true){
        std::cin >> e;
        if(e == 0) break;
        std::cout << solve() << std::endl;
    }
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// vector print(debug or stdout)
template <class Iit>
void vout(const Iit &begin,const Iit &end,ostream &out) {
    for(auto it = begin; it != end; it++) {
        auto tmp = it;
        if (++tmp == end) out << *it << '\n';
        else out << *it << " ";
    }
}

int main(void)
{
    IOS
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    REP(i,K) {
        vector<int> imos(N+1);
        REP(j,N) {
            int u = max(0,j-A[j]);
            int d = min(N,j+A[j]+1);
            imos[u] += 1;
            imos[d] -= 1;
            // cerr << u << " " << d << endl;
        }
        int cnt = 0;
        int all = A[0];
        int stop = true;
        REP(i,N) {
            cnt += imos[i];
            A[i] = cnt;
            if (stop && A[i] != all) stop = false;
        }
        if (stop) break;
    }
    vout(ALL(A),cout);

    return 0;
}

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

double _stack[128];
int it;

void push(double v)
{
	_stack[it++] = v;
}
double pop(void)
{
	return _stack[--it];
}
void clear(void)
{
	it = 0;
}

double calc(double y, double x, char o)
{
	switch (o){
	  case '/': return y / x;
	  case '*': return y * x;
	  case '+': return y + x;
	  case '-': return y - x;
	}
}

int main(void)
{
	char tokens[128];
	char *token;

	while (fgets(tokens, 128, stdin)){
		clear();
		token = tokens;
		while (*token != '\n' && *token != '\0'){
			if (isdigit(*token) || (*token == '-' && isdigit(token[1]))) push(atoi(token));
			else push(calc(pop(), pop(), *token));

			while (*token != '\n' && *token != '\0' && *token != ' ') token++;
			while (*token == ' ') token++;
		}

		printf("%lf\n", pop());
	}
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,ans;
  int A,B;
  cin >> S;

  A = (S[0]-'0') * 10 + (S[1]-'0');
  B = (S[2]-'0') * 10 + (S[3]-'0');

  bool YYMM = (1 <= B && B <=12);
  bool MMYY = (1 <= A && A <=12);

  if (YYMM) {
    if (MMYY) { 
      ans = "AMBIGUOUS";
      }
    else {
      ans = "YYMM";
      }
    }
  else {
    if (MMYY) { 
      ans = "MMYY";
      }
    else {
      ans = "NA";
      }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[105],cnt,n, num;

int main() {
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        a[num]=a[num]+1;
    }
    for(int i=0;i<105;i++)
    {
        if(a[i]>=1)
        {
            cnt=cnt+1;
        }
    }
    cout<<cnt;
    
}
    
    
    
       

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define INFTY 1.0e9
#define N 500000
int merge_count = 0;
int array[N];

void merge(int left, int right) {
	int mid = (left+right)/2;
	int n1 = mid-left;
	int n2 = right-mid;
	int l[n1+1];
	int r[n2+1];
	for(int i = 0; i < n1; i++) {
		l[i] = array[left+i];
	}
	for(int i = 0; i < n2; i++) {
		r[i] = array[mid+i];
	}
	l[n1] = INFTY;
	r[n2] = INFTY;

	int p = 0;
	int q = 0;

	for(int i = left; i < right; i++) {
		merge_count++;
		if(l[p] <= r[q]) {
			array[i] = l[p];
			p++;
		}
		else {
			array[i] = r[q];
			q++;
		}
	}
	
}

void merge_sort(int left, int right) {
	if(left+1 < right) {
		int mid = (left+right)/2;
		merge_sort(left, mid);
		merge_sort(mid, right);
		merge(left, right);
	}
}

int main() {
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++) {
		cin >> array[i];
	}

	merge_sort(0, n);

	for(int i = 0; i < n-1; i++) {
		cout << array[i] << " ";
	}
	cout << array[n-1];
	cout << endl;

	cout << merge_count << endl;
	return 0;
}



Measured memory_bytes: 6972
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <functional>
#include <string>
#include <sstream>
#include <bitset>  // std::bitset<N>

#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define rep(i,n) for (int i=0; i < int(n); i++)


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    ll A[X], B[Y], C[Z];
    for(int i = 0; i < X; i++){
      cin >> A[i];
    }
    for(int i = 0; i < Y; i++){
      cin >> B[i];
    }
    for(int i = 0; i < Z; i++){
      cin >> C[i];
    }

    ll D[X*Y]={0};
    for (int i = 0; i < X; i++){
      for(int j = 0; j < Y; j++){
        D[i*Y + j] = A[i] + B[j];
      }
    }
    sort(D, D+(X*Y),  std::greater<ll>());
    if(X*Y >= 3000){
      ll E[3000 * Z]={0};
      for(int i = 0; i < 3000; i++){
        for(int j = 0; j < Z; j++){
          E[j*3000 + i] = D[i] + C[j];
        }
      }
      sort(E, E+(3000*Z), std::greater<ll>());
      for(int i = 0; i < K; i++){
        cout << E[i] << endl;
      }
    }else{
      ll E[X*Y*Z] = {0};
      for(int i = 0; i < X*Y; i++){
        for(int j = 0; j < Z; j++){
          E[j*X*Y + i] = D[i] + C[j];
        }
      }

      sort(E, E+(X*Y*Z), std::greater<ll>());
      for(int i = 0; i < K; i++){
        cout << E[i] << endl;
      }

    }

    return 0;
}

Measured memory_bytes: 31616
#include<stdio.h>
void swap(int *a, int *b){
  int c;
  c=*a;*a=*b;*b=c;
}
int main(){
  int x,y,z;
  scanf("%d %d %d",&x,&y,&z);
  swap(&x,&y);swap(&x,&z);
  printf("%d %d %d\n",x,y,z);
  return 0;
}

Measured memory_bytes: 128
module Main where

import           Data.List

main :: IO ()
main = do
    [h, w] <- (map read . words) <$> getLine :: IO [Int]
    list   <-
        (map (map read . words)) <$> (sequence . take h . repeat) getLine :: IO
            [[Int]]
    let res1    = (map goRight . enumerate2d) list
    let list2   = (map snd) res1
    let result1 = (concatMap fst) res1
    let res2    = (goRight . map last) list2
    let result2 = fst res2
    let result  = concat [result1, result2]

    putStr
        $ (unlines . (((show . length) result) :) . map
              (unwords . (\((a, b), (c, d)) -> (map show) [a, b, c, d]))
          )
              result

    return ()
goRight
    :: [((Int, Int), Int)] -> ([((Int, Int), (Int, Int))], [((Int, Int), Int)])
goRight list@[_         ] = ([], list)
goRight (     a : b : xs) = if even (snd a)
    then let res = goRight (b : xs) in (fst res, a : (snd res))
    else
        let res = goRight (mapSnd (+ 1) b : xs)
        in  ((fst a, fst b) : (fst res), mapSnd (subtract 1) a : (snd res))

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d list =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)
        list

mapTuple f1 f2 (a, b) = (f1 a, f2 b)

mapFst f = mapTuple f id
mapSnd f = mapTuple id f


Measured memory_bytes: 84476
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,cnt=0;
	cin>>x>>y;
	for(int i=0;i<=x;i++)
		for(int j=0;j<=x;j++)
		{
			int z=y-i-j;
			if(z>=0 && z<=x)cnt++;
		 } 
	cout<<cnt;
	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int h,w;
int c[26];
main()
{
	cin>>h>>w;
	string s;
	for(int i=0;i<h;i++)
	{
		cin>>s;
		for(int j=0;j<w;j++)
		{
			c[s[j]-'a']++;
		}
	}
	int cnt1=0,cnt2=0;
	for(int i=0;i<26;i++)
	{
		if(c[i]%2)cnt1++;
		c[i]-=c[i]%2;
		if(c[i]%4==2)cnt2++;
	}
	int ans1=h*w%2,ans2=h%2*(w/2)+w%2*(h/2);
	if(cnt1!=ans1||cnt2>ans2||(ans2-cnt2)%2)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

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

int main()
{
    int n;
    cin>>n;
    int F[50];
    F[0]=F[1]=1;
    for(int i=2;i<=n;i++) F[i]=F[i-1]+F[i-2];
    
    cout<<F[n]<<endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	while (S != "#") {
		int y, m, d;
		cin >> y >> m >> d;
		if (y >= 32 || (y == 31 && m > 4)) {
			y -= 30;
			printf("? %d %d %d\n", y, m, d);
		}
		else {
			printf("%s %d %d %d\n", S.c_str(), y, m, d);
		}
		cin >> S;
	}
	return 0;
}



Measured memory_bytes: 3316
from collections import deque
h,w=map(int,input().split())
S=[input() for _ in range(h)]
inf=float("inf")
ans=0
for i in range(h):
    for j in range(w):
        if S[i][j]=="#":
            continue
        else:
            D=[[inf for _ in range(w)]for _ in range(h)]
            D[i][j]=0
            que=deque([(i,j)])
            while que:
                si,sj=que.popleft()
                for ni,nj in [(si+1,sj),(si-1,sj),(si,sj+1),(si,sj-1)]:
                    if 0<=ni<h and 0<=nj<w and S[ni][nj]!="#":
                        if D[ni][nj]>D[si][sj]+1:
                            D[ni][nj]=D[si][sj]+1
                            ans=max(ans,D[si][sj]+1)
                            que.append((ni,nj))
print(ans)

Measured memory_bytes: 48220
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[MAX+1];
int head=1, tail=0, n;


int isEmpty(int head, int tail){
  if(head == tail) return head;
  else return -1;
}
int isFull(int head, int tail){
  if(head == (tail+1)%MAX) return head;
  else return -1;
}
void enqueue(P x){
  if(isFull(head, tail) == head){
    fprintf(stderr, "overflow!\n");
    exit(1);
  }
  Q[tail] = x;
  if(tail+1 == MAX) tail = 0;
  else tail++;
}

P dequeue(){
  P x;
  if(isEmpty(head, tail) == head){
    fprintf(stderr, "underflow!\n");
    exit(1);
  }
  //printf("Q[tail] is %s, %d\n", Q[tail-1].name, Q[tail-1].t);
  x = Q[head];
  if(head+1 == MAX){
    head = 0;
  } else{
    head++;
  }
  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  
  scanf("%d %d", &n, &q);
  tail = n+1;
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  while(1){
    if(head == tail)break;
    if(Q[head].t-q <= 0){
      //printf("if   Worked!\n");
      u = dequeue();
      elaps += u.t;
      printf("%s %d\n", u.name, elaps);
    } else{
      //printf("else Worked!\n");
      elaps += q;
      u = dequeue();
      u.t -= q;
      enqueue(u);
    }
  }

  
  return 0;
}



Measured memory_bytes: 11892
X = input()
Y = input()

dp = [[0]*(len(Y)+1) for _ in [0]*(len(X)+1)]

for i, x in enumerate(X):
    i += 1
    for j, y in enumerate(Y):
        j += 1
        dp[i][j] = max(dp[i-1][j-1]+int(x == y),
                       dp[i-1][j], dp[i][j-1])

ans = []
cnt = dp[-1][-1]
x = y = -1
while cnt:
    while dp[x-1][y] == cnt:
        x -= 1
    while dp[x][y-1] == cnt:
        y -= 1
    ans.append(X[x])
    cnt -= 1
    x -= 1
    y -= 1
ans = ''.join(ans)[::-1]
print(ans)


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

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
  long long N = S.size();

  for(long long i = 0; i < N; i++){
    for(long long j = 0; j < (N-i); j++) {
      string tmp = S;

      if(tmp.erase(i,j) == "keyence") {
        cout << YES << endl;
        return;
      }
    }
  }

  cout << NO << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
  std::cin >> S;
    solve(S);
    return 0;
}


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

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

    int n;
    cin >> n;

    vector<pair<int,int>> red(n);
    vector<pair<int,int>> blue(n);

    for(int i = 0; i < n; i++) cin >> red[i].second >> red[i].first;
    for(int i = 0; i < n; i++) cin >> blue[i].first >> blue[i].second;

    sort(red.rbegin(),red.rend());
    sort(blue.begin(),blue.end());

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(blue[i].first > red[j].second && blue[i].second > red[j].first){
                ans++;
                red[j].first = 2 * n;
                red[j].second = 2 * n;
                blue[i].first = 0;
                blue[i].second = 0;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final int numOfSorceCodes = scanner.nextInt();
		final int features = scanner.nextInt();
		final int constatnt = scanner.nextInt();

		final int[] feature = new int[features];
		for (int i = 0; i < features; i++) {
			feature[i] = scanner.nextInt();
		}

		int result = 0;
		for (int i = 0; i < numOfSorceCodes; i++) {
			final int[] sourceCodeFeature = new int[features];
			for (int j = 0; j < features; j++) {
				sourceCodeFeature[j] = scanner.nextInt();
			}

			int tmp = 0;
			for (int j = 0; j < features; j++) {
				tmp += feature[j] * sourceCodeFeature[j];
			}

			if (tmp + constatnt > 0) {
				result++;
			}

		}
		System.out.println(result);
		scanner.close();
	}

}


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

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if(x / d >= k) {
        cout << x - k * d << endl;
    }
    else {
        k -= x / d;
        if(k % 2 == 1) {
            cout << abs(d - x % d) << endl;
        }
        else {
            cout << x % d << endl;
        }
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n, a, b;
    while(cin >> n, n){
        int as = 0, bs = 0;
        rep(i,n){
            cin >> a >> b;
            if(a > b){
                as += (a + b);
            }else if(a < b)
                bs += (a + b);
            else{
                as += a;
                bs += b;
            }
        }
        cout << as << ' ' << bs << endl;
    }
}

Measured memory_bytes: 1160
import math

X = int(input())

def trial_division(target):
    dest = int(math.sqrt(target))
 
    for i in range(2,dest):
        if target % i == 0:
            return False
            
    return True
    
myans = False    

while myans == False:
    myans = trial_division(X)
    X += 1
    
print(X-1)

Measured memory_bytes: 3060
N, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
hash = Hash.new(0)
as.each do |a|
    hash[a] += 1
end

values = hash.values.sort
if values.length <= K
    puts 0
else
    puts values[0, values.length-K].inject(:+)
end

Measured memory_bytes: 32880
#coding : utf-8
while True:
    aa, op, bb = input().split()
    if op == '?':
        break
    a = int(aa)
    b = int(bb)
    if op == '+':
        print (a+b)
    elif op == '-':
        print (a-b)
    elif op == '*':
        print (a*b)
    elif op == '/':
        print (a//b)


Measured memory_bytes: 5592
import java.io.*;

class Main{
    public static void main(String args[]){
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = br.readLine();
            String[] strArr = str.split(" ");
            int a = Integer.parseInt(strArr[0]);
            int b = Integer.parseInt(strArr[1]);

            if(a<b){
                System.out.println("a < b");
            }else if(a > b){
                System.out.println("a > b");
            }else{
                System.out.println("a == b");
            }

        }catch(IOException e){
            e.printStackTrace();
        }

    }

}

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

bool prime_factrization(const int n)
{
    for (int i = 2; i <= sqrt(n); ++i)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

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

    const int MAX = 100001;

    vector<int> sum(MAX);
    sum[0] = sum[1] = sum[2] = 0;

    for (int i = 3; i < MAX; ++i)
        sum[i] = sum[i - 1] + (prime_factrization(i) && prime_factrization((i + 1) / 2));

    rep(q, Q)
    {
        int l, r;
        cin >> l >> r;

        cout << sum[r] - sum[l - 1] << endl;
    }
}

Measured memory_bytes: 1024
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Char (intToDigit)

main :: IO ()
main = do
  [n, k] <- getl $ wrds toInt
  solve n <$> getl (wrds toInt) >>= print

solve :: Int -> [Int] -> Int
solve n xs = f n
  where
    ls = map intToDigit xs
    f x
      | null (intersect (show x) ls) = x
      | otherwise = f (x+1)

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int n, a[maxn], ans[maxn], x[maxn];

signed main() {

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

	int sum = 0, prod = 1;
	for(int i = 0; i < n-1; i++){
		prod *= -1;
		sum += (prod * a[i]);
	}

	int x1 = (a[n-1] - sum) / 2;
	x[0] = x1;

	for(int i = 1; i < n; i++){
		x[i] = a[i-1] - x[i-1];
	}

	for(int i = 0; i < n; i++){
		cout << x[i] * 2 << " ";
	}
 
 
	return 0;
}

Measured memory_bytes: 6144
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[0] - h[1])
for i in range(1, n):
  dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]) for j in range(1, k + 1) if i - j >= 0)
print(dp[-1])


Measured memory_bytes: 53472
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N];
int seg[N<<2];
int lazy[N<<2];


void push(int nd,int L,int R){
    if( lazy[nd]==0 )return;
    seg[nd] = (R-L+1) ;

    if( L != R ) { // have children
    lazy[nd<<1  ]+=lazy[nd];// push to left child
    lazy[nd<<1|1]+=lazy[nd];// push to right child
    }
    lazy[nd]=0;
}


int query(int nd,int L,int R,int from,int to){
    push(nd,L,R);

    if( from<=L && R<=to )return seg[nd];
    if( from>R || to<L )return 0;

    int mid = (L+R) >>1;

    int leftAns = query(nd<<1  ,  L  ,mid,from,to);
    int rightAns= query(nd<<1|1,mid+1, R ,from,to);
    return  leftAns +rightAns ;
}

void updateRange(int nd,int L,int R,int from,int to,int val){
    push(nd,L,R);

    if( R <from  || L>to )return; // out
    if( from<=L && R<=to ){       // in
        lazy[nd] += val ;
        push(nd,L,R);
        return;
    }

    int mid = (L+R) >>1;
    updateRange(nd<<1  ,  L  ,mid,from,to,val);
    updateRange(nd<<1|1,mid+1, R ,from,to,val);
seg[nd]= seg[nd<<1] + seg[nd<<1|1] ;

 }



int main(){
  scanf("%d",&n);
   int l , r ;
   while ( n-- ){
        scanf("%d%d",&l,&r);
    updateRange(1,1,N,l,r,1);
   }
   printf("%d",seg[1]);
    return 0;
    }


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 3e5+1;
ll row[inf], col[inf];
void solve()
{

    ll h,w; cin >> h >> w;
    ll m; cin >> m;
    set<pair<ll,ll>> s;
    while(m--){
        ll x,y; cin >> x >> y;
        row[x]++;
        col[y]++;
        s.insert({x,y});
    }
    ll maxX=0, maxY=0;
    for(ll i=1; i<=h; i++)
        maxX = max(maxX, row[i]);
    for(ll i=1; i<=w; i++)
        maxY = max(maxY, col[i]);
    ll ans = maxX + maxY -1;

    vector<ll> allmaxX, allmaxY;
    for(ll i=1; i<=h; i++)
        if(row[i]==maxX) allmaxX.pb(i);
    for(ll i=1; i<=w; i++)
        if(col[i]==maxY) allmaxY.pb(i);
    
    for(auto A : allmaxX){
        for(auto B : allmaxY)
            if(!s.count({A,B}))
            {
                ans++; goto printing;
            }
    }
    printing:
    cout << ans << endl;
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
    return 0;
}


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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll a[2*n+1];
	rep(i,1,2*n+1) {cin >> a[i];trace1(a[i]);}
	sort(a+1,a+2*n+1);
	ll ans=0;
	rep(i,1,2*n+1){
		trace1(a[i]);
	}
	for(ll i=1; i<=2*n; i++){
		if(i%2)ans=ans+min(a[i],a[i+1]);
	}
	trace1(ans);
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>

using namespace std;

int flg[1000005];

int main(){
  int s;  
  scanf("%d",&s);
  for(int i=1;;i++){
    flg[s]++;
    if(flg[s]==2){
      printf("%d\n",i);
      break;
    }
    if(s%2) s=3*s+1;
    else s/=2;
    
  }

  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second
#define MOD 1000000007LL

using namespace std;
using pii = pair<int, int>;
using ll = long long;

vector<ll> f(3000000);

tuple<ll, ll, ll> exgcd(ll a, ll b) {
    if (b == 0)
        return make_tuple(a, 1, 0);
    ll g, x, y;
    tie(g, x, y) = exgcd(b, a % b);
    return make_tuple(g, y, x - (a / b) * y);
}

ll moddiv(ll a, ll b)
{
    ll bb;
    tie(ignore, bb, ignore) = exgcd(b, MOD);
    if (bb < 0) b += MOD;
    return (a * bb) % MOD;
}

ll getC(int a, int b)
{
    if (a < b) return 0;
    return moddiv(moddiv(f[a], f[a - b]), f[b]);
}

ll getH(int a, int b)
{
    return getC(a + b - 1, b);
}

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

    f[0] = 1;
    for (int i = 1; i < f.size(); i++) f[i] = (f[i - 1] * i) % MOD;

    int k;
    cin >> k;
    string s;
    cin >> s;
    ll answer = 0;
    vector<ll> p26(k + 1), p25(k + 1);
    p26[0] = p25[0] = 1;
    for (int i = 1; i <= k; i++) {
        p26[i] = (p26[i - 1] * 26) % MOD;
        p25[i] = (p25[i - 1] * 25) % MOD;
    }
    for (int i = 0; i <= k; i++) {
        ll tmp = (p26[i] * getH(s.length(), k - i)) % MOD;
        tmp = (tmp * p25[k - i]) % MOD;
        answer = (answer + tmp) % MOD;
    }
    if (answer < 0) answer += MOD;
    cout << answer;

    return 0;
}

Measured memory_bytes: 43432
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();

    S = S.replaceAll("eraser",  "-");
    S = S.replaceAll("erase",   "-");
    S = S.replaceAll("dreamer", "-");
    S = S.replaceAll("dream",   "-");
    S = S.replaceAll("-", "");
    
    if(S.length() == 0) {
        System.out.println("YES");
    }else {
        System.out.println("NO");
    } 
  }
}


Measured memory_bytes: 29908
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<u64>();
    let mut count = HashMap::new();

    for i in 0..n {
        *count.entry(a[i]).or_insert(0) += 1;
    }
    let mut ans = 0;
    for &key in count.keys() {
        if count[&key] >= key {
            ans += count[&key] - key;
        } else {
            ans += count[&key];
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 13560
# -*- coding: utf-8 -*-
from collections import deque

N,M = list(map(int, input().rstrip().split()))
AB_list = [list(map(int, input().rstrip().split())) for i in range(M)]
#-----

edge_dic = {}

# "idx 0" doesn't use
# 1: visited, 0: not visited
visited = [1] + [0]*N

# We use on and after "idx 2"
guidepost = [0]*2 + [None]*(N-1)


for a,b in AB_list:
    edge_dic.setdefault(a, [])
    edge_dic[a].append(b)
    
    edge_dic.setdefault(b, [])
    edge_dic[b].append(a)


queue = deque([1])
visited[1] = 1

while queue:
    current = queue.popleft()
    
    for next_room in edge_dic[current]:
        if visited[next_room] == 0:
            guidepost[next_room] = current
            visited[next_room] = 1
            queue.append(next_room)


if (visited.count(0) == 0) and (guidepost.count(None) == 0):
    print("Yes")
    
    for num in guidepost[2:]:
        print(num)
    
else:
    print("No")


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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;

int main()
{
    IOS;
    //freopen("fr.txt","r",stdin);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++){
        sum=sum+a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <cstdlib>

#define VMAX 100
#define EMAX 1000

using namespace std;

struct Node{
    vector<int> connect;
    char visit;
};

void dfs_visit(Node data[VMAX], Node &n);

int main(){
    int vn, en;
    int source, target;
    Node data[VMAX];
    
    cin >> vn >> en;
    
    if(!(1 <= vn && vn <= VMAX) || !(0 <= en && en <= EMAX))
        return -1;
    
    for(int i = 0;i < vn;i++)
        data[i].visit = 'W';
    
    for(int i = 0;i < en;i++){
        cin >> source >> target;
        
        if(!(0 <= source && source < vn) || !(0 <= target && target < vn))
            return -1;
        if(source == target)
            return -1;
        
        data[source].connect.push_back(target);
    }
    
    for(int i = 0; i < vn; i++)
        if(data[i].visit == 'W')
            dfs_visit(data, data[i]);
    
    cout << "0" << endl;

    return 0;
}

void dfs_visit(Node data[VMAX], Node &n){
    if(n.visit == 'G'){
        cout << "1" << endl;
        exit(0);
    }
    else if(n.visit == 'W'){
        n.visit = 'G';
        for(vector<int>::size_type i = 0;i < n.connect.size();i++)
            dfs_visit(data, data[n.connect[i]]);
        n.visit = 'B';
    }
}



Measured memory_bytes: 3172
from bisect import bisect_right, bisect_left
from collections import Counter, deque
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import groupby, permutations, combinations, product
from sys import stdin, stderr


# 最大公約数（ユークリッドの互除法）
# Python3.5 で math.gcd()が追加され、
# AtCoder環境と最新環境でパッケージが分かれてしまったので、自分で書いておく
def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)


# 拡張ユークリッド互除法
# 正整数x, y について、a*x + b*y == gcd(x,y)なるa,bを返す。
# 特に、互いに素なるx, yについては a*x + b*y == 1 となる a, b。
def exgcd(x, y):
    if y == 0:
        return 1, 0
    a, b = exgcd(y, x % y)
    return b, a - (x // y) * b


# 最小公倍数
def lcm(x, y):
    m = gcd(x, y)
    return (x // m) * (y // m)


def main():
    n = int(input())
    xs = [int(x) for x in input().split()]
    ave = sum(xs) // n
    kouho = 0
    kouho2 = 0
    ave2 = ave + 1
    for i in range(n):
        kouho += pow(xs[i] - ave, 2)
        kouho2 += pow(xs[i] - ave2, 2)

    return min(kouho, kouho2)


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

Measured memory_bytes: 3692
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=110;
int a[N],b[N];
int k1[N],k2[N];
int cnt1,cnt2,cnt;
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int n,m,i;
	scanf("%d%d",&n,&m);
	rep(i,1,m)	scanf("%d",&a[i]);
	if(m==1){
		if(n==1)	printf("1\n1\n1\n");
		else printf("%d\n2\n%d 1\n",a[1],a[1]-1);
		return 0;
	}
	rep(i,1,m){
		if(a[i]&1)	k1[++cnt1]=a[i];
		else k2[++cnt2]=a[i];
	}
	if(cnt1>2)	{printf("Impossible\n");return 0;}
	if(cnt1)	b[++cnt]=k1[1];
	rep(i,1,cnt2)	b[++cnt]=k2[i];
	if(cnt1>1)	b[++cnt]=k1[2];
	rep(i,1,cnt)	printf("%d ",b[i]);
	printf("\n");
	b[1]++;b[cnt]--;if(!b[cnt])	cnt--;
	printf("%d\n",cnt);
	rep(i,1,cnt)	printf("%d ",b[i]);
}
	
	

Measured memory_bytes: 128