akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

const int N = 1001;


int compute(int x,int y,int n){
  double z = sqrt(n-(double)x*x-(double)y*y);
  if (isnan(z))return 0;
  if ( fabs(z-(n-(double)x*x-(double)y*y))<1e-10)return (int)z;
  else return (int)ceil(z);
}

int height[N][N];
int th[N+1][N+1];

void estimate(int n,int tn){
  rep(i,tn)rep(j,tn)height[i][j]=0;
  rep(y,tn+1){
    rep(x,tn+1)th[y][x]=compute(x,y,n);
  }
  rep(y,tn){
    rep(x,tn){
      int p=0;
      height[y][x]=max(max(th[y][x],th[y+1][x]),
		       max(th[y+1][x],th[y+1][x+1]));
    }
  }
}

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

void dfs(int n,int y,int x,int d,bool &xzero,bool &yzero){
  if (y==-1||x==-1||y==n||x==n||height[y][x] != d)return;
  height[y][x]=0;
  if(x==0)xzero=true;
  if(y==0)yzero=true;
  rep(i,4)dfs(n,y+dy[i],x+dx[i],d,xzero,yzero);
}

int solve(int n){
  int ret=0;
  rep(i,n){
    rep(j,n){
      if (height[i][j] != 0){
	bool xzero=false,yzero=false;
	int tmp=1;
	dfs(n,i,j,height[i][j],xzero,yzero);
	if (xzero&&yzero);
	else if (xzero||yzero)tmp*=2;
	else tmp*=4;
	ret+=tmp;
      }
    }
  }
  return ret*6;
}

main(){
  int n;
  while(cin>>n && n){
    int tn = (int)(ceil(sqrt(n)));
    estimate(n,tn);
    cout << solve(tn) << endl;
  }
  return false;
}

Measured memory_bytes: 8792
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using ULL = int64_t;
using P = pair<LL, LL>;
#define rep(i, n) for (LL i = 0; i < (n); ++i)
#define all(v) (v).begin(), (v).end()
#define DEBUG

LL n;
LL abc[3];

#define HUGE (9999999LL)
LL dfs(const LL depth,
       vector<LL>& which,
       const vector<LL>& len) {
  if (depth == n) {
    LL count[] = {(LL)0, (LL)0, (LL)0, (LL)0};
    LL len_sum[] = {(LL)0, (LL)0, (LL)0, (LL)0};
    rep(i, n) {
      count[which[i]]++;
      len_sum[which[i]] += len[i];
    }
    if (count[0] == 0 || count[1] == 0 || count[2] == 0) {
      return HUGE;
    }

    LL cost = 0;
    rep(i, 3) {
      cost += (count[i] - 1) * 10;
      cost += abs(len_sum[i] - abc[i]) * 1;
    }
//    rep(i, n) {
//      cout << which[i] << "\t";
//    }
//    cout << " : " << cost << "\n";
    return cost;
  }

  LL ans = (LL)HUGE;
  rep (i, 4) {
    which.at(depth) = i;
    LL v = dfs(depth + 1, which, len);
    ans = min(ans, v);
  }
  return ans;
}

int main() {
  cin >> n >> abc[0] >> abc[1] >> abc[2];
  vector<LL> which(n, -1);
  vector<LL> len(n, -1);
  rep (i, n) {
    cin >> len.at(i);
  }

  LL ans = dfs(0, which, len);
  cout << ans << endl;

  #ifdef DEBUG
  // cout << 123 << endl;
  #endif
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[112345], b[112345];
    for (int i = 0; i < n;i++){
        cin >> a[i];
        b[a[i]] = i + 1;
    }
    for (int i = 1; i <= n;i++){
        cout << b[i] << ' ';
    }
}

Measured memory_bytes: 1664
import sys

n = int(input())
t = input()
w = [t]

for i in range(n-1):
    s = input()
    if s in w:
        print('No')
        sys.exit()
    w += [s]

for i in range(1,n):
    if list(list(w)[i-1])[-1] != list(list(w)[i])[0]:
        print('No')
        sys.exit()


print('Yes')


Measured memory_bytes: 3060
def reconstruction(left, right, pre_order, in_order, traversal):
    if left >= right:
        return traversal
    else:
        next_pre_node = pre_order.pop(0)
        pos_in_order = in_order.index(next_pre_node)

        traversal = reconstruction(left, pos_in_order, pre_order, in_order, traversal)
        traversal = reconstruction(pos_in_order + 1, right, pre_order, in_order, traversal)
        traversal.append(next_pre_node)
        return traversal


if __name__ == "__main__":
    n = int(input())
    pre_order = list(map(int, input().split()))
    in_order = list(map(int, input().split()))
    traversal = reconstruction(0, n, pre_order, in_order, [])
    print(*traversal)


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

