akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <complex>
const double pi = 3.14159265358979;
using namespace std;

int koch(complex <double> p1, complex <double> p2, int n){
	complex <double> v1, v2, q1, q2, q3;
	double norm, angle;

	if (n>0){
		v1 = (p2 - p1)/ 3.0;
		norm = abs(v1);
		angle = arg(v1)+pi/3;
		v2 = polar(norm, angle);
		q1 = p1+v1;
		q2 = q1+v2;
		q3 = q1+v1;

		koch(p1, q1, n-1);
		koch(q1, q2, n-1);
		koch(q2, q3, n-1);
		koch(q3, p2, n-1);
	}else{
		cout << fixed << real(p1) << " " << imag(p1) << endl;
	}
	return 0;
}

int main(void){
	int n;
	cin >> n;
	complex <double> p1=0, p2=100;

	koch(p1,p2,n);
	cout << fixed << real(p2) << " " << imag(p2) << endl;
	cout << endl;
	return 0;
}

Measured memory_bytes: 1304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int main(){

	string str1,str2;
	while(cin>>str1>>str2&&!(str1=="0"&&str2=="0")){
		int hit=0;
		int blow=0;

		set<char> s1,s2;
		for(int i = 0; i < 4; i++){
			if(str1[i]==str2[i]){
				hit++;
			}
			else{
				s1.insert(str1[i]);
				s2.insert(str2[i]);
			}
		}
		for(set<char>::iterator it = s1.begin(); it!=s1.end(); it++){
			if(s2.find(*it)!=s2.end()){
				blow++;
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}


	return 0;
}

Measured memory_bytes: 924
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
int M, N;
vstring A;
vstring B;

bool test(int sh, int sw){

	int BW = B[0].length();
	int AW = A[0].length();

	rep(bh, M)
		rep(bw, BW){
		int ah = sh + bh;
		int aw = sw + bw;
		if (ah >= N || aw >= AW) return false;
		if (A[ah][aw] != B[bh][bw]) return false;
	}
	return true;

}

int main() {

	cin >> N >> M;
	
	rep(i, N){
		string s; cin >> s;
		A.push_back(s);
	}
	rep(i, M){
		string s; cin >> s;
		B.push_back(s);
	}

	bool ret = false;

	int AW = A[0].length();
	rep(sh, N)
		rep(sw, AW)
	{
		ret = ret || test(sh, sw);

	}

	cout << (ret ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import math
from fractions import Fraction
n=int(input())
x=[1,1]
for i in range(n):
  a0,b0=x
  a ,b =[int(i) for i in input().split()]
  m=math.ceil(max(Fraction(a0,a),Fraction(b0,b)))
  x=[m*a,m*b]
  
print(int(sum(x)))

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,Q;
int A[111111],B[111111];

int latte[111111];

bool ex[111111];

signed main(){
    cin>>N>>Q;
    rep(i,Q)cin>>A[i]>>B[i],A[i]--,B[i]--;
    rep(i,N)latte[i]=i;

    int pos=0;
    rep(i,N){
        if(A[i]==pos)pos=B[i];
        else if(B[i]==pos)pos=A[i];
    }

    if(pos>0)ex[pos-1]=true;
    ex[pos]=true;
    if(pos+1<N)ex[pos+1]=true;

    rep(i,N)latte[i]=i;
    for(int i=Q-1;i>=0;i--){
        if(A[i]==pos)pos=B[i];
        else if(B[i]==pos)pos=A[i];

        swap(latte[A[i]],latte[B[i]]);


        if(pos>0)ex[latte[pos-1]]=true;
        ex[latte[pos]]=true;
        if(pos+1<N)ex[latte[pos+1]]=true;
    }

    cout<<accumulate(ex,ex+N,0ll)<<endl;
    return 0;
}


Measured memory_bytes: 2688
import java.util.Scanner;

/**
 * 鈴木くんの参考 与えられた２つのサイコロが同じものかどうかを判定する
 * 
 * @author U633758
 *
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		Dice4 dc = new Dice4();
		Dice4 hikaku_dc = new Dice4();
		dc.dice(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
		
		boolean same_flag = false;	//ごめんなさい、フラグ使いました
		for(int i = 0; i < count -1  ; i++){
			hikaku_dc.dice(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
			if (dc.check(hikaku_dc)) {	//同じものが一つでもあると即実行
				System.out.println("No");
				same_flag = true;
				break;
			}
		}
		//全部違うときにやっと入力
		if(!same_flag){
			System.out.println("Yes");
		}
		sc.close();// Scannerを閉じる


	}
}

/**
 * Dice4クラス ダイスの面に数字をインプットする。回転させたりする。
 * 
 * @author U633758
 *
 */
class Dice4 {
	private int T, S, E, W, N, U;

	Dice4() {
		this.T = 0; // Top
		this.S = 0;
		this.E = 0;
		this.W = 0;
		this.N = 0;
		this.U = 0; // Under
	}

	/**
	 * Diceに数字をインプットする
	 * 
	 * @param T_1
	 *            真上
	 * @param S_2
	 *            南
	 * @param E_3
	 *            東
	 * @param W_4
	 *            西
	 * @param N_5
	 *            北
	 * @param U_6
	 *            真下
	 */
	void dice(int T_1, int S_2, int E_3, int W_4, int N_5, int U_6) {
		this.T = T_1; // Top
		this.S = S_2;
		this.E = E_3;
		this.W = W_4;
		this.N = N_5;
		this.U = U_6; // Under
		// TODO 自動生成されたコンストラクター・スタブ
	}

	/**
	 * 南方向にサイコロを傾ける
	 */
	void MoveSouth() {
		int a = T;
		T = N;
		N = U;
		U = S;
		S = a;
	}

	void MoveEast() {
		int a = T;
		T = W;
		W = U;
		U = E;
		E = a;
	}

	void MoveNorth() {
		int a = T;
		T = S;
		S = U;
		U = N;
		N = a;
	}

	void MoveWest() {
		int a = T;
		T = E;
		E = U;
		U = W;
		W = a;
	}

	void right() {// 時計周りの回転
		int a = S;
		S = E;
		E = N;
		N = W;
		W = a;
	}

	/**
	 * 
	 * @param t
	 *            真上の数字（上面）
	 * @param f
	 *            南側の数字（前面）
	 * @return 東側（側面）の求めるべき数字
	 */
	int getRight(int t, int f) {
		for (int i = 0; i < 3; i++) {
			if (t == T) {
				break;
			}
			MoveNorth();
			if (t == T) {
				break;
			}
			MoveWest();
		}
		for (int i = 0; i < 3; i++) {
			if (f == S) {
				break;
			}
			right();
		}
		return E;
	}

	/**
	 * 引数と同じサイコロであるか判定する
	 * 
	 * @param hikaku
	 *            比較するサイコロ
	 * @return true:同じ false:異なる
	 */
	boolean check(Dice4 hikaku) {
		for (int i = 0; i < 4; i++) {
			if (checkAll(hikaku)) {
				break;
			}
			MoveNorth();
			for (int j = 0; j < 4; j++) {
				if (checkAll(hikaku)) {
					break;
				}
				right();
			}
		}

		for (int i = 0; i < 4; i++) {
			if (checkAll(hikaku)) {
				break;
			}
			MoveWest();
			for (int j = 0; j < 4; j++) {
				if (checkAll(hikaku)) {
					break;
				}
				right();
			}
		}
		if (checkAll(hikaku)) {
			return true;
		}
		return false;
	}

	boolean checkAll(Dice4 hikaku) {
		if (this.T == hikaku.T && this.S == hikaku.S && this.W == hikaku.W && this.E == hikaku.E && this.N == hikaku.N
				&& this.U == hikaku.U) {

			return true;
		}
		return false;
	}

}


Measured memory_bytes: 28220
"use strict";

function main(input){
  const args = input.trim();
  const WORDS = ["dream","dreamer","erase","eraser"].map(_=>_.split('').reverse().join("")); 
  const s = args.split('').reverse().join(""); 
  
  let idx = 0;
  while(true){
    var w = WORDS.find(_=> s.startsWith(_, idx));
    if(!w) break;
    idx += w.length;
  }
  console.log(idx === s.length ? "YES" : "NO");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 9624
from itertools import permutations
from heapq import heappop, heappush


def main():
    *A, = map(int, open(0).read().split())
    initial = get_hash(A)
    goal = get_hash([1, 2, 3, 4, 5, 6, 7, 8, 0])

    ans = search(initial, goal)
    print(ans)


def get_hash(A):
    board = 0
    for i, a in enumerate(A):
        board += a << i*4
    return board


def gen_move_table():
    mask = 0b1111
    dirs = [(-1, 0), (0, -1), (0, 1), (1, 0)]
    ret = [[] for _ in [0]*9]
    for y in range(3):
        for x in range(3):
            i = 3*y+x
            for dy, dx in dirs:
                dr = 3*dy+dx
                if 0 <= y+dy < 3 and 0 <= x+dx < 3:
                    sqmask = mask << (i+dr)*4
                    ret[i].append((dr, sqmask))
    return ret


def gen_next_board(board, move_table):
    mask = 0b1111
    ret = []
    for i in range(9):
        piece = board >> 4*i & mask
        if piece == 0:
            for move in move_table[i]:
                ret.append(do_move(board, move))
    return ret


def do_move(board, move):
    dr, sqmask = move

    sq = board & sqmask
    board ^= sq
    if dr > 0:
        board ^= sq >> dr*4
    else:
        board ^= sq << -dr*4

    return board


def heuristic(board):
    mask = 0b1111
    h = 0
    for i in range(9):
        y, x = divmod(i, 3)

        piece = board >> 4*i & mask
        if piece == 0:
            py, px = 2, 2
        else:
            py, px = divmod(piece-1, 3)
        h += abs(py-y)+abs(px-x)

    return h


def search(initial, goal):
    move_table = gen_move_table()

    dist = {}
    q = []

    dist[initial] = 0
    heappush(q, (heuristic(initial), 0, initial))
    while q:
        _, d, board = heappop(q)

        if board == goal:
            return d

        if board in dist and d > dist[board]:
            continue
        dist[board] = d

        for nboard in gen_next_board(board, move_table):
            nd = d + 1
            if (
                nboard not in dist or
                nboard in dist and nd < dist[nboard]
            ):
                heappush(q, (nd+heuristic(nboard), nd, nboard))


if __name__ == '__main__':
    main()



Measured memory_bytes: 8200
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
ll a,b;
int main(){ //srand((unsigned)time(NULL));
  cin >> a >> b;
  cout << a/b << " ";
  cout << a%b << " ";
  cout << syo(6) << (double)a / (double)b << endl;
}



Measured memory_bytes: 3272
#include <stdio.h>

int main(void)
{
	int i, n, a;
	long int goukei = 0;
	int M = -1000000, m = 10000000;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &a);
		goukei = goukei + a;

		if (a >= M)
		{
			M = a;
		}
		if (a <= m)
		{
			m = a;
		}
	}

	printf("%d %d %ld\n", m, M, goukei);

	return 0;
}



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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

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

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

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

  var(i64, N, M);

  i64 res = 0;

  res += min(M / 2, N);
  M -= min(2 * N, 2 * (M / 2));
  res += M / 4;

  outl(res);

  return 0;
}


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

vector<long long> input(int N){
    int i;
    vector<long long> output(N);
    for(i=0;i<N;i++)cin>>output[i];
    return output;
}

int main(){
    int N,i;
    long long result=0;
    vector<long long> A,B;
    cin>>N;
    A=input(N+1);
    B=input(N);

    for(i=0;i<N;i++){
        result+=min(A[i],B[i]);
        B[i]-=min(A[i],B[i]);
        result+=min(A[i+1],B[i]);
        A[i+1]-=min(A[i+1],B[i]);
    }

    cout<<result<<endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
	using namespace std;
	#define sim template < class c
	#define ris return * this
	#define dor > debug & operator <<
	#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
	sim > struct rge { c b, e; };
	sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
	sim > auto dud(c* x) -> decltype(cerr << *x, 0);
	sim > char dud(...);
	struct debug {
	#ifdef LOCAL
	~debug() { cerr << endl; }
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
	}
	#else
	sim dor(const c&) { ris; }
	#endif
	};
	#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
	#define deb debug()
	#define lel(...) deb << " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
	#define ll long long
	#define all(x) (x).begin(), (x).end()
	// 
using namespace std;
 
const int N = 50010;
ll mod = 998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} 


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}



	
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
 int i,j;
 char str[12];
 while(fgets(str,12,stdin)!=NULL){
  i=10;
  while(i>0){
   for(j=0;j<i-1;j++){
    str[j]='0'+((str[j]-'0')+(str[j+1]-'0'))%10;
   }
   i--;
  }
  printf("%c\n",str[0]);
 }
 return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> &a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
