akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ABetweenTwoIntegers {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b, c;
	    in >> a >> b >> c;
	    ans(a<=c && c<=b, out);
	}
};


int main() {
	ABetweenTwoIntegers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;



int main() {


	int p,q,r;
	cin >> p >> q >> r;
	
	int mn = min(p + q, q + r);
	mn= min(p + r, mn);


	cout << mn << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll H, N;
    cin >> H >> N;
    rep(i, N){
        ll a;
        cin >> a;
        H -= a;
    }
    if(H <= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main(){
  int n,count;
  char ch[201];

  while(cin>>n){
    if(n==0)break;
    n=2*n;
    count=0;
    for(int i=0;i<n;i++)
      cin>>ch[i];

    for(int i=0;i+3<=n;i++)
      if((ch[i]=='l' && ch[i+1]=='u')&&(ch[i+2]=='r' && ch[i+3]=='u'))count++;
      else if((ch[i]=='l' && ch[i+1]=='d')&&(ch[i+2]=='r' && ch[i+3]=='d'))count++;
      else if((ch[i]=='r' && ch[i+1]=='u')&&(ch[i+2]=='l' && ch[i+3]=='u'))count++;
      else if((ch[i]=='r' && ch[i+1]=='d')&&(ch[i+2]=='l' && ch[i+3]=='d'))count++;
    cout<<count<<endl;
  }
  return 0;
}

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


long long ans( long long L, long long X, long long* p, long long* total ){
    if( X == 1 && L >= 1 ) return 0;
    else if( 1 < X && X < total[L-1]+2 ) return ans(L-1, X-1, p, total);
    else if( X == total[L-1]+2 ) return p[L-1] + 1;
    else if( total[L-1]+2 < X && X < total[L] ) return p[L-1] + 1 + ans(L-1, X-total[L-1]-2, p, total);
    else return p[L];
}


int main(){

    long long N, X;
    cin >> N >> X;
    

    long long p[51], total[51];
    p[0] = total[0] = 1;
    for( long long i = 0; i < N; i++ ){
        p[i+1] = 2 * p[i] + 1;
        total[i+1] = 2 * total[i] + 3;
    }
    
    cout << ans( N, X, p, total ) << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b,c,a1,b1,c1,a2,b2,c2,a3,b3,c3;
    cin >>a>>b>>c;
    if(a>b){
        a1=b;
        b1=a;
        c1=c;}
        else{
            a1=a;
            b1=b;
            c1=c;}
    if(b1>c1){
        a2=a1;
        b2=c1;
        c2=b1;}
        else{
            a2=a1;
            b2=b1;
            c2=c1;}
    if(a2>b2){
        a3=b2;
        b3=a2;
        c3=c2;}
        else{
            a3=a2;
            b3=b2;
            c3=c2;}
    cout<<a3<<" "<<b3<<" "<<c3<<endl;
    }


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;



//少数点表示
//cout <<std::fixed << std::setprecision(14)

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n,m;
    cin >> n >> m;
    vector<pair<int,string>> ps(m+1);
    rep(i,m){
        cin >> ps[i].first >> ps[i].second;    
    }
    vector<vector<int>> ac(n+1,vector<int>(2,0));
    int seitou=0;
    rep(i,m){
        if(seitou==n) break;
        if(ps[i].second=="AC"){
            if(ac[ps[i].first][0]!=1){
                ac[ps[i].first][0]=1;
                seitou++;
            }else{
                continue;
            }
        }
        if(ps[i].second=="WA"){
            if(ac[ps[i].first][0]!=1){
                ac[ps[i].first][1]+=1;
            }
        }
    }
    int acn=0,wan=0;
    rep(i,n+1){
        acn+=ac[i][0];
        if(ac[i][0]==1){
            wan+=ac[i][1];
        }
        //cout << ac[i][0] <<" "<<ac[i][1]<<endl;
    }

    cout << acn<<" " << wan<<endl;


}

Measured memory_bytes: 12032
#include<iostream>
#include<algorithm>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<cctype>
#include<vector>
#include<limits.h>
#include<queue>

using namespace std;


int main()
{

    int i;
    long long  n;
    long long   p[10];
    int s[10];
    cin>>n;
    for(i=0; i<5; ++i)
        cin>>p[i];
    long long a=*min_element(p,p+5);
    long long b=n/a+5;
    if(n%a==0)
        b--;
    cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int N, R; cin >> N >> R;
    int ans;
    if (N>=10) {
        ans = R;
    } else {
        ans = R + 100 * (10-N);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

ot = int(s[0:2])
tf = int(s[2:4])

if ot > 12 or ot == 0:
	if tf > 12 or tf == 0:
		print("NA")
	else:
		print("YYMM")
elif tf > 12 or tf == 0:
	print("MMYY")
else:
	print("AMBIGUOUS")


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

int main(){
int N, M;
cin >> N >> M;

vector<bool>b(N + 1, true);
for(int i = 0; i < M + 1; i++){ 
       int a;
       cin >> a;
       b.at(a) = false;
}

vector<int> dp(N + 1, 0);
dp.at(0) = 1;
int mod = 1000000007;
if(b.at(1)) dp.at(1) = 1;
for(int i = 2; i < N + 1; i++){ 
       if(b.at(i)) dp.at(i) = (dp.at(i - 1) + dp.at(i - 2));
  		dp.at(i) %= mod;
}

cout << dp.at(N) << endl; 

}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int count(int a);

int main(void){
    int n;
    int tmp;
    int i;
    int c=0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &tmp);
    	c += count(tmp);
    }
    printf("%d", c);
    return 0;
}

int count(int a){
    int ct=0;
	while(a % 2 == 0){
		ct++;
		a /= 2;
	}
    return ct;
}

Measured memory_bytes: 128
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
#$v2 = explode(" ", $stdin[0]);

$b = explode(" ", $stdin[1]);
$b2 = $b;

for($i = 0; $i < $stdin[0] - 1; $i++){
  if($i == 0){
    continue;
  }
  
  if($b[$i-1] > $b[$i]){
    $b[$i-1] = $b[$i];
  }
}

$sum = 0;
foreach($b as $v){
  $sum = $sum + $v;
}

$ans = $sum + $b2[0];


echo $ans . PHP_EOL;




Measured memory_bytes: 3700
N = int(input())
H = [int(i) for i in input().split()]
H.reverse()
for i in range(len(H)-1):
    if H[i]+1 < H[i+1]:
        print('No')
        exit(0)
    if H[i]+1 == H[i+1]: 
        H[i+1] -= 1
print('Yes')
    

Measured memory_bytes: 14252
#include <iostream>

using namespace std;

int main(void){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	bool both_switch_on = false;
	int count = -1;
	for(int i=0;i<=100;i++){
		if((a <= i && i <= b) && (c <= i && i <= d)){
			both_switch_on = true;
			count++;
		}else{
			both_switch_on = false;
		}
	}
	cout << ((count<0) ? 0 : count) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  int h[100001];
  int mini = INT_MAX;
  
  cin >> n >> k;

  for(int i = 0;i < n;i++){
	cin >> h[i];
  }

  sort(h, h + n);

  for(int i = n - 1;i >= k - 1;i--){
	mini = min(h[i] - h[i - k + 1], mini);
  }

  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 640
#include <string.h>
#include <stdio.h>

int calc_score() {                                                              
    int out = 0;                                                                
    char str[100];                                                              
    int score = 0;                                                              
    int base = 0;                                                               
                                                                                
    while (out < 3) {                                                           
        scanf("%s", str);                                                       
        if (strcmp(str, "OUT") == 0) {                                          
            out++;                                                              
        } else if (strcmp(str, "HIT") == 0) {                                   
            if (base == 3) {                                                    
                score++;                                                        
            } else {                                                            
                base++;                                                         
            }                                                                   
        } else if (strcmp(str, "HOMERUN") == 0) {                               
            score += (base + 1);                                                
            base = 0;                                                           
        }                                                                       
    }                                                                           
                                                                                
    return score;                                                               
}

int main(void) {                                                                
    int n;                                                                      
    int inning = 0;                                                             
                                                                                
    scanf("%d", &n);                                                            
                                                                                
    while (inning < n) {                                                        
        printf("%d\n", calc_score());                                           
        inning++;                                                               
    }                                                                           
                                                                                
    return 0;                                                                   
}

Measured memory_bytes: 596
from collections import deque
import copy

n,u,v = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n-1)]
tree = [list() for i in range(n)]
depth = [0] * n
depth2 = [0] * n
already = [1] * n
already[v-1] = 0
q = deque([v-1])
for a,b in ab:
  a,b = a-1,b-1
  tree[a].append(b)
  tree[b].append(a)
d = 0
last = [0] * n
for key,i in enumerate(tree):
  if len(i) == 1:
    last[key] = 1
while True:
  q2 = deque()
  while q:
    now = q.popleft()
    depth[now] = d
    for i in tree[now]:
      if already[i]:
        q2.append(i)
        already[i] = 0
  if q2:
    q = copy.copy(q2)
    d += 1
  else:
    break
# print(depth)
q = deque([u-1])
d = 0
ans = 0
already = [1] * n
already[v-1] = 0
while True:
  q2 = deque()
  while q:
    now = q.popleft()
    if depth[now] == d:
      ans = max(ans,d)
      continue
    elif depth[now] < d:
      ans = max(ans,d-1)
      continue
    if last[now]:
      if depth[now] % 2 == d % 2:
        ans = max(ans,depth[now]-1)
      else:
        ans = max(ans,depth[now]-1)
    for i in tree[now]:
      if already[i]:
        q2.append(i)
        already[i] = 0
  if q2:
    q = copy.copy(q2)
    d += 1
  else:
    break
print(ans)

Measured memory_bytes: 81880
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


pii dir8[8] = {
    {0, -1},
    {0, 1},
    {-1, -1},
    {-1, 0},
    {-1, 1},
    {1, -1},
    {1, 0},
    {1, 1},
};

int main(void) {
    int row, col;
    cin >> row >> col;
    vector<vector<char>> map(row+2, vector<char>(col+2, '.'));

    for(int i = 1; i <= row; i++) {
        string str;
        cin >> str;
        for(int j = 1; j <= col; j++) {
            map[i][j] = str[j-1];
        }
    }

    vector<vector<char>> ans(row+2, vector<char>(col+2, '#'));
    for(int i = 1; i <= row; i++) {
        for(int j = 1; j <= col; j++) {
            if(map[i][j] == '#') continue;
            int cnt = 0;
            for(pii d: dir8) {
                pii np = make_pair(
                    i+d.first,
                    j+d.second
                );
                cnt += (map[np.first][np.second] == '#');
            }
            ans[i][j] = cnt + '0';
        }
    }

    // presentation
    for(int i = 1; i <= row; i++) {
        for(int j = 1; j <= col; j++) {
            putchar(ans[i][j]);
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

bool check(string s)
{
    string t = "";
    for(int i = 0; i < s.size(); i++) t += s[i];
    reverse(t.begin(), t.end());
    if(s == t) return true;
    return false;
}

void solve()
{
    string s; cin >> s;
    int n = s.size();
    string t = "";
    for(int i = 0; i < n / 2; i++) t += s[i];
    string u = "";
    for(int i = n / 2 + 1; i < n; i++) u += s[i];
    bool isOK = true;
    isOK &= check(s);
    isOK &= check(t);
    isOK &= check(u);
    cout << (isOK ? "Yes" : "No") << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100001];
int main(){
  int m,n;
  dp[0] = 1;
  dp[1] = 1;
  cin >> n >> m;
  int a[100007]={};
  for(int i=0;i<m;i++){
     int b;
    cin >> b;
    a[b] = 1;
  }
  for(int i=0;i<n-1;i++){
    if(a[1]==1){
      dp[1] = 0;
    }
    dp[i+2] = dp[i+1] + dp[i];
    dp[i+2] %= 1000000007;
    if(a[i+2] == 1)
      dp[i+2] = 0;
  }
  cout << dp[n] << endl;
}

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

#define lli long long int
#define pb push_back

lli dp[100001];

main()
{
    lli n,i,a,j,k,b;

    cin>>n>>k;
    lli arr[n];

    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    dp[0] = 0;

    for(i=1;i<n;i++)
    {
        a = INT_MAX;
        for(j=1;j<=k;j++)
        {
            if(i>=j)
            {
                a = min(a,dp[i-j]+abs(arr[i]-arr[i-j]));
            }
            else
            {
                break;
            }
        }
        dp[i] = a;
    }

    cout<<dp[n-1];

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int a;
cin>>a;
  int b;
  b=a%10;
  if(b==3) cout<<"bon";
else if(b==0 || b==1 || b==6 || b==8) cout<<"pon";
  else cout<<"hon";
  
}

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

const int MAXN = 101;
const int MAXL = 101;

struct Edge {
  int to, d, e;
};
struct State {
  int v, l, c;
  bool operator <(const State &s) const {
    if(c != s.c) return c > s.c;
    if(l != s.l) return l < s.l;
    return v < s.v;
  }
};
const int INF = 1<<28;

int N, M, L;
int cost[MAXN][MAXL];
vector<Edge> E[MAXN];

int dijkstra(int start, int goal) {
  priority_queue<State> que;
  State s = {start, L, 0};
  fill(cost[0], cost[MAXN], INF);
  cost[s.v][s.l] = 0;
  que.push(s);
  while(!que.empty()) {
    s = que.top();
    que.pop();
    if(cost[s.v][s.l] < s.c) continue;
    for(int i = 0; i < E[s.v].size(); ++i) {
      const Edge &e = E[s.v][i];
      do {
        State t = {e.to,
                   s.l - e.d,
                   s.c};
        if(t.l < 0) break;
        if(cost[t.v][t.l] <= t.c) break;
        cost[t.v][t.l] = t.c;
        que.push(t);
      }while(0);
      do {
        State t = {e.to,
                   s.l,
                   s.c + e.e};
        if(cost[t.v][t.l] <= t.c) break;
        cost[t.v][t.l] = t.c;
        que.push(t);
      }while(0);
    }
  }
  int res = INF;
  for(int j = 0; j <= L; ++j) {
    res = min(res, cost[N-1][j]);
  }
  return res;
}

int main() {
  while(cin >> N >> M >> L && (N|M|L)) {
    fill(E,E+MAXN,vector<Edge>());
    for(int i = 0; i < M; ++i) {
      int a, b, d, e;
      cin >> a >> b >> d >> e;
      --a; --b;
      E[a].push_back((Edge){b,d,e});
      E[b].push_back((Edge){a,d,e});
    }
    cout << dijkstra(0,N-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1756
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int get_ab(string str) {
	bool isA = false;
	int res = 0;
	if (str[0] == 'A') isA = true;
	for (int i = 1; i < str.length(); i++) {
		if (isA && str[i] == 'B') { res++; isA = false; }
		else if (str[i] == 'A') isA = true;
		else isA = false;
	}
	return res;
}

int main(void) {
	//Program Start	

	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	K--;

	char x;
	if (S[K] == 'A') x = 'a';
	if (S[K] == 'B') x = 'b';
	if (S[K] == 'C') x = 'c';

	S[K] = x;

	cout << S << endl;






ProgramEndPointLabel:;


	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,tmp;cin>>n;
  vector<int>a(1e5+3,0);
  for(int i=0;i<n;i++)cin>>tmp,a[tmp]++,a[tmp+1]++,a[tmp+2]++;
  cout<<*max_element(a.begin(),a.end())<<endl;
  return 0;
}

Measured memory_bytes: 640
// {{{ Templates
#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

// }}}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<ll>> A(N, vector<ll>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }

    vector<vector<bool>> use(N, vector<bool>(N, true));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                if (A[i][j] + A[j][k] < A[i][k]) {
                    cout << -1 << endl;
                    return 0;
                } else if (A[i][j] + A[j][k] == A[i][k] and i != j and j != k and k != i) {
                    use[i][k] = false;
                    use[k][i] = false;
                }
            }
        }
    }

    ll sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (use[i][j]) {
                sum += A[i][j];
            }
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
using namespace std ;
const int INF=1e9+5;
#define  IO cin.tie(0); cin.sync_with_stdio(0)
typedef  long long ll ;


int main(){
    IO;
     int n ;
     cin>>n ;
     ll best_even_begin_not_token=0,best_odd_begin_not_token=0,best_even_begin_token=-INF,best_odd_begin_token=-INF;
     ll arr[n+10];
     for(int i =0 ; i < n ; i++)cin>>arr[i];
     for(int i=n;i<n+6;i++)arr[i]=0;
     for(int i =0 ; i< n ; i+=2){
         ll temp_best_even_begin_not_token=best_even_begin_not_token,temp_best_odd_begin_not_token=best_odd_begin_not_token,
         temp_best_even_begin_token=best_even_begin_token,temp_best_odd_begin_token=best_odd_begin_token;

           best_even_begin_not_token=temp_best_even_begin_not_token+arr[i];
           best_odd_begin_not_token=max(temp_best_odd_begin_not_token,temp_best_even_begin_not_token)+arr[i+1];
           best_even_begin_token=max(temp_best_even_begin_token,temp_best_even_begin_not_token)+arr[i+1];
           best_odd_begin_token=max({temp_best_odd_begin_token,temp_best_even_begin_token,temp_best_odd_begin_not_token})+arr[i+2];
     }
     if(n%2==0)cout<<max(best_even_begin_not_token,best_odd_begin_not_token);
     else cout<<max(best_even_begin_token,best_odd_begin_token);
    return 0;
}


Measured memory_bytes: 5108
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
S=input()
res = 0
for i in range(N-2):
    res += S[i:i+3] == "ABC"
print(res)


Measured memory_bytes: 3064
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<cstring>
#include<iostream>
#define _PI acos(-1.0)
#define INF 0x3f3f3f3f
#define esp 1e-9
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define FRE freopen("abc.in", "r", stdin)
#define MEM(X,Y) memset(X,Y,sizeof(X))
typedef long long LL;
typedef unsigned long long ULL;
long long int gcd(long long int a, long long int b) { return b ? gcd(b, a % b) : a; }
using namespace std;
/*===========================================*/

int main(void)
{
	IOS;
	string a;
	getline(cin, a);
	if (a[2] == a[3] && a[4] == a[5])
		printf("Yes");
	else
		printf("No");

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int kurikaesu;
	cin >> kurikaesu;
	while (kurikaesu--) {
		int n, m;
		cin >> n >> m;
		int mal = n*n + m*m;
		int cnt = 0;
		for (int p = 0; p*p <= mal; p++){
			for (int q = 0; q*q <= mal;q++){
				if (p*p + q*q < 1)continue;
				if ((m*p + n*q) % (p*p + q*q) == 0 && (n*p - m*q) % (p*p + q*q) == 0)cnt++;
			}
		}
		if (cnt*2 > 8)
			cout << "C" << endl;
		else
			cout << "P" << endl;
	}
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

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

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

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

struct ConvexHullTrick {
	//(slope,intercept)
	deque<pair<ll, ll> > dq;

	void add(ll a, ll b) {
		pair<ll, ll> p0 = make_pair(a, b);
		while (dq.size() >= 2) {
			ll sz = dq.size();
			pair<ll, ll> p1 = dq[sz - 1];
			pair<ll, ll> p2 = dq[sz - 2];
			if ((p0.second - p1.second) * (p0.first - p2.first) < (p0.second - p2.second) * (p0.first - p1.first)) { break; }
			dq.pop_back();
		}
		dq.push_back(p0);
	}

	ll query(ll x) {
		while (dq.size() >= 2) {
			ll v1 = dq[0].first * x + dq[0].second;
			ll v2 = dq[1].first * x + dq[1].second;
			if (v1 <= v2) { break; }
			dq.pop_front();
		}
		return dq[0].first * x + dq[0].second;
	}
};

ll a, b;
vector<ll>v, dp;
int main() {
	cin >> a >> b;
	v.resize(a), dp.resize(a);

	for (int i = 0; i < a; ++i) { cin >> v[i]; }

	ConvexHullTrick cht;
	dp[0] = 0;
	cht.add(-2 * v[0], v[0] * v[0]);

	for (int i = 1; i < a; ++i) {
		dp[i] = cht.query(v[i]) + v[i] * v[i] + b;
		cht.add(-2 * v[i], v[i] * v[i] + dp[i]);
	}

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


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

using namespace std;

#define ll long long



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

	if (n * a > b)
	{
		cout << b << endl;
	}
	else
	{
		cout << n * a << endl;
	}
}

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

int main() {
  int a, b, c, r = 0, L = 0;
  char d;
  while (cin >> a >> d >> b >> d >> c) {
    if (a * a + b * b == c * c) r++;
    else if (a == b) L++;
  }
  cout << r << "\n" << L << "\n";
}


Measured memory_bytes: 3060
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};

ll i,j,k;
ll a,b,c;
ll n,m;
ll d[105][105];
ll aa[1005],bb[1005],cc[1005];


int main(){
	cin>>n>>m;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			d[i][j]=INF;
		}
	}
	for(i=0;i<m;i++){
		cin>>a>>b>>c;
		d[a][b]=d[b][a]=c;
		aa[i]=a;
		bb[i]=b;
		cc[i]=c;

	}
	for(k=1;k<=n;k++){
		for(i=1;i<=n;i++){
			for(j=1;j<=n;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	ll ans=0;
	for(i=0;i<m;i++){
		if(d[aa[i]][bb[i]]<cc[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#!/usr/bin/env python3
import sys


def solve(N: int):
    ans = 100000
    if(0  <= N <= 99):
        ans = min(9,N)
    elif(100 <= N <= 9999):
        ans = min(N, 999)-99+9
    elif(10000 <= N <= 100000):
        ans = min(N, 99999) - 9999 + 999 - 99 + 9

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <deque>
#include <cmath>
using namespace std;

int main()
{
    // 整数の入力
    long long N,stable,headB,tailA,headtailAB;
    stable = 0;
    headB = 0;
    tailA = 0;
    headtailAB = 0;
    cin >> N;
    for (int i = 0;i< N;i++){
        string s;
        cin >> s;
        for (int j = 1; j < s.size();j++){
            if (s[j] == 'B' && s[j-1] == 'A'){
                stable++;
            }
        }
        if (s[0] == 'B' && s[s.size() -1] != 'A'){
            headB++;
        }
        if (s[0] != 'B' && s[s.size() -1] == 'A'){
            tailA++;
        }
        if (s[0] == 'B' && s[s.size() -1] == 'A'){
            headtailAB++;
        }
    }
    // cout << stable << " " << headB << " " << tailA << " " << headtailAB << endl;
    if (headtailAB > 0){
        if (headB != tailA){
            cout << stable + max(headtailAB - 1LL,0LL) + min(headB,tailA) + 1 << endl;
        }else{
            if (headB == 0){
                cout << stable + max(headtailAB - 1LL,0LL) + min(headB,tailA) << endl;
            }else{
                cout << stable + max(headtailAB - 1LL,0LL) + min(headB,tailA) + 1 << endl;
            }
        }
    }else{
        cout << stable + min(headB,tailA) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
 
using namespace std;
 
int main (){
  
  long long int a,b,c;
  
  
  cin >>a;
   cin >>b ;
  cin >> c;
  
  cout <<(a+1-b)*(a+1-c) << endl;
  
 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int l;cin>>l;if(!l)return 0;
        int m,n,allm=0;
        int ans=0;
        for(int i=0;i<12;++i){
            cin>>m>>n;
            allm+=m-n;
            if(!ans&allm>=l)ans=i+1;
        }
        if(ans)cout<<ans<<endl;
        else cout<<"NA"<<endl;
    }
    return 0;
}

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

int main() {
  
  char s;
  
  cin >> s;
  if(s=='A')cout << 'T' << endl;
    if(s=='T')cout << 'A' << endl;
	  if(s=='C')cout << 'G' << endl;
	    if(s=='G')cout << 'C' << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a;
    string s;
    cin>>a>>s;
    (a<3200)?cout<<"red\n":cout<<s<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
inline PI operator +(PI a,PI b){
	return a>b?mp(a.first,max(a.second,b.first)):mp(b.first,max(b.second,a.first));
} 
PI a[1<<18];
int ans[1<<18];
int main(){
	int n=read();
	for(int i=0;i<(1<<n);i++)a[i]=mp(read(),0);
	for(int i=0;i<n;i++){
		for(int j=0;j<(1<<n);j++)if(j>>i&1){
			a[j]=a[j]+a[j^(1<<i)];
		}
	}
	for(int i=1;i<(1<<n);i++){ans[i]=max(ans[i-1],a[i].first+a[i].second); writeln(ans[i]);}
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for(int i=0;i<(int)n;i++)
#define fore(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MAX=1005;
int n,m;
char mat[MAX][MAX];
const ll mod=1e9+7;
ll mem[MAX][MAX];
ll dp(int i,int j){
    if(i>=n||j>=m)return 0;
    if(i==n-1&&j==m-1)return 1;
    ll &ans=mem[i][j];
    if(ans!=-1)return ans;
    if(mat[i][j]=='#')return 0;
    ll rta=0;

    rta+=(dp(i+1,j)%mod+dp(i,j+1)%mod)%mod;
    ans=rta;
    return ans;
}
int main()
{

#ifdef LOCAL
    freopen("output/input.txt", "r", stdin);
    //freopen("main.out", "w", stdout);
#else
    ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
#endif
    //memset(mem,-1,sizeof(mem));
    memset(mem,-1,sizeof mem);
    cin>>n>>m;
    forn(i,n){
        forn(j,m)cin>>mat[i][j];
    }
    cout<<dp(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool f_u,f_l;//0=amb,1=YY
  
  //upper
  int sum=0;
  sum+=((s[0]-'0')*10);
  sum+=(s[1]-'0');
  if(sum>12||sum<1){f_u=1;}
  else{f_u=0;}
  
  //lower
  sum=0;
  sum+=((s[2]-'0')*10);
  sum+=(s[3]-'0');
  if(sum>12||sum<1){f_l=1;}
  else{f_l=0;}
  
  if(f_u==0&&f_l==0){cout << "AMBIGUOUS" << endl;}
  if(f_u==1&&f_l==0){cout << "YYMM" << endl;}
  if(f_u==0&&f_l==1){cout << "MMYY" << endl;}
  if(f_u==1&&f_l==1){cout << "NA" << endl;}
  
  return 0;
}


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

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

fn min<T: std::cmp::PartialOrd>(a: T, b: T) -> T {
    if a < b {
        return a;
    } else {
        return b;
    }
}

fn main() {
    let n: usize = read();
    let hi: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut dp = vec![std::i32::MAX; n];
    dp[0] = 0;

    for i in 0..n-1 {
        dp[i+1] = min(dp[i+1], dp[i] + (hi[i+1] - hi[i]).abs());
        if i < n-2 {
            dp[i+2] = min(dp[i+2], dp[i] + (hi[i+2] - hi[i]).abs());
        }
    }

    println!("{}", dp[n-1]);
}


Measured memory_bytes: 4352
n, m = gets.chomp.split(" ").map(&:to_i)
p = []
n.times{
  x, y, z = gets.chomp.split(" ").map(&:to_i)
  p << [x, y, z]
}

if m == 0 then
  print("0")
  exit
end
wk = []
[-1, 1].each{|i|
  [-1, 1].each{|j|
    [-1, 1].each{|k|
      wk << p.map{|e| i * e[0] + j * e[1] + k * e[2]}.sort!.reverse![0..m-1].inject(:+)
    }
  }
}

print("#{wk.max}")


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  rep(i,n/2){
    if(s.at(i) != s.at(n-1-i)) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
    int N;
    std::cin >> N;

    int longest_length = 0;
    int sum_of_lenth = 0;

    for (int i=0; i<N; i++) {
        int l;
        std::cin >> l;
        sum_of_lenth += l;
        if (l > longest_length) longest_length = l;
    }

    if (sum_of_lenth - longest_length > longest_length)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  rep(i,n){
    ll low=-d*i+c*(n-1-i),high=-c*i+(n-1-i)*d;
    if(low<=b-a && b-a<=high){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
    int a,b;
    char arr[100];
    scanf("%d %d",&a,&b);
    cin>>arr;
    bool ans=false;
    int siz=strlen(arr);
    if(arr[a]==45)
    {
        for(int i=0;i<siz;i++)
        {
            if(arr[i]>='0'&&arr[i]<='9')
            {
                ans=true;
            }
            else
            {
                if(i!=a)
                {
                  ans=false;
                  break;
                }
            }
        }
    }
    if(ans)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>A(N);

    rep(i,N){
        cin>>A[i];
    }
    sort(all(A));
    ll b;
    ll mx=A[N-1];
    ll mn=INF;
    rep(i,N){
        if(mx%2==0){
            if(abs(A[i]-mx/2)<mn){
                mn=abs(A[i]-mx/2);
                b=A[i];
            }
        }else{
            if(abs(A[i]-(mx+1)/2)<mn){
                mn=abs(A[i]-(mx+1)/2);
                b=A[i];
            }
            if(abs(A[i]-(mx-1)/2)<mn){
                mn=abs(A[i]-(mx-1)/2);
                b=A[i];
            }
        }
    }
    cout << mx<<" "<<b << endl;


    return 0;
    

}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
    	int c[11] = {0};
      	int A, B, C;
      	cin >> A >> B >> C;
      	c[A]++;
      	c[B]++;
      	c[C]++;
      	if (c[5] == 2 && c[7] == 1)
          	cout << "YES" << endl;
      	else
          	cout << "NO" << endl;
    	return 0;
    }

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

int main() {
    int N;
    cin >> N;
    int check = 0;
    vector<int> L(N);
    for(int i=0; i<N; i++){
        cin >> L.at(i);
    }
    if(N<3){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0; i<N-2; i++){
        for(int j=i; j<N-1; j++){
            for(int k=j; k<N; k++){
                if(L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(i) != L.at(k)){
                    if(L.at(i)+L.at(j) > L.at(k) &&
                       L.at(j)+L.at(k) > L.at(i) &&
                       L.at(i)+L.at(k) > L.at(j)){
                        check += 1;
                        
                    }
                }
            }
        }
    }
    cout << check << endl;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
int h[110];
int main (){
    cin >> N;
    for(int i=0; i<N; i++) cin >> h[i];
    int cnt = 0;
    while( true ) {
        bool fin = true;
        for(int i=0; i<N; i++) {
            if(h[i] > 0) fin = false;
        }
        if(fin) break;
        int x = 0;
        while( h[x] < 1 ) x++;

        while( h[x] ) {
            h[x]--;
            x++;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    vector<long long>a(n+1);
    vector<long long>b(n);
    long long ans=0;
    for(int i=0;i<n+1;i++)cin >> a[i];
    for(int i=0;i<n;i++)cin >> b[i];
    for(int i=0;i<n;i++){
        int tm=min(a[i],b[i]);
        b[i] -= tm;
        int re=min(a[i+1],b[i]);
        a[i+1] -= re;
        ans += re + tm;
        
    }
    cout << ans;
}

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

using ll = long long;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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

    ll x = 1,
       y = 1;
    for (int i = 0; i < N; i++) {
        ll c, d;
        cin >> c >> d;

        ll z = max((x + d - 1) / d, (y + c - 1) / c);
        x = d * z;
        y = c * z;
    }
    cout << x + y << endl;

    return 0;
}


Measured memory_bytes: 256