akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int r=0,b=0,n;
	cin>>n;
	char s[n];
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R') r++;
		else b++;
	}
	if(b<r) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,j,k,N,ans=0;
  cin>>N;
  vector<ll> v(30,0),slv(5,0);
  string ss,t="MARCH";
  rep(i,N){
    cin>>ss;
    v[ss[0]-'A']++;
  }
  rep(i,5){
    slv[i]=v[t[i]-'A'];
  }
  rep(i,5){
    For(j,i+1,5){
      For(k,j+1,5){
        ans+=slv[i]*slv[j]*slv[k];
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  static const int MAX = 21;
  int N, dp[MAX+1][1<<MAX];
  bool as[MAX][MAX];

  void init() {
    cin >> N;
    rep(i, N) rep(j, N) {
      cin >> as[i][j];
    }
  }

  void solve() {
    int U = (1 << N) - 1;
    dp[N][U] = 1;
    REPCM(i, N-1, 0) {
      int S = (1 << i) - 1;
      while(S <= U) {
        rep(j, N) if(as[i][j]) if(!((S>>j)&1)) {
          dp[i][S] += dp[i+1][S | (1 << j)];
          dp[i][S] %= MOD_1_000_000_007;
        }
        if(S!=0) {
          int x = S & -S;
          int y = S + x;
          S = ((S & ~y) / x >> 1) | y;
        } else S = U+1;
      }
    }
    cout << dp[0][0] << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 162048
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int p[10000000];
signed main()
{
	int n,x,y;
	cin>>n>>x>>y;
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			p[ min( j-i , abs(x-i)+1+abs(y-j) ) ] ++;
		}
	}
	for (int i=1;i<n;i++){
		cout<<p[i]<<endl;
	}
	re 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>

#include <utility>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <list>
using namespace std;

#define rep_init(i, init, n) for(int i = (init); i < n; ++i)
#define rep(i, n) rep_init(i, 0, n)
void Main()
{
	string S;
	int K;
	cin >> K >> S;

	if (S.size() <= K)
	{
		cout << S << endl;
	}
	else
	{
		string newS;
		for (int i = 0; i < K; ++i)
		{
			newS.push_back(S[i]);
		}
		newS += "...";

		cout << newS << endl;
	}

	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 3660
#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() {
    ll n, k;
    cin >> n >> k;
    ll a = n % k;
    if(a == 0) {
        cout << 0 << endl;
        return 0;
    } else {
        ll b = abs(a - k);
        if(a > b) {
            cout << b << endl;
            return 0;
        } else {
            cout << a << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long X;
  scanf("%lld", &X);
  for (ll i = -500; i <= 500; ++i)
  {
    for (ll j = -500; j <= 500; ++j)
    {
      if (i * i * i * i * i - j * j * j * j * j == X)
      {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3292
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str[] = {sc.next(), sc.next()};
		int length[] = {str[0].length(), str[1].length()};
		char ch[][] = {str[0].toCharArray(), str[1].toCharArray()};
		int dpLength[][] = new int[length[0] + 1][length[1] + 1];

		for(int i = 0; i <= length[0]; i ++) {
			dpLength[i][0] = 0;
		}
		for(int j = 0; j <= length[1]; j ++) {
			dpLength[0][j] = 0;
		}

		for(int i = 1; i <= length[0]; i ++) {
			for(int j = 1; j <= length[1]; j ++) {
				dpLength[i][j] = ch[0][i - 1] == ch[1][j - 1]
					? dpLength[i - 1][j - 1] + 1
					: Math.max(dpLength[i - 1][j], dpLength[i][j - 1]);
			}
		}

		String ans = "";
		int i = length[0];
		int j = length[1];
		while(i > 0 && j > 0) {
			if(ch[0][i - 1] == ch[1][j - 1]) {
				ans = ch[0][i - 1] + ans;
				i --;
				j --;
			}else if(dpLength[i - 1][j] > dpLength[i][j - 1]) {
				i --;
			}else {
				j --;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 86476
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}



int main() {
    ll n,k;
    std::cin >> n>>k;
    if( k <= (n+1)/2){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1.0/LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class DSummerVacation {
public:
    int N, M;
    vector<int> x[ten(5)+7];

    void solve(std::istream &in, std::ostream &out) {
        in >> N >> M;

        REP(i, N) {
            int a, b;
            in >> a >> b;
            x[a].push_back(b);
        }

        ll ans = 0;
        priority_queue<int> pq;
        for (int rd = 1; rd <= M; ++rd) {
            FOREACH(e, x[rd]) {
                pq.push(e);
            }
            if (pq.size()) {
                ans += pq.top();
                pq.pop();
            }
        }
        OUT(ans);
    }
};


int main() {
    DSummerVacation solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 5632
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, n-1):
    if h[i] == h[i+1] + 1:
        if h[i-1] != h[i]:
            h[i] -= 1
        else:
            print('No')
            exit()
    elif h[i] < h[i+1] + 1:
        if h[i-1] != h[i]:
            h[i] -= 1
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 14252
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define do long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
int a;
  string b;
  cin>>a>>b;
  if(a%2==1)
    cout<<"No";
  else{
    bool j=true;
      rep(i,a/2){
    if(b[i]!=b[i+a/2])
      j=false;
      }
          if(j)
  cout<<"Yes";
          else
          cout<<"No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
 int a;
 cin>>a;
 cout<<a+a*a+a*a*a<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define int long long

vector<int> tmp;
signed main() {
	int N;
	cin >> N;
	int A, B;
	cin >> A >> B;
	int x[100000] = {};
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	int cost = 0;
	for (int i = 1; i < N; i++) {
		if ((x[i] - x[i - 1])*A >=B) {
			cost += B;
		}
		else {
			cost += A*(x[i] - x[i - 1]);
		}
	}
	cout << cost << endl;
}


Measured memory_bytes: 1024
import itertools
N = int(input())
dic = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for i in range(N):
  s = input()
  if s[0] in dic:
    dic[s[0]] += 1
lst = list(dic.values())
ans = list(itertools.combinations(lst, 3))
cnt = 0
for i in ans:
    if 0 in ans:
        break
    else:
        cnt += i[0]*i[1]*i[2]

print(cnt)

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

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

lst = []

flg = True

for i in range(len(a)):
    if a[i] % 2 == 0:
        lst.append(a[i])

for i in range(len(lst)):
    if lst[i] % 2 == 0 and lst[i] % 3 == 0 or lst[i] % 5 == 0:
        flg = True
    else:
        flg = False
        break

if flg == True:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(){
double a,b,c,d,l,lad,z,h,s;
double pai =3.1415926;

scanf("%lf%lf%lf",&a,&b,&d);
lad=d/180*pai;
s=a*b*sin(lad)/2;
z=a*a+b*b-2*a*b*cos(lad);
c=sqrt(z);
l=a+b+c;
h=2*s/a;



printf("%lf\n",s);
printf("%lf\n",l);
printf("%lf\n",h);

return 0;
}

  


Measured memory_bytes: 2104
/*input
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
*/
 
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<long long int, long long int> mpi;
typedef set<long long int> seti;
typedef multiset<long long int> mseti;
typedef priority_queue<long long int> pq;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define PI 3.14159265
#define dbg(x) cerr << "\n" << (#x) << " = " << (x) << endl ;
//#define cerr if(false)cerr
  
struct node{
    ll val;
};
struct Interval {int start, end;};
bool compare(struct node n1, struct node n2) {
    return (n1.val < n2.val);
}
 
 
 ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 








vector <ll> adj[100005];
vector <bool> visited(100005,false);

void addedge(ll u, ll v){
	adj[u].pb(v);
}

vector <ll> dp(100005,0);

void dfs(ll u){
	visited[u] = true;
	//cout<<u<<" ";
	bool isleaf = true;
	if(adj[u].size()!=0)isleaf=false;

	if(isleaf){dp[u] = 0; return ;}

	rep(i,adj[u].size()){
		if(visited[adj[u][i]] == false){
			dfs(adj[u][i]);
			dp[u] = max(dp[u], dp[adj[u][i]]+1);
			continue;
		}
		dp[u] = max(dp[u], dp[adj[u][i]]+1);
	}
}

int main() 
{
	ll n,m; cin>>n>>m;
	rep(i,m){ll u,v; cin>>u>>v; addedge(u,v);}

	repA(i,1,n){
		if(visited[i] == false)
			dfs(i);
	}
	//cout<<endl;
	ll ans=0;
	repA(i,1,n){ans = max(dp[i], ans);}
	cout<<ans<<endl;
    return 0;  
}



















 

Measured memory_bytes: 11520
#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()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, d, x;
	cin >> n >> d >> x;
	int eaten;
	eaten = 0;
	rep(i, n)
	{
		int a;
		cin >> a;
		eaten += (d + a - 1) / a;
	}
	cout << eaten + x << endl;
}


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

int main (){
    string a,b;
    cin >> a >>b;
    if(a[0]==b[2] && b[0] == a[2] && a[1] == b[1]){
        cout << "YES";
    }else{
        cout << "NO";
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int x; int a; int b;
    cin >> x >> a >> b;
    if (a - b >= - x && a - b < 0)
        cout << "safe" << endl;
    else if (a - b >= 0)
        cout << "delicious" << endl;
    else
        cout << "dangerous" << endl;
}


Measured memory_bytes: 256
// Problem : C - H and V
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_c
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

ll h, w, k;
ll A[7][7];

int check(ll row, ll col) {
  int ans = 0;
  for (ll i = 0; i < h; i++)
    for (ll j = 0; j < w; j++) {
      if (!(((1ll << i) & row) | ((1ll << j) & col)))
        if (A[i][j]) ans++;
    }
  return ans;
}

void solve() {
  cin >> h >> w >> k;
  rep(i, 0, h) rep(j, 0, w) {
    char x;
    cin >> x;
    A[i][j] = (x == '#');
  }
  ll ans = 0;

  ll rowm = (1ll << h), colm = (1ll << w);
  for (ll i = 0; i < rowm; i++)
    for (ll j = 0; j < colm; j++) {
      ans += (check(i, j) == k);
    }

  cout << ans;
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3636
S = input()
K = int(input())
N = len(S)
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for i in range(N):
    s = S[i]
    index = alp.find(s)
    if i == N-1:
        ans += alp[(index+K)%26]
    else:
        if s=="a":
            ans += "a"
        elif 26-index <= K:
            ans += "a"
            K -= (26-index)
        else:
            ans += s
print(ans)


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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

vector<edge> graph;

class UnionFind
{
  private:
    vector<int> par;
    vector<int> sizes;

  public:
    UnionFind(int N) : par(N), sizes(N, 1)
    {
        rep(i, N) par[i] = i;
    }

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

        return par[x] = find(par[x]);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);

        if (x == y)
            return;

        if (sizes[x] < sizes[y])
            swap(x, y);

        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    int size(int x)
    {
        return sizes[find(x)];
    }
};

int main()
{
    int V, E;
    cin >> V >> E;
    vector<tuple<int, int, int>> graph; //cost, from, to
    rep(i, E)
    {
        int s, t, w;
        cin >> s >> t >> w;
        graph.push_back(T{w, s, t});
        graph.push_back(T{w, t, s});
    }   

    sort(graph.begin(), graph.end());

    UnionFind uf(V);

    ll ans = 0;

    for(auto e : graph)
    {
        int from, to, cost;
        tie(cost, from, to) = e;

        if(!uf.same(from, to))
        {
            ans += cost;
            uf.unite(from, to);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5988
#include <bits/stdc++.h>
#define N 100010
#define P 1000000007
using namespace std;

int n;
long long a[N], inv[N], sum[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sum[0] = 0, inv[1] = 1;
    for (int i = 1; i <= n; ++i) {
        if (i > 1) inv[i] = (P - P / i) * inv[P % i] % P;
        sum[i] = (sum[i - 1] + inv[i]) % P;
    }
    long long ret = 0, fact = 1;
    for (int i = 1; i <= n; ++i) 
        ret = (ret + (sum[i] - 1) * a[i] % P + sum[n - i + 1] * a[i] % P) % P, fact = fact * i % P;
    cout << ret * fact % P << endl;  
    return 0;
}

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int count = 0;
    for(int i = 0;i < C; i++){
        count++;
        if(B > 0){
            count++;
            B--;
        }else if(A > 0){
            A--;
        }else{
            break;
        }
    }
    count += B;
    cout << count << endl;
    return 0;
}

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

void trace(int A[], int N) {
    for (int i = 0; i < N; i++){
        if (i > 0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

int selectionSort(int A[], int N) {
    int cnt = 0;
    for(int i=0; i<N; i++) {
        int minj = i;
        for(int j=i+1; j<N; j++) {
            if(A[j] < A[minj]) {
                minj = j;
            }
        }
        if(i != minj) {
            swap(A[i], A[minj]);
            cnt++;
        }
    }
    return cnt;
} 

int main(){
    int N, cnt;
    cin >> N;
    int A[N];
    for (int i=0; i < N; i++) {
        cin >> A[i]; 
    }
    cnt = selectionSort(A, N);
    trace(A, N);
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

// ???/????????????
struct Point {
  double x, y;
  Point(double x = 0.0, double y = 0.0):x(x), y(y){}
  
  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(x * a, y * a); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point& p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point& p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;

// ??????/??´???
struct Segment {
  Point p1, p2;
};
typedef Segment Line;

// ?????????????????????
double dot(Vector a, Vector b)
{
  return a.x*b.x + a.y*b.y;
}
// ??????????????????????????§??????
double cross(Vector a, Vector b)
{
  return a.x*b.y - a.y*b.x;
}
// ??´?????????
bool isOrthogonal(Vector a, Vector b)
{
  return equals(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2)
{
  return isOrthogonal(a1 - a2, b1 - b2);
}
bool isOrthogonal(Segment s1, Segment s2)
{
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
// ????????????
bool isParallel(Vector a, Vector b)
{
  return equals(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
  return isParallel(a1 - a2, b1 - b2);
}
bool isParallel(Segment s1, Segment s2)
{
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
// ?°???±
Point project(Segment s, Point p)
{
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
}

int main()
{
  Segment s;
  cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
  int q; cin >> q;
  while(q--) {
    Point p;
    cin >> p.x >> p.y;
    Point x = project(s, p);
    printf("%.10f %.10f\n", x.x, x.y);
  }
  return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
string s,p;
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>s;
    for(char c:s)
    {
        if(c=='0')
        {
            p+='0';
        }
        else if(c=='1')
        {
            p+='1';
        }
        else
        {
            if(p!="")
            {
                p.pop_back();
            }
        }
    }
    cout<<p<<"\n";
    return 0;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int n,l,ans=0;
  cin>>n>>l;
  vector<int> v(n);
  rep(i,n) cin>>v[i],v[i]=l+i;
  rep(i,n) ans+=v[i];
  if(v[n-1]<0){
    cout<<ans-v[n-1]<<endl;
    return 0;
  }else if(v[0]>0){
    cout<<ans-v[0]<<endl;
    return 0;
  }else if(v[0]<=0 && v[n-1]>=0){
    cout<<ans<<endl;
    return 0;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
       int a,b,c;
       cin>>a>>b>>c;
       if(a < b && a+b >= c && a < c){
           cout<<c-a<<endl;
       }
       else if(a > b && a+b >= c && a < c){
           cout<<c-a<<endl;
       }
       else if(a == b && a+b >= c && a < c){
           cout<<c-a<<endl;
       }
       else if(a>=c){
           cout<<"0"<<endl;
       }
       else if(a+b < c){
           cout<<"NA"<<endl;
       }
       
       
       return 0;
    
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int a,b;
  cin>>a>>b;
  if(a>b)cout<<a-1<<endl;
  else cout<<a<<endl;

return 0;}


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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int d,x;
  cin>>d>>x;
  int a[104];
  int sum=n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=(d-1)/(a[i]);
  }
  sum+=x;
  cout<<sum;
  

  

}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int main() {
    string s;
    cin >> s;
    vector<char> v;
    v.resize(10);
    int li = -1;
    for(int i = 0;i < s.size();i++) {
        if(s[i] == 'B') {
            li = max(-1, li - 1);
        }else{
            li++;
            v[li] = s[i];
        }
    }
    for(int i = 0;i <= li;i++) {
        cout << v[i];
    }
    cout << endl;
    return 0;
}


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

int main(){
	int k, p;
	char s[100];
	
	scanf("%d", &k);
	
	scanf("%s", &s);
	
	
	
	if (strlen(s) <= k){
		printf("%s", s);
	}else {
		for(int i = 0; i < k; i++){
			printf("%c", s[i]);
		} puts("...");
	}
	
		
	
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
ll max(ll a,ll b)
{
  if (a>b) {

    return a;
  }
  return b;
}

ll min(ll a,ll b)
{
  if (a<b) {

    return a;
  }
  return b;
}

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

ll lcm(ll a,ll b)
{
  return a/gcd(a,b)*b;
}
int main()
{
   int n;
   cin>>n;
   int a[n];
   int b[n];
   int minm=200001;
   int maxm=0;
   int maxm2=0;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       b[i]=a[i];
   }
   sort(b,b+n);
    maxm=b[n-1];
    maxm2=b[n-2];


    for(int i=0;i<n;i++)
    {
        if(a[i]!=maxm)
        cout<<maxm<<endl;
        else
        {
            cout<<maxm2<<endl;
        }
    }



    return 0;
}




Measured memory_bytes: 5112
N = int(input())
S = list(input())

s = [0]*(N+1)
e = [0]*(N+1)
for i in range(1, N+1):
    k = 0
    if S[i-1] == "W":
        k = 1
    s[i] = s[i-1] + k

for i in reversed(range(0, N)):
    k = 0
    if S[i] == "E":
        k = 1
    e[i] = e[i+1] + k

ans = N
for i in range(1, N+1):
    ans = min(ans, s[i-1]+e[i])


print(ans)


Measured memory_bytes: 29260
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size()){
    cout<<"GREATER"<<endl;
  }else if(b.size()>a.size()){
    cout<<"LESS"<<endl;
  }else{
    for(int i=0;i<a.size();i++){
      if(a[i]>b[i]){
        cout<<"GREATER"<<endl;
        return 0;
      }else if(b[i]>a[i]){
        cout<<"LESS"<<endl;
        return 0;
      }
    }
    cout<<"EQUAL"<<endl;
  }
}


Measured memory_bytes: 256
/* ex6_2
   shu_t */

#include<stdio.h>
#include<string.h>
//1<=|S|<=100
#define SIZE 101

int main(void){
  int length;//length of array
  char word[SIZE];//storing input data
  
  //input word
  scanf("%s",word);
  //length of word
  length = strlen(word);
  
  //output initial letter + length of word minus 2 + final letter
  printf("%c%d%c\n",word[0],length-2,word[length-1]);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main (){
	int c;
	scanf ("%d", &c);
	long long int arr[c], max = 1e18, prod = 1, flag = 0, zero = 0;
	for (int i = 0; i < c; i++){
		scanf ("%lld", &arr[i]);
		flag = (arr[i] > max) ? 1 : flag;
		prod *= arr[i];
		(arr[i]) ? max /= arr[i] : zero = 1;
	}
	(zero) ? puts ("0") : ((flag) ? puts ("-1") : printf ("%lld\n", prod));
	return 0;
}

Measured memory_bytes: 2512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;

struct data_t {
	int ID;
	int correct;
	int pena;

	bool operator<( const data_t& right) const {
		if ( correct == right.correct) {
			if ( pena == right.pena ) {
				return ( ID < right.ID);
			}
			else {
				return ( pena < right.pena);
			}
		}
		else {
			return ( correct > right.correct );
		}
	}
};

int main(void) {
	int T,P,R;
	cin >> T;
	cin >> P;
	cin >> R;

	while (T!=0||P!=0||R!=0) {
		vector<data_t> data(T);
		vector< vector<int> > wrong(T, vector<int>(P,0));
		int team,prob,time;
		string mes;

		for (int i = 0; i < T; i++) {
			data[i].ID = i + 1;
			data[i].correct = 0;
			data[i].pena = 0;
		} 

		for (int i = 0; i < R; i++) {
			cin >> team;
			cin >> prob;
			cin >> time;
			cin >> mes;

			if (mes == "CORRECT") {
				data[team-1].correct++;
				data[team-1].pena += (wrong[team-1][prob-1] * 1200) + time;
			}
			else if (mes == "WRONG") {
				wrong[team-1][prob-1]++;
			}
		}

		std::sort(data.begin(), data.end());

		for (int i = 0; i < T; i++) {
			cout << data[i].ID << " " << data[i].correct << " " << data[i].pena << endl;
		}

		cin >> T;
		cin >> P;
		cin >> R;
	}
	return 0;
}

Measured memory_bytes: 3228
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

x = int(input())

y = int(x**(1/3))

for a in range(-y, y+1):
    for b in range(-y, y+1):
        if a**5 - b**5 == x:
            print(a, b)
            exit()


Measured memory_bytes: 69196
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long 
	int n,a,b;
	cin >> n >> a >> b;
	if (n == 1) {
		if (a == b) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	else {
		if (a > b) {
			cout << 0 << endl;
		}
		else {
			int bot = (n - 2) * (b - a) + 1;
			cout << bot << endl;
		}
	}
}

Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;






public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    //public static long mod = (long) (1e9+7);
    public final static int MAX = (int)1e5;
  // static Scanner sc = new Scanner(System.in);
   static List<Integer>[] edge;
   private static int N = (int) (2e5 + 11);
	public static void main(String[] args) {
	   
	 FastReader sc = new FastReader();

	int a = sc.nextInt();
	int b = sc.nextInt();
	int ans = (b+a-3)/(a-1);
	 out.print(ans);
	 out.close();
	}
}

Measured memory_bytes: 21588
DVSR = 998244353
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def II(): return int(input())

N = int(input())
INL = [II() for _ in range(N)]
SM = sum(INL)
HSM = SM//2

DP1 = [[0]*(SM+1) for _ in range(N+1)]
DP2 = [[0]*(SM+1) for _ in range(N+1)]
DP1[0][0] = 1
DP2[0][0] = 1

for i in range(1,N+1):
    value = INL[i-1]
    for j in range(SM+1):
        if j-value >= 0:
            DP1[i][j] = (2*DP1[i-1][j]+DP1[i-1][j-value])%DVSR
            DP2[i][j] = (DP2[i-1][j]+DP2[i-1][j-value])%DVSR
        else:
            DP1[i][j] = (2*DP1[i-1][j])%DVSR
            DP2[i][j] = DP2[i-1][j]

sub = 0
patall = POW(3, N)
for i in range(HSM+1, SM+1):
    sub += DP1[N][i]*3

if SM % 2 == 0:
    sub += 3*(DP1[N][HSM] - 2*DP2[N][HSM])
    sub += 3*DP2[N][HSM]

# print(DP2[N])
# print(SM)
print((patall - sub) % DVSR)

Measured memory_bytes: 458520
package main

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

type AdjacentList struct {
	matrix [][]int
}

func NewEmptyAdjacentList(dim int) *AdjacentList {
	matrix := make([][]int, dim)
	for i := 0; i < dim; i++ {
		matrix[i] = make([]int, dim)
	}
	return &AdjacentList{matrix: matrix}
}

func (al *AdjacentList) set(node int, adjacent int) {
	al.matrix[node-1][adjacent-1] = 1
}

func (al *AdjacentList) findAdjacentsFor(node int) []int {
	adjacents := []int{}
	for i, v := range al.matrix[node-1] {
		if v == 1 {
			adjacents = append(adjacents, i+1)
		}
	}
	return adjacents
}

type DistanceList struct {
	list []int
}

func NewDistanceList(dim int) *DistanceList {
	list := make([]int, dim)
	for i := 0; i < dim; i++ {
		list[i] = -1
	}
	return &DistanceList{list: list}
}

func (dl *DistanceList) set(node int, distance int) {
	dl.list[node-1] = distance
}

func (dl *DistanceList) get(node int) int {
	return dl.list[node-1]
}

func (dl *DistanceList) isVisited(node int) bool {
	return dl.list[node-1] >= 0
}

type Position struct {
	node     int
	distance int
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	dim, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	al := NewEmptyAdjacentList(dim)

	for i := 1; i <= dim; i++ {
		node, err := nextInt(sc)
		if err != nil {
			panic(err)
		}

		adjacentNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < adjacentNum; j++ {
			adjacent, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			al.set(node, adjacent)
		}
	}

	dl := NewDistanceList(dim)

	bfs(al, dl)

	for i := 1; i <= dim; i++ {
		fmt.Printf("%d %d\n", i, dl.get(i))
	}
}

func bfs(al *AdjacentList, dl *DistanceList) {
	stack := []Position{Position{node: 1, distance: 0}}
	for len(stack) > 0 {
		currentPosition := stack[0]
		stack = stack[1:]
		if !dl.isVisited(currentPosition.node) {
			dl.set(currentPosition.node, currentPosition.distance)
		}
		for _, v := range al.findAdjacentsFor(currentPosition.node) {
			if !dl.isVisited(v) {
				stack = append(stack, Position{node: v, distance: currentPosition.distance + 1})
			}
		}
	}
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}



Measured memory_bytes: 8192
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int n = ni();
		for (;;) {
			if (n <= 1000) {
				out(1000 - n);
				break;
			}
			n -= 1000;
		}

	}

	/*
	 * 以下メソッド集
	 */
	static double[] sort(double[] r) {
		Arrays.sort(r);
		return r;
	}

	static void debug() {
		out("---");
	}

	static void debug(long a) {
		out("-------");
		out(a);
		out("-------");
	}

	static void debug(String a) {
		out("-------");
		out(a);
		out("-------");
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static long min(long d, long e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 35784
import java.util.*;

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

        show(calc(N, K));
    }

    private static double calc(int N, int K) {
        double answer = 0;

        for (int i = 1; i <= N; i++) {
            double prob = 1d / N;
            int now = i;

            while (now < K) {
                now = now * 2;
                prob = prob * 0.5;
            }
            answer = answer + prob;
        }

        return answer;
    }

    private static void show(double answer) {
        System.out.println(answer);
    }

    private static int nextInt(Scanner sc) {
        return Integer.parseInt(sc.next());
    }
}


Measured memory_bytes: 21588
import sys
A, B, C, x, y = map(int, sys.stdin.readline().split())

ans = float('inf')
for i in range(0, 2*max(x, y)+1, 2):
    tmp = A*max(x-i//2, 0) + C*i + B*max(y-i//2, 0)
    if tmp < ans:
        ans = tmp
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>

#define MAX 250

int main(){
  int A[MAX+1];
  int i,heap;

  scanf("%d",&heap);
  for(i=1;i<=heap;i++) scanf("%d",&A[i]);

  for(i=1;i<=heap;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i/2!=0) printf("parent key = %d, ",A[i/2]);
    if(i*2<=heap) printf("left key = %d, ",A[i*2]);
    if(i*2+1<=heap) printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2112
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int main(){
  int i;
  int k;
  rd(N);
  for(i=(0);i<(N+1);i++){
    k = i * 108 / 100;
    if(k==N){
      wt_L(i);
      wt_L('\n');
      return 0;
    }
  }
  wt_L(":(");
  wt_L('\n');
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// int N;
// {
//   int k;
//   rd(N);
//   rep(i,N+1){
//     k = i * 108 / 100;
//     if(k==N) wt(i), return 0;
//   }
//   wt(":(");
// }


Measured memory_bytes: 256
function Main(input) {
  const arr = ['dream','dreamer','erase','eraser'];
  const rev = str => [...str].reduce((prev, curr) => curr + prev);
  const arrRev = arr.map(rev);
  let inputRev = rev(input.trim());

  for (;;) {
    if (inputRev.length === 0) {
      console.log('YES');
      break;
    }
    const target = inputRev.slice(0, 7);
    const arrFiltered = arrRev.filter(word => target.indexOf(word) === 0);

    if (arrFiltered.length === 0) {
      console.log('NO');
      break;
    } else {
      const len = arrFiltered[0].length;
      inputRev = inputRev.substring(len);
    }
  }

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 39960
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String input1 = "";
		String input2 = "";
		String[] input_rc = new String[2];
		int r = 0;
		int c = 0;
		boolean judge = true;

		input1 = sc.nextLine();
		input_rc = input1.split(" ");
		r = Integer.parseInt(input_rc[0]);
		c = Integer.parseInt(input_rc[1]);

		if (r < 1 || r > 100) {
			judge = false;
		}

		if (c < 1 || c > 100) {
			judge = false;
		}

		if (judge == true) {
			// String[] outputstring = new String[r + 1];
			int[][] output_data = new int[r + 1][c + 1];
			String[] string_data = new String[c];

			// 1行ずつ入力される行列データを処理する
			out: for (int i = 0; i < r; i++) {
				input2 = sc.nextLine(); // 1行ずつ入力される各行のデータを受け取る
				string_data = input2.split(" "); // 1行ずつ入力される各行のデータを半角区切りで分けて格納する

				// 各行の各列のデータの処理を行う
				for (int j = 0; j < c; j++) {
					output_data[i][j] = Integer.parseInt(string_data[j]);
					if (output_data[i][j] < 0 || output_data[i][j] > 100) {
						judge = false;
						break out;
					}
					output_data[r][j] += output_data[i][j];
					output_data[i][c] += output_data[i][j];
					output_data[r][c] += output_data[i][j];
				}

			}

			if (judge == true) {
				for (int k = 0; k < (r + 1); k++) {
					for (int m = 0; m < (c + 1); m++) {
						if (m == 0) {
							System.out.print("" + output_data[k][m]);
						} else {
							System.out.print(" " + output_data[k][m]);
						}

					}
					System.out.println();

				}
			}

		}
	}
}



Measured memory_bytes: 33492