akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

bool isOK(int p[]){
	for (int i = 1; i < 9; i++){
		if (p[i - 1] != p[i])
			return false;
	}
	for (int i = 10; i < 12; i++){
		if (p[i - 1] != p[i])
			return false;
	}
	for (int i = 13; i < 15; i++){
		if (p[i - 1] != p[i])
			return false;
	}
	for (int i = 16; i < 18; i++){
		if (p[i - 1] != p[i])
			return false;
	}
	for (int i = 19; i < 21; i++){
		if (p[i - 1] != p[i])
			return false;
	}
	for (int i = 22; i < 30; i++){
		if (p[i - 1] != p[i])
			return false;
	}

	return true;

}

void swap_p(int p[], int i, int j){
	int tmp = p[i - 1];
	p[i - 1] = p[j - 1];
	p[j - 1] = tmp;
}

int FCube(int p[],int cnt){
	if (isOK(p))
		return cnt;
	else if (cnt > 8){
		return 8;
	}
	int tmp[4][30];
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 30; j++){
			tmp[i][j] = p[j];
		}
	}

	swap_p(tmp[0], 18, 13);
	swap_p(tmp[0], 12, 10);
	for (int i = 0; i < 3; i++){
		swap_p(tmp[0], 7 + i, 22 + i);
	}

	swap_p(tmp[1], 16, 15);
	swap_p(tmp[1], 21, 19);
	for (int i = 0; i < 3; i++){
		swap_p(tmp[1], 1 + i, 28 + i);
	}

	swap_p(tmp[2], 21, 10);
	swap_p(tmp[2], 16, 18);
	for (int i = 0; i < 3; i++){
		swap_p(tmp[2], 1 + i * 3, 24 + i * 3);
	}

	swap_p(tmp[3], 19, 12);
	swap_p(tmp[3], 15, 13);
	for (int i = 0; i < 3; i++){
		swap_p(tmp[3], 3 + i * 3, 22 + i * 3);
	}

	int MIN[4];
	for (int i = 0; i < 4; i++){
		MIN[i] = FCube(tmp[i], cnt + 1);
	}

	return min(MIN[0], min(MIN[1], min(MIN[2], MIN[3])));
}

int main(){
	int N, p[30];
	cin >> N;
	for (int i = 0; i < N; i++){
		for (int j = 0; j < 30; j++){
			cin >> p[j];
		}
		cout << FCube(p, 0) << endl;
	}
	return 0;
}


Measured memory_bytes: 1164
N = input()
first_place  = N[-1]

if (first_place is  "2") or (first_place is "4") or (first_place is "5") or (first_place is "7") or (first_place is "9"):
    print("hon")
elif (first_place is "0") or (first_place is "1") or (first_place  is "6") or (first_place is "8"):
    print("pon")
elif first_place is "3":
    print("bon")
    

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

using namespace std;

const int MAXN = 100000 + 10;
const long long INF = (long long)(1e18);

struct IT_min {
    long long T[4 * MAXN];
    int n;

    void init(int _n) {
        n = _n;
        ++n;
        for(int i = 0; i <= 4 * n; ++i) T[i] = INF;
    }

    void update(int x, int i, int j, int p, long long v) {
        if ((j < p) || (i > p)) return;
        if (i == j) {
            T[x] = v;
            return;
        }
        int mid = (i + j) >> 1;
        update(x + x, i, mid, p, v);
        update(x + x + 1, mid + 1, j, p, v);
        T[x] = min(T[x + x], T[x + x +1]);
    }

    long long get_min(int x, int i, int j, int l, int r) {
        if ((j < l) || (i > r)) return INF;
        if ((i >= l) && (j <= r)) return T[x];
        int mid = (i + j) >> 1;
        return min(get_min(x + x, i, mid, l, r), get_min(x + x + 1, mid + 1, j, l, r));
    }

    long long get_min(int l, int r) {
        ++l; ++r;
        if (r < 1) return 0;
        if (l > r) return 0;
        return get_min(1, 1, n, l, r);
    }

    void update(int p, long long v) {
        ++p;
        update(1, 1, n, p, v);
    }

} T1, T2;

