akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

bool check(string s) {
  if (s[0] != 'A') return false;
  const int n = s.size();
  int cnt = 0;
  for (int i = 2; i < n - 1; ++i) {
    cnt += s[i] == 'C';
  }
  if (cnt != 1) return false;
  int upper = 0;
  for (auto &c : s) if ('A' <= c && c <= 'Z') ++upper;
  if (upper != 2) return false;
  return true;
}

int main() {
  string s;
  cin >> s;
  if (check(s)) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){int n,a,b,c,d,e,f,g,h,x,y,z,w;while(cin>>n,n)while(n--){cin>>a>>b>>c>>d>>e>>f>>g>>h;cout<<a*e-b*f-c*g-d*h<<" "<<a*f+b*e+c*h-d*g<<" "<<a*g-b*h+c*e+d*f<<" "<<a*h+b*g-c*f+d*e<<endl;}}

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

char nth_letter(int n)
{
    assert(n >= 0 && n <= 25);
    return "abcdefghijklmnopqrstuvwxyz"[n];
}

int main() {
   char s;
   cin >> s;
   rep(i,26){
      if(s==nth_letter(i)){
         cout << 'a' << endl;
         return 0;
      }
   }
   cout << 'A' << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int fun(ll a,int b){
    int ans=0;
    while(1){
        ans++;
        int c=a%b;
        if(c==0){
            break;
        }else{
            bitset<2*100000> s(c);
            int su=0;
            rep(i,100){
                if(s.test(i))su++;
            }
            a=c;
            b=su;
        }
    }
    return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;

	bitset<2*100000+1> s;
	cin>>s;
	int ho=0;
	rep(i,n){
	    if(s.test(i))ho++;
	}
	int hom=ho-1;
	int hop=ho+1;
	vector<int> Hom(n,0);
	vector<int> Hop(n);
	if(hom!=0){
	    rep(i,n){
	        if(i==0){
	            Hom[i]=1%hom;
	            Hop[i]=1%hop;
	        }else{
	            Hom[i]=Hom[i-1]*2%hom;
	            Hop[i]=Hop[i-1]*2%hop;
	        }
	    }
	}else{
	    rep(i,n){
	        if(i==0){
	            Hop[i]=1%hop;
	        }else{
	           
	            Hop[i]=Hop[i-1]*2%hop;
	        }
	    }
	}
	if(hom!=0){
	ll msum=0;
	ll psum=0;
	rep(i,n){
	    if(s.test(i)){
	        msum+=Hom[i];
	        psum+=Hop[i];
	    };
	}
	rep(i,n){
	    ll hoho;
	    if(s.test(n-1-i)){
	        hoho=msum-Hom[n-1-i];
	        cout<<fun(hoho,hom)<<endl;
	    }else{
	        hoho=psum+Hop[n-1-i];
	        cout<<fun(hoho,hop)<<endl;
	    }
	}
	}else{
	    ll msum=0;
	ll psum=0;
	rep(i,n){
	    if(s.test(i)){
	        msum+=Hom[i];
	        psum+=Hop[i];
	    };
	}
	rep(i,n){
	    ll hoho;
	    if(s.test(n-1-i)){
	        cout<<0<<endl;
	    }else{
	        hoho=psum+Hop[n-1-i];
	        cout<<fun(hoho,hop)<<endl;
	    }
	}
	}
	return 0;
}


Measured memory_bytes: 5008
#include<iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
int main(){
	int a,b,c,d,i;
	cin>>a>>b>>c>>d;
	int sum=0;
	int flag[110]={0};
	for(i=0;i<110;i++){
		if(i>=a&&i<b){
			flag[i]++;
		}
		if(i>=c&&i<d){
			flag[i]++;
		}
	}
	for(i=0;i<110;i++){
		if(flag[i]==2)
			sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  string s;
  cin >> s;
  int d;
  cin >> d;

  int n = sz(s);
  int dp[n + 1][d + 1][2];
  fill_n(**dp, (n + 1) * (d + 1) * 2, 0);
  dp[0][0][0] = 1;

  rep(i, n) rep(j, d) rep(k, 2) rep(l, 10) {
    if (k == 0 && (s[i] - '0' < l)) continue;
    add(dp[i + 1][(j + l) % d][k | (s[i] - '0' > l)], dp[i][j][k]);
  }
  int ans = dp[n][0][0];
  add(ans, dp[n][0][1]);
  add(ans, -1 + mod);
  cout << ans << endl;
}


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

int main(void){
    int A, B, C, X, Y;
    long long int res = 0;
    std::cin >> A >> B >> C >> X >> Y;

    int m = std::min(X, Y);
    if(A + B <= C * 2) res += (A + B) * m;
    else res += C * 2 * m;

    if(X - m > 0) {
        if (A <= C * 2) res += (X - m) * A;
        else res += (X - m) * (C * 2);
    }
    if(Y - m > 0){
        if(B <= C * 2) res += (Y - m) * B;
        else res += (Y - m) * (C * 2);
    }

    std::cout << res << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
 
int main(void)
{
  	int N;
  	int count=0;
  	int i=0;
    // 整数の入力
    scanf("%d\n",&N);
  	int P[N];
  	int min=N;
  	for(i=0;i<N;i++){
      	scanf("%d\n",&P[i]);
    }
   	for(i=0;i<N;i++){
    	if(P[i]<=min){
          	count++;
          	min=P[i];
        }
    }
      printf("%d\n",count);
    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    string s;
    cin >> s;

    set<char> st;
    rep(i, s.size()){
        st.insert(s[i]);
    }

    if(s.size() == st.size()){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;
    int n;
    cin>>n;
    n%=10;
    if(n==3) cout<<"bon";
    else if (n==0 || n==1 || n==6 || n==8) cout<<"pon";
    else cout<<"hon";
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n,ans=0;
  cin >> n;
  vector<int> p=input(n);
  for(int i=2;i<n;i++){
    if(p[i-1]<p[i]&&p[i-2]<p[i-1]){
      ans++;
      continue;
    }
    if(p[i-1]>p[i]&&p[i-2]>p[i-1]){
      ans++;
    }
  }
  cout << ans << endl;
}


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

#define ff first
#define ss second
#define ll long long
#define pq priority_queue
#define mii map<int,int>

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;

string s;
int d;
int tb[10005][105][2];
vi num;

int dp(int i, int n, int f) {
    if(i == (int)s.size() and n == 0) return 1;
    if(i == (int)s.size()) return 0;
    if(tb[i][n][f] != -1) return tb[i][n][f];

    int limit = f == 0 ? num[i] : 9;
    // Se o número formado já é menor que a entrada, podemos colocar qualquer dígito.

    int ans = 0;
    for(int dgt = 0; dgt <= limit; dgt++)
    {
        if(f == 0 and dgt < limit) ans = ans%oo + dp(i+1, (n%d+dgt%d)%d, 1)%oo;
        else if(f == 0 and dgt == limit) ans = ans%oo + dp(i+1, (n%d+dgt%d)%d, 0)%oo;
        if(f == 1) ans = ans%oo + dp(i+1, (n%d+dgt%d)%d, f)%oo;  
    }
    tb[i][n][f] = ans % oo;
    return ans % oo;
}

int main() {
    cin >> s >> d;

    
    for(size_t i = 0; i < s.size(); i++)
    {
        num.push_back(s[i] - '0');
    }
    
    memset(tb, -1, sizeof tb);
    printf("%d\n", ((dp(0, 0, 0)-1)+oo)%oo);

    return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

i64 dp[3001][3001][4];

int main(int argc, char **argv) {
    i64 r,c,k;
    cin >> r>>c>>k;

    for (int i=0; i<3001; ++i) {
        for (int j=0; j<3001; ++j) {
            for (int k=0; k<3; ++k) {
                dp[i][j][k] = 0;
            }
        }
    }
    map<pair<i64, i64>, i64> tgt;

    for (int i=0; i<k; ++i) {
        i64 r1, c1, v;
        cin >> r1 >> c1 >> v;
        tgt[make_pair(r1, c1)] = v;
    }

    for (int i=1; i<r+1; ++i) {
        for (int j=1; j<c+1; ++j) {
            P p(i,j);
            i64 v;
            if (tgt.find(p) == tgt.end()) {
                v=0;
            } else {
                v=tgt[p];
            }
            dp[i][j][0] = max(dp[i][j-1][0], dp[i-1][j][3]);
            dp[i][j][1] = max(dp[i][j-1][1], dp[i][j-1][0]+v);
            dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][3]+v);
            dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1]+v);
            dp[i][j][2] = max(dp[i][j][2], dp[i][j][1]);
            dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2]+v);
            dp[i][j][3] = max(dp[i][j][3], dp[i][j][2]);
        }
    }