int main(){
  int N;
  cin >> N;
  double n = 0.0;
  if (N % 2 == 0){
    n = N / 2.0;
  }
  else{
    n = (N + 1) / 2.0;
  }
  cout << n / N << endl;
}
  


Measured memory_bytes: 3760
MOD=10**9+7
N=int(input())
x=list(map(int, input().split()))
y=[x[i+1]-x[i] for i in range(N-1)]
 
upp=[1]*(N+1)
for i in range(2, N+1):
  upp[i]=upp[i-1]*i
  upp[i]%=MOD
  
a=[0]*(N-1)
a[0]=upp[N-1]
for i in range(1, N-1):
  a[i]=a[0]*pow(i+1, MOD-2, MOD)
  a[i]%=MOD

b=[0]*(N-1)
b[0]=a[0]
for i in range(1, N-1):
  b[i]=b[i-1]+a[i]
  b[i]%=MOD
  
def moddot(v1, v2):
  n=len(v1)
  out=0
  for i in range(n):
    out+=v1[i]*v2[i]%MOD
    out%=MOD
  return out
 
ex=moddot(b, y)
print(ex)

Measured memory_bytes: 64152
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

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); }

int dy[] = {1,0,-1,0,1,-1,-1,1}; //次に行くところ
int dx[] = {0,1,0,-1,1,1,-1,-1}; //上に同じ



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  vector<int> h(n),dp(n,INT_MAX);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  dp[0] = 0;
  for (int i = 1; i < n; i++){
    for (int j = 1; j <= k; j++){
      if (i - j < 0){
        continue;
      }
      chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }  
  }
  cout << dp[n-1] << '\n';
  return 0;
}

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

using namespace std;

const int MAXN = 200010;

int n, k;
int ans;

int v[MAXN];

int main()
{
	scanf("%d %d",&n,&k);

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	int last = v[1];

	for(int i = 2 ; i <= n ; i++)
	{
		if( v[i] - v[i - 1] > k )
		{
			ans += (v[i - 1] + k) - last;
			last = v[i];
		}
	}

	ans += (v[n] + k) - last;

	printf("%d\n",ans);
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " ";
#define outline(x) cout << x << endl;
#define sortvector(v) sort(v.begin(), v.end());
#define sortvectorrev(v) sort(v.rbegin(), v.rend());
#define inf INT64_MAX
int32_t main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int n1 = a*d, n2 = a*c, n3 = b*d, n4 = b*c;
    int ans = 0;
    ans = max(n1, n2);
    ans = max(n3, max(ans, n4));
    outline(ans)
    return 0;
}

Measured memory_bytes: 3652
// 2011/01/12 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int num[100];
		for(int i=0; i<n; i++)
			cin >> num[i];

		int cnt = 0;
		for(int i=n-1; i>=0; i--)
			for(int j=0; j<i; j++)
				if(num[j]>num[j+1]){
					int tmp = num[j];
					num[j] = num[j+1];
					num[j+1] = tmp;
					cnt++;
				}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main (int argc, char * argv[])
{
    int a,b,c;
    while(1){
        scanf("%d %dn\n",&a,&b);
        if(a==0&&b==0){
            break;
        }
        if(a>b){
            c = a;
            a = b;
            b = c;
        }
        printf("%d %d\n",a,b);
    }
    return 0;
}



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

signed main(){

    
    string S;
    cin>>S;
    for (int i = 0; i < S.size() ; i++) {
        if(i%2 == 0 ){
            if (!(S[i] == 'R' || S[i] == 'U' || S[i] == 'D')) {
                cout << "No";
                return 0;
            }
            }else {
            if (!(S[i] == 'L' || S[i] == 'U' ||S[i] == 'D')) {
                cout << "No";
                return 0;
            }
        }
    }
    cout<< "Yes";

    return 0;
}

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

int lis(std::vector<int> &a, int n) {
  const int INF = 1e9;
  std::vector<int> dp(n, INF);
  for (int i = 0; i < n; i++) {
    *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
  }
  return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << lis(a, n) << endl;
}



Measured memory_bytes: 3568
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def dfs(H,W,L):
    d=0
    c=True
    if L[0][0]==False:
        d=1
        c=False
    q=deque([(d*10000,c)])
    dxs=((0,1),(1,0))
    visited=[False]*10000
    while len(q):
        
        #print(q)
        dxy,c=q.popleft()#ここをpopleftにすると幅優先探索BFSになる
        d,xy=divmod(dxy,10000)
        x,y=divmod(xy,100)
        if visited[xy]: continue
        visited[xy]=True
        if x==H-1 and y==W-1:
            return d
        for dx in dxs:
            nx=x+dx[0]
            ny=y+dx[1]
            if nx>=H or ny>=W:
                continue
            if visited[nx*100+ny]:continue

            if L[nx][ny] or c==False:
                q.appendleft((d*10000+nx*100+ny,L[nx][ny]))
            else:
                q.append(((d+1)*10000+nx*100+ny,False))

                