template<class T>void prArr(T a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

const int N = 20000000;
_int p[N];


void calc(){
  p[0] = p[1] = 1;
  for(Int i=2; i * i < N; i++){
    if(p[i] == 1) continue;
    for(Int j=2;i * j < N; j++) p[i * j] = 1;
  }
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  calc();

  Int n;
  cin>>n;
  Int cnt = 0;
  for(Int i=0;i<=n;i++){
    if(p[i] == 0 && p[i+2] == 0) cnt++;
  }

  Int ans= cnt * 2;
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 81336
#include<iostream>
#include<cmath>
using namespace std;
int main(){
 int n,k;
 cin>>n>>k;
 int sum = 1; 
 
   for(int i = 0; i<n; i++){
       sum = min(sum*2,sum+k);
   }
   cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define MOD 1000000007
#define lowbit(x) (x&-x) 
using namespace std; 
const int MAXN = 500005; 
int a[MAXN],n,c[MAXN];
typedef long long ll;
inline void add(int &x,int a)
{
	x+=a;
	if(x>=MOD)x-=MOD;
}
inline void add(int x)
{
	for(;x<=n;x+=lowbit(x))add(c[x],1);
}
inline int sum(int x) {
	int ret=0;
	for(;x;x-=lowbit(x))add(ret,c[x]);
	return ret;
}
inline int ksm(int x,int k)
{
	int ret=1;
	while(k){
		if(k&1)ret=(ll)ret*x%MOD;
		x=(ll)x*x%MOD;
		k>>=1;
	}
	return ret;
}
int s[MAXN];
int ans=0,tot,fac[MAXN],t[MAXN],inv,inv1,ave;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
		if(a[i])s[a[i]]=1;
		else ++tot;
	}
	for(int i=1;i<=n;++i){
		if(!s[i])add(ave,i-1);
		s[i]=s[i-1]+s[i];
	}
	inv=ksm(tot,MOD-2);
	inv1=ksm(tot-1,MOD-2);
	int now=0,t=0;
	for(int i=1;i<=tot;++i){
		add(t,(ll)(i-1)*inv1%MOD);
	}
	fac[0]=1;
	for(int i=1;i<=n;++i)fac[i]=(ll)fac[i-1]*i%MOD;
	t=(ll)t*inv%MOD;
	int del=0;
	for(int i=1;i<n;++i){
		int o=sum(a[i]);
		if(!a[i])add(ans,(ll)(((ll)ave*inv%MOD-(ll)now*t%MOD+MOD)%MOD-del+MOD)%MOD*fac[tot]%MOD*fac[n-i]%MOD);
		else add(ans,(ll)(((a[i]-1+MOD)%MOD-o+MOD)%MOD-(ll)now*(a[i]-s[a[i]])%MOD*inv%MOD+MOD)%MOD*fac[tot]%MOD*fac[n-i]%MOD);
		if(a[i]) add(del,(ll)(tot-(a[i]-s[a[i]]))*inv%MOD),add(a[i]);
		else ++now;
	}
	add(ans,fac[tot]);
	cout<<ans<<endl;
	return 0;
}  


Measured memory_bytes: 8064
import collections
def solve(S):
    r_ix = len(S)
    while len(S):
        is_hit = False

        for word in ['dream', 'dreamer', 'erase', 'eraser']:
            l_ix = r_ix - len(word)
            if S[l_ix:r_ix] == word:
                S = S[:l_ix]
                r_ix = l_ix
                is_hit = True

        if not is_hit:
            return "NO"
                
    return "YES"


def solve2(S):
    word = ['dream', 'dreamer', 'erase', 'eraser']
    buf = []
    for ch in S:
        buf.append(ch)
    curchar = ''
    while len(buf) > 0:
        c = buf.pop()
        curchar = c + curchar
        if curchar in word:
            curchar = ''

    if curchar == '':
        return "YES"

    return "NO"

if __name__ == "__main__":
    S = input()
    print(solve2(S))


Measured memory_bytes: 4340
function Main(input) {
    if (input < 1200) {
        input = Math.floor(Math.random() * (input + 1));
        console.log('ABC');
    }
    if (input >= 1200 && input < 2800) {
        input = Math.floor(Math.random() * (input + 1));
        console.log('ARC');
    }
    if (input <= 4208) {
        input = Math.floor(Math.random() * (input + 1));
        console.log('AGC');
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
# https://atcoder.jp/contests/abc098/tasks/abc098_b
n = int(input())
s = input()
r = []
for i in range(len(s) - 1):
    x = s[:i+1]
    y = s[-len(s) + 1 + i:]
    r.append(len(set(x) & set(y)))
print(max(r))


Measured memory_bytes: 2940
R, G, B, N = map(int, input().split())

ans = 0
for i in range(3001):
    for j in range(3001):
        b = (N-i*R-j*G)/B
        if b.is_integer() and b >= 0:
            ans += 1
        if b < 0:
            break

print(ans)

Measured memory_bytes: 40556
#include<iostream>
using namespace std;
typedef long long ll;
ll ax,mx,ay,my,az,mz,tmp,a,b,c,nx,ny,nz;
ll compute(ll x,ll y){
  a=x;
  b=y;
  c=x%y;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
  return x/b*y;
}
ll compute2(ll a,ll m){
  b=1;
  c=1;
  b=b*a%m;
  while(b!=1){
    b=b*a%m;
    c++;
  }
  return c;
}

int main(){
  while(cin>>ax>>mx>>ay>>my>>az>>mz&&mx){
    nx=compute2(ax,mx);
    ny=compute2(ay,my);
    nz=compute2(az,mz);
    cout<<compute(nx,compute(ny,nz))<<endl;
  }
  return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    string s1, s2, s3;
    int a = 'a' - 'A';
    cin >> s1 >> s2 >> s3;
    cout << char(s1[0] - a) << char(s2[0] - a) << char(s3[0] - a) << endl;
}


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

int main(){
    int n, d; cin >> n >> d;
    int x[n],y[n];
    rep(i,n) cin >> x[i] >> y[i];
    int ans = 0;
    rep(i,n) {
        ll dis = (ll)x[i]*x[i] + (ll)y[i]*y[i];
        if(dis <= (ll)d*d) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5184
#include <iostream>
#include <cstdlib>
#define MAX_SIZE 101
using namespace std;

int main () {
  while( 1 ) {
    int n, w, h, s, t;
    int mesh[ MAX_SIZE ][ MAX_SIZE ] = {0};

    cin >> n;
    if( !n ){ return EXIT_SUCCESS; }
    cin >> w >> h;
    for( int i = 0; i < n; i++ ) {
      int xi, yi;
      cin >> xi >> yi;
      mesh[ xi ][ yi ] = 1;
    }
    cin >> s >> t;
    
    int maxt = 0;
    for( int y = 1; y <= h - t + 1; y++ ) {
      for( int x = 1; x <= w - s + 1; x++ ) {
        int counter = 0;
        for( int j = 0; j < t; j++ ) {
          for( int i = 0; i < s; i++ ){
            if( mesh[ x + i ][ y + j ] ) {
              counter++;
            }
          }
        }
        if( counter > maxt ){
          maxt = counter;
        }
      }
    }
    cout << maxt << endl;   
  }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define ii pair<int,int>
#define fi first
#define se second

using namespace std;

vector<ii> vec[20];
int cnt[20];

int main()
{
    int n,res=0;
    scanf("%d",&n);
    for (int i=0;i<n;i++)
    {
        vec[i].clear();
        scanf("%d",&cnt[i]);
        for (int j=1,x,y;j<=cnt[i];j++)
        {
            scanf("%d%d",&x,&y);
            vec[i].emplace_back(ii(x,y));
        }
    }
    int lim=1<<n;
    for (int cur=0;cur<lim;cur++)
    {
        int tmp=0;
        bool flag=true;
        for (int i=0;i<n;i++)
            if (cur&(1<<i)) 
            {
                tmp++;
                for (int j=0;j<cnt[i];j++)
                {
                    int x=vec[i][j].fi,y=vec[i][j].se;
                    x--;
                    bool tt=(cur&(1<<x))>0;
                    if (tt!=y) {
                        flag=false;
                        break;
                    }
                }
                if (!flag) break;
            }
        if (flag) res=max(res,tmp);
    }
    printf("%d\n",res);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,n;
	long long a[10005],b[10005],suma,sumb,t,count=0,s1=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	 scanf("%lld",&a[i]);
	for(i=0;i<n;i++)
	 scanf("%lld",&b[i]);
		suma=0;sumb=0;
	  for(i=0;i<n;i++)
	  {
	  	suma+=a[i];
	  	sumb+=b[i];
	  }
	  t=sumb-suma;
	  	 for(i=0;i<n;i++)
	  	 {
	  	 	if(a[i]<b[i])
	  	 	{
	  	 	  s1=s1+(b[i]-a[i])/2;
			  if((b[i]-a[i])%2!=0) 
			  {
			  	 s1++;
			  }
			}
		 }
		 if(s1>t) count=-1;
		 else
		 	count=1;
  if(count==-1)  printf("No\n");
  else  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=2e5+5;
int n,m,i,now,x,y,et,he[N],g[N],cnt;
long long sum,ans;
struct edge{int l,x;}e[N];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
void line(int x,int y){
	e[++et].l=he[x];he[x]=et;e[et].x=y;
}
void add(int x,int k){
	for (int i=he[x];i;i=e[i].l){
		int y=e[i].x;
		if (y<=now) sum-=(now-y)*k,cnt+=k;
		if (y>0&&y<=m) g[y]+=k;
	}
}
int main(){
	n=read();m=read();x=read();
	for (i=2;i<=n;i++){
		y=x;x=read();
		if (y<=x) sum+=x-y,line(x,y);
		else sum+=m+x-y,line(x,y-m),line(x+m,y);
	}
	ans=sum;
	for (i=1;i<=m;i++) add(i,1);
	for (now=1;now<=m;now++){
		if (sum<ans) ans=sum;
		sum-=cnt;cnt+=g[now];
		add(now,-1);add(now+m,1);	
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2944
from decimal import Decimal
from math import log2, ceil
N, K = list(map(int, input().strip().split()))
r = max(N - (K - 1), 0) # 確実に勝てるケース

t = Decimal(0)
d = Decimal(N)
for i in range(1, N-r +1):
    t += 1/d * (Decimal(0.5) ** Decimal(ceil(log2(K/i))))

if r > 0:
    t += Decimal(r) / Decimal(N)

print(str(t)[:14])



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

#define MAX_N 2000

long long n;
long long maxn;

int main() {
	while (cin >> n) {
		maxn = 9999999999;
		if (n == 0) { break; }
		for (long long i = 1; i <= MAX_N; i++) {
			for (long long j = 1; j <= MAX_N; j++) {
				long long v = i*i*i + j*j*j;
				if (n*n*n >= v) {
					maxn = min(maxn, n*n*n - v);
				}
			}
		}
		cout << maxn << endl;
	}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq              priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
}

int32_t main()
{
	c_p_c();
	int n,k;
	cin>>n>>k;
	unordered_map<int,int>mp;
	for(int i=0;i<k;i++)
	{
		int a;
		cin>>a;
		int arr[a];
		for(int i=0;i<a;i++)
		{
			cin>>arr[i];
			mp[arr[i]]++;
		}
		
	}
	int c=0;
	for(int i=1;i<=n;i++)
	{
		if(mp.find(i)==mp.end())
		c++;
	}
	cout<<c<<endl;
	
	return 0;
}


Measured memory_bytes: 3660
x,y,z,k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

li = []
ans = []

for i in a:
    for j in b:
        li.append(i + j)
        
li.sort(reverse = True)
li = li[:min(k,x*y)]

for i in c:
    for j in li:
        ans.append(i + j)
        
ans.sort(reverse = True)

for i in range(k):
    print(ans[i])

Measured memory_bytes: 160444
#include<iostream>
#include<algorithm>
using namespace std;
int n,b[105],ans;
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a;cin>>a;
        b[i]=a;
    }
    ans+=b[0]+b[n-2];
    for(int i=1;i<n-1;i++){
        ans+=min(b[i-1],b[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
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 lint mod = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<double, lint> Pa;

lint R, C, K, r, c, v;

lint dp[3030][3030][4];
lint arr[3000][3000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> R >> C >> K;
	REP(i, R + 1) {
		REP(j, C + 1) {
			REP(k, 4) {
				dp[i][j][k] = -INF;
			}
		}
	}
	REP(i, R) {
		REP(j, C) {
			arr[i][j] = 0;
		}
	}
	REP(i, K) {
		cin >> r >> c >> v; r--; c--;
		arr[r][c] = v;
	}
	dp[0][0][0] = 0;
	REP(i, R) {
		REP(j, C) {
			IREP(k, 3) if (dp[i][j][k] >= 0) chmax(dp[i][j][k + 1], dp[i][j][k] + arr[i][j]);
			REP(k, 4){
				if (dp[i][j][k] >= 0) {
					chmax(dp[i][j + 1][k], dp[i][j][k]);
					chmax(dp[i + 1][j][0], dp[i][j][k]);
				}
			}
		}
	}
	lint ans = -INF;
	REP(i, 4) chmax(ans, dp[R - 1][C - 1][i]);
	cout << ans << endk;
}


Measured memory_bytes: 358044
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

int main()
{
	ll n;

	lscn(n);

	ll ans=1;

	ll val=n-1;

	if(val!=1)
	ans++;

	for(int i=2;1LL*i*i<=val;i++)
	if(val%i==0)
	{
		ans++;

		if(val/i!=i)
		ans++;
	}

	//cout<<ans<<endl;

	for(int i=2;1LL*i*i<=n;i++)
	if(n%i==0)
	{
		ll here=n,fac=i;

		while(here%fac==0)
		here/=fac;

		if(here%fac==1)
		ans++;

		if(i!=n/i)
		{		
			here=n,fac=n/i;

			while(here%fac==0)
			here/=fac;

			if(here%fac==1)
			ans++;
		}
	}

	lpri(ans);

    return 0;
}

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



int main() {
	int n;
	scanf("%d", &n);
	vector<pair<int,int>> a(n);
	int streak = 0;
	for(int i = 0; i < n; ++i) {
		scanf("%d%d", &a[i].first, &a[i].second);
		if(a[i].first == a[i].second) {
			streak++;
		}
		else {
			streak = 0;
		}
		if(streak == 3) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
    long long A,B,N,ans;
    cin >> N >> A >> B;
    if(A > B) ans = 0;
    else if(N == 1 && A != B) ans = 0;
    else ans = (N-2)*(B-A) + 1;
    cout << ans << endl;
    return 0;
}


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

int main(int argc, char *argv[]) {
	//  偶数と奇数は50個ずつある
	//  それぞれ取り出す組み合わせはたかだか 50 * 49 通りしかない
	int K = 0;
	std::cin >> K;

	int answer = 0;
	for (int i = 1; i <= K; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j <= K; j++) {
				if (j % 2 == 1) {
					answer++;
				}
			}
		}
	}

	std::cout << answer << std::endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    n, *a = map(int, open(0).read().split())
    x1 = sum(a[::2]) - sum(a[1::2])
    x = [0] * n
    x[0] = x1
    for i, j in enumerate(a[:-1], 1):
        x[i] = 2 * j - x[i - 1]
    ans = ' '.join(map(str, x))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19164
#include <stdio.h>

int main(void)
{
    int m, f, r, mf;

    scanf("%d %d %d", &m, &f, &r);

    while ((m != -1) || (f != -1) || (r != -1)) {
        if ((m == -1) || (f == -1) ) {
            printf("F\n");
        } else {
            mf = m + f;
            if (mf >= 80) {
                printf("A\n");
            } else if (mf >= 65) {
                printf("B\n");
            } else if (mf >= 50) {
                printf("C\n");
            } else if (mf >= 30) {
                if (r >= 50) {
                    printf("C\n");
                } else {
                    printf("D\n");
                }
            } else {
                printf("F\n");
            }
        }
        scanf("%d %d %d", &m, &f, &r);
    }

    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'


int main() {
	#ifndef ONLINE_JUDGE
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n, x, t; cin >> n >> x >> t;
	ll d = n/x;
	if (n % x != 0) d += 1;
	cout << d*t << endl;

	return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<fstream>
#include<math.h>
#include<algorithm>
using namespace std;

int main()
{
    int s[5];
    int n=5,num=0;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        if(s[i]==0)
            num=i+1;
    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,M,T;
P H[311];
int dp[311];

int solve(int id){
  if( dp[id] != -1 ) return dp[id];
  if( id == 0 ) return 0;
  int res = 0;
  for(int i=0;i<id;i++){
    if( H[id].first > H[i].first && H[id].second > H[i].second )
      res = max( res, solve(i) + 1 );
  }
  return dp[id] = res;
}

int main(){

  while( cin >> N && N ){
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++) cin >> H[i].first >> H[i].second;
    cin >> M;
    for(int i=0;i<M;i++) cin >> H[i+N].first >> H[i+N].second;
    
    sort(H,H+N+M);
    H[N+M] = P(100000,100000);
    cout << solve(N+M) << endl;
  }
}

Measured memory_bytes: 1168
#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>;
int main() {
  int h = 0;
  ll x;
  cin >> x;
  while (x > 0) {
    if (x - 500 >= 0) {
      h += 1000;
      x -= 500;
    } else if (x - 100 >= 0) {
      h += 100;
      x -= 100;
    } else if (x - 50 >= 0) {
      h += 50;
      x -= 50;
    } else if (x - 10 >= 0) {
      h += 10;
      x -= 10;
    } else if (x - 5 >= 0) {
      h += 5;
      x -= 5;
    } else {
      break;
    }
  }
  cout << h << endl;
  return 0;
}

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

int main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N);
    vector<int> y(M);

    for(int i = 0; i < N; i++) cin >> x[i];
    for(int i = 0; i < M; i++) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    int Z = x[N-1] + 1;
    if(Z > X && Z <= Y && Z <= y[0]) cout << "No War" << endl;
    else cout << "War" << endl;
}

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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var l = new List<Tuple<int,int>>();

            for(int i = 0; i < n; i++){
                var _ = Console.ReadLine().Split();
                var x = int.Parse(_[0]);
                var y = int.Parse(_[1]);
                l.Add(Tuple.Create(x,y));
            }

            var total = 0.0;
            var count = 0;
            foreach(var i in Enumerate(Enumerable.Range(0, n).ToArray())){
                for(var j = 0; j < i.Length - 1; j++){
                    var p1 = l[i[j]];
                    var p2 = l[i[j+1]];
                    var len =  Math.Sqrt(Math.Pow(p1.Item1 - p2.Item1, 2) + Math.Pow(p1.Item2 - p2.Item2, 2));
                    total += len;
                }
                count++;
            }

            Console.WriteLine(string.Format("{0:f10}",total / count));
        }

        static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items){
            if (items.Count() == 1){
                yield return new T[]{items.First()};
                yield break;
            }

            foreach (var item in items){
                var leftside = new T[]{item};
                var unused = items.Except(leftside);
                foreach(var rightside in Enumerate(unused)){
                    yield return leftside.Concat(rightside).ToArray();
                }
            }
        }
    }
}


Measured memory_bytes: 21336
#include <stdio.h>
typedef long long int ll;
 
int main(void) {
  int scan;
  ll  n;
  ll  answer;
 
  scan = scanf("%lld", &n);
  answer = 0;
  for (ll k = 1; k <= n; k++) {
    answer += ((n / k) * (n / k + 1) / 2) * k;
  }
  printf("%lld", answer);
  return (0);
}


Measured memory_bytes: 1732
let () =
  let a, b, c = Scanf.scanf "%c%c%c\n" (fun a b c -> a, b, c) in
  700
  |> (+) (if a = 'o' then 100 else 0)
  |> (+) (if b = 'o' then 100 else 0)
  |> (+) (if c = 'o' then 100 else 0)
|> Printf.printf "%d\n"


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

typedef long long int ll;
ll cnt = 0;
void dfs(ll n, ll d, string s,char h = 'a')
{
    if(s[s.size() - 1] > h + 1){
        return;
    }

    if(d - 1 == n){
        cout << s << "\n";
        return;
    }
    h = max(h, s[s.size() - 1]);
    char t = 'a';
    for(ll i = 0;i < d;i++){
        s.push_back(t);
        dfs(n, d + 1, s, h);
        s.pop_back();
        t += 1;
    }
}

int main()
{
    ll n;
    cin >> n;
    string s;
    s.push_back('a');
    dfs(n, 2, s);


    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void){
    
        int a, b;
        int i;
    
        printf("\n");
        scanf("%d%d", &a, &b);
        
    
        if(a>b)
        {
            //printf("33");
            
            for(i=0;i<a;i++){//1번, 2번,..., a번 반복
                printf("%d", b);
                
            }
             
        }
        else
        {
            //printf("44");
            
            for(i=0;i<b;i++){//1번, 2번,..., b번 반복
                printf("%d", a);
            }
             
        }
        
    return 0;
}


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

int main() {
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
    cin>>ar[i];
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(ar[i]==ar[i-1])
        {   ans++;
            ar[i]=99;
            if(i<n-1)
           { if(ar[i]==ar[i+1]){ar[i]=100;
           if(ar[i-1]==100)ar[i]=101;}
               
           }
        }
    }
    cout<<ans<<'\n';
	// your code goes here
	return 0;
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d %d\n" @@ fun h n ->
  let abs = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  let dp = Array.make (h + 10001) 1145141919810 in
  dp.(0) <- 0;
  Array.iter (fun (a, b) ->
    for i = a downto 0 do
      dp.(i) <- min b dp.(i)
    done) abs;
  for i = 0 to h do
    Array.iter (fun (a, b) ->
      dp.(i + a) <- min dp.(i + a) (dp.(i) + b)) abs
  done;
  Printf.printf "%d\n" @@ dp.(h)


Measured memory_bytes: 3584
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    if (c>=a and c<=b) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3600
N = int(input())
pointR = []
pointB = []
for i in range(N):
    pointR.append(list(map(int, input().split())))
for i in range(N):
    pointB.append(list(map(int, input().split())))
pointR.sort(key = lambda t: t[0], reverse = True)
pointB.sort(key = lambda t: t[1])
ans = 0

Aok = [True] * N
Bok = [True] * N

for i in range(N):
    for j in range(N):
        if Aok[j] and Bok[i]:
            if pointR[j][0] < pointB[i][0] and pointR[j][1] < pointB[i][1]:
                ans += 1
                Aok[j] = False
                Bok[i] = False
                break
print(ans)

Measured memory_bytes: 3064
def main():

    # 引数を受け取る
    r = float(input())

    pi = 3.141592653589

    area = pi * r * r
    length = 2 * pi *r

    print('{0:.8f} {1:.8f}'.format(area, length))
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 5588
ns = $<.map(&:to_i)[0..-2]
squares = (0..Math.sqrt(ns.max).to_i).map {|x| x * x}
m = squares.size-1

ns.each do |n| 
    count = 0 
    (0..m).each do |i| 
        x = squares[i]
        break if 4 * x > n 
        (i..m).each do |j| 
            y = squares[j]
            break if x + y * 3 > n 
            l = m 
            (j..m).each do |k| 
                z = squares[k]
                s = x + y + z 
                l -= 1 while s + squares[l] > n 
                break if l < k 
                count += 1 if s + squares[l] == n
            end
        end
    end 
    p count
end

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

int main() {
  string S;
  int N=0;
  cin >>S;
  for(int i=0;i<4;i++){
    if(S.at(i)=='+'){
      N++;
    }
    else{
      N--;
    }
  }
  cout <<N <<endl;
  
  return 0;
}


Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {

        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var s = Console.ReadLine().Trim();
            var sc = s.ToCharArray();
            var c = new int[n, 2];
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                c[i, 0] = int.Parse(line[0]) - 1;
                c[i, 1] = int.Parse(line[1]) - 1;
            }
            for (int i = n - 1; i >= 0; i--)
                calc(n, sc, c[i, 0], c[i, 1]);
            Console.WriteLine(new string(sc));
        }
    }
    static char conv(char a, int d)
    {
        var res = a - 'a' + d;
        if (res >= 26) res -= 26;
        return (char)(res + 'a');
    }

    static void calc(int n, char[] sc, int c1, int c2)
    {
        var w = sc[c1];
        sc[c1] = sc[c2];
        sc[c2] = w;
        var d = (c2 - c1) % 26;
        sc[c1] = conv(sc[c1], d);
        sc[c2] = conv(sc[c2], d);
    }
}



Measured memory_bytes: 15932
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

const ll RANDOM =chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
 

ll n;
vector<ll>a;
vector<ll>b;

ll T=100;

int main(){
FLASH;
srand(time(0));
cin>>n;
for(ll i=1;i<=n;i++)
{
  ll x;
  cin>>x;
  a.pb(x);
}

for(ll i=1;i<=n;i++)
{
  ll x;
  cin>>x;
  b.pb(x);
}

vector<ll>cp=b;
ll sig=0;

for(ll i=0;i<n;i++)
{
  if(a[i]==b[i]){sig=1;break;}
}

if(sig==0)
{
  cout<<"Yes"<<endl;
  vecc(b,n);
  return 0;
}

reverse(all(b));
sig=0;
for(ll i=0;i<n;i++)
{
  if(a[i]==b[i]){sig=1;break;}
}

if(sig==0)
{
  cout<<"Yes"<<endl;
  vecc(b,n);
  return 0;
}

b=cp;
while(T--)
{ 
  shuffle(all(b),rng);
  sig=0;
  for(ll i=0;i<n;i++)
  {
   if(a[i]==b[i]){sig=1;break;}
  }
  if(sig==0)
  {
   cout<<"Yes"<<endl;
   vecc(b,n);
   return 0;
  }

}

T=60;
b=cp;
while(T--)
{
  rotate(b.begin(),b.begin()+rng()%n,b.end());
  sig=0;
  for(ll i=0;i<n;i++)
  {
   if(a[i]==b[i]){sig=1;break;}
  }
  if(sig==0)
  {
   cout<<"Yes"<<endl;
   vecc(b,n);
   return 0;
  }
}


cout<<"No"<<endl;





return 0;
} 


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

int main(int argc, char const* argv[]) {
  string s;
  cin >> s;
  int size = s.size();

  bool ans = true;
  for (int i = 0; i < size; i++) {
    if ((i + 1) % 2 == 1) {
      if (s[i] == 'L')
        ans = false;
    } else {
      if (s[i] == 'R')
        ans = false;
    }
  }

  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int k,s,count=0;
    cin >> k >> s;
    for(int i=0;i<=k;i++){
        for(int z=0;z<=k;z++){
            if(s-i-z>=0&&s-i-z<=k){
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256