/*
    for (int k=0; k<3; ++k) {
        for (int i=0; i<=r; ++i) {
            for (int j=0; j<=c; ++j) {
                cout << dp[i][j][k] << " ";
            }
            cout << endl;
        }
        cout << endl;
    }
*/
    cout << dp[r][c][3] << endl;

    return 0;
}

Measured memory_bytes: 297516
r,c=map(int,input().split())
lst=[list(map(int,input().split()))for i in range(r)]
all_lst=[0 for i in range(c+1)]
for mini_lst in lst:
    for i in range(c):
        all_lst[i]+=mini_lst[i]
    mini_sum=sum(mini_lst)
    all_lst[-1]+=mini_sum
    mini_lst.append(mini_sum)
    print(' '.join(map(str,mini_lst)))
print(' '.join(map(str,all_lst)))


Measured memory_bytes: 5692
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<(x)<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  int l=0,r=w,u=h,b=0;
  rep(i,n){
    int x,y,d;
    scanf("%d %d %d", &x, &y, &d);
    switch(d){
      case 1:
      l=max(l, x);
      break;
      case 2:
      r=min(r,x);
      break;
      case 3:
      b=max(b,y);
      break;
      case 4:
      u=min(u,y);
      break;
    }
  }
  if(l>=r || u<=b) cout<<0<<endl;
  else cout<< (r-l)*(u-b) << endl;

  return 0;
}


