akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int w, h, n; cin >> w >> h >> n;
   int rong = w, cao = h;
   int l = 0, r = 0, b = 0, t = 0;
   for(int i = 0; i < n; i++)
   {
      int x, y, a; cin >> x >> y >> a;
      if(a==1)
         l = max(l, x);
      else if(a == 2)
         r= max(rong-x, r);
      else if(a==3)
         b = max(b,y);
      else
         t = max(cao - y, t);
   }
   w = w- l - r;
   h = h - t - b;
//   cout << w << " " << h << nl;
   if(w < 0 || h < 0)
   {
      cout << 0 << nl;
      return 0;
   }

   cout << w*h << nl;




	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int main(){
  ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c);
  if(a%2==0||b%2==0||c%2==0){
    printf("0\n");
  }else{
    printf("%lld\n",min(a*b,min(a*c,b*c)));
  }
  return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  
  vector<vector<char>> map(h,vector<char>(w));
  
  for (int i = 0; i < w + 2; i++) {
    cout << '#';
    if (i == w + 1) cout << endl;
  }
  
  for (int i = 0; i < h; i++) {
    cout << '#';
    for (int j = 0; j < w; j++) {
      char x;
      cin >> x;
      cout << x;
    }
    cout << '#' << endl;
  }
  
  for (int i = 0; i < w + 2; i++) {
  cout << '#';
  if (i == w + 1) cout << endl;
  }
}

Measured memory_bytes: 3644
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from functools import lru_cache

mod = 10 **9 + 7