int n, e;
long long t;
long long x[MAXN];
long long f[MAXN];

void run() {
    cin >> n >> e >> t;
    for(int i = 1; i <= n; i++) cin >> x[i];

    x[0] = 0;
    f[0] = 0;

    T1.init(n); T2.init(n);
    T1.update(0, f[0] + -x[0]); T2.update(0, f[0] + -x[1] * 2 - x[0]);
    for(int i = 1; i <= n; ++i) {
        int j = upper_bound(x, x + n + 1, x[i] - (t / 2) - (t % 2)) - x;
        f[i] = INF;
        if (j <= i) {
            f[i] = x[i] + T1.get_min(j - 1, i - 1) + t;
            //cout << ">> " << j << " " << x[i] << " " << f[i] << endl;
        }
        j = min(j - 1, i);
        if (j > 0) {
            f[i] = min(f[i], x[i] * 3 + T2.get_min(0, j - 1));
        }
        T1.update(i, f[i] + -x[i]);
        T2.update(i, f[i] + -x[i + 1] * 2 - x[i]);
        //cout << i << " " << f[i] << endl;
    }

    cout << f[n] + (e - x[n]) << endl;
}

int main()
{
    //freopen("input.txt", "r", stdin);

    int ntests = 1;
    //cin >> ntests;
    for(int tc = 1; tc <= ntests; ++tc) {
        run();
    }
}



Measured memory_bytes: 8064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#define pb push_back

using namespace std;
struct mypair{
  int x,y;
  mypair(int a,int b){ x=a; y=b;}
  bool operator<( const mypair& another) const {
    if(x==another.x) return y < another.y;
    return x < another.x;
  } 
};

int main(void){
  long long int H,W,N;
  int a,b;
  int i,j,k;
  vector<mypair> pairs;
  vector<mypair> resp;
  long long int res[11];
  int tmp;

  scanf("%lld %lld %lld",&H,&W,&N);
  for(i=1;i<=N;i++){
    scanf("%d %d",&a,&b);
    pairs.pb(mypair(a,b));
  }
  sort(pairs.begin(),pairs.end());
  for(i=0;i<pairs.size();i++){
    for(j=-1;j<=1;j++){
      for(k=-1;k<=1;k++){
        resp.pb(mypair(pairs[i].x+j,pairs[i].y+k));
      }
    }
  }
  res[0]=(H-2)*(W-2);
  for(i=1;i<10;i++) res[i]=0;

  sort(resp.begin(),resp.end());
  int t1,t2;
  t1=t2=-1;
  tmp=1;
  for(i=0;i<resp.size();i++){
    if(resp[i].x>1&&resp[i].x<H&&resp[i].y>1&&resp[i].y<W){
      //printf("%d %d\n",resp[i].x,resp[i].y);
      if(t1!=resp[i].x||t2!=resp[i].y){
        t1=resp[i].x;
        t2=resp[i].y;
        res[tmp]++;
        res[0]--;
        tmp=1;
      }
      else{
        tmp++;
      }
    }
  }
  res[tmp]++;
  res[1]--;
  for(i=0;i<10;i++){
    printf("%lld\n",res[i]);
  }

  return 0;
}

Measured memory_bytes: 9324
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
#include <vector>	
#include <cstddef>
#include <list>
#include <iterator>

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long long> vl;

typedef pair<int,int> pi;
typedef pair<double,double> pd;

#define pb push_back
#define pf push_front
#define mp make_pair

#define endl "\n"
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned int uint;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}

int INF = 1e9+1;

void showlist(list <char> g) 
{ 
    list <char> :: iterator it; 
    for(it = g.begin(); it != g.end(); ++it) 
        cout<<*it; 
    cout<<endl;
}