Measured memory_bytes: 384
import numpy as np
N, K= map(int, input().split())
A=[int(i) for i in input().split()]
F=[int(i) for i in input().split()]

A=np.array(sorted(A, reverse=True))
F=np.array(sorted(F))

lower_bound=0
upper_bound=np.max(A*F)
K_tmp=0

while upper_bound>=lower_bound:
    mid=(lower_bound+upper_bound)//2
    K_tmp=np.sum(np.maximum(A-mid//F, 0))
    if K_tmp<=K:
        upper_bound=mid-1
    else:
        lower_bound=mid+1

print(lower_bound)

Measured memory_bytes: 43644
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var A, B, ans int
	fmt.Scan(&A, &B)

	for i := A; i <= B; i++ {
		var str = strconv.Itoa(i)
		for j := 0; j <= len(str); j++ {
			if len(str)-j < j {
				ans++
				break
			}

			if str[j] != str[len(str)-1-j] {
				break
			}
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) < abs(a[j]) }


Measured memory_bytes: 1024
def _agc022_b(N):
    if N >= 4:
        S = []
        a = N // 8

        l = [2, 3, 4, 6, 8, 9, 10, 12]

        for i in range(a):
            for v in l:
                S.append(i * 12 + v)

        b = N % 8
        if b == 1:
            l = [6]
        elif b == 2:
            l = [6, 12]
        elif b == 3:
            l = [3, 6, 9]
        elif b == 4:
            l = [3, 4, 8, 9]
        elif b == 5:
            l = [2, 3, 6, 9, 10]
        elif b == 6:
            l = [2, 3, 4, 8, 9, 10]
        elif b == 7:
            l = [2, 3, 4, 6, 8, 9, 10]
        elif b == 0:
            l = []

        for v in l:
            S.append(a * 12 + v)
        print(' '.join(map(str, S)))
    elif N == 3:
        print('2 5 63')

N = int(input())
_agc022_b(N)

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

#define IS_EVEN(a) ( ((a)&0x01) == 0 )

int cmp(const void *a, const void *b) {
    return (*(const int*)b)-(*(const int*)a);
}

int n,y;
int main() {
    cin >> n >> y;

    int a,b,c;
    int a_max,b_max,c_max;
    //a+b+c=n
    //10000*a + 5000*b + 1000*c = y

    a_max = y/10000;
    b_max = y/5000;
    c_max = y/1000;
    for(int i = 0 ; i <= n ; i++) {
        for(int j = 0 ; j <= n-i ; j++) {
            int k = n-i-j;
            if( i*10000+j*5000+k*1000 == y && i+j+k == n) {
                cout << i << " " << j << " " << k << endl;
                goto end;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
end:
    return 0;
}

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

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

    int a, b;
    char op;
    while (true){
        cin >> a >> op >> b;
        if (op == '?') break;
        else{
            if (op == '+') cout << a + b << endl;
            else if (op == '-') cout << a - b << endl;
            else if (op == '*') cout << a * b << endl;
            else if (op == '/') cout << a / b << endl;
        }
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }

  int count = 0;
  for(int i = 1; i < n-1; i++){
    if(max({p.at(i-1),p.at(i),p.at(i+1)}) != p.at(i) && min({p.at(i-1),p.at(i),p.at(i+1)}) != p.at(i)){
      count += 1;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
// D.

#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	int h, w;
	cin >> h >> w;
	int b[500][500];
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> b[i][j];
		}
	}
	vector<string> ans;
	int c = 0, px, py;
	for (int i = 0; i < h; ++i) {
		int st = i % 2 ? 0 : w - 1;
		int ed = i % 2 ? w : -1;
		int dir = i % 2 ? 1 : -1;
		for (int j = st; j != ed; j += dir) {
			if (c) {
				char w[64];
				sprintf(w, "%d %d %d %d", py + 1, px + 1, i + 1, j + 1);
				ans.push_back(w);
				b[i][j]++;
			}
			c = b[i][j] % 2;
			py = i, px = j;
		}
	}
	cout << ans.size() << endl;
	for (string s : ans) {
		cout << s << endl;
	}
	return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, ans = 0, score = 0;
	cin >> n;
	vector<int> h(n);
	cin >> h[0];
	for(int i = 1; i < n; ++i)
	{
		cin >> h[i];
		if (h[i - 1] >= h[i])
		{
			score++;
		}
		else
		{
			ans = max(ans, score);
			score = 0;
		}
	}
	ans = max(ans, score);

	cout << ans;

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define prin(a) cout<<a<<"\n"
#define kaigyo cout<<"\n"
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)
#define mem(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,-1,sizeof(x))
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<string> vst;
typedef vector<char> vc;
typedef vector<long double> vd;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
typedef vector<vector<int>> vint2;
ll mod=1e9+7;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;
#define int3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define int4(x,y,z,w) int x,y,z,w;cin>>x>>y>>z>>w;
#define ll1(x) ll x;cin>>x;
#define ll2(x,y) ll x,y;cin>>x>>y;
#define vint1(a,n) vint a(n);rep(i,n)cin>>a[i];
#define vint2(a,b,n) vint a(n),b(n);rep(i,n)cin>>a[i]>>b[i];
#define vll1(a,n) vll a(n);rep(i,n)cin>>a[i];
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

const double pi=acos(-1.0);
const ll inf=1LL<<60;


bool isPrime(ll n){if(n<2)return false;for(ll x = 2;
x*x <=n;x++){if(n%x == 0)return false;}return true;}
ll kaizyo(ll k){ll sum=1;rep1(i,k){sum*=i;sum%=mod;}return sum;}
ll ncr(ll n,ll r){return kaizyo(n)/(kaizyo(r)*kaizyo(n-r));}
unsigned keta(unsigned num){
    return log10(num)+1;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){

string s;
cin>>s;
int n=s.size();
cout<<((s[n-1]=='s')?s+"es":s+'s');



}


Measured memory_bytes: 3672
namespace diverta2019.B
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;
    public class Program
    {
        public static void Main(string[] args)
        {
            var l = ReadLineAsInts().ToList();
            var r = l[0];
            var g = l[1];
            var b = l[2];
            var n = l[3];

            WriteLine(Solve(r, g, b, n));
        }

        public static IEnumerable<int> ReadLineAsInts() => ReadLine().Split(' ').Select(x => int.Parse(x));

        public static int Solve(int R, int G, int B, int n)
        {
            var count = 0;

            for (int i = 0; ; i++)
            {
                if (i * R > n) break;

                for (int j = 0; ; j++)
                {
                    if (i * R + j * G > n) break;

                    if ((n - (i * R + j * G)) % B == 0) count++;
                }
            }


            return count;
        }
    }
}

Measured memory_bytes: 13268
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let H = cin.getInt(), W = cin.getInt();
    let S = new Array(H);
    for (let n = 0; n < H; n++) {
        S[n] = cin.getStr().substr(0, W).split('').map(v => v == '#' ? 1 : 0);
    }
    for (let h = 0; h < H; h++) {
        for (let w = 0; w < H; w++) {
            if (S[h][w]) {
                let f = false;
                if (w >= 1 && S[h][w - 1] == 1) f = true;
                if (w < W - 1 && S[h][w + 1] == 1) f = true;
                if (h >= 1 && S[h - 1][w] == 1) f = true;
                if (h < H - 1 && S[h + 1][w] == 1) f = true;
                if (!f) {
                    console.log('No');
                    return;
                }
            }
        }
    }
    console.log('Yes');
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
import numpy as np
N = input()
a = np.array(input().split()).astype(int)
a = np.sort(a)
print((np.power(2, np.arange(len(a)) - np.insert(np.ones(len(a)-1), 0, 0)) * a / np.power(2, len(a) - 1)).sum())

Measured memory_bytes: 12392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;
string l;
int n;
ll mod;
ll mem[100100][2];
ll dp(int at, bool same){
    if(at == n){
        if(same){
            if(l[at] == '1'){
                return 2;
            }else{
                return 1;
            }
        }else{
            return 1;
        }
    }
    if(mem[at][same] != -1) return mem[at][same];
    if(same){
        if(l[at] == '1'){
            return (dp(at+1,false)+2*dp(at+1,true))% mod  ;
        }else{
            return dp(at+1,true)% mod  ;
        }
    }
    return mem[at][same] = (3*dp(at+1, false) )% mod  ;
}

int main(){
    cin.sync_with_stdio(false);
    cin >> l;
    memset(mem,-1,sizeof(mem));
    mod = 1000000007;
    n = l.size();
    cout << dp(0,true) % mod  << endl;
    return 0;
}


Measured memory_bytes: 5200
k=gets.to_i
if k<=9
  puts k
  exit
end
prev=[*1..9]
k-=9
loop {
  cur=[]
  prev.each{|e|
    r=e%10
    cur.push(e*10+r-1) if r>0
    cur.push(e*10+r)
    cur.push(e*10+r+1) if r<9
  }
  if k<=cur.size
    puts cur[k-1]
    break
  end
  prev=cur
  k-=cur.size
}

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

long long keta_wa(long long n){
  long long res=0;
  while(n>0){
    res+=n%10;
    n/=10;
  }
  return res;
}//nの各桁の和を求める関数

double sunuke(long long n){
  return double(n)/keta_wa(n);
}//nのsunuke数を求める関数

int main(){
  vector<long long>res;
  long long base=1;

  for(int i=0;i<15;++i){
    for(int j=1;j<150;++j){
      res.push_back(base*(j+1)-1);
    }
    base*=10;
  }
  sort(res.begin(),res.end());
  res.erase(unique(res.begin(),res.end()),res.end());

  for(long long int i=0;i<res.size();++i){
    for(long long int j=i+1;j<res.size();++j){
      if(sunuke(res[i])>sunuke(res[j])){
        res.erase(res.begin() + i--);
        break;
      }
    }
  }
  long long int k;
  int a=0;
  cin>>k;
  for(int i=0;i<k;++i){
    cout<<res[i]<<endl;
    if(res[i+1]-res[i]==res[i]-res[i-1]){
      a++;
    }else{
      //cout<<"計算回数="<<a<<endl;a=0;
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define int long long
#define rep(i, a, b) for (register int i=(a); i<=(b); ++i)
#define per(i, a, b) for (register int i=(a); i>=(b); --i)
using namespace std;
typedef long long ll;
inline void chkmax(int &x, int y){x<y?(x=y):0;}
inline void chkmin(int &x, int y){x>y?(x=y):0;}
const int N=5005;
int dp[N][N], a[N];

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

signed main()
{
    int n=read(), A=read(), B=read(), ans=1ll<<60;
    rep(i, 1, n) a[i]=read();
    memset(dp, 0x3f, sizeof(dp)); dp[0][0]=0;
    rep(i, 1, n) rep(j, 0, n)
        if (a[i]>j) 
            chkmin(dp[i][j], dp[i-1][j]+A), 
            chkmin(dp[i][a[i]], dp[i-1][j]);
        else
            chkmin(dp[i][j], dp[i-1][j]+B);
    rep(i, 0, n) chkmin(ans, dp[n][i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 196472
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const ll INF = 1e16;

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

  vector<vector<ll>> dp(n + 1, vector<ll>(100001, INF));
  vector<int> w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  dp[0][0] = 0;

  rep(i, n) rep(j, 100001) {
    chmin(dp[i + 1][j], dp[i][j]);
    if (j + v[i] <= 100000) chmin(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
  }


  ll ans = 0;
  rep(j, 100001) {
    if (dp[n][j] <= W) chmax(ans, j);
  }

  cout << ans << endl;

}

Measured memory_bytes: 83196
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <limits>
#include<stdlib.h>
using namespace std;

int main()
{
string s; int n,x=0,m=0; cin>>n>>s;
for(int i=0;i<n;i++)
{
    if(s.at(i)=='I') {x++; if(x>m)m=x;}
    else {x--; if(x>m)m=x;}
}
cout<<m;
}


Measured memory_bytes: 3588
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 4/28/2018
 
 11:30-11:50 pause
 
 6/7/2018
 
 20:05-
 
 */

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N,K;
LL A[MAX_N];
LL cum[MAX_N];
LL solve() {
  LL res=0;
  cum[0]=0;
  REP(i,N) cum[i+1]=cum[i]+(A[i]>0?A[i]:0);
  LL cur=accumulate(A,A+K,0LL);
  REPE(i,N-K) {
    LL a=cum[i]+(cum[N]-cum[i+K]);
    LL b=a+cur;
    res=max({res,a,b});
    
//    dump4(i,a,cur,b);
    
    cur-=A[i];
    if(i+K<N) cur+=A[i+K];
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>K;
  REP(i,N) cin>>A[i];
  cout<<solve()<<endl;
  return 0;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool b = [&] {
        for (int l = 0; l <= n; l++) {
            for (int r = l; r <= n; r++) {
                string before = s.substr(0, l);
                string after = s.substr(r);
                string t = before + after;
                if (t == "keyence") return true;
            }
        }
        return false;
    }();

    string ans = b ? "YES" : "NO";
    cout << ans << endl;

}


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

typedef long long ll;
ll max(ll a, ll b){ return ( a > b )?a:b;}
ll min(ll a, ll b){ return ( a < b )?a:b;}


ll cnt[100];
char S[101];

ll K;
int main(){
        scanf("%s",S);
        scanf("%lld",&K);
        int i = 0;
        while(S[i] == '1' && i <= 100){
                i++;
        }
        if(S[i] == '\0' || K <= i){
                puts("1");
        }else{
                printf("%c\n",S[i]);
        }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(std::string s)
{
    string ans;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'B')
        {
            if (ans.size() != 0)
            {
                ans.pop_back();
            }
        }
        else
        {
            ans += s[i];
        }
    }

    cout << ans << endl;
}

int main()
{
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, K, Q) = (input[0], input[1], input[2])
var cnt = (0..<N).map{_ in 0}
for _ in 0..<Q {
  cnt[Int(readLine()!)!-1] += 1
}
cnt.forEach{print($0>Q-K ?"Yes":"No")}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  ll k;
  cin>>k;
  if(k%2==0){
    cout<<0.5;
  }else{
    float k2=k;
    cout<<(float)(((k2+1)/2)/(k2));
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i,j,sum,len;
  
  while(1){
    char ch[1001];
    char *l=ch;
  scanf("%s",ch);
  sum=0;
  len=strlen(l);
  for(i=0;i<len;i++){
    j=ch[i]-'0';
    sum=sum+j;
  }
  

  if(ch[0]=='0') break;
  printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
struct edge {int to, cost;};

signed main() {
	int a, b; cin >> a >> b;
	rep(i, 3) {
		if ((a*b*(i + 1)) & 1) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a, b, c;
int main() {
	scanf("%d%d%d", &a, &b, &c);
	if(a > b)swap(a, b);
	if(a > c)swap(a, c);
	if(b > c)swap(b, c);
	int d = c - b;
	b += d;
	a += d;
	d += (c - a + 1) / 2;
	if((c - a) & 1)d++;
	printf("%d\n", d);
	return 0;
}

Measured memory_bytes: 256
var
	n,i,ans:Longint;
	a,b,c:String[100];
begin
	readln(n);
	readln(a);
	readln(b);
	readln(c);
	for i:=1 to n do begin
		if a[i]=b[i]then begin
			if a[i]<>c[i]then inc(ans);
		end else begin
			if(a[i]=c[i])or(b[i]=c[i])then inc(ans)else inc(ans,2);
		end;
	end;
	writeln(ans);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
constexpr lint MOD = 1000000007;

int N;
vector<int> h;

lint power(lint x, lint n)
{
    lint ans = 1;
    while (n > 0)
    {
        if (n & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ans;
}

int main()
{
    cin >> N;
    h.resize(N);
    for (auto &val : h) cin >> val;

    vector<lint> dp(N);
    vector<vector<lint>> dpa(N, vector<lint>(N));
    dp[0] = power(2, h[0]);
    for (int i=0; i<N; i++)
    {
        dpa[0][i] = 2LL * power(2, h[0] - h[i]) % MOD;
    }

    for (int i = 1; i < N; i++)
    {
        dp[i] = dp[i - 1] * power(2, h[i] - h[i - 1]);
        dp[i] += dpa[i - 1][i] * power(2, h[i] - h[i - 1]);
        dp[i] %= MOD;
        for (int j = 0; j < N; j++)
        {
            // 前の列の逆
            if (h[i] <= h[i-1])
            {
                if (h[j] < h[i]) dpa[i][j] = dpa[i-1][j];
                else dpa[i][j] = dpa[i-1][i];
            }
            else 
            {
                if (h[i] > h[j])
                {
                    if (h[j] > h[i-1]) dpa[i][j] = dpa[i-1][j] * power(2, h[i] - h[j]);
                    else dpa[i][j] = dpa[i-1][j] * power(2, h[i] - h[i-1]);
                }
                else dpa[i][j] = dpa[i - 1][j];
            }

            // 前の列と同じ
            dpa[i][j] += dpa[i - 1][i] * power(2, h[i] - max(h[i - 1], h[j]));
            dpa[i][j] %= MOD;
        }
    }
    // cout << endl;
    // for (auto vec : dpa)
    // {
    //     for (auto val : vec) cout << val << " ";
    //     cout << endl;
    // }
    // cout << endl;
    // for (auto v : dp) cout << v << endl;
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  string s; cin >> s;

  int ans;
  if (s == "SUN") ans = 7;
  else if (s == "MON") ans = 6;
  else if (s == "TUE") ans = 5;
  else if (s == "WED") ans = 4;
  else if (s == "THU") ans = 3;
  else if (s == "FRI") ans = 2;
  else if (s == "SAT") ans = 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<i64> X;

int main(){
  cin >> N;
  X.resize(N);
  rep(i,0,N - 1) cin >> X[i];
  auto Y = X;
  sort(Y.begin(),Y.end());

  rep(i,0,N - 1){
    if(X[i] <= Y[N / 2 - 1]){
      cout << Y[N / 2] << endl;
    }
    else{
      cout << Y[N / 2 - 1] << endl;
    }
  }
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n;
    cin>>n;
    ll arr[n];
    rep(i, 0, n) {
        cin>>arr[i];
    }
    ll ans=0;
    rep(i, 1, n) {
        if (arr[i]<arr[i-1]) {
            ans+=arr[i-1]-arr[i];
            arr[i]=arr[i-1];
        }
    }
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 5216
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, L = MAP()
a = LIST()

for i in range(N-1):
    if a[i]+a[i+1] >= L:
        idx = i
        break
else:
    print("Impossible")
    exit()

print("Possible")

for i in range(1, i+1):
    print(i)

for i in range(N-1, i, -1):
    print(i)


Measured memory_bytes: 21560
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int can_make(std::vector<int> v, int resolution) {
  int x = 0;
  std::sort(v.begin(), v.end(), std::greater<int>());
  for (int e : v) {
    if (x < resolution) x += e;
    else x -= e;
  }
  return x == resolution;
}

int main() {
  std::string s;
  int x, y;
  std::cin >> s >> x >> y;
  s += 'T';
  x -= s.find('T');
  s = s.substr(s.find('T') + 1);
  std::vector<int> vertical, horizontal;
  bool is_vertical = true;
  int count = 0;
  for (auto c : s) {
    if (c == 'T') {
      (is_vertical ? vertical : horizontal).push_back(count);
      is_vertical = not is_vertical;
      count = 0;
    } else {
      ++count;
    }
  }
  std::cout << (can_make(vertical, y) and can_make(horizontal, x) ? "Yes" : "No") << std::endl;

  return 0;
}

Measured memory_bytes: 888
def solve(A, k):
  if len(A) == 0:
    return 0
  elif len(A) == 1:
    return A[0] - k
  else:
    m = A.index(min(A))
    return A[m] - k + solve(A[:m], A[m]) + solve(A[m+1:], A[m])
  
if __name__ == '__main__':
  N, *h = map(int, open(0).read().split())
  print(solve(h, 0))

Measured memory_bytes: 3064
#include <stdio.h>

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

  int A[30];
  for(int i = 0; i < M; i++) {
    A[i] = 0;
  }
  for(int i = 0; i < N; i++) {
    int K;
    scanf("%d", &K);
    for(int j = 0; j < K; j++) {
      int L;
      scanf("%d", &L);
      A[L-1]++;
    }
  }

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

  return 0;
}


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

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int b[m],num=0;
  rep(i,m) cin >> b[i];
  rep(i,n){
    int tmp=c;
    rep(j,m){
      int aij;
      cin >> aij;
      tmp += aij*b[j];
    }
    if(tmp > 0) num++;
  }
  
  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int a[26] = {};
  rep(i, s.length()) {
    a[s[i] - 'a'] += 1;
  }
  int cnt = 0;
  rep(i, 26) {
    cnt +=
    a[i] % 2;
  }
  cout << cnt / 2 << endl;
}

Measured memory_bytes: 3172