akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
long long dp[100010],h[100010];
int main(){
	int i,n;
	cin >> n;
	for(i=1;i<=n;i++){
		cin >> h[i];
		dp[i] = 10000000000000000;
	}
	dp[1] = 0;
	for(i=1;i<=n;i++){
		dp[i+1] = min(dp[i+1],dp[i] + abs(h[i+1] - h[i]));
		dp[i+2] = min(dp[i+2],dp[i] + abs(h[i+2] - h[i]));
	}
	cout << dp[n] << endl;
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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 main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    
    int ans = 0;
    REP(i,30){
        bool divisible = true;
        REP(j,N) {
            if ( A[j] % 2 != 0 ) divisible = false;
        }
        if ( divisible ){
            REP(j,N) A[j] /= 2;
            ++ans;
        } else {
            goto OUT;
        }
    }
    OUT:
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>

int main()
{
	int x, y, i = 0;
	while(1)
	{
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0)
		{
			break;
		}
		else
		{
			i++;
			if (x > y)
			{
				printf("%d %d\n", y, x);
				continue;
			}
			else if (x < y)
			{
				printf("%d %d\n", x, y);
				continue;
			}
			else
			{
				printf("%d %d\n", x , y);
				continue;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define sp << " " <<

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,w;
    cin >> n >> w;
    long long d[n],p[n];
    for(int i=0;i<n;i++)
    cin >> p[i] >> d[i];
    long long dp[n+1][w+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=w;j++)
            dp[i][j]=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(p[i-1]<=w&&j>=p[i-1])
                dp[i][j]=max(d[i-1]+dp[i-1][j-p[i-1]],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout << dp[n][w];
    return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n), c(m), d(m), num(n);
    vector<pair<ll, ll>> ans(n, {inf,inf});
    rep(i, n)cin >> a.at(i) >> b.at(i);
    rep(i, m)cin >> c.at(i) >> d.at(i);
    rep(i, n){
        rep(j, m){
            ll man = abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
            ll now = abs(a.at(i)-ans.at(i).first)+abs(b.at(i)-ans.at(i).second);
            if(man < now){
                ans.at(i).first=c.at(j);
                ans.at(i).second=d.at(j);
                num.at(i)=j+1;
            }
        }
    }
    rep(i, n){
        cout << num.at(i) << endl;
    }
}

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

int main()
{
    int a,b;
    int s[3];
    cin>>a>>b;
    s[0]=a+b;
    s[1]=a-b;
    s[2]=a*b;
    sort(s,s+3);
    printf("%d\n",s[2]);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);

  if(a<1 || a>100 || b<1 || b>100) {
    return 0;
  }

  printf("%d %d\n", a*b, 2*(a+b));

  return 0;
}


Measured memory_bytes: 2044
#include <vector>
#include <iostream>
#include <algorithm>
std::vector<long long> solve(int N, std::vector<int> X, std::vector<int> Y, std::vector<int> P) {
	const long long inf = 1LL << 62;
	int mul = 1;
	for (int i = 0; i < N; ++i) {
		mul *= 3;
	}
	std::vector<std::vector<int> > xsel(1 << N, std::vector<int>(N));
	std::vector<std::vector<int> > ysel(1 << N, std::vector<int>(N));
	for (int i = 0; i < 1 << N; ++i) {
		for (int j = 0; j < N; ++j) {
			xsel[i][j] = std::abs(X[j]);
			ysel[i][j] = std::abs(Y[j]);
			for (int k = 0; k < N; ++k) {
				if ((i >> k) & 1) {
					xsel[i][j] = std::min(xsel[i][j], std::abs(X[j] - X[k]));
					ysel[i][j] = std::min(ysel[i][j], std::abs(Y[j] - Y[k]));
				}
			}
		}
	}
	std::vector<long long> ans(N + 1, inf);
	for (int i = 0; i < 1 << N; ++i) {
		int cnt = 0;
		for (int j = 0; j < N; ++j) {
			if ((i >> j) & 1) ++cnt;
		}
		for (int j = i; j >= 0; --j) {
			j &= i;
			long long cost = 0;
			for (int k = 0; k < N; ++k) {
				if (!((i >> k) & 1)) {
					cost += 1LL * std::min({ xsel[j][k], ysel[i - j][k] }) * P[k];
				}
			}
			ans[cnt] = std::min(ans[cnt], cost);
		}
	}
	return ans;
}
int main() {
	int N;
	std::cin >> N;
	std::vector<int> X(N), Y(N), P(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i] >> Y[i] >> P[i];
	}
	std::vector<long long> ans = solve(N, X, Y, P);
	for (int i = 0; i <= N; ++i) {
		std::cout << ans[i] << std::endl;
	}
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

string dp[10100];
//use[i] i本使ったときの最大数
lli use[10];
bool vis[10010];

signed main(){

	REP(i,0,10)use[i]=-1;

	lli n,m;
	cin>>n>>m;

	lli d[9]={2,5,5,4,5,6,3,7,6};

	REP(i,0,m){
		lli a;
		cin>>a;
		use[d[a-1]] = max(use[d[a-1]],a);
	}

	if(DEBUG){


		REP(i,0,10){
			cout<<use[i]<<endl;
		}
	}
	vis[0]=true;

	REP(i,0,n){
		if(!vis[i])continue;
		REP(j,0,10){
			if(use[j]==-1)continue;
			if(dp[i+j].size() < (dp[i]+to_string(use[j])).size()){
				dp[i+j] = dp[i]+to_string(use[j]);
			}
			else{
				dp[i+j] = max(dp[i]+to_string(use[j]),dp[i+j]);
			}
			vis[i+j]=true;
		}
	}

	if(DEBUG)REP(i,0,n)cout<<"i="<<i<<" dp="<<dp[i]<<endl;

	cout<<dp[n]<<endl;



	return 0;
}

Measured memory_bytes: 32512
use proconio::marker::Chars;
use proconio::{fastout, input};
use std::{cmp::Reverse, collections::BinaryHeap};

// 最終的に R..RW..W という状態にする
// WRWWRWRR
// RRWWRWRW
// RRRWRWWW
// RRRRWWWW

#[fastout]
fn main() {
    input! {
        n: usize,
        c: Chars,
    }

    // rは添字の大きい順に並べる
    let mut r = BinaryHeap::new();
    // wは添字の小さい順に並べる
    let mut w = BinaryHeap::new();
    for i in 0..n {
        if c[i] == 'R' {
            r.push(i);
        } else {
            w.push(Reverse(i));
        }
    }

    let mut count = 0i64;
    loop {
        let r_rightmost = r.pop();
        let w_leftmost = w.pop();
        match (r_rightmost, w_leftmost) {
            (None, _) | (_, None) => {
                break;
            },
            (Some(r_rightmost), Some(Reverse(w_leftmost))) => {
                if r_rightmost < w_leftmost {
                    break;
                }
            }
        }
        count += 1;
    }

    println!("{}", count);
}


Measured memory_bytes: 4692
#include<stdio.h>

int main()
{
   int x, y, tmp;

   while (1){
      scanf("%d %d", &x, &y);
      if (x==0 && y==0)
         break;

      if (x>y){
         tmp = x;
         x = y;
         y = tmp;
      }

      printf("%d %d\n", x, y);
   }

   return 0;
}

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

int main() {
	int n,x,t,q=0,r=0;
	cin >> n>>x>>t;
	r=n%x;
	q=(n/x);
	if(r!=0)
	q=q+1;
	q=q*t;
	cout<<q;
	return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define all(c) begin(c),end(c)
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
using ll = long long;
using vi = vector<int>; using vs = vector<string>;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	int N;
	cin >> N;
	if (N == 0)
	{
		cout << 0 << endl;
		return;
	}
	const int J = 16;
	map<int, string> M;

	for (int i = 0; i < 1 << J; ++i)
	{
		int x = 0;
		string a = "";
		for (int j = 0; j < J; ++j)
		{
			x += (j % 2 ? -1 : 1)*((i >> j & 1) << j);
			a = to_string(i >> j & 1) + a;
		}
		M.emplace(x, a);
	}


	for (int i = 0; i < 1 << J; i++)
	{
		int x = 0;
		string a = "";
		for (int j = 0; j < J; ++j)
		{
			x += (j % 2 ? -1 : 1)*((i >> j & 1) << j);
			a = to_string(i >> j & 1) + a;
		}
		x <<= J;

		if (M.find(N - x) != M.end())
		{
			bool ok = false;
			for (char c : a)
			{
				if (c == '1' || ok)
				{
					cout << c;
					ok = true;
				}
			}
			for (char c : M[N - x]) 
			{
				if (c == '1' || ok)
				{
					cout << c;
					ok = true;
				}
			}
			cout << endl;
			return;
		}
	}
}

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

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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

/*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)



void solve(){
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    vector<int> c(S+1,0);
    c[0]=1;
    
    rep(i,N){
        // c = c*(2+x^A[i])
        vector<int> next(S+1,0);
        rep(j,S+1){
            (next[j] += 2*c[j])%=mod;
            if(j+A[i]<=S)
                (next[j+A[i]] += c[j])%=mod;
        }
        dump(next);
        swap(next, c);
    }
    cout << c[S] << endl;
    
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3692
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*  ________       __      ________  _    __       __       ________               *
* |  ______|     /  \    |  ____  || |  / /      /  \     |  ____  |              *
* | |______     / /\ \   | |____| || |_/ /      / /\ \    | |____| |              *
* |______  |   / /__\ \  |  __  __||  __ \     / /__\ \   |  __  __|              *
*  ______| |  / ______ \ | |  \ \  | |  \ \   / ______ \  | |  \ \                *
* |________| /_/      \_\|_|   \_\ |_|   \_\ /_/      \_\ |_|   \_\               *
*                                                                                 *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include<bits/stdc++.h>
using namespace std;

const int N = (int) 1e5 + 5;



int main() 
{
	int N,A[10],i,j,B[11],cnt=0,ct=0,c=0,a=0,b=0,x=0,d=0,e=0;

	for(i = 0; i < 9; i++)
	{
		cin >> A[i];
	}

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

	for(i = 0; i < N; i++)
	{
		if(B[i] == A[0] || B[i] == A[1] || B[i] == A[2])
		{
			cnt++;
		}
	}

	for(i = 0; i < N; i++)
	{
		if(B[i] == A[0] || B[i] == A[3] || B[i] == A[6])
		{
			ct++;
		}
	}

	for(i = 0; i < N; i++)
	{
		if(B[i] == A[0] || B[i] == A[4] || B[i] == A[8])
		{
			c++;
		}
	}

	for(i = 0; i < N; i++)
	{
		if(B[i] == A[1] || B[i] == A[4] || B[i] == A[7])
		{
			a++;
		}
	}
    
    for(i = 0; i < N; i++)
	{
		if(B[i] == A[2] || B[i] == A[5] || B[i] == A[8])
		{
			b++;
		}
	}

	for(i = 0; i < N; i++)
	{
		if(B[i] == A[3] || B[i] == A[4] || B[i] == A[5])
		{
			x++;
		}
	}
    for(i = 0; i < N; i++)
	{
		if(B[i] == A[6] || B[i] == A[7] || B[i] == A[8])
		{
			d++;
		}
	}

	for(i = 0; i < N; i++)
	{
		if(B[i] == A[2] || B[i] == A[4] || B[i] == A[6])
		{
			e++;
		}
	}




	if(cnt >= 3 || ct >= 3 || c >= 3 || a>=3 || b >= 3 || x >= 3 || d >= 3 || e >= 3)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    int a, mod, c;
    cin >> a >> mod >> c;
    
    for (int i = a; i <= 1e5; i += a)
        if (i % mod == c)
        {
            cout << "YES";
            return 0;
        }
    
    cout << "NO";
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {

	int s, w;
	cin >> s >> w;
	if (s > w) {
		cout << "safe" << endl;
	}
	else cout << "unsafe" << endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	int N;
	std::cin >> N;
	int a[N];
	int maxnum = -1;
	for (size_t i = 0; i < N; i++) {
		std::cin >> a[i];
		maxnum = max(maxnum,a[i]);
	}

	int lst[maxnum+1];
	for (size_t i = 0; i < maxnum+1; i++) {
		lst[i] = 0;
	}
	for (size_t i = 0; i < N; i++) {
		if (a[i] == 0) {
			lst[0]++;
			lst[1]++;
		}
		else if (a[i] == maxnum) {
			lst[maxnum-1]++;
			lst[maxnum]++;
		}
		else {
			lst[a[i]-1]++;
			lst[a[i]]++;
			lst[a[i]+1]++;
		}
	}

	int ans = -1;
	for (size_t i = 0; i < maxnum+1; i++) {
		ans = max(ans,lst[i]);
	}

	std::cout << ans << '\n';
	return 0;
}


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

const int N = 105;
const int Maxn = 0x3f3f3f3f;
int f[N][N], n, m;
char s[N][N];

template <class T>
inline void CkMin(T &x, T y) {x > y ? x = y : 0;}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%s", s[i] + 1);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			if (i == 1 && j == 1)
				f[i][j] = 0;
			else		
				f[i][j] = Maxn;
			if (i > 1)
				CkMin(f[i][j], f[i - 1][j] + (s[i][j] != s[i - 1][j]));
			if (j > 1)
				CkMin(f[i][j], f[i][j - 1] + (s[i][j] != s[i][j - 1]));
		}
	if (f[n][m] == 0)
	{
		if (s[1][1] == '#')
			puts("1");
		else
			puts("0");
	}
	else
	{
		if (s[1][1] == '.' && s[n][m] == '.')
			printf("%d\n", f[n][m] >> 1);
		else if (s[1][1] == '.' || s[n][m] == '.')
			printf("%d\n", f[n][m] + 1 >> 1);
		else
			printf("%d\n", f[n][m] + 2 >> 1);
	}
		
}

Measured memory_bytes: 256
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-01-02
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    string a, b;
    cin >> a >> b;
    cout << b << a << "\n";
    return 0;
}


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

int	main() {
	string S,T,U;
	int		A,B;
  
  	cin >> S >> T;
  	cin >> A >> B;
  	cin >> U;
  
  	if (S==U) A -= 1;
    else if (T==U) B -= 1;
  
  
      cout << A << " " << B;

}

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

int main(){
  
  while(1){
    int h,w; cin >> h >> w;
    if(h==0)break;
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	if(i == 0 || i ==h-1 || j == 0 || j ==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }

}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= 5) cout << 0 << endl;
    else if (a >= 13) cout << b << endl;
    else cout << b / 2 << endl;
}


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

#define all(x) x.begin(), x.end()
#define lc (i << 1)
#define rc (i << 1 | 1)
// #define m ((l + r) >> 1)

using namespace std;

void setIO(string name) {
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
}

// using namespace __gnu_pbds;
// using mii = gp_hash_table<int, int>;
// typedef tree<pii, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MN = 200 * 1e3 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    string temp;
    cin >> temp;
    deque<char> s;
    for (int i = 0; i < temp.length(); i++) s.push_back(temp[i]);
    bool rev = false;
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int t, f;
        char c;
        cin >> t;
        if (t == 1) {
            rev = !rev;
        } else {
            cin >> f >> c;
            if (rev) {
                if (f == 1) s.push_back(c);
                else s.push_front(c);
            } else {
                if (f == 1) s.push_front(c);
                else s.push_back(c);
            }
        }
    }
    if (rev) {
        while (!s.empty()) cout << s.back(), s.pop_back();
    } else {
        while (!s.empty()) cout << s.front(), s.pop_front();
    }
    return 0;
}


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

int main() {
    string A, s, C; cin >> A >> s >> C;
    cout << A.at(0) << s.at(0) << C.at(0) << endl;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll h;

ll solve(ll u) {
    if (u == 1) return 1;
    return 2LL * solve(u / 2) + 1;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> h;
    cout << solve(h);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (A >= B) {
            System.out.println("delicious");
        } else if (B - A < X + 1) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}

Measured memory_bytes: 21332
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>
#include<map>
#include<set>
#include<functional>

using namespace std;

typedef pair<int, int> P;
typedef long long int ll;

ll A, B, C, D;

ll lcm(ll a, ll b) {
	if (a < b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = a * b;
	ll r = a % b;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return x / b;
}

int main() {
	cin >> A >> B >> C >> D;
	ll ans = 0;
	ll x = lcm(C, D);
	ans += B / C;
	ans += B / D;
	ans -= (A - 1) / C;
	ans -= (A - 1) / D;
	ans -= B / x;
	ans += (A - 1) / x;
	/*cout << c << endl;
	cout << d << endl;
	cout << cd << endl;*/
	cout << (B - A + 1) - ans << endl;
}

Measured memory_bytes: 256
import numpy as np
import sys

input = sys.stdin.readline

S = input()

cnt = 0
acgt = ['A','C','G','T']

x = []
for i in range(len(S)):
    if S[i] in acgt:
        x.append(True)
    else:
        x.append(False)

ans = 0
cnt = 0
for i in x:
    if i :
        cnt+=1
    else:
        ans = max(ans,cnt)
        cnt = 0

print(ans)

Measured memory_bytes: 21012
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int ans = 8;
  for(int i = 400; ; i += 200){
    if(i <= N && N < i+200){
      cout << ans << "\n";
      return 0;
    }
    ans--;
  }

  return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a (n);
    for (int i = 0; i < n; ++i) cin >> a[i], --a[i];
    int res = 0;
    for (int i = 0; i < n; ++i) if (a[a[i]] == i) ++res;
    cout << res / 2 << endl;
    return 0;
}


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

