akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define Foru(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
int main()
{
	int n; cin >> n;
	int a[30] = {0}, b[30] = {0}, c[30] = {0};
	long long sum = 0;
	Foru(i, 1, n)
	{

		cin >> a[i];
	}
	Foru(i, 1, n)
	{

		cin >> b[i];
	}
	Foru(i, 1, n - 1)
	{

		cin >> c[i];
	}
	Foru(i, 1, n)
	{
		sum += b[a[i]];
		if (a[i - 1] + 1 == a[i])
			sum += c[a[i - 1]];
	}
	cout << sum << endl;
	return 0;
}

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


int countWays(int n)
{
    // To store count of such pairs
    int count = 0;

    // Counting number of pairs
    // upto sqrt(n) - 1
    for (int i = 1; i * i < n; i++)
        if (n % i == 0)
            count++;

    // To return count of pairs
    return count;
}

bool isPerfectSquare(long double x)
{
  // Find floating point value of
  // square root of x.
  long double sr = sqrt(x);

  // If square root is an integer
  return ((sr - floor(sr)) == 0);
}





int main(){

int n,sum=0;
  cin>>n;

  for(int i=1;i<n;i++){


  sum=sum+2*countWays(n-i)+isPerfectSquare(n-i);





  }



cout<<sum<<endl;



}


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

    signed main() {
        string s;int k;
        cin>>s>>k;
        for(int i=0;i<s.size()-1;i++){
            if(s[i]=='a')continue;
            if(('z'-s[i])+1<=k){
                k-=('z'-s[i])+1;
                s[i]='a';
            }
                
        }
        s[s.size()-1]=char('a'+(s[s.size()-1]+k-'a')%('z'-'a'+1));
        cout<<s;
    }


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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

//Warsaw debug template
#define LOCAL
#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 <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string s;
    cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) cout<<"Bad";
    else cout<<"Good";

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
# define INF 1e18
int main() {
	int n;
	cin>>n;
	int arr[n];
	long long prefix_sum[n+1];
	prefix_sum[0] = 0;
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	    prefix_sum[i+1] = prefix_sum[i] + arr[i];
	}
	long long dp[n][n];
	for(int i=0;i<n;i++){
	    dp[i][i] = 0;
	}
	for(int gap=1;gap<n;gap++){
	    for(int i=0;i<n-gap;i++){
	        int j = i + gap;
	        dp[i][j] = INF;
	        long long sum = prefix_sum[j+1] - prefix_sum[i];
	        for(int k=i;k<j;k++){
	            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j]);
	        }
	        dp[i][j] += sum;
	    }
	}
	cout<<dp[0][n-1];
	return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		for (int n = 1; n <= N; n++) {
			int count = 0;

			for (int x = 1; x < n; x++) {
				if (x * x >= n) break;
				for (int y = x; y < n; y++) {
					if (x * x + y * y >= n) break;
					for (int z = y; z < n; z++) {
						if (x * x + y * y + z * z >= n) break;
						if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
							if (x == y && y == z) {
								count +=1;
							} else if (x == y || y ==z){
								count +=3;
							} else {
								count +=6;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}


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

void prlr(int n){
	if(n<0){
		n=-n;
		while(n--){
			cout << "L";
		}
	}
	else{
		while(n--){
			cout << "R";
		}
	}
}

void prud(int n){
	if(n<0){
		n=-n;
		while(n--) cout << "D";
	}
	else while(n--) cout << "U";
}

int main(){
	int sx,sy,tx,ty;
	
	cin >> sx >> sy >> tx >> ty;
	prud(ty-sy);
	prlr(tx-sx);
	prud(sy-ty);
	prlr(sx-tx);
	if(tx>sx) prlr(-1);
	else prlr(1);
	if(ty>sy) prud(ty-sy+1);
	else prud(ty-sy-1);
	if(tx>sx) prlr(tx-sx+1);
	else prlr(tx-sx-1);
	if(tx>sx) prud(-1);
	else prud(1);
	
	if(tx>sx) prlr(1);
	else prlr(-1);
	if(ty>sy) prud(-ty+sy-1);
	else prud(-ty+sy+1);
	if(tx>sx) prlr(-tx+sx-1);
	else prlr(-tx+sx+1);
	if(tx>sx) prud(1);
	else prud(-1);
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int k, x;
    cin >> k >> x;

    int leftmost = max(-1000000, x-k+1);
    int rightmost = min(1000000, x+k-1);
    IFOR(i, leftmost, rightmost){
        cout << (i==leftmost ? "": " ") << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import Foundation
let arr = ["dream", "erase", "eraser", "dreamer"]
var S = readLine()!
var flag = false
repeat {
    flag = false
    for s in arr {
        if S.hasSuffix(s) {
            S = S.substringToIndex(S.endIndex.advancedBy(-s.characters.count))
            flag = true
        }
    }
} while flag
print(S=="" ?"YES":"NO")

Measured memory_bytes: 6240
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(),(x).end()
typedef unsigned long long int ll;
using namespace std;
ll part(ll n, ll m)
{
  if(n < m){
    return part(m, n);
  }
  return n*(n + 1)/2 + m*(m - 1)/2;
}
int main()
{
  string a;
  cin >> a;
  ll n = a.size();
  vector<ll > num(0,0);

  // cout << n << endl;		
  REP(i, n){
    ll tmp = 1;
    char c = a[i];
    // cout << "i1 = " << i <<endl;
    while(a[i + 1] == c){
      tmp ++;
      i ++;
    }
    // cout << "i2 = " << i <<"tmp = "<<tmp << endl;
    num.push_back(tmp);
  }
  ll nsize = num.size();
  // cout << "nsize = " << nsize << endl;
  // REP(i, nsize){
  //   cout << num[i] << endl;
  // }
  // cout << "check end "<< endl;
  ////////////////////
  if(nsize == 1){
    cout << n*(n + 1)/2 << endl;
    return 0;
  }
  ////////////////////
  ll ans = 0;
  if(a[0] == '<'){
    // cout << "begin with <" << endl;
    REP(i, nsize/2){
      // cout << num[2*i] << " " << num[2*i + 1] <<" " << part(num[2*i], num[2*i + 1])<< endl;
      ans += part(num[2*i], num[2*i + 1]);
    }
    if(nsize%2 != 0){
      // cout << "a[-1](<) = "<< a[n -1]<< "num[-1] = "<< num[nsize - 1] << endl;
      ans += part(num[nsize - 1], 0);
    }
  }else{
    // cout << "begin with >" << endl;
    ans += part(num[0],0);
    if(nsize == 2){
      ans += part(num[1], 0);
    }else{
      REP(i, nsize/2){
	// cout << 2*i + 1 << " " << 2*i + 2 << endl;
	ans += part(num[2*i + 1], num[2*i + 2]);
      }
      // cout << ans << endl;
      // if(nsize%2 == 0){
      // 	cout << "a[-1](>) = "<< a[n -1]<< "num[-1] = "<< num[nsize - 1] << endl;
      // 	ans += part(num[nsize - 1], 0);
      // }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3068
let s = read_line () in
let n = String.length s in
let rec palindrome a b =
    if a >= b then true else
        if s.[a] = s.[b] then palindrome (a + 1) (b - 1) else false
in
print_endline @@
    if palindrome 0 (n - 1) && palindrome 0 ((n - 3) / 2) && palindrome ((n + 1) / 2) (n - 1) then "Yes" else "No"

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <cfloat>

namespace
{
	struct equation
	{
		double a, b, c;
	};
	auto calculate_x = [](equation e1, equation e2)
	{
		return (e1.c * e2.b - e1.b * e2.c) / (e1.a * e2.b - e1.b * e2.a);
	};
	auto calculate_y = [](equation e1, equation e2)
	{
		return (e1.c * e2.a - e1.a * e2.c) / (e1.b * e2.a - e1.a * e2.b);
	};
	auto round_off = [](double d, unsigned int digit)
	{
		d *= std::pow(10, digit - 1);
		d = std::round(d);
		d /= std::pow(10, digit - 1);
		return d;
	};
}

namespace
{
	equation e1, e2;
}

int main()
{
	while (std::scanf("%lf", &e1.a) != EOF)
	{
		std::scanf("%lf%lf%lf%lf%lf", &e1.b, &e1.c, &e2.a, &e2.b, &e2.c);
		double x = round_off(calculate_x(e1, e2), 4);
		double y = round_off(calculate_y(e1, e2), 4);
		std::printf("%.3f %.3f\n", x + DBL_EPSILON, y + DBL_EPSILON);
	}
	return 0;
}


Measured memory_bytes: 2784
mod=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))
kk=k-1

cnt=0
res=0
for i in range(n):
    cnt=0
    rev=0

    for j in range(i+1,n):
        if a[i]>a[j]:
            cnt+=1
        if a[i]<a[j]:
            rev+=1
    res+=rev*((kk+1)*kk)//2
    res+=cnt*((k+1)*k)//2
    res%=mod

print(res)

Measured memory_bytes: 3188
/*
* Author : Omkar Deshmukh
*/
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define endl '\n'
#define all(v) v.begin(), v.end()
#define intvect vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define boolv vector<bool>
#define ld long double
#define deb(x) cout << #x << " " << x << endl;
#define pb push_back
#define pob pop_back
#define fom(i, k, p, q) for (int i = k; i < p; i += q)
#define F first
#define S second
#define ull unsigned long long
#define mkp make_pair

const ll mod = 1e9 + 7;
const ll N = (ll)5e5 + 4;
int n;

template <typename... T>
void read(T &... args)
{
    ((cin >> args), ...);
}

template <typename... T>
void write(T &&... args) //rvalue references
{
    ((cout << args), ...);
}

void vjudge()
{
#ifndef ONLINE_JUDGE
    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
bool isprime(int n)
{
    fom(i, 2, sqrt(n) + 1, 1) if (n % i == 0) return false;
    return true;
}
void solve()
{
    ll x;
    read(x);
    ll ans = 0;
    ll t = 0;
    while (1)
    {
        ans++;
        t += x;
        if (t % 360 == 0)
        {
            write(ans);
            return;
        }
    }
}

int main()
{
    vjudge();
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}


Measured memory_bytes: 3688
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as M




getBysplit = map read . words <$> getLine



count :: [String] -> [Int]
count lst = let
              xs = if (head . head) lst == '0' then [] : lst else lst
              ys = if (head . last) lst == '0' then xs ++ [] else xs
            in map length ys

solve :: Int -> M.Map Int Int -> Int -> Int
solve width mmap limit = foldl f 0 [0,2..limit]
      where
        f acc x = let
                    Just left = M.lookup x mmap
                    Just right = M.lookup (min (x + width) limit) mmap
                  in max (right - left) acc

main :: IO ()
main = do
  [n, k] <- getBysplit :: IO [Int]
  s <- getLine :: IO String
  let nums = (count . group) s --group 連続するものをリストに分割して二次元リストを返す
  let sums = scanl (+) 0 nums -- 累積和を作成する関数
  let width = 2 * k + 1
  let mmap = M.fromList $ zip [0..] sums
  print $ solve width mmap (length nums)


Measured memory_bytes: 48508
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


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


 ll s=0;
 for(ll i=0;i<n;i++) s ^= a[i];
 for(ll i=0;i<n;i++){
  if(i!=0)cout<<' ';
  cout<<(s^a[i]);
 }
 cout<<endl;


    return 0;
}


Measured memory_bytes: 4760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int n;cin>>n;
   int x[n];
   rep(i,n)cin>>x[i];
   int next[18][n+1];
   int l;cin>>l;
   rep(i,n)next[0][i]=(upper_bound(x, x+n, x[i]+l)-x)-1;
   next[0][n]=n;
   rep(i,17)rep(j,n+1)next[i+1][j]=next[i][next[i][j]];
   int q;cin>>q;
   while(q--){
       int a,b;
       cin>>a>>b;
       a--;b--;
       if(a>b)swap(a,b);
       int ans=1;
       for(int i=17;i>=0;i--){
           if(next[i][a]<b){
               a=next[i][a];
               ans+=(1<<i);
           }
       }
       cout<<ans<<endl;
   }
   return 0;
}

Measured memory_bytes: 8192
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

#define ll long long
#define ull unsigned long long
#define lld long double
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl '\n'
template <typename T> using mxpq = priority_queue<T>;
template <typename T> using mnpq = priority_queue<T, vt<T>, greater<T>>;
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)

#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"

const ll mod = 1e9 + 7;
const ll N = 6e4 + 6;
const ll maxN = 1e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

int dx[4] = { -1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// up, right, down, left
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions
//int dx[]={-2,-2,-1,1,-1,1,2,2};///Knight moves
//int dy[]={1,-1,-2,-2,2,2,-1,1};///Knight moves

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in4.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	FIO
	ll n;
	cin >> n;
	if (n == 1) {
		cout << 0;
	}
	else {
      // Principle of inclusion and exclusion
      // we start with all the cases and then remove those which we don't need
      // req ans = 10^n -9^n - 9^n + 8^n
      // total series - without 0 - without 9 + without 0 and 9
		ll tot = powerM(10, n);
		tot -= powerM(9, n);
		tot += mod;
		tot %= mod;
		tot -= powerM(9, n);
		tot += mod;
		tot %= mod;
		tot += powerM(8, n);
		tot %= mod;
		cout << tot << endl;
	}
	return 0;
}


Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
void end() {
	puts("NO");
	exit(0);
}
int main() {
	int h, w, n, sx, sy, sx2, sy2;
	string s, t;
	cin >> h >> w >> n >> sy >> sx >> s >> t;
	sx--, sy--;
	sx2 = sx, sy2 = sy;
	rep(i, 0, n) {
		if (s[i] == 'U') {
			sy--;
			if (sy < 0)end();
		}
		if (t[i] == 'D')sy++;
		sy = min(h - 1, sy);

		if (s[i] == 'D') {
			sy2++;
			if (sy2 >= h)end();
		}
		if (t[i] == 'U')sy2--;
		sy2 = max(0, sy2);

		if (s[i] == 'L') {
			sx--;
			if (sx < 0)end();
		}
		if (t[i] == 'R')sx++;
		sx = min(w - 1, sx);

		if (s[i] == 'R') {
			sx2++;
			if (sx2 >= w)end();
		}
		if (t[i] == 'L')sx2--;
		sx2 = max(0, sx2);
	}
	puts("YES");
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  char c;
  cin>>c;
  if(c=='A')c='T';
  else if(c=='T')c='A';
  else if(c=='G')c='C';
  else c='G';
  cout<<c<<nl;
}

int main()
{
    su;
    f();
    return 0;
}


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

int main() {

    int  a, b;
    char op;

    for ( ;; ) {

        std::cin >> a >> op >> b;

        switch ( op ) {

        case '+': std::cout << a + b << std::endl; break;
        case '-': std::cout << a - b << std::endl; break;
        case '*': std::cout << a * b << std::endl; break;
        case '/': std::cout << a / b << std::endl; break;
        case '?': goto END;

        }
    }

END:

    return 0;
}



Measured memory_bytes: 3080
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Main m = new Main();
        m.run();
    }
    
    public void run(){
        Scanner sc = new Scanner(System.in);
        
        for(;;){
            int n = sc.nextInt();
            if(n == 0) break;
            
            int sum = 0;
            int min = 1000;
            int max = 0;
            for(int i = 0 ; i < n ; i++){
                int buff = sc.nextInt();
                sum += buff;
                min = Math.min(min,buff);
                max = Math.max(max,buff);
            }
            int ans = (sum - min - max)/(n-2);
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 29464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int INF = 2e9;
 
int main(){
    string s;
    int count=0;
    cin >> s;
    for(int i=0; i<s.length(); i++){
        if(s[i]=='o'){
            count++;
        }
    }
    count += 15-s.length();
    if(count>=8) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
from copy import deepcopy

N = int(input())
A = list(map(int, input().split()))
ans = [0]*20
L = [[0]*20 for _ in range(N)]
for i in range(N):
    for j in range(20):
        if (A[i] >> j) & 1:
            L[i][j] += 1
# print(L)
x = deepcopy(L[0])
ct = 0
j = 0
flag = True
for i in range(N):
    while flag and j < N:
        j += 1
        if j == N:
            break
        for k in range(20):
            x[k] += L[j][k]
            if x[k] >= 2:
                flag = False
    ct += j-i
    for k in range(20):
        x[k] -= L[i][k]
    if all(x[k] <= 1 for k in range(20)):
        flag = True
    # print(x)
    # print(ct)
print(ct)


Measured memory_bytes: 138296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    int n, k; cin >> n >> k;
    string s; cin >> s;
    if(s[k-1]=='A'){
        s[k-1] = 'a';
    }else if(s[k-1]=='B'){
        s[k-1] = 'b';
    }else {
        s[k-1] = 'c';
    }
    cout << s << endl;

}


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
ans = 0
for i in a:
    ans += i-1
print(ans)

Measured memory_bytes: 39024
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll X;
    cin >> X;
    ll now = 100;
    int c = 0;
    while(1) {
        c++;
        now = now + now / 100;
        if(now >= X)
            break;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3676
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n, a;
  cin >> n >> a;
  n %= 500;
  if (n==0) cout << "Yes" << endl;
  else if (n<=a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	int N; cin >> N;
	vint X(N); cin >> X;
	int minv = INF;
	for (int x = 1; x <= 100; x++) {
		int sum = 0;
		for (auto &v : X) {
			sum += (v - x) * (v - x);
		}
		minv = min(minv, sum);
	}
	cout << minv << endl;
	return (0);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	n := nextInt()
	k := nextInt()
	var g, m int

	for i := 0; i < n; i++ {
		a := nextInt()
		if i == 0 {
			g = a
			m = a
		}
		g = gcd(g, a)
		m = max(m, a)
	}
	if k%g == 0 && k <= m {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

func gcd(x, y int) int {
	for y != 0 {
		x %= y
		x, y = y, x
	}
	if x < 0 {
		x *= -1
	}
	return x
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 2176
n, m = gets.split(" ").map(&:to_i)
brokens = []
m.times do
  brokens.push(gets.to_i)
end

memo = []
memo.push(1) #0マス先
memo.push(1) #1マス先
n.times do |index| #2マス先以降
  memo.push(memo[index] + memo[index + 1])
end

now = 0
multipliers = []
brokens.each do |broken|
  if now == broken
    puts 0
    exit
  end
  multipliers.push(memo[(broken - 1) - now])
  now = broken + 1
end

multipliers.push(memo[n - now])

answer = 1
multipliers.each do |multiplier|
  answer *= multiplier
  answer = answer % 1_000_000_007
end

puts answer

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

#define pb push_back
#define mp make_pair
#define ll long long int
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    

 	int n;
 	cin >> n;
 	int h[n];
 	for (int i=0;i<n;i++)
 	cin >> h[i];

 	int dp[n];
 	dp[1]=abs(h[1]-h[0]);

 	if (n>2)
 	{
 		dp[2]=min(dp[1]+abs(h[2]-h[1]),abs(h[2]-h[0]));
 		for (int i=3;i<n;i++)
 			dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));

 	}   
 	/*for (int i=0;i<n;i++)
 		printf("%d ",dp[i]);
 	cout << endl;*/
 	cout << dp[n-1] << endl;
	return 0;
}

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

tenki = input()
tenki = list(tenki)

max = 0

num = tenki.count("R")

if num == 0:
  out = 0
elif num == 1:
  out = 1
elif num == 3:
  out = 3
elif num == 2:
  if tenki[1]=="S":
    out = 1
  else:
    out = 2

print(out)

Measured memory_bytes: 26980
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, X[1 << 18], Y[1 << 18];
long long D, cnt = 0;

int main() {
	cin >> N >> D;
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i];
		if (X[i] * X[i] + Y[i] * Y[i] <= D * D) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> l(N);
    for(int i = 0; i < N; ++i) cin >> l[i];
    sort(l.begin(), l.end(), greater<int>());
    for(int i = 0; i < K; ++i) ans += l[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  double q = N / 3;
  long long w = q * q * q;
  int e = N % 3;
  if(e == 1) {
    double s = q + 0.33333333333;
    cout << fixed << setprecision(6) << s * s * s << endl;
  }
  else if(e == 2) {
    double s = q + 0.66666666666;
    cout << fixed << setprecision(6) << s * s * s << endl;
  }
  else if(e == 0) {
    cout << fixed << setprecision(6) << w << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    mint ans_n = 0;
    combination cb(n*m);

    rep(i, m){
      mint tans = 0;
      tans = n*n;
      tans *= i*(m-i);
      tans *= cb((n*m)-2, k-2);
      ans_n += tans;
    }

    rep(i, n){
      mint tans = 0;
      tans = m*m;
      tans *= i*(n-i);
      tans *= cb((n*m)-2, k-2);
      ans_n += tans;
    }

    cout << ans_n.x << endl;

}



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

using  namespace std;

#define FOR(x,z,y) for(int x = z; x < y; x++)
typedef long long ll;
typedef pair<int,int> iPair;






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

    string s;
    int counter=0, n;
    cin >> s;
    n = s.length();
    FOR(i,0,s.length()/2){
        if(s[i] == s[s.length()-i -1] ){
            counter++;
        }
    }
    if(counter == s.length()/2 && s[0] == s[((n-1)/2)-1] && s[((n+3)/2)-1] == s[n-1]){
        cout << "Yes";
    } else{
        cout << "No";
    }
}

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

int main(void) {
    int N,L;
    int val,sum,minval;
    cin >> N >> L;
    
    // L+(1karaN)-1 の最小
    minval = 1000;
    sum = 0;
    for(int i=0;i<N;i++) {
        val = L + i;
        if(abs(minval) > abs(val)) {
            minval = val;
        }
        sum += val;
    }

    cout << sum - minval << endl;

    return 0;
}


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


void solve(long long n, long long m){
    cout << (n-1) * (m-1) << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    long long m;
    scanf("%lld",&m);
    solve(n, m);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <array>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <stdexcept>


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


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// util
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

std::vector<std::string> split(const std::string& input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// user func
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


void printList(const vector<int>& list) {
    // print
    for(int i = 0; i < list.size(); i++){
        printf("%d", list[i]);
        if(i != list.size() -1){
            printf(" ");
        }
    }
    printf("\n");
}


bool isInteger(const string& input){
    try {
        std::stoi(input);
        return true;
    } catch(...) {
        return false;
    }
}
int calc(const string& expression, int lhs, int rhs) {
    if (expression == string("+")){
        return lhs + rhs;
    } else if (expression == string("-")){
        return lhs - rhs;
    } else if (expression == string("*")){
        return lhs * rhs;
    } else if (expression == string("/")){
        return lhs / rhs;
    } else {
        throw new std::runtime_error("invalid operator");
    }
}

void solve() {
    string buffer;
    std::getline(std::cin, buffer);
    vector<string> inputs = split(buffer, ' ');

    vector<int> values;
    for(auto each: inputs) {
        if(isInteger(each)) {
            values.push_back(std::stoi(each));
        }else{
            int rhs = values.back();
            values.pop_back();
            int lhs = values.back();
            values.pop_back();
            int result = calc(each, lhs, rhs);
            values.push_back(result);
        }
    }
    printf("%d\n", values.back());
}


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


Measured memory_bytes: 3412
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;

    int N, x[100] = {0}, A[100], B[100],K;
    int temp = 0;

    cin >> N >> K;
 
    for(int i = 0; i < N; i++)
    {
        cin >> x[i];
    }

    for(int i = 0; i < N; i++)
    {
        temp += (K - x[i] < x[i]) ? (K - x[i])*2 : x[i]*2;
    }

    cout << temp << endl;

}

Measured memory_bytes: 764
limit=50
graph=[[False]*limit for i in range(limit)]
visited=[]*limit

def dfs(v,n,graph,visited):
    visited[v]=True
    for v2 in range(n):
        if graph[v][v2]==False:
            continue
        if visited[v2]==True:
            continue
        dfs(v2,n,graph,visited)

n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
    ai,bi=map(int,input().split())
    a[i]=ai-1
    b[i]=bi-1
    graph[a[i]][b[i]]=True
    graph[b[i]][a[i]]=True
    
ans=0 
for i in range(m):
    graph[a[i]][b[i]]=False
    graph[b[i]][a[i]]=False
    visited=[False]*n
    dfs(0,n,graph,visited)
    bridge=False
    for j in range(n):
        if visited[j]==False:
            bridge=True
    if bridge:
        ans+=1
    graph[a[i]][b[i]]=True
    graph[b[i]][a[i]]=True
    
print(ans)

Measured memory_bytes: 3064
A=[]
B=[]
for i in range(5):
    a=int(input())
    A.append(((a-1)//10)*10+10)
    if a%10!=0:
        B.append(a%10)
if B==[]:
    print(sum(A))
else:
    print(sum(A)-10+min(B))

Measured memory_bytes: 38384
#B https://atcoder.jp/contests/abc134/tasks/abc134_b
n,d=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#n,d = map(int,"20 4".split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

dd=2*d+1
if(n%dd):
    print(int(n/dd)+1)
else:
    print(int(n/dd))

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

int main() {
    int K;
    cin >> K;
    vector<ll> runrun;
    rep(i,9) runrun.push_back(i+1);
    int a=0;
    while(runrun.size()<K){
        if(runrun[a]%10==0){
            runrun.push_back(runrun[a]*10);
            runrun.push_back(runrun[a]*10+1);
        }else if(runrun[a]%10==9){
            runrun.push_back(runrun[a]*10+8);
            runrun.push_back(runrun[a]*10+9);
        }else{
            runrun.push_back(runrun[a]*10+(runrun[a]%10-1));
            runrun.push_back(runrun[a]*10+(runrun[a]%10));
            runrun.push_back(runrun[a]*10+(runrun[a]%10+1));
        }
        a++;
    }
    cout << runrun[K-1] << endl;
}

Measured memory_bytes: 4260
#include<stdio.h>

int main(void) {
	int year, month, day;
	int x = 0;

	scanf("%d", &year);
	getchar();
	scanf("%d", &month);
	getchar();
	scanf("%d", &day);

	x = month * 100 + day;

	if (year>2019) {
		puts("TBD");
	}else {
		if(year==2019&&x > 430)		puts("TBD");
		else puts("Heisei");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vl ww(10),kk(10);
	rep(i,10)cin>>ww[i];
	rep(i,10)cin>>kk[i];
	sort(all(ww),greater<ll>());
	sort(all(kk),greater<ll>());
	cout<<ww[0]+ww[1]+ww[2]<<" "<<kk[0]+kk[1]+kk[2]<<endl;
}



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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  int ans = 0;
  function<void(string, bool, bool, bool)> rec = [&](string s, bool three,
                                                     bool five, bool seven) {
    if (s.size() >= 10) return;
    if (three && five && seven && stoll(s) <= n) ++ans;
    rec(s + '3', true, five, seven);
    rec(s + '5', three, true, seven);
    rec(s + '7', three, five, true);
  };
  rec("", false, false, false);
  out(ans);
}


Measured memory_bytes: 3624
#include<algorithm>
#include<chrono>
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

const int MAXN = 1e5 + 20;


int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;
 	
    int n, k, a, res = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
    	cin >> a;
    	res += (a >= k);
    }
    cout << res << endl;

    return 0;
}























Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  vector<string> W = { "dream", "dreamer", "erase", "eraser"}; 

  reverse( S.begin(), S.end() );
  for (int i=0; i<4; i++) reverse( W.at(i).begin(), W.at(i).end() );
  
  bool fla = true;
  for (int i=0; i<S.size();) {
    bool fla2 = false;
    for (int j=0; j<4; j++) {
      string d = W.at(j);
      if(S.substr(i, d.size()) == d) {
        fla2 = true;
        i += d.size();
      }
    }
    if(!fla2) {
      fla = false;
      break;
    }
  
  }
  
  if(fla) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int N, H;
  cin >> N >> H;
  vector<int> a(N), b(N);
  int maxa = 0;
  REP(i, N){
    cin >> a[i] >> b[i];
    maxa = max(maxa, a[i]);
  }
  sort(b.rbegin(), b.rend());
  int cnt = 0, sum = 0;
  REP(i, N){
    if(b[i] < maxa){
      break;
    }
    sum+= b[i];
    cnt++;
    if(sum >= H){
      break;
    }
  }
  if(sum < H){
    cnt += (H-sum)/maxa;
    if((H-sum)%maxa){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int H,W,id[22][22],maxL,answer=0;
char s;
bool t[22][22]={0};

void move(int x,int y,int n){
	//cout<<x<<y<<endl;
	if(t[y][x]&&(id[y][x]>n||id[y][x]==-1)){
		id[y][x]=n;
		move(x+1,y,n+1);
		move(x-1,y,n+1);
		move(x,y+1,n+1);
		move(x,y-1,n+1);
	}
}

int main(){
	cin>>H>>W;
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
		cin>>s;
		t[i][j]=(s=='.');
	}
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
		for(int ii=1;ii<=H;ii++)for(int jj=1;jj<=W;jj++)id[ii][jj]=-1;
		maxL=0;
		move(i,j,0);
		for(int ii=1;ii<=H;ii++)for(int jj=1;jj<=W;jj++)maxL=max(maxL,id[ii][jj]);
		answer=max(maxL,answer);
	}
	cout<<answer;
	return 0;
}

Measured memory_bytes: 384
from time import time, sleep
from random import random
def inpl(): return list(map(int, input().split()))
start = time()
D = int(input())
C = inpl()
S = [inpl() for _ in range(D)]
X = [0]*D
res = []
max_score = -10**9

while (time() - start < 1.8):
    score = 0
    A = [[] for _ in range(26)]
    for i in range(D):
        X[i] = int(random()*26)
        A[X[i]].append(i)
    for i in range(26):
        s = -1
        for j in range(len(A[i])):
            a = A[i][j]
            n = a - s - 1
            score += S[a][i] - n*(n-1)*C[i]//2
            s = a
        n = D - 1 - s
        score -= n*(n-1)*C[i]//2
    if score > max_score:
        max_score = score
        res = [x for x in X]
for x in res:
    print(x+1)

Measured memory_bytes: 79300