akhauriyash/Code-Regression huggingface dataset:
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = show $ (n - 1) * (m - 1) where [n, m] = fmap read (words s) :: [Int]

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

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

int main(){
  deque<char> str;
  int Q, T, F, a, b;
  string S;
  char C;
  cin >> S >> Q;
  a = S.size();
  rep(i,a){
    str.push_back(S.at(i));
  }
  bool rev = false;
  rep(i, Q){
    cin >> T;
    if (T == 1) rev = !rev;
    else{
      cin >> F >> C;
      if(rev){
        F = 3-F;
      }
      if (F == 1) str.push_front(C);
      else str.push_back(C);
    }
  }
  if(rev){
    reverse(str.begin(), str.end());
  }
  a = str.size();
  rep(i,a){
    cout << str.at(i);
  }
  cout << endl;  
}

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

const long long md=1e9+7;//mod
const int maxn=1001000;
long long fac[maxn],inv[maxn];

// cal x^y in logy order
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
// calc n! by fermat's little theory
void csh(){
	fac[0]=1;
	for(int i=1;i<=1000000;i++)
		fac[i]=fac[i-1]*i%md;
	inv[1000000]=powd(fac[1000000],md-2);
	for(int i=1000000;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
}
//calc combination in xlonx
long long C(int x,int y){
	return fac[x]*inv[y]%md*inv[x-y]%md;
}



int main(){
  csh();
  int X, Y;
  cin >> X >> Y;
  if ((X+Y)%3!=0||2*Y-X<0||2*X-Y<0){
    cout << 0 << endl;
  } else {
    cout << C((X+Y)/3,(2*Y-X)/3) << endl;
  }
}


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

int main() {

	int H, W;
	cin >> H >> W;
	
	vector<vector<char>> A(H+1, vector<char>(W+1, '1'));

	for(int i =1;i <= H; i++){
		for(int j =1;j <= W; j++)
			cin >> A.at(i).at(j);
	}

	for(int i = 1;i <= H; i++){
		for(int j = 1;j<= W; j++){
			if(A.at(i).at(j) == '#'){
				A.at(i).at(0) = '0'; //消せない行のフラグ 				
				A.at(0).at(j) = '0'; //消せない列のフラグ 				
				continue;
			}
		}
	}

	for(int i = 1;i <= H; i++){
		if(A.at(i).at(0) == '0'){
			for(int j = 1;j<= W; j++){
				if(A.at(0).at(j) == '0') cout << A.at(i).at(j);
				if(j == W) cout << endl;
				}
			}
		}
	}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define MAX 1010

int main(){
  int n;
  while(scanf("%d",&n),n){
    int ans[n][n];
    int x = n/2, y = n/2 + 1;
    memset(ans, 0, sizeof(ans));
    REP(i,n*n){
      ans[y][x] = i + 1;

      x++; y++;
      x = (x + n) % n;
      y = (y + n) % n;
      if(i != n*n-1)
      while(ans[y][x] != 0){
	x--; y++;
	x = (x + n) % n;
	y = (y + n) % n;
      }
    }
    REP(i, n){ 
      REP(j, n)
	printf("%4d",ans[i][j]);
      puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

vector<int>graph[114514], revgr[114514], hozon[114514];

int N;
vector<int>cash;
//0->N-1までの距離
int dfs(int v, int las)
{
	if (v == N - 1)return 0;
	int res = 114514810;
	int pus = -1;
	for (int nxt : hozon[v])
	{
		if (nxt == las)continue;
		int can = dfs(nxt, v);
		if (res > can)
		{
			res = can;
			pus = nxt;
		}
	}
	if (res < 114514)
	{
		cash.push_back(pus);
	}
	return res;
}


//到達可能な頂点の個数
int dfs2(int v, int las)
{
	int res = 1;
	for (int nxt : graph[v])
	{
		if (nxt == las)continue;
		res += dfs2(nxt, v);
	}
	return res;
}

//到達可能な頂点の個数
int dfs3(int v, int las)
{
	int res = 1;
	for (int nxt : revgr[v])
	{
		if (nxt == las)continue;
		res += dfs3(nxt, v);
	}
	return res;
}


//到達可能な頂点の個数
int dfs4(int v, int las)
{
	int res = 1;
	for (int nxt : hozon[v])
	{
		if (nxt == las)continue;
		res += dfs4(nxt, v);
	}
	return res;
}


int main(void)
{
	cin >> N;
	for (int i = 0; i < N - 1; ++i)
	{
		int p, q;
		cin >> p >> q;
		--p; --q;
		graph[p].push_back(q);
		graph[q].push_back(p);
		revgr[p].push_back(q);
		revgr[q].push_back(p);
		hozon[p].push_back(q);
		hozon[q].push_back(p);
	}
	graph[N - 1].clear();
	revgr[0].clear();
	int X = dfs2(0, -1);
	int Z = dfs3(N - 1, -1);
	int Y = X + Z - N;
	X -= Y;
	Z -= Y;
	Y -= 2;
	//まずはYをすべて消費
	bool snuke = Y % 2;

	dfs(0, -1);
	reverse(cash.begin(), cash.end());

	cash.pop_back();

	int fe = 0;
	int sn = cash.size() - 1;
	while (true)
	{
		if (sn - fe < 0)break;
		//Fe
		//X += hozon[cash[fe]].size() - 2;
		for (int nxt : hozon[cash[fe]])
		{
			int lef = ((fe == 0) ? 0 : cash[fe - 1]);
			int rht = ((fe + 1 == cash.size()) ? N-1 : cash[fe + 1]);
			if (nxt == lef || nxt == rht)continue;
			X += dfs4(nxt, cash[fe]);
		}
		Y -= hozon[cash[fe]].size() - 1;
		fe++;
		if (sn - fe < 0)break;
		//Sn
		//Z += hozon[cash[sn]].size() - 2;
		for (int nxt : hozon[cash[sn]])
		{
			int lef = ((sn == 0) ? 0 : cash[sn - 1]);
			int rht = ((sn + 1 == cash.size()) ? N-1 : cash[sn + 1]);
			if (nxt == lef || nxt == rht)continue; 
			Z += dfs4(nxt, cash[sn]);
		}
		Y -= hozon[cash[sn]].size() - 1;
		sn--;
	}

	//assert(!Y);

	snuke = cash.size() % 2;

	if (X < Z)
	{
		cout << "Snuke\n";
	}
	else if(X > Z)
	{
		cout << "Fennec\n";
	}
	else if (snuke)
	{
		cout << "Fennec\n";
	}
	else
	{
		cout << "Snuke\n";
	}
	return 0;
}






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

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

int h,a,m,b,s;

h = S/3600;//何時間
a = S%3600;//残り秒数
m = a/60;//何分
b = a%60;//残り秒数
s = b;

cout << h << ":" << m << ":" << s << endl;

}


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

using namespace std;
using ll = long long;

int main() {
    string s, t = "";
    cin >> s >> t;
    int cnt = 0;
    for(int i = 0;i < s.size();i++){
        if(s[i] != t[i]){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;

	while(getline(cin,s))
	{
		for ( int i=0; i<26; i++ )
		{
			string t;
			for ( int j=0; j<(int)s.length(); j++ )
				if ( 'a'<=s[j]&&s[j]<='z' )
					t += (s[j]-'a'+i)%26+'a';
				else
					t += s[j];
			if ( t.find("the")!=t.npos ||
				 t.find("this")!=t.npos ||
				 t.find("that")!=t.npos )
			{
				cout << t << endl;
				break;
			}

		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

int main(){
	string S,a[10] = {
		"* = ****",
		"* =* ***",
		"* =** **",
		"* =*** *",
		"* =**** ",
		" *= ****",
		" *=* ***",
		" *=** **",
		" *=*** *",
		" *=**** "};
	for(int ds=0; cin>>S; ds++){
		if(ds!=0) puts("");
		while(S.size()<5) S = "0"+S;
		for(int i=0;i<8;i++){
			for(int j=0;j<S.size();j++){
				printf("%c",a[S[j]-'0'][i]);
			}puts("");
		}
	}
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    ll n, m;
    cin >> n >> m;

    if (n >= 3 && m >= 3) {
        cout << (n - 2) * (m - 2) << endl;
    } else {
        if (n == 2 || m == 2) {
            cout << 0 << endl;
        } else {
            if (n == 1 && m == 1) {
                cout << 1 << endl;
            } else {
                if (n < m) {
                    cout << max(m - 2, 0LL) << endl;
                } else {
                    cout << max(n - 2, 0LL) << endl;
                }
            }
        }
    }
}

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

ll N;
vector<vector<ll>> A;
int main(){
    cin >> N;
    A.resize(2, vector<ll>(N, 0));
    ll ans = 0;
    cin >> ans;
    rep(j, 0, 2){
        rep(i, 1, N){
            ll t;
            cin >> t;
            A[j][i] = t + A[j][i-1];
        }
    }
    ll t; cin >> t;
    ans += t;

    ll mx = 0;
    rep(i, 0, N){
        mx = max(mx, A[0][i]-A[0][0]+A[1][N-1]-A[1][i]);
    }
    cout << ans+mx << endl;
    return 0;
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> Nx(N), Ny(N), Mx(M), My(M);
    for (int i = 0; i < N; i++)
        cin >> Nx[i] >> Ny[i];
    for (int i = 0; i < M; i++)
        cin >> Mx[i] >> My[i];

    for (int i = 0; i < N; i++)
    {
        int ans, d = MOD;
        for (int j = 0; j < M; j++)
        {
            int tmp = abs(Nx[i] - Mx[j]) + abs(Ny[i] - My[j]);
            if (tmp < d)
                ans = j, d = tmp;
        }
        cout << ans + 1 << endl;
    }
}

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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

struct BinarySearchTree {
    BinarySearchTree *left = nullptr, *right = nullptr;
    int value;
    BinarySearchTree(int value) : value(value) {}
};

BinarySearchTree* insert(BinarySearchTree *root, BinarySearchTree *z) {
    BinarySearchTree *y = nullptr;
    BinarySearchTree *x = root;

    while (x != nullptr) {
        y = x;
        if (z->value < x->value) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    if (y == nullptr) {
        return z;
    } else if (z->value < y->value) {
        y->left = z;
    } else {
        y->right = z;
    }

    return root;
}

void preorder_print(BinarySearchTree *node) {
    if (node == nullptr) { return; }
    cout << " " << node->value;
    preorder_print(node->left);
    preorder_print(node->right);
}

void inorder_print(BinarySearchTree *node) {
    if (node == nullptr) { return; }
    inorder_print(node->left);
    cout << " " << node->value;
    inorder_print(node->right);
}

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

    int n;
    cin >> n;

    string command;
    int value;
    BinarySearchTree *root = nullptr;

    FOR(i,0,n) {
        cin >> command;
        if (command == "insert") {
            cin >> value;
            auto z = new BinarySearchTree(value);
            root = insert(root, z);
        } else {
            inorder_print(root);
            cout << endl;
            preorder_print(root);
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 18828
#include<bits/stdc++.h>
using namespace std;
int n,t,x,y;
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>t>>x>>y;
		if(x+y>t||(t-x-y)%2!=0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long
#include <map>
#undef ll
#define int long long 
#undef int
#define rep(i,a,n) for(int (i)=(a);i<=(n);i++)
using i64 = long long;
int main()
{
  unsigned n;
  std::cin>>n;
  std::vector<std::string> s(n);
  for(auto & ss : s){
    std::cin >> ss;
  }
  i64 M=0,A=0,R=0,C=0;
  std::map<char, i64> mp;
  using namespace std;
  for(int i = 0; i < n; ++i){
    mp[s[i][0]]++;
  }
  #define int long long
  string mmmmmmmmmmmmmmmmmmmmmmmmaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrccccccccccccchhhhhhhhhh = "MARCH";
  string S = mmmmmmmmmmmmmmmmmmmmmmmmaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrccccccccccccchhhhhhhhhh;
  string march = S;
  rep(i,0,4){
    string ugis = "Kutimotitokura";
    for(int j = i + 1;j <= 4;i++){
      ++j;
      break;
      return 0;
      return main();
      i -= 114514;
    }
    switch(M){
      case 0:
      break;
      default:
      break;
    }
    /*
    int ei1333 = 1333
    rep(j,i+1,4)rep(k,j+1,4) M+=mp[S[i]]*mp[S[j]]*mp[S[k]];
    cout<<M<<endl;
    return 0;
    open and close coment by Hide1204*/
    // I want to be blue coder
    rep(j,i+1,4)rep(k,j+1,4)mp['!']+=mp[S[i]]*mp[S[j]]*mp[S[k]];
  }
  printf("%ld",mp['!']);
  cerr<<"Hide1204"<<endl;
  cerr << "playroller" << endl;
  cerr << fixed << "kutimotitokura" << "kutimotitokura\n"[14];
  cerr << "ugis" <<endl;
  cerr << "karaitarako" << endl << endl;
  return 0;
  return main();
}

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

int main(){
	int n,m; //n:card num, m:operation num
	cin>>n>>m;
	int li[]={1};
	vector<int> vec(li,li+1);
	//vec.pop_back();
	for(int i=2;i<=n*2;i++)vec.push_back(i); //init
	int k;
	vector<int>::iterator it;
	int debug=0;
	if(debug){
		cout<<"[0]: ";	//[0]
		for(it=vec.begin();it!=vec.end();++it)cout<<*it<<" ";
		cout<<"\n";
	}
	for(int i=1;i<=m;i++){
		cin>>k;
		if(k==0){	//[1]
			for(int a=0;a<n;a++){//最初のカードを0枚目とする。
				//a枚目
				it=vec.begin()+a;
				vec.push_back(*it);
				//n+a枚目
				it=vec.begin()+n+a;
				vec.push_back(*it);
			}
			vec.erase(vec.begin(),vec.begin()+n*2);      //0枚目からn*2-1枚目を消す
			if(debug)cout<<"[1]: ";
		}else{		//[2]
			for(int b=0;b<k;b++){
				int jk=vec.front();
				vec.erase(vec.begin());
				vec.push_back(jk);
			}
			if(debug)cout<<"[2]: ";
		}
		if(debug){
			for(it=vec.begin();it!=vec.end();++it)cout<<*it<<" ";
			cout<<"\n";
		}
	}
	if(debug){		//[3]
		cout<<"[3]: ";
		for(it=vec.begin();it!=vec.end();++it)cout<<*it<<" ";
		cout<<"\n";
	}else for(it=vec.begin();it!=vec.end();++it)cout<<*it<<endl;
	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll MOD = 1e9 + 7 ;
const ll dx[4] = { -1,1,0,0 };
const ll dy[4] = { 0,0,-1,1 };
const ll MAX =  1e5 + 10 ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
long long gcd(long long  a, long long  b) { return (b == 0 ? a : gcd(b, a % b)); }
ll n , m , x , k , Q , ans ; string s,t;
int dp[MAX];
vector < vector < int > > g ;
bool vis[MAX];
int dfs(int u){

    vis[u] = true;

    int &ret = dp[u];

    if(~ret)
        return ret;

    ret = 0;

    for(auto v : g[u])
            ret = max(ret , 1 + dfs(v));

    return ret;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
//    freopen("test.in","r",stdin);

    cin>>n>>m;
    g.clear();
    g.resize(n + 1);
    for(int i = 0 ; i < m ; ++i){
        int u , v ;
        cin>>u>>v;
        --u; --v;
        g[u].pb(v);
    }

    for(int i = 0 ; i < n ; ++i)
        dp[i] =  -1;

    int ans = 0 ;
    for(int i = 0 ; i < n ; ++i)
        if(!vis[i])
            ans = max(ans,dfs(i));

    cout<<ans<<'\n';


    return 0;
}


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

long long gcd(long long a,long long b){long long r,tmp;if(a < b){tmp = a;a = b;b = tmp;}r = a % b;while(r != 0){a = b;b = r;r = a % b;}return b;}

int main()
{
    int n;
    cin >> n;
    int a;
    cin >> a;
    int ans = a;
    for (int i = 1; i < n; i++)
    {
        cin >> a;
        ans = gcd(ans, a);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

template <class T, class Comp=std::less<T>>
auto cartesian_tree(vec<T> const& a, Comp const& comp={}) {
    usize n = a.size();
    vec<T> stack;
    vec<usize> p(n, n);
    for (usize i=0; i<n; i++) {
        usize j = n;
        while (!stack.empty() && comp(a.at(i), a.at(stack.back()))) {
            j = stack.back();
            stack.pop_back();
        }
        if (j!=n) {
            p.at(j) = i;
        }
        if (!stack.empty()) {
            p.at(i) = stack.back();
        }
        stack.push_back(i);
    }

    usize root = n;
    vec<vec<usize>> g(n);
    for (usize i=0; i<n; i++) {
        if (p.at(i)==n) {
            root = i;
        } else {
            g.at(p.at(i)).push_back(i);
        }
    }
    return std::make_pair(root, g);
}

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

    usize n;
    std::cin >> n;
    vec<usize> a(n);
    for (usize& x: a) std::cin >> x;

    usize r;
    vec<vec<usize>> g;
    std::tie(r, g) = cartesian_tree(a);

    usize ans = 0;
    auto dfs = [&](auto&& f, usize x) -> usize {
        usize sz = 1;
        usize now = a.at(x);
        for (usize y: g.at(x)) {
            usize s = f(f, y);
            sz += s;
            now *= s + 1;
        }
        ans += now;
        return sz;
    };
    dfs(dfs, r);

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


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

using namespace std;

int main()
{
	int x[5];

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

		if (x[i] == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}

	
}


Measured memory_bytes: 3564
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {

  string s,t;
  cin >> s>>t;
  


  cout << ( t.substr(0,s.size())==s      ?  "Yes " : "No" ) << endl ;     //小文字だったら直す


}


Measured memory_bytes: 3628
A,B,C,X,Y= map(int, input().split())

x = 2*X
y = 2*Y
p = 0

if A+B >= 2*C:
    k = max(X,Y)-abs(X-Y)
    p += 2 * k * C
    X -= k
    Y -= k

while X>0:
    X -= 1
    if A > 2*C:
        p += 2*C
    else:
        p += A

while Y>0:
    Y -= 1
    if B > 2*C:
        p += 2*C
    else:
        p += B
        
print(p)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <cmath>

using namespace std;
#define inf 10101010
typedef pair<int,int> pii;

int main(void){
    int n, ans;
    cin >> n;
    vector<int> g(n);
    vector<int> g2(n, -1);
    for (int i = 0; i < n; i++) cin >> g[i];
    set<int> se;
    for (int i = 0; i < n; i++) {
        if (g[i] == 0) continue;
        if (se.count(i)) continue;
        set<int> s;
        int j = i;
        while (g[j] != 0) {
            if (g2[j] != -1) {
                j = g2[j];
                break;
            }
            if (s.count(j) || se.count(j)) {
                se.insert(s.begin(), s.end());
                break;
            }
            s.insert(j);
            j += g[j];
        }
        if (!se.count(j)) {
            for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
                g2[*it] = j;
            }
        }
    }
    vector<int> dp(n, inf);
    dp[0] = 0;
    
    priority_queue<pii, vector<pii>, greater<pii> > que;
    que.push(make_pair(0, 0));
    while (!que.empty()) {
        pii p = que.top(); que.pop();
        int  cnt = p.first, pos = p.second;
        if (pos >= n-1) {
            ans = cnt;
            break;
        }
        for (int i = 1; i < 7; i++) {
            if (se.count(pos+i)) continue;
            int t = pos+i;
            if (g2[t] != -1) t = g2[t];
            if (dp[t] > cnt+1) {
                dp[t] = cnt+1;
                que.push(make_pair(cnt+1, t));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11356
import java.util.Scanner;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args){
		Scanner sc  = new Scanner(System.in);
		
		while(sc.hasNextLine()){
			//double preX,preY;
			String[] s = sc.nextLine().split("[\\s]+");
			long[] data = new long[s.length];
			for(int i=0;i<s.length;i++){
				data[i] = Long.parseLong(s[i]);
			}
			
			System.out.println(gcd(data[0],data[1])+" "+lcm(data[0],data[1]));
			
		}
	}
	
	public static long gcd(long a,long b){
		return b==0 ? a : gcd(b,a%b);
	}
	
	public static long lcm(long a,long b){
		return a*b / gcd(a,b);
	}
}

Measured memory_bytes: 17204
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int N;
    int K;
    string S;
    cin >> N;
    cin >> K;
    cin >> S;

    S[K-1] = char(tolower(S[K-1]));

    cout << S;

    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
n = s.size
d = Array.new(n)
m = n

("a".."z").each do |c|
    j = 1

    (n - 1).downto(0) do |i|
        j = 0 if s[i] == c
        d[i] = j
        j += 1
    end

    t = d.max
    m = t if m > t
    d.clear
end

puts m

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

int main() {
    int a,b;
    cin >> a >> b;
    for(int i = 1;i <= 1250; ++i) {
        if(floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i ;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

struct edge { int to, cost; };
vector<edge> G[10000];

ll BF(ll s,ll V) {
	vector<ll> d(V+3, INF);
	d[s] = 0;
	ll cnt = 0;
	bool update = false;

	while (1) {
		update = false;
		for (int i = 1; i <= V; i++)
		{
			for (int j = 0; j < G[i].size(); j++)
			{
				if (d[i] != INF && d[G[i][j].to]> d[i] + G[i][j].cost) {
					update = true;
					d[G[i][j].to] = d[i] + G[i][j].cost;
					if (cnt == V - 1) {
						d[G[i][j].to] = -INF;
					}
				}
			}
		}

		if (!update)break;
		cnt++;

		if (cnt>2 * V) {
			break;
		}
	}
	if (d[V]<-1e12) {
		return INF;
	}
	else {
		return d[V];
	}
}

ll n, m, p, ans;

signed main() {
	cin >> n >> m >> p;

	ll a, b, c;
	for (int i = 0; i <m ;i++){	
		cin >> a >> b >> c;
		edge f = { b,p - c };
		G[a].push_back(f);
	}

	ans = BF(1,n);

	if (ans == INF) {
		cout << -1 << endl;
	}
	else {
		cout << max(-ans, 0ll) << endl;
	}
}


Measured memory_bytes: 640
import sys
input = sys.stdin.buffer.readline

from collections import deque

N, M = map(int, input().split())

X = [-10**9, 0, 10**9]
Y = [-10**9, 0, 10**9]

tate = []
yoko = []

for _ in range(N):
    a, b, c = map(int, input().split())
    X.append(a)
    X.append(b)
    Y.append(c)
    tate.append((a, b, c))

for _ in range(M):
    d, e, f = map(int, input().split())
    X.append(d)
    Y.append(e)
    Y.append(f)
    yoko.append((d, e, f))

X = sorted(set(X))
Y = sorted(set(Y))

Cx = {val: idx * 2 for idx, val in enumerate(X)}
Cy = {val: idx * 2 for idx, val in enumerate(Y)}

H = len(X) * 2 - 1
W = len(Y) * 2 - 1

G = [0] * (H * W)

for a, b, c in tate:
    j = Cy[c]
    for i in range(Cx[a], Cx[b] + 1):
        G[i * W + j] = -1

for d, e, f in yoko:
    i = Cx[d]
    for j in range(Cy[e], Cy[f] + 1):
        G[i * W + j] = -1

for i in range(1, H, 2):
    for j in range(1, W, 2):
        G[i * W + j] = (X[(i + 1) // 2] - X[(i - 1) // 2]) * (Y[(j + 1) // 2] - Y[(j - 1) // 2])

queue = deque([Cx[0] * W + Cy[0]])

visited = [0] * (H * W)
visited[Cx[0] * W + Cy[0]] = 1

res = 0

while queue:
    z = queue.pop()

    nz = z + W
    if G[nz] != -1 and not visited[nz]:
        nx = nz // W
        if nx == H - 1:
            print('INF')
            break
        visited[nz] = 1
        res += G[nz]
        queue.append(nz)

    nz = z - W
    if G[nz] != -1 and not visited[nz]:
        nx = nz // W
        if nx == 0:
            print('INF')
            break
        visited[nz] = 1
        res += G[nz]
        queue.append(nz)

    nz = z + 1
    if G[nz] != -1 and not visited[nz]:
        ny = nz % W
        if ny == W - 1:
            print('INF')
            break
        visited[nz] = 1
        res += G[nz]
        queue.append(nz)

    nz = z - 1
    if G[nz] != -1 and not visited[nz]:
        ny = nz % W
        if ny == 0:
            print('INF')
            break
        visited[nz] = 1
        res += G[nz]
        queue.append(nz)
else:
    print(res)

Measured memory_bytes: 890064
main :: IO ()
main = do
    ab <- getLine
    let list = words ab
    let list2 = map read list :: [Int]
    -- putStrLn $ unwords $ map show list2
    solve list2
    
solve :: [Int] -> IO ()
solve listt
    | ( mod ( listt !! 0 ) 2 == 1 ) && ( mod ( listt !! 1 ) 2 == 1 ) = putStrLn "Yes"
    | otherwise = putStrLn "No"

Measured memory_bytes: 508
#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int dpA[100001], dpB[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	ll N = getint(), A = getint(), B = getint();
	ll S[100001];
	rep(i, N) S[i] = getint();
	S[N] = 3e18;

	const int mod = 1e9 + 7;

	int a = 1, b = 1;
	int ka = 0, kb = 0;
	dpA[0] = 1;
	dpB[0] = 1;
	rep(i, N - 1) {	
		while (S[i] + A > S[a]) {
			ka += (S[a - 1] + B > S[a++]);
		}
		while (S[i] + B > S[b]) {
			kb += (S[b - 1] + A > S[b++]);
		};
		ka -= (S[i + 1] - S[i] < B);
		kb -= (S[i + 1] - S[i] < A);

		if (S[i + 1] - S[i] >= A) {
			dpA[i + 1] = (dpA[i] + dpA[i + 1]) % mod;
			dpB[i + 1] = (dpA[i] + dpB[i + 1]) % mod;
		}
		else if (ka <= 0) dpB[a - 1] = (dpA[i] + dpB[a - 1]) % mod;
		
		if (S[i + 1] - S[i] >= B) {
			dpA[i + 1] = (dpB[i] + dpA[i + 1]) % mod;
			dpB[i + 1] = (dpB[i] + dpB[i + 1]) % mod;
		}
		else if (kb <= 0) dpA[b - 1] = (dpB[i] + dpA[b - 1]) % mod;
	}
	printf("%d\n", (dpA[N - 1] + dpB[N - 1]) % mod);

	Would you please return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  ll r, g, b;
  r = g = b = 0;
  rep(i, N) {
    if (S.at(i) == 'R') r++;
    if (S.at(i) == 'G') g++;
    if (S.at(i) == 'B') b++;
  }
  ll cnt = r * g * b;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int k = 2 * j - i;
      if (k >= N) continue;
      if (S.at(i) != S.at(j) && S.at(j) != S.at(k) && S.at(k) != S.at(i)) cnt--;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3644
x, y = list(map(int, input().split()))


for i in range(x+1):
    zzz = y - i * 4
    if x - i != 0:
        if zzz / (x - i) == 2.0:
            print('Yes')
            quit()
    else:
        if zzz == 0:
            print('Yes')
            quit()

print('No')


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

typedef long long LL;

const int N=200000,C=30;

struct operate{
  int opt,x,y,z;
  operate(int Opt=0,int X=0,int Y=0,int Z=0){opt=Opt;x=X;y=Y;z=Z;}
}ans[N+9];
int ca,cp;

void Add_ans(int opt,int x,int y,int z){ans[++ca]=operate(opt,x,y,z);}

int pw[C+9];

void Get_pw(){
  Add_ans(1,0,3,3);
  Add_ans(1,1,3,3);
  Add_ans(1,3,3,3);
  Add_ans(0,0,3,3);
  pw[0]=cp=3;
  for (int i=1;i<C;++i) Add_ans(1,cp,cp,pw[i]=cp+1),++cp;
}

int bit[2][C+9];

void Get_bit(int id){
  Add_ans(1,id,pw[0],id);
  int sum=++cp;
  for (int i=C-1;i>=0;--i){
	int t=++cp;
	Add_ans(1,sum,pw[i],t);
	Add_ans(0,t,id,t);
	bit[id][i]=t;
	++cp;Add_ans(1,cp,t,cp);
	for (int j=1;j<=i;++j) Add_ans(1,cp,cp,cp);
	Add_ans(1,sum,cp,sum);
  }
}

void Get_mul(){
  for (int i=0;i<C;++i)
	for (int j=0;j<C;++j){
	  int t=++cp;
	  Add_ans(1,bit[0][i],bit[1][j],t);
	  Add_ans(0,pw[0],t,t);
	  for (int k=1;k<=i+j;++k) Add_ans(1,t,t,t);
	  Add_ans(1,2,t,2);
	}
}

void work(){
  Get_pw();
  Get_bit(0);
  Get_bit(1);
  Get_mul();
}

void outo(){
  printf("%d\n",ca);
  for (int i=1;i<=ca;++i)
	printf("%c %d %d %d\n",ans[i].opt?'+':'<',ans[i].x,ans[i].y,ans[i].z);
}

int main(){
  work();
  outo();
  return 0;
}

Measured memory_bytes: 6892
#include<iostream> 
#include<string>
#include<string.h> 
#include<map> 
#include<set> 
#include<vector> 
#include<stdio.h> 
#include<math.h>
#include<algorithm> 
#include<queue> 
#define pb push_back
#define ll long long
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++) 
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(),(x).end()
#define sqr ((x)*(x)) 
#define y0 y3487465
#define y1 y8687969
using namespace std;
int main(){
string s;
cin>>s;
if (s[0]=='a'){
    if (s[1]=='a'||s[2]=='a'){
        cout<<"No"<<endl;
        system ("pause"); 
        return 0;}}
if (s[0]=='b'){
    if (s[1]=='b'||s[2]=='b'){
        cout<<"No"<<endl;
        system ("pause"); 
        return 0;}}
if (s[0]=='c'){
    if (s[1]=='c'||s[2]=='c'){
        cout<<"No"<<endl;
        system ("pause"); 
        return 0;}}
if (s[1]=='c'){
    if (s[2]=='c'){
        cout<<"No"<<endl;
        system ("pause"); 
        return 0;}}
if (s[1]=='b'){
    if (s[2]=='b'){
        cout<<"No"<<endl;
        system ("pause"); 
        return 0;}}
if (s[1]=='a'){
    if (s[2]=='a'){
        cout<<"No"<<endl;
        system ("pause"); 
        return 0;}}
cout<<"Yes"<<endl;
system ("pause"); 
return 0;
}   

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 string n;
 cin>>n;
int f=1;
  for(int i=1;i<3;i++){
    if(n[0]==n[i]) f++;
  }
if(f==3) {
 cout<<"Yes"<<endl;
 return 0;
}
f=1;
for(int i=2;i<4;i++){
    if(n[1]==n[i]) f++;
  }
if(f==3) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
 
return 0;
}

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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n, k;
    cin >> n >> k;

    vector<int> x(n), y(n);
    vector<int> xary, yary;
    
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }

    sort(begin(xary), end(xary));
    sort(begin(yary), end(yary));

    ll ans = 1LL * (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);

    for(int xi = 0; xi < n; xi++){
        for(int xj = xi + 1; xj < n; xj++){
            for(int yi = 0; yi < n; yi++){
                for(int yj = yi + 1; yj < n; yj++){
                    int num = 0;
                    ll lx = xary[xi], rx = xary[xj];
                    ll by = yary[yi], uy = yary[yj];

                    for(int i = 0; i < n; i++){
                        if(lx <= x[i] && x[i] <= rx && by <= y[i] && y[i] <= uy){
                            num++;
                        }
                    }

                    if(k <= num) ans = min(ans, 1LL * (rx - lx) * (uy - by));
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	// your code goes here
   long long int n,m;
	cin>>n>>m;
	long long int arr[m];
	long long int sum=0;
	for(long long int i=0;i<m;i++){
		cin>>arr[i];
		sum+=arr[i];
		if(sum>n){
			cout<<"-1";
			return 0;
		}
	}
	cout<<n-sum;
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>

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

using namespace std;

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int N,K,A,B,C;
string ans="Yes";

int main() {
    cin >> A >> B;

    if(1<= A && A<= 9 && B<= 9 && B>=1){
        cout << A*B << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, a, b, c, ans;
	cin >> a >> b >> c;
	ans = c * (a / b);
	if (a % b)
		ans += c;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
typedef unsigned long long ll;
ll mod = (10e+8)+ 7;


int main(){
	int A,B,C;
	cin>>A>>B>>C;
	cout<<max(0,C - (A-B))<<endl;
}

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

int main(void)
{
	int a = 0,n,x,i,j,k;
	while (cin >> n >> x)
	{
		a = 0;
		if(n == 0 && x == 0)break;
		for (i = 1; i <= n - 2;i++)
		{
			for (j = i + 1;j <= n - 1;j++)
			{
				for (k = j + 1;k <= n;k++)
				{
					if (i + j + k == x)
					{
						a++;
					}
				}
			}
		}
		cout << a << endl;
	}
	return 0;
}

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

int b[10000];
int c[1024];

void count() {
	for (int x = 0; x < 1024; x++)
		for (int i = 0; i < 10; i++)
			c[x] += (x >> i) & 1;
}

int main() {
	count();
	for (;;) {
		int R, C;
		scanf("%d%d", &R, &C);
		if (R == 0 && C == 0)
			break;
		fill(b, b + 10000, 0);
		for (int i = 0; i < R; i++)
			for (int j = 0; j < C; j++) {
				int a;
				scanf("%d", &a);
				b[j] = (b[j] << 1) + a;
			}
		int ans = 0;
		for (int x = 0; x < (1 << R); x++) {
			int k = 0;
			for (int j = 0; j < C; j++)
				k += max(c[b[j] ^ x], R - c[b[j] ^ x]);
			ans = max(ans, k);
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1068
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int a, p;
	cin >> a >> p;
	cout << (3*a+p)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
S = input ()
Z = ''.join(list(reversed(S)))
Z = Z.replace('resare', '')
Z = Z.replace('esare', '')
Z = Z.replace('remaerd', '')
Z = Z.replace('maerd', '')
z = len (Z)
if z == 0:
    print ('YES')
else:
    print ('NO')

Measured memory_bytes: 9544
<?php

fscanf(STDIN, "%d", $N);

$list = explode(" ", trim(fgets(STDIN)));
$sum_list = [];
$diff_list = [];

foreach($list as $key => $value){
    $diff = $value - $key;
    if(isset($sum_list[$diff])){
        $sum_list[$diff]++;
    }else{
        $sum_list[$diff] = 1;
    }
    $diff_list[$key] = $diff;
}
$ans = 0;
foreach($diff_list as $i => $value){
    $sum_list[$value]--;
    $target = ($i * -2)- $value ;
    if(isset($sum_list[$target])){
        $ans += $sum_list[$target];
    }


}
echo $ans;

Measured memory_bytes: 45720
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long H = sc.nextLong();
			final long W = sc.nextLong();
			
			if(H == 1 || W == 1) {
				System.out.println(1);
			}else {
				System.out.println((H * W) - ((H * W) / 2));
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 21076
//#include <stdio.h>
#define MAX(x,y) x>y?x:y
typedef long long int ll;

ll N,C,x[100002],v[100002];

ll Solve(){
	ll lg=0,tem=0;
        ll max[100001];
        max[0]=0;
	for(ll i=0;i<N;i++)
	{
		lg+=v[i+1]+x[i]-x[i+1];
		max[i+1]=MAX(max[i],lg);
                //printf("f(%lld)=%lld\n",i+1,max[i+1]);
	}
	ll ans=max[N];
	for(ll i=N;i>1;i--)
	{
		tem+=v[i]+x[i]-x[i+1];
		ans=MAX(tem+x[i]-C+max[i-1],ans);
	}
        //printf("ans: %lld\n",ans);
	return ans;
}

int main(){
	scanf("%lld %lld",&N,&C);
	for(ll i=0;i<N;i++) scanf("%lld %lld",&x[i+1],&v[i+1]);
	x[N+1]=C;
        x[0]=0;
	ll Ans1=Solve();
	for(ll i=1;i<=N;i++) x[i]=C-x[i];
        for(ll i=1;i<=N/2;i++) {
            ll t=x[i];
            x[i]=x[N+1-i];
            x[N+1-i]=t;
            t=v[i];
            v[i]=v[N+1-i];
            v[N+1-i]=t;
        }
       /*for(ll i=1;i<=N;i++) printf("x[%lld]=%lld\n",i,x[i]);
        for(ll i=1;i<=N;i++) printf("v[%lld]=%lld\n",i,v[i]);*/
	ll Ans2=Solve();
	printf("%lld",MAX(Ans1,Ans2));
	return 0;
}


Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    solve(java.util.Scanner(System.`in`), pw)
    pw.flush()
}

fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
    val N = sc.nextInt()
    val X = Array(N) { sc.next().toLong() }

    val Xs = X.sorted()
    val midL = Xs[N / 2 - 1]
    val midR = Xs[N / 2]

    for (i in 0 until N) {
        pw.println(if (X[i] < midR) midR else midL)
    }
}


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

vector<pair<int,int>> fac(ll x){
  vector<pair<int,int>> res;
  for(ll i=2;i*i<=x;i++){
    if(x%i)continue;
    res.emplace_back(i,0);
    while(x%i==0){
      x /= i;
      res.back().second++;
    }
  }
  if(x!=1)res.emplace_back(x,1);
  return res;
}

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}
 
int main(){
  ll a,b;
  cin >> a >> b;
  ll g = gcd(a,b);
  auto f = fac(g);
  ll ans = f.size()+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i <= x ; i --) 
using namespace std ;
typedef long long ll ;
typedef pair<int , int> pii ;
const int inf = 0x3f3f3f3f ;
const int maxn = 5005 ;
const int maxm = 5005 ;
ll x ;
int main()
{
	ll ans = 0 ;
	scanf("%lld" , &x) ;
	ans += (x / 500) * 1000 ;
	x %= 500 ;
	ans += (x / 5) * 5 ;
	printf("%lld\n" , ans) ;
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int SIZE = 100000;
int n;

int partition(int *A, int p, int r) {
    int x = A[r];
    int i, j;
    i = p - 1;
    int tmp;
    for( j = p; j < r; j ++) {
        if(A[j] <= x) {
            i++;
            tmp = A[j];
            A[j] = A[i];
            A[i] = tmp;
        }
    }
    tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;
    return i + 1;
}

int main () {
    cin >> n;
    int A[SIZE];
    for(int i = 0; i < n; i++) cin >> A[i];
    int q = partition(A, 0, n - 1);
    for(int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        if (i == q) cout << "[";
        cout << A[i] ;
        if (i == q) cout << "]";
    }
    cout << endl;

}



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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t sum = 0;
  int64_t n;
  std::cin >> n;

  for (int64_t i = 1; i <= n; i++) {
    for (int64_t j = 1; j <= n; j++) {
      for (int64_t k = 1; k <= n; k++) {
        sum += std::gcd(std::gcd(i, j), k);
      }
    }
  }
  std::cout << sum << std::endl;

  return 0;
}

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

int main() {
    string s; cin >> s;
    int k; cin >> k;
    int n = s.size();
    vector<vector<vector<int>>> dp(n, vector<vector<int>>(n, vector<int>(k + 1, -1)));

    constexpr int kInf = 1'000'000'000;

    function<int(int, int, int)> Dfs = [&](int l, int r, int c) {
        if (dp[l][r][c] >= 0) return dp[l][r][c];
        if (l == r) return 1;
        if (l == r - 1) {
            if (s[l] == s[r]) return 2;
            if (s[l] != s[r] && c > 0) return 2;
            return 1;
        }
        if (s[l] == s[r]) return dp[l][r][c] = Dfs(l + 1, r - 1, c) + 2;
        dp[l][r][c] = max(Dfs(l + 1, r, c), Dfs(l, r - 1, c));
        if (c > 0) dp[l][r][c] = max(dp[l][r][c], Dfs(l + 1, r - 1, c - 1) + 2);
        return dp[l][r][c];
    };

    int ans = 0;
    for (int i = 0; i <= k; ++i) ans = max(ans, Dfs(0, n - 1, i));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 109568
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string S;
	cin >> S;
	bool c = false, f = false;
	REP(i, S.length()) {
		if (S[i] == 'C') c = true;
		if (c && S[i] == 'F') f = true;
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 764