int main(){
	fastio();
	
	string s;
	cin>>s;
	
	list <char> finale;
	
	for(auto &c: s){
		finale.pb(c);
	}
	
	int q;
	cin>>q;
	
	bool rev = 0;
	while(q--){
		int t;
		cin>>t;
		if (t==1){
			rev = !rev;
		}
		else{
			int f;
			cin>>f;
			char c;
			cin>>c;
			if (f==1){
				if (!rev)
					finale.pf(c);
				else
					finale.pb(c);
			}
			else{
				if (!rev)
					finale.pb(c);
				else
					finale.pf(c);
			}
		}
	}
	
	if (rev)
		finale.reverse();
			
	showlist(finale);
	
	return 0;
}


Measured memory_bytes: 19408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    
    string res = "";

    for (int i = 0; i < s.size(); i++)
    {
        if ((i + 1) % 2 != 0)
        {
            res += s.at(i);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-3;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;

int n; ll a[16][16];
ll v[1 << 16];
ll dp[1 <<16];
int main() {
	cin >> n;
	rep(i, n)rep(j, n)cin >> a[i][j];
	rep(i, (1 << n)) {
		vector<int> v;
		rep(j, n) {
			if (i&(1 << j))v.push_back(j);
		}
		rep(j, v.size()) {
			Rep(k, j + 1, v.size()) {
				dp[i] += a[v[j]][v[k]];
			}
		}
	}
	rep(i, (1 << n)) {
		vector<int> v,u;
		rep(j, n) {
			if (i&(1 << j))v.push_back(j);
		}
		int len = v.size();
		rep(j, (1 << len)) {
			int c = 0;
			rep(k, len) {
				if (j&(1 << k)) {
					c += (1 << v[k]);
				}
			}
			int r = i - c;
			dp[i] = max(dp[i], dp[r] + dp[c]);
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	//stop
	return 0;
}

Measured memory_bytes: 768
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9+10
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

int64 w[102], v[102];
int64 dp[102][100002];
int main(){
    FAST
    //Do awesome things here
    int64 n, wt, sum = 0;
    cin >> n >> wt;
    fre(i, 1, n){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    rp(i, n + 1){
        dp[i][0] = inf;
    }
    rp(i, sum + 1){
        dp[0][i] = inf;
    }
    dp[0][0] = 0;
    fre(i, 1, n){
        fre(j, 0, sum){
            dp[i][j] = inf;
            if(j >= v[i]){
                dp[i][j] = w[i] + dp[i - 1][j - v[i]];
            }
            // cout << dp[i][j] << endl;
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            // cout << i << " " << j << "  " << dp[i][j] << endl;
        }
    }
    frd(i, sum, 0){
        // cout << dp[n][i] << endl;
        if(dp[n][i] <= wt){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 79232
a, b, c = map(int, input().split())
 
ans = 'NO'
if a < b and c%a == 0:
  ans = 'YES'
else:
  for i in range(1, 1000):
    if (b*i + c)%a == 0:
      ans = 'YES'
      break
  
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
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;}

string ans[10] = {"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  cout<<ans[N%100%10]<<endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast","inline")
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef vector <int> vi;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005;
int x,y;
int main(){
	x=read(),y=read();
	if (x%y==0)
		puts("-1");
	else {
		LL a=x+x;
		while (a%y==0)
			a+=x;
		cout<<a<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a1=sorted(a)
b1=sorted(b)
mini=a1[0]+b1[0]
for i in range(M):
    x,y,z=map(int,input().split())
    price=a[x-1]+b[y-1]-z
    if mini>price:
        mini=price
print(mini)

Measured memory_bytes: 18612
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/3
Solved on 2019/3/3
@author: shinjisu
"""


# ABC 120
# import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**12


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_A():
    A, B, C = getIntList()
    dmp((A, B, C))
    count = min(B // A, C)
    return count


debug = False  # True False
ans = prob_A()
print(ans)
#for row in ans:
#    print(row)


def prob_B():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123


def prob_C():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123


def prob_D():
    N = getInt()
    A = getIntList()
    dmp((N, A))
    return 123




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int H,W;
  cin >> H >> W;
  int dx[4] = {1,-1,0,0};
  int dy[4] = {0,0,1,-1};
  int dist[H][W];
  char A[H][W];
  queue<P> que;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
      if (A[i][j] == '#') {
        dist[i][j] = 0;
        que.push(make_pair(i,j));
      } else {
        dist[i][j] = 1000000;
      }
    }
  }
  while (!que.empty()) {
    P p = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int x = p.first + dx[i];
      int y = p.second + dy[i];
      if (0 <= x && x < H && 0 <= y && y < W) {
        if (dist[x][y] > dist[p.first][p.second] + 1) {
          dist[x][y] = dist[p.first][p.second] + 1;
          que.push(make_pair(x,y));
        }
      }
    }
  }
  int ans = -1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      ans = max(ans,dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  	int a, b, c;
  	cin >> a >> b >> c;
  	int ans = 10*a+b+c;
  	ans = 10*b+a+c > ans ? 10*b+a+c : ans;
  	ans = 10*c+a+b > ans ? 10*c+a+b : ans;
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

fn main() {
    let N = read::<usize>();
    let mut h = HashMap::new();
    let mut old_w = String::new();
    let w = read::<String>();
    h.insert(w.to_string(), 1);
    old_w = w.to_string();

    for i in 1..N {
        let w = read::<String>();
        if !h.contains_key(&w) {
            h.insert(w.to_string(), 1);
        } else {
            break;
        }

        if old_w.chars().nth(old_w.len()-1).unwrap() != w.chars().nth(0).unwrap() {
            break;
        }

        if i == N-1 {
            println!("Yes");
            return;
        }

        old_w = w.to_string();
    }
    println!("No");
}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
    int n;
    cin >> n;
    string a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    map<string,int> str;
    for(int i=0;i<n;i++){
        sort(a[i].begin(),a[i].end());
    }
    rep(i,n){
        str[a[i]]=0;
    }
    rep(i,n){
        str[a[i]]++;
    }

    long long int ans=0;
    for(int i=0;i<n;i++){
        if(str[a[i]]>1){
            ans+=(long long)(str[a[i]])*(str[a[i]]-1)/2;
            str[a[i]]=0;
        }
    }

    cout << ans;





return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define ull unsigned ll 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP1(i,n) for (int i=1;i<=(n);i++)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define pii pair<int,int>
#define f first
#define s second
#define SZ(x) x.size()
#define ALL(x) x.begin(), x.end()
#define ull unsigned ll 
#define pb push_back
#define SQ(x) (x)*(x)
#define endl '\n'
using namespace std;
ll mod=1e9+7;
int main() 
{ 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll x,y; cin>>x>>y;
	if (abs(x-y)<=1) cout<<"Brown"<<endl;
	else cout<<"Alice"<<endl; 
} 


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    var answer = ""
    val alphabets = arrayOf("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")
    loop@ for (i in 10 downTo 0) {
        var tmp = n-1
        for (j in 0 until i) {
            tmp /= 26
            if (tmp <= 0L) {
                continue@loop
            }
            tmp -= 1
        }
        answer += alphabets[(tmp%26).toInt()]
    }
    println(answer)
}


Measured memory_bytes: 34532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool ok = true;
    if(a+b+1 != (int)s.size()) ok = false;
    else{
        if(s[a] != '-') ok = false;
        else{
            for(int i = 0; i < a; i++){
                if((s[i] < '0') || ('9' < s[i])) ok = false;
            }
            for(int i = a+1; i < (int)s.size()-1; i++){
                if((s[i] < '0') || ('9' < s[i])) ok = false;
            }
        }
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3500
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define pb push_back
using namespace std;
string s,ans;

int main(){
	ans="";
	cin>>s;
	for (int i=0;i<(int)s.size();i++){
		if (s[i]=='0')ans+='0';
		if (s[i]=='1')ans+='1';
		if (s[i]=='B' && ans!="")ans=ans.substr(0, (int)ans.size()-1);
		
	}
	cout <<ans<<endl;
}

Measured memory_bytes: 256
# 貪欲的アプローチで何かよくわからないが失敗
# 抽象度をあげて解決する必要があった

import collections

A = input()
B = input()

A_c = collections.Counter(A)
B_c = collections.Counter(B)
A_c = A_c.values()
B_c = B_c.values()

A_c = list(A_c)
B_c = list(B_c)
A_c.sort()
B_c.sort()
if A_c == B_c:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
#define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

const ll MOD = 1e9 + 7;
const ll maxn = 2e5 + 5;

void solve(){
	
	ll n;
	cin >> n;
	ll prod=26LL;
	int cnt=1;
	while(n > prod){
		n -= prod;
		cnt++;
		prod*=26LL;
	}
	string ans = string(cnt,'a');
	prod=26;
	vi alpha(26);
	for(int i=1;i<=25;i++){
		alpha[i]='a'+i-1;
	}
	
	n--;
	for(int i=cnt-1;i>=0;i--){
		ans[i] += n%26;
		n/=26;
	}
	cout << ans << '\n';
    
}

int main() {
    IOS
    
        solve();
    cerr << endl << "[ Time : " << (float) clock() / CLOCKS_PER_SEC << " secs ]" << endl;

}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a[5], k;

	for(int i = 0; i < 5; i++)
		cin >> a[i];
	cin >> k;

	if(a[4] - a[0] > k)
		cout << ":(" << endl;
	else
		cout << "Yay!" << endl;

	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long int arr[5];
    int ans=0;
    for(int i=0;i<5;i++){
        cin>>arr[i];
        if(arr[i]==0){
            ans=i;
        }
    }
    cout<<ans+1;
}


Measured memory_bytes: 3588
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<=5)
    printf("0");
    else if(a>=13)
    printf("%d",b);
    else if(a>=6&&a<=12)
    printf("%d",b/2);
    return 0;

}

Measured memory_bytes: 128
import java.util.*;


public class Main {
	
	
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		
		int n = s.nextInt();
		int[] a = new int[n+1];
		for(int i = 1;i<=n;i++)a[i] = s.nextInt();
		int c=  0;
		
		Arrays.sort(a,1,n+1);
		
		// 1 4 4 6 7 9
		int l = a[n/2], h = a[n/2+1] ;
		for(int i = a[n/2]-1; i<=a[n/2 +1] ; i++)
		{
			if(l<=i && h > i)c++;
		}
		
		 System.out.println(c);
	}
}


Measured memory_bytes: 48736
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

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

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

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int n;
    n = r*100 + g*10 + b;
    if(n % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

int check(const int n, const long long a, const long long b, const long long c, const long long d){
    for(int i=0; i<=n; i++){
        const int lef=i;
        const int rig=n-i;
        const long long low=-d*lef+c*rig;
        const long long hig=-c*lef+d*rig;
        if(b-a>=low && b-a<=hig){
            //fprintf(stderr, "lef=%d rig=%d low=%lld hig=%lld\n", lef, rig, low, hig);
            return 1;
        }
    }
    return 0;
}

int main(){
    int n, a, b, c, d;
    while(scanf("%d%d%d%d%d", &n, &a, &b, &c, &d)!=EOF){
        if(check(n-1, a*1LL, b*1LL, c*1LL, d*1LL)){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
<?php
//Minor Change

$S = trim(fgets(STDIN));
$T = trim(fgets(STDIN));

$t_str_count = strlen($T);
$exchange_count = 0;
for ( $i=0; $i<$t_str_count; $i++ ) {
    if ( $S[$i] != $T[$i] ) {
        //$S[$i] = $T[$i];
        $exchange_count++;
    }   
}

echo($exchange_count)."\n";

?>

Measured memory_bytes: 16780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N,M; cin >> N >> M;
    vector<int> H(N);
    rep(i,N) cin >> H[i];
    vector<vector<int>> G(N);
    rep(i,M) {
        int a,b; cin >> a >> b;
        --a; -- b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    rep(i,N) {
        bool flag = true;
        for (int j:G[i]) {
            if (H[j] >= H[i]) {
                flag = false;
                break;
            }
        }
        if (flag) ++ans;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 8804
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var ab = Console.ReadLine().SplittedStringToBigInteger();
        Console.WriteLine(ab[0] / ab[1]);
    }
    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();

    public const int INF = int.MaxValue / 2;
    #endregion
}



Measured memory_bytes: 20580
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    string s;
    cin >> s;
    map<char, int> mp;
    char a;
    for (int i = 0; i < 4; i++)
    {
        mp[s[i]]++;
    }
    if (mp.size() == 2 && mp[s[0]] == 2)
    {
        Yes(1);
    }
    else
    {
        Yes(0);
    }
}

Measured memory_bytes: 256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int d,t,s;
    cin>>d>>t>>s;
    int x=s*t;
    if(x>=d) Yes;
    else No;
}/*
./problem.exe
*/

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	//cin.tie(0)->sync_with_stdio(0);
	//cin.exceptions(cin.failbit);

	int n; cin >> n;
	vi v(n + 2), jf(n + 2, n + 1), jf2(n + 2, n + 1), jb(n + 2, 0), jb2(n + 2, 0);

	rep(i, 1, n + 1) cin >> v[i];

	// build jump array
	{
		set<int> indices;
		set<int, greater<int>> indices_dec;
		
		vector<pair<int, int>> prs;
		rep(i, 1, n + 1) prs.push_back({ v[i], i });
		sort(all(prs)); reverse(all(prs));
	
		for (auto p : prs) {
			{
				auto it = indices.upper_bound(p.second);
				if (it != indices.end()) {
					jf[p.second] = *it;
					++it;
					if (it != indices.end()) {
						jf2[p.second] = *it;
					}
				}
			}
			{
				auto it = indices_dec.upper_bound(p.second);
				if (it != indices_dec.end()) {
					jb[p.second] = *it;
					++it;
					if (it != indices_dec.end()) {
						jb2[p.second] = *it;
					}
				}
			}
			indices.insert(p.second);
			indices_dec.insert(p.second);
		}
	}

	ll ans = 0;
	rep(i, 1, n + 1) {
		//printf("Elem: %d, Index: %d, Left: %d %d %d %d, Right: %d %d %d %d\n",
		//		v[i], i,
		//		jb2[i], jb[i], i, jf[i],
		//		jb[i], i, jf[i], jf2[i]);
		ll p = 0;
		p += 1ll * (jb[i] - jb2[i]) * (jf[i] - i); //printf("Left: %lld\n", 1ll * (jb[i] - jb2[i]) * (jf[i] - i));
		p += 1ll * (i - jb[i]) * (jf2[i] - jf[i]); //printf("Right: %lld\n", 1ll * (i - jb[i]) * (jf2[i] - jf[i]));
		ans += 1ll * p * v[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 12404
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int n, p;
    
    while(cin >> n >> p, n && p){
        int wan = p;
        int* isi = new int[n]{0};
        bool game = true;
        while(game){
            for(int i=0; i<n; i++){
                if(wan == 0){
                    wan = isi[i];
                    isi[i] = 0;
                }else{
                    wan--;
                    isi[i]++;
                }
            }
            for(int i=0; i<n; i++){
                if(isi[i] == p){
                    cout << i << endl;
                    game = false;
                    break;
                }
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3104
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int k,x;
    cin >> k >> x;
    cout << (500 * k >= x ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define re(a,n) reverse(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
const int twx=500+100;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n;
ll a[twx][twx];
ll s[2][twx][twx];
ll asd[twx][twx];
void update(ll &x,ll y)
{
    x=x<y?x:y;
}
ll sum(int t,int lx,int rx,int ly,int ry)
{
    return s[t][rx][ry]-s[t][lx-1][ry]-s[t][rx][ly-1]+s[t][lx-1][ly-1];
}
void init()
{
	n=read();
    f1(1,n,i)
    {
        f1(1,n,j)
        {
            if(j==i)
            {
                continue ;
            }
            a[i][j]=read();
        }
    }
    f1(1,n,i)
    {
        f1(1,n,j)
        {
            if(i<j) 
            {
                s[0][i][j]=a[i][j];
            }
            s[0][i][j]+=s[0][i][j-1];
        }
        f1(1,n,j)
        {
            s[0][i][j]+=s[0][i-1][j];
        }
    }
    f1(1,n,i)
    {
        f1(1,n,j)
        {
            if(i>j)
            {
                s[1][i][j]=a[i][j];
            }
            s[1][i][j]+=s[1][i][j-1];
        }
        f1(1,n,j)
        {
            s[1][i][j]+=s[1][i-1][j];
        }
    }
    memset(asd,42,sizeof(asd));
    asd[0][0]=0ll;
    f1(0,n,i)
    {
        f1(0,(int)(max(i,1)-1),j)
        {
            f1(i+1,n,k)
            {
                ll tmp=asd[i][j]+sum(1,k+1,n,j+1,i)+sum(0,i+1,k,i+1,k);
                update(asd[k][i],tmp);
            }
        }
    }
    ll ans=asd[n][1];
    f1(1,n,i)
    {
        update(ans,asd[n][i]);//哪一位q[i]是1都可以，取最小。
    }
    printf("%lld\n",ans);
}
void work()
{
	
}
void print()
{
	
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    init();
	return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(1e18)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;
ll md[2] = {231, 3006703054056749LL}, pw[MAX];

ll mult (ll a, ll b, bool fl) {
	return (a * 1LL * b) % md[fl];
}

ll add (ll a, ll b, bool fl) {
	b += md[fl], a += md[fl];
	return (a % md[fl] + b % md[fl]) % md[fl];
}

map<ll, int> m1;

int main () {
	ios_base :: sync_with_stdio (false);
	cin.tie (nullptr);
	pw[0] = 1;
	vector<pair<int, int>> vp;
	for (int i = 1; i < MAX; i++) {
		pw[i] = mult (md[0], pw[i - 1], 1);
	}
	vector<ll> vv;
	ll n;
	cin >> n;
	vector<string> vs (n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> vs[i];
		vp.push_back (make_pair ((int)vs[i].size (), i));
	}
	sort (vp.begin (), vp.end ());
	for (int y = 0; y < n; y++) {
		int i = vp[y].second, nn = vp[y].first;
		int ch[26] = {};
		for (char x : vs[i]) {
			ch[x - 'a']++;
		}
		ll h = 0;
		for (int j = 0; j < vs[i].size (); j++) {
			for (int k = 0; k < 26; k++) {
				ll r = 0;
				if (ch[k]) {
					r = add (h, mult (pw[j], k + 1, 1), 1);
					auto x = m1.find (r);
					if (x != m1.end ()) {
						ans += x -> second;
					}
				}
			}
			int x = vs[i][nn - j - 1] - 'a';
			h = add (h, mult (pw[j], x + 1, 1), 1);
			ch[x]--;
		}
		m1[h]++;
	}
	cout << ans << "\n";
}


Measured memory_bytes: 31220
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<usize> = sc.read_vec(n);
    let mut ans = a[0] - 1;
    let mut cur = 2;
    for i in 1..n {
        if a[i] == cur {
            cur += 1;
        } else {
            ans += (a[i] - 1) / cur;
        }
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列
// 追加１
#include <fstream>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int H, W;
    cin >> H >> W;

    vvll A(H, vll(W, INF));

    queue<pair<int, int>> q;
    rep(i, H)
    {
        string s;
        cin >> s;

        rep(j, W)
        {
            if (s[j] == '#')
            {
                A[i][j] = 0;
                q.emplace(i, j);
            }
        }
    }

    int dh[4] = { 1, 0, -1, 0 };
    int dw[4] = { 0, 1, 0, -1 };

    auto last = q.front();
    while (!q.empty())
    {
        auto p = q.front(); q.pop();
        ll num = A[p.first][p.second];

        rep(i, 4)
        {
            int h = p.first + dh[i];
            int w = p.second + dw[i];

            if (!(h >= 0 && h < H && w >= 0 && w < W)) continue;
            if (A[h][w] <= num + 1) continue;

            A[h][w] = num + 1;
            q.emplace(h, w);
        }

        last = p;
    }

    cout << A[last.first][last.second] << endl;

    return 0;
}

Measured memory_bytes: 19140
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const int maxn = 1000 + 5;

int n, a, b;

int main(){
    cin >> n;
    if (n == 1) return puts("Hello World"), 0;
    cin >> a >> b;
    cout << a + b;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	string s;
	cin >> s;
	cout << s.substr(0,s.size()-8) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
using namespace std;
int main() {
	int n; cin >> n;
	int b[100], a[100];
	for (int i = 0; i < n-1; ++i) cin >> b[i];
	a[0] = b[0];
	for (int i = 0; i < n-2; ++i) {
		a[i + 1] = min(b[i], b[i + 1]);
	}
	a[n - 1] = b[n - 2];
	int sum = 0;
	for (int i = 0; i < n; ++i) sum += a[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(string& s) {
        const int N = 2019;
        vector<long long> dp(N, 0);
        vector<long long> ndp(N, 0);
        int n = s.length();
        long long res = 0;
        for (int i = 0; i < n; ++i) {
            int d = s[i] - '0';
            dp[0] += 1;
            fill(ndp.begin(), ndp.end(), 0);
            for (int j = 0; j < N; ++j) {
                if (dp[j] == 0) {
                    continue;
                }
                // cout << i << " " << j << " " << dp[j] << endl;
                //int nj = (j << 3) + (j << 1) + d;
                int nj = j * 10 + d;
                nj %= N;
                ndp[nj] += dp[j];
            }
            swap(ndp, dp);
            res += dp[0];
        }

        
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    Solution sol;
    cout << sol.solve(s) << "\n";

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define queue QQQ
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RAnK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 2e5+233;
const int mod = 1e9+7;
int n;
int c1[maxn],c2[maxn],cnt[maxn],a[maxn],tot,D[maxn],invD[maxn];
int zero[maxn],S[maxn];
#define lowbit(x) ((x) & (-x))
inline int qpow(int a,int b){
	int ans = 1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
void add(int c[],int x,int v){
	for(;x<=n;x+=lowbit(x))
		(c[x] += v) %= mod;
}
int query(int c[],int x){
	int ans = 0;
	for(;x;x-=lowbit(x))
		(ans += c[x]) %= mod;
	return ans;
}
int main(){
	n = rd();
	Rep(i,1,n) cnt[a[i]=rd()]++;
	Dep(i,n-1,1) cnt[i]+=cnt[i+1];
	tot = 1;
	Dep(i,n,1) cnt[i] -= n-i;
	Dep(i,n,1) tot = 1ll * tot * cnt[i] % mod; 
	if(!tot){puts("0");return 0;}
	S[0] = 1;D[0] = 1;
	Rep(i,1,n){
		if(cnt[i]==1) D[i] = D[i-1]; else  
					  D[i] = 1ll * (cnt[i]-1) * qpow(cnt[i],mod-2) % mod * D[i-1] % mod;
		if(cnt[i]==1){
			zero[i] = zero[i-1] + 1;
			S[zero[i]] = i;
		} else{
			zero[i] = zero[i-1];
		}
		invD[i] = qpow(D[i],mod-2);
	}
	mem(c1,0);mem(c2,0);
	ll ans = 0;
	Rep(i,1,n){
		ans = (ans + 1ll * tot * qpow(2,mod-2) %mod * (query(c1,a[i]) - query(c1,a[i]-1))) % mod;//same
		ans = (ans + 1ll * tot * qpow(2,mod-2) %mod * D[a[i]] %mod * (query(c2,a[i]-1) - query(c2,S[zero[a[i]]]) + mod) % mod) % mod;//small
		add(c1,a[i],1);
		add(c2,a[i],invD[a[i]]);
	}//相同的
//	writeln(ans);
	mem(c1,0);mem(c2,0);
	Dep(i,n,1){
		ans = (ans - 1ll * tot * qpow(2,mod-2) %mod * D[a[i]] %mod * (query(c2,a[i]-1) - query(c2,S[zero[a[i]]]) + mod)% mod + mod) % mod;
		ans = (ans + 1ll * query(c1,a[i]-1) * tot) % mod;
		add(c1,a[i],1);
		add(c2,a[i],invD[a[i]]);
	} 
	writeln(ans);
	return 0;
}

Measured memory_bytes: 6528