struct Node {
	int val, id;
};

const int N = 1e5 + 10;

Node a[N];
long long sum[N];

int main() {
	int n, m, v, p;
	scanf("%d %d %d %d", &n, &m, &v, &p);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i].val);
		a[i].id = i;
	}
	sort(a + 1, a + n + 1, [&](Node x, Node y){return x.val > y.val;});
	for (int i = 1; i <= n; i++) {
		sum[i] = sum[i - 1] + a[i].val;
	}
	for (int i = p + 1, last = p; i <= n; i++) {
		if (i == n || a[i].val != a[i + 1].val) {
			if (a[i].val + m < a[p].val) {
				printf("%d\n", last);
				return 0;
			}
			if (n - i + p < v) {
				if (1LL * (a[i].val + m) * (i - p) - (sum[i - 1] - sum[p - 1]) < 1LL * m * (v - n + i - p)) {
					printf("%d\n", last);
					return 0;
				}
			}
			last = i;
		}
	}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

char a[1010][1010];
string s[4] = {"aabcddbcefggefhh", "aabbcdde.cffegg..hij..hij", "aabbccddeeffghi...ghi......jkl...jkl", "aabbcc.ddee..fgghh..f....ijk....ijk....lmn....lmn"};

int main(){
    int n;
    scanf("%d", &n);
    if(n == 2) puts("-1");
    else if(n == 3) puts("abb\na.c\nddc\n");
    else{
        rep(i, n)rep(j, n) a[i][j] = '.';
        int cur = 0;
        rep(_, n/4-1){
            rep(i, 4)rep(j, 4) a[cur+i][cur+j] = s[0][i*4+j];
            cur += 4;
        }
        int k = 4+n%4;
        rep(i, k)rep(j, k) a[cur+i][cur+j] = s[n%4][i*k+j];
        rep(i, n){
            rep(j, n) printf("%c", a[i][j]);
            printf("\n");
        }
    }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1<<30;
vector<int>v1,v2,v3,v4;
signed main(){
	//WA!!
	int n,w;
	cin>>n>>w;
	int we,vl;
	cin>>we>>vl;
	int cmp=we;v1.push_back(vl);
	for(int i=1;i<n;i++){
		int we,vl;
		cin>>we>>vl;
		if(we==cmp)v1.push_back(vl);
		if(we==cmp+1)v2.push_back(vl);
		if(we==cmp+2)v3.push_back(vl);
		if(we==cmp+3)v4.push_back(vl);
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	sort(v3.begin(),v3.end());
	sort(v4.begin(),v4.end());
	reverse(v1.begin(),v1.end());
	reverse(v2.begin(),v2.end());
	reverse(v3.begin(),v3.end());
	reverse(v4.begin(),v4.end());
	int ans=0;int w1;
	for(int sum=1;sum<=n;sum++)
		for(int i=0;i<=v1.size();i++)
			for(int j=0;j<=v2.size();j++){
				int k=sum-i-j;
				w1=w;
				if(k<0)continue;
				if(k>v3.size())continue;
				w1-=i*cmp;
				w1-=j*(cmp+1);
				w1-=k*(cmp+2);
				if(w1<0)continue;
				int l=w1/(cmp+3);
				//cout<<l<<" "<<v4.size()<<endl;
				if(l>v4.size())l=v4.size();
				int gt=0;
				//cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<w1<<" "<<cmp+3<<endl;
				for(int g=0;g<i;g++)gt+=max(0ll,v1[g]);
				for(int g=0;g<j;g++)gt+=max(0ll,v2[g]);
				for(int g=0;g<k;g++)gt+=max(0ll,v3[g]);
				for(int g=0;g<l;g++)gt+=max(0ll,v4[g]);
				ans=max(ans,gt);
			}
	cout<<ans<<endl;
	return 0;
}

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

const int INF = 1001001001;

int main(void){
    int n, m, x;
    cin >> n >> m >> x;

    int a[12][12];
    vector<int> c(n);
    rep(i,n) {
        cin >> c[i];
        rep(j,m) {
            cin >> a[i][j];
        }
    }

    int ans = INF;
    rep(s,1<<n) {
        int cost = 0;
        vector<int> d(m, 0);
        rep(i,n) {
            if (s>>i&1) {
                cost += c[i];
                rep(j,m) {
                    d[j] += a[i][j];
                }
            } 
        }
        bool ok = true;
        rep(i,m) {
            if (d[i] < x){
                ok = false;
            }
        }
        if (ok) {
            ans = min(ans, cost);
        }
    }

    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  long long n,a[205];
  long long dp[200];
  cin >> n;

  for(int i=0;i<n;i++){
    cin >> a[i];
    dp[i] = 0;
  }
  dp[0] = 1000;
  for(int i = 0; i < n ; i ++){
    long long stock = dp[i] / a[i];
    for(int j = i+1; j < n; j ++){
      dp[j] = max(dp[i], dp[i] - stock * a[i] + stock * a[j]);
    }
  }
  cout << dp[n-1];
  return 0;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
auto& errStream=cerr;
#ifdef LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%"  SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

signed main(){
	int n=read(),p=read();
	if(n==1){
		print(p);
		return 0;
	}
	int ans=1;
	for(int x=2;x*x<=p;x++){
		if(p%x==0){
			int cnt=0;
			while(p%x==0){
				cnt++;
				p/=x;
			}
			cnt/=n;
			REP(_,cnt)
				ans*=x;
		}
	}
	print(ans);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	string s; cin >> s;
	int won = 15-sz(s);
	each(c, s) won += (c == 'o');
	cout << (won >= 8 ? "YES\n" : "NO\n");
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}



int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll q;
    cin>>q;
    while (q--){
        ll a,b;
        cin>>a>>b;
        if(a>b){
            swap(a,b);
        }
        ll z = a*b-1;
        ll v = sqrt(1LL*a*b);

        ll ans = 2*v-1;
        if(v*(v+1)>=a*b){
            ans--;
        }
        if(a*b == v*v && a!=b){
            ans--;
        }
        cout<<ans<<endl;
    }

    return  0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

cnt1 = 0
cnt2 = 0
for s in S[::2]:
    if s == '0':
        cnt1 += 1
    elif s == '1':
        cnt2 += 1
for s in S[1::2]:
    if s == '1':
        cnt1 += 1
    elif s == '0':
        cnt2 += 1

print(N-max(cnt1, cnt2))

Measured memory_bytes: 9184
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int tg[maxn];

bool get(int n){
	cout<<n<<endl;
	string tmp;
	cin>>tmp;
	if(tmp[0]=='V') exit(0);
	if(tmp[0]=='M') return 0;
	return 1;
}

int main()
{
	int n;
	cin>>n;
	int l=0,r=n;
	int meow=get(0);
	tg[n]=tg[0]=meow;
	while(l!=r-2){
		int mid=(l+r)/2;
		tg[mid]=get(mid);
		if((mid-l+tg[l])%2!=tg[mid]){
			r=mid;
		}
		else l=mid;
	}
	cout<<l+1<<endl;

	return 0;
}


Measured memory_bytes: 852
import java.util.*;

class Main{
  public static void main(String[] args)throws Exception{
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    
    for(int i=n; i>0; i--){
      double ans = Math.sqrt(i);
      if((ans-(int)Math.sqrt(i))==0){
        System.out.println(i);
        break;
      }
    }
  }
}

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


int main(void){
    int N, M; cin >> N >> M;
    vector<int> a;
    int total=0;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
        total += tmp;
    }
    sort(a.begin(), a.end());
    int ans=1;

    for(int i=0; i<M; i++){
        //cout << a[N-i-1] << " ";
        if((double)a[N-1-i] < (double)total/(4*M)) ans =0;
    }
    if(ans == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[2004][3],ans[2005][2005],k[20005];
int n;
void dfs(int cur,int base,int dis)
{  ans[base][cur]=min(dis,ans[base][cur]);
   printf("cur=%d base=%d dis=%d\n",cur,base,dis);
   if(cur==base)return;
   if(cur==n)return;
   for(int i=0;i<3;i++)
   {   if(a[cur][i]!=0)dfs(a[cur][i],base,dis+1);
   }
}
int main()
{   int x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
    {
          for(int j=i+1;j<=n;j++)
          {   if(i<=x)
              {   int d=min(j-i,x-i+1+abs(y-j));
                  //printf("i=%d j=%d d=%d\n",i,j,d);
                  k[d]++;
              }
            else if(i<y)
            {  int d=min(i-x+1+abs(j-y),j-i);
               // printf("i=%d j=%d d=%d\n",i,j,d);
                k[d]++;
            }
            else
            {  // printf("i=%d j=%d d=%d\n",i,j,j-i);
                k[j-i]++;
            }
          }
    }
    for(int i=1;i<n;i++)
        printf("%d\n",k[i]);






    return 0;
}


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

#define ll long long
#define v vector

int main()
{
 	int i,n,m;
 	cin>>n;
 	cin>>m;
 	v<ll> a(n);
 	for(i = 0 ; i < n ; i++)
 	cin>>a[i];
 	make_heap(a.begin(),a.end());
 	while(m > 0)
 	{
 		ll x = a.front();
		x = x/2;
		pop_heap(a.begin(), a.end()); 
    	a.pop_back();
    	a.push_back(x);
    	push_heap(a.begin(),a.end());
    	m--;
	}
	ll sum = 0;
	for( i = 0 ; i < n ; i++)
	sum += a[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))

#値を修正する場合、1か−1にすればよい
##そのためには、値の絶対値に1を足した数を加えればよい

#正、負のパターンと負、正のパターンの両方について算出し、小さい方を出力する
##没解だと、所与のA[0]の符号を基準としたまま、答えを提出していたが、
##当然、それが最適値であるとは限らない！！！

total = 0
ans = 0
total2 = 0
ans2 = 0

for i in range(N):
    total += A[i]
    #奇数番目を正にする
    if i % 2 == 0:
        #1より小さい == 0以下
        if total < 1:
            ans += 1 - total
            total = 1
    else:
        #0以上
        if total > -1:
            ans += (1 + total)
            total = -1

for i in range(N):
    total2 += A[i]
    #偶数番目を正にする
    if i % 2 == 1:
        if total2 < 1:
            ans2 += 1 - total2
            total2 = 1
    else:
        if total2 > -1:
            ans2 += 1 + total2
            total2 = -1

print(min(ans,ans2))

Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define p pair<int,int>
template<class T> void chmax(T& a, T b){if(a < b) a = b;}
template<class T> void chmin(T& a, T b){if(a > b) a = b;}
int N, H ,W, ans;
int main(){
    cin >> N >> H >> W;
    for(int i = 0; i < N; i++){
        int A, B;
        cin >> A >> B;
        if(A >= H && B >= W) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int a,b,c,d,e,k;
  int ans = 0;

  cin >> a>> b>> c>> d>> e>> k;
  // vi v(n);
  // REP(i, n) {
  //   cin >> v[i];
  // }

  cout << (e - a > k ? ":(" : "Yay!") << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


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

int main(){
  int n;
  cin >> n;
  vector<long long> data(n);
  for(int i=0; i<n; i++){
    cin >> data.at(i);
  }
  
  long long sum=0;
  
  for(int i=0; i<n; i++){
    if(i%2 == 0){
      sum += data.at(i);
    }else{
      sum -= data.at(i);
    }
  }
  
  long long answer = sum;
  
  vector<long long> rain(n);
  
  rain.at(0) = answer;
  
  for(int i=1; i<n; i++){
    rain.at(i) = (data.at(i-1) - (rain.at(i-1)/2))*2;
  }
  
  for(int i=0; i<n; i++){
    cout << rain.at(i) << " ";
  }
  cout << endl;
      
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

bool contain(string T, vector<char> a){
  int cnt = 0, j = 0;
  int t_size = T.size();
  rep(i, a.size()){
    // cout << "debug:" << a[i] << " " << T.at(j)<< endl;
    if (cnt == t_size) return true;
    if (a.at(i) == T.at(j)) {
        cnt++;
        j++;
    } else {
      cnt = 0;
    }
    if(j == t_size) j = 0;
  }
  return false;
}

int main() {
  string S, T;
  cin >> S >> T;
  vector<char> a;
  rep(i, 2)  {
    rep(i, S.size()){ // 順番に2回代入していく。
        a.push_back(S[i]);
    }
  }

  if (contain(T, a)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256