@lru_cache(100)
def calc(n):
    m = (n-5) // 2

    #return (1+m)*(2+m)*(3+m)*(4+m)*(5+m)*(1025024*m**10+3003*(-4+n)*(-3+n)*(-2+n)*(-1+n)*n*(1+n)*(2+n)*(3+n)*(4+n)*(5+n)-549120*m**9*(-1+10*n)+42240*m**8*(-398+45*n*(-1+7*n))-369600*m**7*(3+2*(-2+n)*n*(49+26*n))+2688*m**6*(33529+75*n*(-33-679*n+91*n**3))-336*m**5*(88065+2*n*(426107+7*n*(-6675+13*n*(-2420+9*n*(5+22*n)))))+560*m**4*(-291598+n*(216249+7*n*(95465+26*n*(-495+n*(-980+11*n*(3+5*n))))))-30*m**3*(-3080960+n*(-10447602+7*n*(854525+13*n*(93170+n*(-15295+22*n*(-714+5*n*(7+6*n)))))))+2*m**2*(28412712+25*n*(-3433650+n*(-4123841+13*n*(189882+n*(142177+22*n*(-1344+n*(-791+27*n*(2+n))))))))-m*(30149280+n*(31294296+n*(-93275400+13*n*(-3808420+n*(2988195+11*n*(111678+25*n*(-1302+n*(-456+n*(45+14*n))))))))))/1307674368000
    return (
        (1+m)*(2+m)*(3+m)*(4+m)*(5+m)%mod*(
            1025024*pow(m,10,mod)+3003*(-4+n)%mod*(-3+n)%mod*(-2+n)%mod*(-1+n)*n*(1+n)%mod*(2+n)%mod*(3+n)%mod*(4+n)%mod*(5+n)%mod
            -549120*pow(m,9,mod)*(-1+10*n)%mod
            +42240*pow(m,8,mod)*(-398+45*n*(-1+7*n)%mod)%mod
            -369600*pow(m,7,mod)*(3+2*(-2+n)*n*(49+26*n)%mod)%mod
            +2688*pow(m,6,mod)*(33529+75*n*(-33-679*n+91*n**3)%mod)%mod
            -336*pow(m,5,mod)*(88065+2*n*(426107+7*n*(-6675+13*n*(-2420+9*n*(5+22*n)%mod)%mod)%mod)%mod)%mod
            +560*pow(m,4,mod)*(-291598+n*(216249+7*n*(95465+26*n*(-495+n*(-980+11*n*(3+5*n)%mod)%mod)%mod)%mod)%mod)%mod
            -30*pow(m,3,mod)*(-3080960+n*(-10447602+7*n*(854525+13*n*(93170+n*(-15295+22*n*(-714+5*n*(7+6*n)%mod)%mod)%mod)%mod)%mod)%mod)%mod
            +2*pow(m,2,mod)*(28412712+25*n*(-3433650+n*(-4123841+13*n*(189882+n*(142177+22*n*(-1344+n*(-791+27*n*(2+n)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod
            -m*(30149280+n*(31294296+n*(-93275400+13*n*(-3808420+n*(2988195+11*n*(111678+25*n*(-1302+n*(-456+n*(45+14*n)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod)%mod
        )%mod*pow(1307674368000%mod, mod-2, mod)%mod
    )

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    ans = [0] * N
    for i in range(N):
        n = next(it)
        ans[i] = calc(n)

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


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

using namespace std;

const int MOD = 1e9 + 7;

int main()
{
  int N;
  cin >> N;
  vector<int> C;
  int size = 0;
  for (int i = 0; i < N; i++)
  {
    int tmp;
    cin >> tmp;
    if (size == 0 || C[size - 1] != tmp)
    {
      C.push_back(tmp);
      size++;
    }
  }
  vector<int> cnt(2e5 + 1, 0);
  long long ans = 0;
  for (int i : C)
  {
    int t = ans;
    ans = (ans + cnt[i]) % MOD;
    cnt[i] = (cnt[i] + t + 1) % MOD;
  }
  cout << (ans + 1) % MOD << endl;

  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  for(int i = 0; i < H; i++) {
    cin >> s[i];
  }
  for(int i = 0; i < H; i++) {
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
}



Measured memory_bytes: 3612
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a,b;
    scanf("%ld %ld", &a, &b);

    printf("%ld\n", (a+b+1)/2);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200005];
int b[200005];
int main(){
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    int l=(1+n)/2,r=(1+n)/2,tot=1;
    if (!(n%2)) l++,r++;
    b[l]=a[1];
    while (tot<n) {
        b[--l]=a[++tot];
        if (tot>=n) break;
        b[++r]=a[++tot];
    }
    if (!(n%2))
    for (int i=1;i<=n;i++)
        cout<<b[i]<<" ";
    else for (int i=n;i>=1;i--) cout<<b[i]<<" ";
    return 0;
}


Measured memory_bytes: 3712
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int flag=0,flag2=0;
  cin>>s;
  int si=s.size();
  rep(i,si){
    if(s[i]=='C'){
      flag=1;
    }
    if(s[i]=='F' && flag==1){
      flag2=1;
    }
  }
  cout<<(flag==1 && flag2==1 ? "Yes" : "No")<<'\n';
  return(0);
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;

using Graph = vector<vector<int>>;

ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
ll mul(ll l, ll r) {
    ll ret =1;
    for(int i=0; i<l-r+1; ++i) {
        ret*=i+r;
        ret%=MOD;
    }
    return ret;
}
ll com(ll n, ll k) {
    ll ret1 = mul(n,n-k+1);
    ll ret2 = mul(k,1);
    ll ret3 = modPow(ret2, MOD-2);
    return ret1*ret3%MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    map<string,int> mpa;
    rep(i,n) {
        string s;
        cin >> s;
        mpa[s]++;
    }
    int m; cin >> m;
    map<string,int> mpb;
    rep(i,m) {
        string s;
        cin >> s;
        mpb[s]++;
    }
    int cnt = 0;
    for(auto x:mpa) {
        cnt = max(cnt, x.second-mpb[x.first]);
    }
    cout << cnt << "\n";

}



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

const int msize = 1e6;
int n, s[msize];

int sum(int i, int j)
{
    return s[j] - s[i - 1];
}

bool better(int l, int r, int i, int j)
{
    int x = sum(l, i), y = sum(i + 1, r);
    int u = sum(l, j), v = sum(j + 1, r);
    if (abs(u - v) < abs(x - y)) return true;
    return false;
}

int _max(int x1, int x2, int x3, int x4)
{
    return max(max(x1, x2), max(x3, x4));
}

int _min(int x1, int x2, int x3, int x4)
{
    return min(min(x1, x2), min(x3, x4));
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> s[i];
        s[i] += s[i - 1];
    }
    int p1 = 1, p2 = 3;
    while (better(3, n, p2, p2 + 1) && p2 < n - 1) ++p2;
    int ans = _max(sum(1, p1), sum(p1 + 1, 2), sum(3, p2), sum(p2 + 1, n)) - _min(sum(1, p1), sum(p1 + 1, 2), sum(3, p2), sum(p2 + 1, n));
    for (int i = 3; i < n - 1; ++i)
    {
        while (better(1, i, p1, p1 + 1) && p1 < i - 1) ++p1;
        while (better(i + 1, n, p2, p2 + 1) && p2 < n - 1) ++p2;
        ans = min(ans, _max(sum(1, p1), sum(p1 + 1, i), sum(i + 1, p2), sum(p2 + 1, n)) - _min(sum(1, p1), sum(p1 + 1, i), sum(i + 1, p2), sum(p2 + 1, n)));
    }
    cout << ans;
}


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

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


int main(){
    const long long INF = 1LL << 60;


    long long N,K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0; i < N; i++){
        cin >> h.at(i);
    }

    // DP テーブル
    long long dp[100010];

    // DP テーブル全体を初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;

    for(int i = 0; i < N; i++){
        for(int j = 1; j < K+1; j++){
          if(i - j <0)break;
            chmin(dp[i],dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 4536
z = []
while True:
	try:
		a, b, c, d, e, f = map(float, raw_input().split())
		x = (c * e - b * f) / (a * e - d * b)
		y = (c * d - f * a) / (b * d - e * a)
		z.append([x, y])
	
	except:
		break
for i in z:
	print("{:.3f} {:.3f}".format(i[0] + 0, i[1] + 0))

Measured memory_bytes: 4240
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b] = input.trim().split(" ").map(Number);
  let sum = a + b;
  if (sum >= 24) {
    return sum - 24;
  } else {
    return sum;
  }
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29648
n=int(input())
a=[i for i in input().split()]

b=[]
c=[]
if n%2==0:
    for i in range(n):
        if i%2==0:
            b.append(a[i])
        else:
            c.append(a[i])
else:
    for i in range(n):
        if i%2==0:
            c.append(a[i])
        else:
            b.append(a[i])
c=c[::-1]
print(" ".join(c)+" "+" ".join(b))


Measured memory_bytes: 27076
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
#define P pair<double, double>

using namespace std;

void printPoint(P point){
  printf("%.8lf %.8lf\n", point.first, point.second);
}

void recursive(P start, P end, int cnt){
  if(cnt == 0)return;
  double third_x = (end.first - start.first)/3.0;
  double third_y = (end.second - start.second)/3.0;
  double rotate_x = third_x/2.0 - third_y*sqrt(3)/2.0;
  double rotate_y = third_x*sqrt(3)/2.0 + third_y/2.0;
  P point1 = P(start.first + third_x, start.second + third_y);
  P point2 = P(start.first + third_x + rotate_x, start.second + third_y+rotate_y);
  P point3 = P(start.first + third_x*2, start.second + third_y*2);
  recursive(start, point1, cnt-1);
  printPoint(point1);
  recursive(point1, point2, cnt-1);
  printPoint(point2);
  recursive(point2, point3, cnt-1);
  printPoint(point3);
  recursive(point3, end, cnt-1);
}

int main(){
  int n; cin >> n;
  P start = P(0.0, 0.0);
  P end = P(100.0, 0.0);
  printPoint(start);
  recursive(P(0.0, 0.0), P(100.0, 0.0), n);
  printPoint(end);
}


Measured memory_bytes: 3216
#include<stdio.h>
int main () {
	int from , to , y;
	int count = 0;
	int i;
	scanf("%d %d %d" , &from , &to , &y);
	for(i = from; i <= to; i++) {
		if (y % i == 0) {
			count++;
		}
	}
	printf("%d\n" , count);
	return 0;
}

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

int main(){
	string s;
	getline(cin, s);
	for(int i = 0;i < s.length();i++){
		if(s.substr(i, 5) == "apple")s.replace(i, 5, "peach");
		else if(s.substr(i, 5) == "peach")s.replace(i, 5, "apple");
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
int a[10];
int test(int x)
{
    int n=0;
    while(x){
        a[n++]=x%10;
        x/=10;
    }
    int flag=1;
    for(int i=0;i<=n/2;i++){
        if(a[i]!=a[n-1-i]){
            flag=0;
            break;
        }
    }
    return flag;
}
int main()
{
    int a,b;
    while(cin>>a>>b){
        int t=0;
        for(int i=a;i<=b;i++){
            if(test(i)) t++;
        }
        cout<<t<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

x, y = list(map(int, sys.stdin.buffer.readline().split()))

ok=False
for i in range(200):
    for j in range(200):
        if i + j == x and         i * 2 + j * 4 == y:
            ok=True
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 27224
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

ll gcd(ll a, ll b) {
    if(a < b) return gcd(b, a);
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g;
    g = gcd(a, b);
    return a*b/g;
}


int main() {
    ll K;
    cin >> K;
    ll sum = 0;
    for (int xi = 1; xi <= K; ++xi) {
        for (int yi = 1; yi <= K; ++yi) {
            for (int zi = 1; zi <= K; ++zi) {
                sum += gcd(xi,gcd(yi,zi));
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3604
c = []

for i in range(3):
    c.append(list(map(int, input().split())))
setset = {len({c[i][0] - c[i][1] for i in range(3)}),
          len({c[i][0] - c[i][2] for i in range(3)}),
          len({c[0][i] - c[2][i] for i in range(3)}),
          len({c[0][i] - c[2][i] for i in range(3)})
          }
l = list(setset)
print('Yes'if l == [1]else 'No')


Measured memory_bytes: 3064
N, K, Q = map(int, input().split())

A = []
point = []
border = 0
for i in range(N):
    point.append(K)

for i in range(Q):
    A.append(int(input()))


for a in A:
    point[a-1] += 1
    border += 1

# result
for i in range(N):
    if point[i] > border:
        print('Yes')
    else:
        print('No')


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<char> pixel = vector<char>(W + 2,'#');
  for(int i = 0;i < pixel.size(); i++){
    cout << pixel.at(i);
  }
  cout << endl;
  
  for(int j = 0;j < H;j++){
    cout << '#';
    for(int k = 0;k<W;k++){
      cin >> pixel.at(k + 1);
      cout << pixel.at(k + 1);
    }
    cout << '#' << endl;
  }
  
  for(int i = 0;i < pixel.size(); i++){
    cout << '#';
  }
  cout << endl;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	int id = 0;
	rep(i,n){
		if(l[id] < l[i]) id = i;
	}
	int sum = 0;
	rep(i,n){
		if(i == id) continue;
		sum += l[i];
	}
	if(sum > l[id]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define rev(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;
using ull = unsigned long long;

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if (a - (b + c) < 0) {
		cout << abs(a - (b + c)) << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

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

using namespace std;

string s;
string ans;

int main() {
  ios::sync_with_stdio(0);
  cin >> s;
  if (s == "Sunny") {
    ans = "Cloudy";
  } else if (s == "Cloudy") {
    ans = "Rainy";
  } else {
    ans = "Sunny";
  }
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    if ((k * 500) >= x) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  vector<int> MONTH = {31,28,31,30,31,30,31,31,30,31,30,31};
  int M,D; cin>>M; cin>>D;
  if(MONTH[M-1] == D)
  {
    cout<<1<<endl;
  }
  else
  {
    cout<<0<<endl;
  }
  
  
  return;

}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
      
      ios
      int s,w;
      cin >> s >> w;
      if(w>=s)cout <<"unsafe" <<"\n";
      else cout <<"safe"<<"\n";

      return 0;
}


Measured memory_bytes: 3648
N = int(input())

words = [chr(ord('a')+i) for i in range(10)]
dp = [('', 0)]
for i in range(1, N+1):
    ndp = []
    for w, c in dp:
        for k in range(c+1):
            ndp.append((w+words[k], c+1 if k == c else c))
    dp = ndp
for l in dp:
    print(l[0])

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

int main(){
	int a,b;
	cin >> a >> b;
	int a1=a+b,a2=a-b,a3=a*b;
	int ans1=max(a1,a2);
	int ans2=max(ans1,a3);
	cout << ans2;
	return 0;
}

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define fore_(i, s, e) for(int i = s; i > e; i--)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FAIL cout << -1 << endl; return 0
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

char m[1001][1001];
ll dp[1001][1001];
ll cota = 1e9 + 7;
ll h, w;

ll solve(int x, int y) {
    if(m[y][x] == '#') return 0;
    if(dp[x][y] != -1) return dp[x][y];
    if(x == w - 1 && y == h - 1) return 1;

    ll ret = 0;

    if(x != w - 1)
        ret += solve(x + 1, y) % cota;
    if(y != h - 1)
        ret += solve(x, y + 1) % cota;

    dp[x][y] = ret % cota;

    return ret;
}

int main() {
    FIN;
    cin >> h >> w;
    memset(dp, -1, sizeof(dp));
    fore(i, 0, h) 
        fore(j, 0, w)
            cin >> m[i][j];
    
    cout << solve(0, 0) % cota << endl;
    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

int main() {
    int L, K;
    cin >> L >> K;
    vector<vector<lint>> dp(2, vector<lint>(L + 1, 0));
    // 0なら直前は白
    dp[0][0] = 1;

    for (int l = 0; l < L; ++l) {
        dp[0][l + 1] += dp[1][l];
        dp[1][l + 1] += dp[0][l];
        if (l + K <= L) dp[1][l + K] += dp[0][l];
    }

    cout << accumulate(dp[1].begin() + 1, dp[1].end(), 0LL) << endl;
    return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
signed main() {
	string s;
	cin >> s;
	s[s.size()] = '1';
	rep(i, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			ggr
		}
		else if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			ggr
		}
	}
	cout << -1 << " " << -1 << endl;
	ggr
}


Measured memory_bytes: 512
// head{{{
/* vim: set foldmethod=marker ft=cpp: */
#include <iostream>
#include <list>
#pragma GCC optimize("O3")
using namespace std;
// }}}
 
int main() {
    //optimize{{{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //---------}}}

    //s.size<=1
    //s.at(0) is uppercase
    //s.at(1) is lowercase
    //AtCoder 's' Contest
    //abbreviation is A'x'c
    //x is s.at(0)
    //cin contest name.
    //I have to cout abbreviation.
    string A,s,C;
    cin >> A >> s >> C;
    char ac = A.at(0);
    char s1 = s.at(0);
    char cc = C.at(0);
    cout << ac << s1 << cc << endl;

}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

using namespace std;

#define PI 3.14159265358979323846
#define INF 1e+9
#define DIV_NUM (1000000007)



int main() {

	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (U == S) A--;
	if (U == T) B--;


	long long int N = 1000000000;
	long long ans = 0;
	for (long long i = 0; i < N; i++) {
		ans += 1;
	}

	cout << A << " " << B << endl;

	return 0;
}


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

int N, M;
int A[102];

int main() {
    scanf("%d %d", &N, &M);

    vector<int> odd;
    for(int i = 0; i < M; i++) {
        scanf("%d", &A[i]);
        if(A[i] % 2) odd.push_back(i);
    }

    if(odd.size() > 2) {
        printf("Impossible");
        return 0;
    }

    if(odd.size()) {
        swap(A[0], A[ odd[0] ]);
    }
    if(odd.size() >= 2) {
        if(odd[1] == 0) odd[1] = odd[0];
        swap(A[M - 1], A[ odd[1] ]);
    }

    for(int i = 0; i < M; i++) {
        printf("%d ", A[i]);
    }
    printf("\n");

    vector<int> sol;
    if(A[0] > 1) sol.push_back(A[0] - 1);
    for(int i = 1; i < M - 1; i++) {
        sol.push_back(A[i]);
    }
    if(M >= 2) sol.push_back(A[M - 1] + 1);
    else sol.push_back(1);

    printf("%d\n", sol.size());
    for(int i = 0; i < sol.size(); i++) {
        printf("%d ", sol[i]);
    }
}


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

int main() {
    string s;
    cin >> s;
    pair<int, int> current;
    for (char c : s) {
        switch(c) {
            case 'N':
            current.second++;
            break;
            case 'W':
            current.first++;
            break;
            case 'S':
            current.second--;
            break;
            case 'E':
            current.first--;
            break;
        }
    }
    if (current.first < 0 && s.find('W') != string::npos || current.first > 0 && s.find('E') != string::npos) {
        current.first = 0;
    }
    if (current.second < 0 && s.find('N') != string::npos || current.second > 0 && s.find('S') != string::npos) {
        current.second = 0;
    }
    if (current.first == 0 && current.second == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
maxl = [0] * (10**5 + 5)
for a in A:
    for i in range(3):
        maxl[a+i] += 1
print(max(maxl))


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
#define sbp(p, n) rep(i, n) { int a, b; scanf("%d %d", &a, &b); p[i] = make_pair(a, b); }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n = 0, k = 0;
	cin >> n>>k;
	int ans = max(n, k);
	if(n>=k) n--;
	else k--;
	ans+= max(n, k);
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N,K;
	cin >> N>>K;

	Int ans = 0;
	Int temp;
	for (Int i = 0; i < N; i++) {
		cin >> temp;
		if (temp >= K) {
			ans++;
		}
	}

	cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main()
{
	int n;
	int a[M];
	int b[M];
	cin >> n;
	for (int i = n-1; i >= 0; i--) {
		cin >> a[i];
	}
	for (int i = 0; i < n-1; i++) {
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 3084
#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) {
    cout << a-1 << " " << b << endl;
  }
  else {
    cout << a << " " << b-1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll a, v, b, w;
    cin >> a >> v >> b >> w;
    ll t;
    cin >> t;
    ll d = abs(a-b);
    string ans = "NO";
    if (d<=(v-w)*t) ans = "YES";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int add(int a, int b){
    return (a + b) % mod;
}

int mul(int a, int b){
    return ll(a) * b % mod;
}

int fact(int n){
    return n ? mul(fact(n - 1), n) : 1;
}

int n, m;

int main(){
    cin >> n >> m;
    if(n == m){
        cout << mul(mul(fact(n), fact(m)), 2) << endl;
    }
    else if(abs(n - m) == 1){
        cout << mul(fact(n), fact(m)) << endl;
    }
    else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T> T in(){T x;cin>>x;return x;}
// long long a = in<long long>();
template<class T> vector<T> inarr(int s,int e, T init=0){
	vector<T> v;T x;
	for(int i=0;i<s;++i)v.push_back(init);
	for(int i=s;i<e;++i){x=in<T>();v.push_back(x);}
	return v;
}
// vi P = inarr<int>(1,N+1,INT_MAX);
// vi P = inarr<int>(0,N);

// #define NMAX 1000000000
int N;
using VS = vector<string>;
VS S;


VS solve(){
	VS ans;
	map<string, int> M;
	int limit = 0;
	rp(i,0,N){
		M[S[i]]++;
		chmax(limit, M[S[i]]);
	}

	for(auto m:M){
		// cout<<m.first<<" "<<m.second<<"\n";//
		if(limit==m.second)
			ans.push_back(m.first);
	}

	return ans;
}

int main(){
	cin>>N;
	rp(i,0,N){
		string s;
		cin>>s;
		S.push_back(s);
	}
	// ote(N);//
	// for(auto s:S) ote(s);
	for(auto a:solve()){
		ote(a);
	}
}


Measured memory_bytes: 28400
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = int(input().rstrip())
    S = (input().rstrip())
    str = list(S)
    K = int(input().rstrip())
    s = str[K-1]
    for i in range(N):
        if(str[i] != s):
            str[i] = "*"
    print(''.join(str))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3944
n = int(input())
words = ['']*n
for i in range(n):
    words[i] = input()
for i in range(len(words) - 1):
    if words.count(words[i]) > 1 or words[i][-1] != words[i+1][0]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;
    int sum = 0;
    F0R (i, m) {
        int t;
        cin >> t;
        sum += t;
    }
    if (sum > n)
        cout << -1 << endl;
    else
        cout << n - sum;

    return 0;
}


Measured memory_bytes: 3664
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>

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

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

bool enough(ll m, ll a, ll b, vl &h){
    vl target = h;
    for(auto &e : target){
        e -= b * m;
    }
    ll temp = a - b;
    for(auto e : target){
        if(e <= 0) continue;
        m -= (e + (temp - 1)) / temp;
    }
    return m >= 0;
}

int main()
{
    int n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    vl h(n);
    rep(i, n)
    {
        cin >> h[i];
    }
    ll l, r;
    l = 0;
    r = 1e9 + 1;
    while(l < r - 1)
    {
        ll m = (l + r) / 2;
        if(enough(m, a, b, h)){
            r = m;
        }else{
            l = m;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main() {
	long long int n, a, b;
	string s;
	cin >> n >> a >> b;
	cin >> s;
	long long int sz = s.size();
	long long int aa, bb;
	aa = bb = 0;
	for (long long int i = 0; i < sz; i++) {
		if (s[i] == 'a') {
			if (aa+bb < a+b) {
				cout << "Yes" << endl;
				aa++;
			} else {
				cout << "No" << endl;
			}
		} else if (s[i] == 'b') {
			if (aa+bb < a+b && bb < b) {
				cout << "Yes" << endl;
				bb++;
			} else {
				cout << "No" << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}
	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            s = new string(s.ToCharArray().OrderBy(o => o).ToArray());
            t = new string(t.ToCharArray().OrderByDescending(p => p).ToArray());

            if (s.CompareTo(t) < 0)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13536
#include<iostream>
#include<string>
//#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(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 findset(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)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N, L,res = 0,MIN = 0;
	cin >> N >> L;
	vector<LLI>vec(N);
	for (int i = 0; i < N;i++) {
		vec[i] = L + i;
	}
	for (int i = 0; i < N;i++) {
		if (abs(vec[i]) < abs(vec[MIN])) {
			MIN = i;
		}
	}
	for (int i = 0; i < N;i++) {
		if (i != MIN) {
			res += vec[i];
		}
	}
	cout << res << endl;
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream& operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T>
inline void printV(vector<T>& a, int n) { for(int i=0; i<n; i++) { cerr<<a[i]<<" "; } cerr<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a) { for(int i=0; i<sz(a); i++) { cerr<<a[i]<<"\n"; } cerr<<"\n"; }
template <typename T>
inline void clearVV(vector<vector<T>>& a) { for(auto &x : a) { x.clear(); } a.clear(); }
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val) { for(int i=0; i<sz(a); i++) { a[i].assign(sz(a[i]), val); } }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n;
	cin>>n;
	vi a(n+1), pre(n+1), suf(n+2);
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		pre[i] = max(pre[i-1], a[i]);
	}
	for(int i=n; i>=1; i--) {
		suf[i] = max(suf[i+1], a[i]);
	}
	for(int i=1; i<=n; i++) {
		cout<<max(pre[i-1], suf[i+1])<<"\n";
	}
    return 0;
}



Measured memory_bytes: 6272
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    int N;
    cin  >> N;
    cout << 3*N*N << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  double x[n];
  string s[n];
  rep(i,n)cin >> x[i] >> s[i];
  double sum=0;
  rep(i,n){
    if(s[i]=="JPY")sum+=x[i];
    else sum+=x[i]*380000.0;
  }
  cout << sum << endl;
return 0;}


Measured memory_bytes: 256