def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    H,W = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    L = list(list(input()) for i in range(H)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    #Lt=[[True]*H for _ in range(W)]
    for i in range (H):
        for j in range(W):
            if L[i][j]=='#':
                L[i][j]=False
            else:
                L[i][j]=True
            
    ans=dfs(H,W,L)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3824
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;

	}
	if (a > b) {
		cout << "a > b" << endl;
	}
	if (a == b) {
		cout << "a == b" << endl;
	}
	return 0;

}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  st s;
  	ci(s);
  //東(右)がeast,西(左)がwest
  vll A(n);//w
  vll B(n);//e
  if(s[0]=='W') A[0]++;
  FOR(i,1,n){
    A[i]+=A[i-1];
    if(s[i]=='W') A[i]++;
  }
  if(s[n-1]=='E') B[n-1]++;
  rFOR(i,n-2,-1){
    B[i]+=B[i+1];
    if(s[i]=='E') B[i]++;
  }
  ll ans=n;
  FOR(i,1,n-1){
    ans=rM(ans,A[i-1]+B[i+1]);
  }
  ans=min({ans,B[1],A[n-2]});
  co(ans)
}

Measured memory_bytes: 5380
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;

int main(){
    string s; cin>>s;
    map <char,int> mp;
    mp[s[0]]++;
    mp[s[1]]++;
    mp[s[2]]++;
    mp[s[3]]++;
    set <char> box;
    box.insert(s[0]);
    box.insert(s[1]);
    box.insert(s[2]);
    box.insert(s[3]);
    if(box.size() != 2){cout<<"No"<<endl; return 0;}

if(mp[s[0]] == mp[s[1]] and mp[s[1]] == mp[s[2]] and mp[s[3]] == mp[s[2]]) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
dp = [_ for _ in range(N+1)]
for i in range(N+1):
  donguri = dp[i]
  if i >= A[0]:
    gold = dp[i-A[0]]+B[0]
  else:
    gold = 0
  if i >= A[1]:
    silver = dp[i-A[1]]+B[1]
  else:
    silver = 0
  if i >= A[2]:
    bronze = dp[i-A[2]]+B[2]
  else:
    bronze = 0
  dp[i] = max(donguri,gold,silver,bronze)
M = dp[N]
#print(dp)
dp = [_ for _ in range(M+1)]
for i in range(M+1):
  donguri = dp[i]
  if i >= B[0]:
    gold = dp[i-B[0]]+A[0]
  else:
    gold = 0
  if i >= B[1]:
    silver = dp[i-B[1]]+A[1]
  else:
    silver = 0
  if i >= B[2]:
    bronze = dp[i-B[2]]+A[2]
  else:
    bronze = 0
  dp[i] = max(donguri,gold,silver,bronze)
ans = dp[M]
print(ans)

Measured memory_bytes: 449048
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;
string s,t;

int main()
{
  finp;
  cin>>n>>s>>t;

  afor(i,0,n-1)
  {
  	bool f = true;
  	afor(j,i,n-1)
  	{
  		if(s[j]!=t[j-i])
  		{
  			f = false;
  			break;
  		}
  	}

  	if(f)
  	{
  		cout<<(2*n - (n - i));
  		return 0;
  	}
  }

  cout<<2*n;
  
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
const int MaxN = 300, Pt = 998244353;
typedef long long LL;
using namespace std;

int n;
LL dp[MaxN * MaxN + 5];
int a[MaxN + 5];

int main() 
{
	while(~scanf("%d", &n)) {
		int sum = 0; LL res = 1;
		for (int i = 1; i <= n; i++) scanf("%d", a + i), sum += a[i], res = res * 3 % Pt;
		dp[0] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = sum; j >= 0; j--) {
				if(j < a[i]) dp[j] = dp[j] * 2 % Pt;
				else dp[j] = (dp[j] * 2 + dp[j - a[i]]) % Pt;
			}
		}
		for (int i = (sum + 1) / 2; i <= sum; i++) {
			res = (res - 3LL * dp[i]) % Pt;
		}
		memset(dp, 0, sizeof(dp)); 
		dp[0] = 1; 
		for (int i = 1; i <= n; i++) {
			for (int j = sum; j >= 0; j--) {
				if(j < a[i]) dp[j] = dp[j] % Pt;
				else dp[j] = (dp[j] + dp[j - a[i]]) % Pt;
			}
		}
		if(sum % 2 == 0) res = (res + dp[sum / 2] * 3) % Pt;
		res = (res + Pt) % Pt;
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 896
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	int x, y; cin >> x >> y;
	int n = s.length();
	int firstFsLen = 0;
	while (firstFsLen < n && s[firstFsLen] == 'F')++firstFsLen;
	vector<int> dx, dy;
	int isX = 1;
	for (int i = firstFsLen; i < n; ++i)
	{
		if (s[i] == 'T')isX = 1 - isX;
		else
		{
			int cnt = 1;
			while (i + 1 < n && s[i + 1] == 'F')
			{
				++cnt;
				++i;
			}
			if (isX)dx.push_back(cnt);
			else dy.push_back(cnt);
		}
	}
	vector<set<int>> xCheck(dx.size() + 1), yCheck(dy.size()+1);
	xCheck[0].insert(firstFsLen);
	yCheck[0].insert(0);
	rep(i, dx.size())
	{
		for (int p : xCheck[i])
		{
			xCheck[i + 1].insert(p - dx[i]);
			xCheck[i + 1].insert(p + dx[i]);
		}
	}
	rep(i, dy.size())
	{
		for (int p : yCheck[i])
		{
			yCheck[i + 1].insert(p - dy[i]);
			yCheck[i + 1].insert(p + dy[i]);
		}
	}
	if (xCheck[dx.size()].find(x) != xCheck[dx.size()].end() && yCheck[dy.size()].find(y) != yCheck[dy.size()].end())
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 188160
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
    long long int n,m,ans=1;
    cin>>n>>m;
    if(n==m){
        for(int i=1;i<n+1;i++){
            ans*=i;
            if(ans>1000000007)ans%=1000000007;
        }
        for(int i=1;i<m+1;i++){
            ans*=i;
            if(ans>1000000007)ans%=1000000007;
        }
        ans*=2;
        if(ans>1000000007)ans%=1000000007;
    }
    else if(n-m==1){
        for(int i=1;i<n+1;i++){
            ans*=i;
            if(ans>1000000007)ans%=1000000007;
        }
        for(int i=1;i<m+1;i++){
            ans*=i;
            if(ans>1000000007)ans%=1000000007;
        }
    }
    else if(m-n==1){
        for(int i=1;i<n+1;i++){
            ans*=i;
            if(ans>1000000007)ans%=1000000007;
        }
        for(int i=1;i<m+1;i++){
            ans*=i;
            if(ans>1000000007)ans%=1000000007;
        }
    }
    else ans=0;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input()

if len(s) == 1:
    print(1)
    exit()


now = s[0]
cnt = 1
i = 1
while True:
    if s[i] != now:
        cnt += 1
        now = s[i]
        i += 1
    else:
        now = now + s[i]
        cnt += 1
        i += 2
        if i > len(s):
            cnt -= 1
    if i >= len(s):
        break
print(cnt)

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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

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

int main() {
    int N; cin >> N;
    V<int> L(N); rep(i, N) cin >> L[i];
    sort(ALL(L));
    ll ans = 0;
    rep(i, N) {
        rep(j, i) {
            int x = L[i] + L[j];
            int t = lower_bound(ALL(L), x) - L.begin() - i - 1;
            ans += t;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  int A[20];
  int X[20][20];
  int Y[20][20];
  cin >> N;
  rep(i, N){
    cin >> A[i];
    rep(j, A[i]){
      cin >> X[i][j];
      X[i][j]--;
      cin >> Y[i][j];
    }
  }

  int ans = 0;
  rep(mask, 1<<N){
    bool flag[N];
    rep(n, N){
      if (mask & (1<<n)) flag[n]=true;
      else flag[n]=false;
    }

    bool check = true;
    int sums = 0;
    rep(i, N){
      if (flag[i]==false) continue;
      rep(j, A[i]){
        if (Y[i][j] != flag[X[i][j]]) check = false;
      }
    }
    if (check == true){
      rep(i, N) sums += flag[i];
      ans = max(ans, sums);
    }
  }
  cout << ans << endl;
}

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

int main(){
	int blood[ 4 ] = { 0 }, dummy;
	string s;
	while ( cin >> s ){
		istringstream is( s );
		is >> dummy >> s;
		if ( s == ",A" ){
			++blood[ 0 ];
		} else if ( s == ",B" ){
			++blood[ 1 ];
		} else if ( s == ",AB" ){
			++blood[ 2 ];
		} else if ( s == ",O" ){
			++blood[ 3 ];
		}else{
			cout << "error" << endl;
		}
	}

	cout << blood[ 0 ] << endl << blood[ 1 ] << endl << blood[ 2 ] << endl << blood[ 3 ] << endl;

	return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int a0 = a;
    for(int i = 0; i < 100000; i++) {
        if(a%b == c) {
            cout << "YES" << endl;
            return 0;
        }
        a += a0;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import numpy as np

n = int(input())
a = list(map(int, input().split()))
check = [0] * 9
for i, val in enumerate(a):
    tar = math.floor(val / 400)
    if (tar > 8):
        tar = 8

    check[int(tar)] += 1


checkA = np.array(check[:8])
#print(checkA)
num = np.count_nonzero(checkA != 0)

less = max(num, 1)
#more = min(8, num + check[8])
more = num + check[8]
# print(check[8])

print(less, more)
'''
checkA = np.array(check[:8])
num = np.count_nonzero(checkA != 0)
if (num == 0):
    num = 1
rest = 8 - num

more = min(8, num + check[8])

print(num, more)
'''


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e13 + 5);

const int MAX_N = (int)(2e5 + 5);

int n;
ll k;

ll a[MAX_N];
ll f[MAX_N];

ll aifi[MAX_N];

bool check(ll x) {
  ll tmp_k = k;

  for (int i = 0; i < n; ++i) {
    ll aifi = a[i] * f[i];

    if (aifi <= x) continue;

    if (tmp_k == 0 && aifi > x) return false;

    ll diff = aifi - x;
    ll times = (diff - 1L) / f[i] + 1L;
    ll actual = min(times, tmp_k);

    aifi -= f[i] * actual;

    tmp_k -= actual;

    if (aifi > x) return false;
  }

  return true;
}

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &k);

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(f[i]));
  }

  if (n == 1) {
    ll ans = (a[0] - min(a[0], k)) * f[0];
    printf("%llf\n", ans);
    return 0;
  }

  sort(a, a + n);

  sort(f, f + n);
  reverse(f, f + n);

  // printf("a: ");
  // for (int i = 0; i < n; ++i) {
  //   printf("%lld ", a[i]);
  // }
  // printf("\n");

  // printf("a: ");
  // for (int i = 0; i < n; ++i) {
  //   printf("%lld ", a[i]);
  // }
  // printf("\n");

  // printf("f: ");
  // for (int i = 0; i < n; ++i) {
  //   printf("%lld ", f[i]);
  // }
  // printf("\n");

  ll ok = INF;
  ll ng = -1L;

  while (abs(ok - ng) > 1) {
    ll next = (ok + ng) / 2L;

    if (check(next)) {
      ok = next;
    } else {
      ng = next;
    }
  }

  ll ans = ok;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3328
N = int(input())
li = list(map(int,input().split()))	
res = 0
for i in range (0,N+1,2):
    res += li[i]
for i in range(1,N,2):
    res -= li[i]
a = res 
ans = [a]
for i in range(N-1):
    b = int(2 * (li[i] - a / 2))
    ans.append(b)
    a = b
for s in ans:
  print(s, end =" ")

Measured memory_bytes: 65892
/*
Xi > Xj && Vi<Vj => i and j will meet each other in some time
Vi<Vk<Vj => k will change color
Max(Vj) && X[j]<Xi = Ri
Min(Vj) && X[j]>X[i] = L[i]
If i change color => (Li,Ri) will change color
F[i] = number 1->i change color
F[R[i]] = sum(F[j]) j=L[i] -> R[i]
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 2e5 + 10;
const int base = 1e9+7;

int n,x[maxn],v[maxn],t[maxn],p[maxn],L[maxn],R[maxn],f[maxn];

void update(int x,int k) {
    while (x<maxn) {
        t[x] = (t[x]+ k)%base;
        x += x&(-x);
    }
}

int Get(int x) {
    int res=0;
    while (x>0) {
        res = (res + t[x])%base;
        x -= x&(-x);
    }
    return res;
}

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=0;i<n;i++) cin>>x[i]>>v[i];
    vector<int> tmpx;
    for (int i=0;i<n;i++) tmpx.push_back(x[i]);
    vector<int> tmpv;
    for (int i=0;i<n;i++) tmpv.push_back(v[i]);
    sort(tmpx.begin(),tmpx.end());
    sort(tmpv.begin(),tmpv.end());
    for (int i=0;i<n;i++) {
        int x_id = lower_bound(tmpx.begin(),tmpx.end(),x[i]) - tmpx.begin();
        int v_id = lower_bound(tmpv.begin(),tmpv.end(),v[i]) - tmpv.begin();
        p[x_id] = v_id +1;
    }
    L[0] = p[0];
    for (int i=1;i<n;i++) L[i] = max(L[i-1],p[i]);
    R[n-1] = p[n-1];
    for (int i=n-2;i>=0;i--) R[i] = min(R[i+1],p[i]);
    update(1,1);
    for (int i=0;i<n;i++) {
        int s = (Get(L[i]+1) - Get(R[i]-1) + base) % base;
        f[L[i]] = (f[L[i]] + s) % base;
        update(L[i]+1,s);
    }
    cout<<f[n];
}


Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (n); i++)
using pint = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    ll x[n], l[n];
    pair<ll, ll> p[n];
    rep (i, n) {
        cin >> x[i] >> l[i];
        p[i].first = x[i] + l[i];
        p[i].second = x[i] + -l[i];
    }
    sort (p, p + n);
    ll now = p[0].first;
    int ans = n;
    for (int i = 1; i < n; i++) {
        if (now <= p[i].second) {
            now = p[i].first;
        } else {
            ans--;
        }
    }
    cout << ans << "\n";
}


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


int main(){
  int k;
  cin >> k;
  ll s = 7;
  int ans = -1;
  for(double i = 1.0; i < 9*k; i = i + 1.0){
    if(k % 2 == 0 || k % 5 == 0) break;
    else{
      s *= 10;
      s %= (9*k);
      if(s == 7){
        ans = i;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "next", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    auto t = new long[](2);
    s.each!(x => t[x - '0']++);
    writeln(t.reduce!(min) * 2);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int x[200];
int main()
{
    int t,n,a,q,ans=0;
    scanf("%d\n",&n);
    for (int i=1;i<=n;i++)
    {
    	scanf("%d\n",&x[i]);
    	ans+=x[i];
    }
    if (ans%10!=0)
    {
    	printf("%d\n",ans);
    	return 0;
    }
    sort(x+1,x+1+n);
    for (int i=1;i<=n;i++)
    {
    	if ((ans-x[i])%10!=0)
    	{
    		ans=ans-x[i];
    		printf("%d\n",ans);
    	    return 0;
    	}
    }
    printf("0\n");
    return 0;
}


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

used = set()
history = []

cur = 0
used.add(0)

while True:
    history.append(cur)
    next_cur = A[cur] - 1
    if next_cur in used:
        loop_start = history.index(next_cur)
        break
    used.add(next_cur)
    cur = next_cur

B = history[loop_start:]
if K <= loop_start:
    result = history[K]
else:
    result = B[(K-loop_start) % len(B)]

print(result+1)


Measured memory_bytes: 124808
#include<stdio.h>

int main(void){
  int MAX = 100;
  int i, j, k, n, A[MAX], v;
  scanf("%d", &n);

  for(i=0;i<n;i++) scanf("%d", &A[i]); //データを取り込む                                                     

  for(k=0;k<n-1;k++) printf("%d ", A[k]);
  printf("%d\n", A[n-1]);

  for(i=1;i<n;i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
      //printf("j = %d\n", j);                                                                                        
      //printf("A[j] = %d, A[j+1] = %d\n", A[j], A[j+1]);                                                             
    }
    A[j+1] = v;
    for(k=0;k<n-1;k++) printf("%d ",A[k]);
    printf("%d\n", A[n-1]);
  }
}



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

using namespace std;

template <class ForwardIterator>
typename vector<typename iterator_traits<ForwardIterator>::value_type>::size_type longest_increasing_subsequence(ForwardIterator first, ForwardIterator last)
{
    vector<typename iterator_traits<ForwardIterator>::value_type> v;
    while (first != last) {
        typename vector<typename iterator_traits<ForwardIterator>::value_type>::iterator it = lower_bound(v.begin(), v.end(), *first);
        if (it == v.end()) {
            v.push_back(*first);
        } else {
            *it = *first;
        }
        ++first;
    }
    return v.size();
}

int main(void)
{
    const int N_MAX = 100000;
    int n;
    int a[N_MAX];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    cout << longest_increasing_subsequence(a, a + n) << endl;

    return 0;
}


Measured memory_bytes: 3716
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main(){
    int n,k;cin>>n>>k;
    vector<ll> v(n);
    rep(i,0,n)cin>>v[i];
    sort(all(v));
    ll ans=0;
    rep(i,0,k)ans+=v[i];
    cout<<ans;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();
			int s = scanner.nextInt();
			int count = 0;
			for (int x = 0; x <= Math.min(k, s); x++) {
				for (int y = Math.max(0, s - x - k); y <= Math.min(k, s - x); y++) {
					int z = s - x - y;
					if ((z >= 0) && (z <= k)) {
						count++;
					}
				}
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int main(){
    int K;
    cin >> K;
    deque<long long> d;
    for(int i = 1;i < 10;i++){
        d.push_back(i);
    }
    if(K < 10){
        cout << K << endl;
        return 0;
    }
    K -= 9;
    while (K){
        long long val = d.front();
        d.pop_front();
        for(int i = -1;i < 2;i++){
            long long next = val % 10 + i;
            if(next < 0 || next >9)
                continue;
            next = next + val *10;
            d.push_back(next);
            K--;
            if(K == 0){
                cout << d.back() << endl;
                return 0;
            }
        }
    }

}


Measured memory_bytes: 4144
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#define ll long long
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    string s,t;
    int cnt=0;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}


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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cll ll t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pii pair<int,int>
#define vint vector<int>

ll mod=1e9+7;

int main(){
    faster;

    int m,n;
    cin>>m>>n;

    if(m>n){
        for(int i=0;i<m;i++) cout<<n;
        cout<<endl;
    }else if(n>=m){
        for(int i=0;i<n;i++) cout<<m;
        cout<<endl;
    }
}

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

template<class T>
ostream& operator<<(ostream& os,vector<T> const& v){
  for(auto itr=v.begin();itr!=v.end();++itr){
    if(itr!=v.begin())os<<" ";
    os<< *itr;
  }
  return os;
}

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  int q;
  cin>>q;
  while(q--){
    int l,r;
    cin>>l>>r;
    reverse(a.begin()+l,a.begin()+r);
  }
  cout<< a <<endl;

}


Measured memory_bytes: 3092
//atRto TLH
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define ll long long
const ll MOD = 1e9 + 7;
#define ln '\n'
#define all(x) (x).begin(), (x).end()
#define rotate rotate(vec.begin(), vec.begin() + k, vec.end())
#define alloc(v) set<int> S(all(v))
#define bitset(n)  bitset<20>(n)
#define Min min({a, b, c, d})
 
      const ll INF=2*1e5;
      char tt[2003][2003];
    
     int vis[107];
     //vector<ll>v[107];
    int size=0;
 

 
 void solve(){
 
 }
    
 
    int main() {
      IOS;
    #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif
   
   ll n;
   cin>>n;
   ll a[n];
    ll dp[n]; 
   for(int i=0;i<n;i++) cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);

    for(int i=2;i<n;i++){
     dp[i]=min((abs(a[i]-a[i-2])+dp[i-2]),(abs(a[i]-a[i-1])+dp[i-1]));
    }
    cout<<dp[n-1]<<ln;
    return 0;
  }


Measured memory_bytes: 5064
n=int(input())
ls=[0,0,0,n]
def col(num):
  if num%2==0:
    return num//2
  else:
    return 3*num+1
while True:
  ls.append(col(ls[-1]))
  if ls[-1]==ls[-4]:
    print(len(ls)-3)
    break

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    cin >> s;
    if (stoi(s.substr(0, 4)) == 2019){
        if (stoi(s.substr(5, 2)) == 4){
            if(stoi(s.substr(8, 2)) <= 30){
                cout << "Heisei" << "\n";
                return 0;
            }
        }
        else if (stoi(s.substr(5, 2)) < 4){
            cout << "Heisei" << "\n";
            return 0;
        }
    }
    if (stoi(s.substr(0, 4)) < 2019){
        cout << "Heisei" << "\n";
        return 0;
    }
    cout << "TBD" << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>

using namespace std;

bool S[2001][2001];
short U[2001][2001];
short D[2001][2001];
short L[2001][2001];
short R[2001][2001];

int main()
{
  int H, W;
  cin >> H >> W;

  for (int h=0; h<H; ++h) {
    for (int w=0; w<W; ++w) {
      char s;
      cin >> s;
      S[h][w] = s=='#';
    }
  }

  for (int h=0; h<H; ++h) {
    L[h][0] = S[h][0] ? 0 : 1;
    for (int w=1; w<W; ++w)
      L[h][w] = S[h][w] ? 0 : L[h][w-1] + 1;

    R[h][W-1] = S[h][W-1] ? 0 : 1;
    for (int w=W-2; w>=0; --w)
      R[h][w] = S[h][w] ? 0 : R[h][w+1] + 1;
  }

  for (int w=0; w<W; ++w) {
    U[0][w] = S[0][w] ? 0 : 1;
    for (int h=1; h<H; ++h)
      U[h][w] = S[h][w] ? 0 : U[h-1][w] + 1;

    D[H-1][w] = S[H-1][w] ? 0 : 1;
    for (int h=H-2; h>=0; --h)
      D[h][w] = S[h][w] ? 0 : D[h+1][w] + 1;
  }

  unsigned max_count = 0;
  for (int h=0; h<H; ++h) {
    for (int w=0; w<W; ++w) {
      if (S[h][w])
	continue;
      unsigned count = 1;

      count += L[h][w] - 1;
      count += R[h][w] - 1;
      count += U[h][w] - 1;
      count += D[h][w] - 1;
      
      max_count = max(max_count, count);
    }
  }
  
  cout << max_count << endl;

  return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
const int v=100001;
#define F(i) for(int i=0;i<200;i++)
int main(){
    int N,M,R; cin>>N>>M>>R;
    VE r;
    FOR(i,0,R){
        int rn; cin>>rn;
        r.PB(rn-1);
    }
    int d[200][200];
    F(i) F(j) d[i][j]=INF;
    FOR(i,0,M){
        int a,b,c; cin>>a>>b>>c;
        d[a-1][b-1]=d[b-1][a-1]=c;
    }
    F(k)F(i)F(j) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    sort(r.begin(),r.end());
    int ans=INF;
    do{
        int k=0;
        FOR(i,0,R-1){
            k+=d[r[i]][r[i+1]];
        }
        ans=min(k,ans);
    }while(next_permutation(r.begin(),r.end()));
    co(ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1000;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    int c = n/MX;
    if(n % MX) ++c;

    int ans = (c * MX) - n;
    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


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

int main()
{
  int a,b;
  int c;
  int i;
  while(true)
  {
    cin >> a >> b;
    if ( cin.eof() ) break;
    c = a + b;
    for (i=1; c>=10; i++)
    {
      c /= 10;
    }
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      char[][] a = new char[h][w];
      for(int i=0;i<h;i++){
        String s = sc.next();
        for(int j=0;j<w;j++){
          a[i][j] = s.charAt(j);
        }
      }
      //行削除
      int[] H = new int[h];
      int c =0;
      for(int i=0;i<h;i++){
        int count =0;
        for(int j=0;j<w;j++){
          if(a[i][j]=='.'){
            count++;
          }
        }
          if(count!=w){
          	H[c]=i;
            c++;
          }
      }
      //列削除
      int[] W = new int[w];
      int d=0;
      for(int j=0;j<w;j++){
        int count =0;
        for(int i=0;i<h;i++){
          if(a[i][j]=='.'){
            count++;
          }
        }
          if(count!=h){
          	W[d]=j;
            d++;
          }
      }
      //出力
      for(int i=0;i<c;i++){
        for(int j=0;j<d;j++){
          System.out.print(a[H[i]][W[j]]);
        }
        System.out.println();
      }
    }
}

Measured memory_bytes: 39040
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
a, b, c = np.sort(np.array(sys.stdin.read().split(), dtype=np.int64).reshape(3, n), axis=1)

def main():
    combs = np.sum(np.searchsorted(a, b) * (n - np.searchsorted(c, b, side='right')))
    print(combs)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 50060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >>N;
    if(N/100==N%10) cout << "Yes"<<endl;
    else cout << "No" <<endl;



}


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

int main() {
    long long x, y;
    cin >> x >> y;
    long long lcm  = x * y / __gcd(x, y);
    if (x < y) {
        cout << x;
    } else if (lcm == x) {
        cout << -1;
    } else {
        cout << lcm - x;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
h = list(li())

cost = [float("inf")]*(n)
cost[0] = 0

for i in range(n-1):
    if i == n-2:
        cost[i+1] = min(cost[i+1],
                        cost[i] + abs(h[i+1]-h[i]))
        
    else:
        cost[i+1] = min(cost[i+1],
                        cost[i] + abs(h[i+1]-h[i]))
        cost[i+2] = min(cost[i+2],
                        cost[i] + abs(h[i+2]-h[i]))
        
print(cost[-1])
        

Measured memory_bytes: 13712
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll>A(X), B(Y), C(Z);
	for (int i = 0; i < X; ++i)cin >> A[i];
	for (int i = 0; i < Y; ++i)cin >> B[i];
	for (int i = 0; i < Z; ++i)cin >> C[i];
	sort(C.begin(), C.end());
	vector<ll>key;
	for (int i = 0; i < X; ++i) {
		for (int j = 0; j < Y; ++j) {
			key.push_back(A[i] + B[j]);
		}
	}
	sort(key.begin(), key.end(),greater<ll>());
	vector<ll>key2;
	for (int i = 0; i < min(K,X*Y); ++i) {
		for (int j = 0; j < Z; ++j) {
			key2.push_back(key[i] + C[j]);
		}
	}
	sort(key2.begin(), key2.end(), greater<ll>());
	for (int i = 0; i < K; ++i) {
		cout << key2[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 42984