akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}



signed main()
{
	int S,W;cin>>S>>W;
	if(W>=S)cout<<"unsafe";
	else cout<<"safe";
	cout<<endl;
}



Measured memory_bytes: 3620
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [collections.defaultdict(int) for _ in range(N+1)] #1_indexed
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
    for dw,dv in dp[i-1].items():
        dp[i][dw] = max(dp[i][dw],dv)
        if w+dw<=W:
            dp[i][w+dw] = max(dp[i][w+dw],v+dv)
print(max(dp[-1].values()))


Measured memory_bytes: 654572
#include<stdio.h>

int main(void) {
  int n,count = 0;
  scanf("%d",&n);
  char s[n+1],t[n+1];
  char ans[2*n+1];
  scanf("%s %s",s,t);
  for(int i = 0; i < n; i++) {
    ans[count] = s[i];
    count++;
    ans[count] = t[i];
    count++;
  }
  ans[count] = '\0';
  printf("%s\n", ans);
  return 0;
}


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

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

  for (int i = 0; i <= n / 500; i++) {
    for (int j = 0; j <= a; j++) {
      if (i * 500 + j == n) {
        cout << "Yes" << endl;
        return 0;
  }}}

  cout << "No" << endl;
  return 0;
}

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

int main(){
    bool nonprime[300000] = {};
    nonprime[1] = true;
    for(int i = 2; i < 300000; i++){
        if(!nonprime[i]){
            for(int j = i+i; j < 300000; j += i)    nonprime[j] = true;
        }
    }

    int sum[300000] = {};
    for(int i = 1; i < 300000; i++) sum[i] = sum[i-1] + !nonprime[i];

    int n;
    while(cin >> n, n)  cout << sum[2*n] - sum[n] << endl;

    return 0;
}


Measured memory_bytes: 4564
#include <stdio.h>

int main(void){
  int N,K,X,Y,T;
  scanf("%d¥n",&N);
  scanf("%d¥n",&K);
  scanf("%d¥n",&X);
  scanf("%d¥n",&Y);
  if(N<K){
    T = N*X;
  }else{
  T = K*X + (N-K)*Y;
  }
  printf("%d",T);
  return 0;
}

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

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//FUNCTION  


void solve(void)
{
  string str;
  cin>>str;
  reverse(ALL(str));
  int N = str.size();
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    vec[i] = str[i] - '0';
  }
  int ANS = 0;
  for (int i = 0; i < 1<<(N-1); i++)
  {
    int SUM = 0;
    int NUM = vec[0];
    int D = 1;
    for (int j = 0; j < N-1; j++)
    {
      if((i>>j)&1)
      {
        NUM += pow(10,D)*vec[j+1];
        D++;
      }
      else
      {
        SUM += NUM;
        NUM = vec[j+1];
        D = 1;
      }
    }
    SUM += NUM;
    // DEBUG(SUM);
    ANS += SUM;
    
  }
  cout<<ANS<<endl;
  
  return;
}

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

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

  return 0;
}


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

int main() {
    string s;
    cin >> s;
    string ch = "";
    int ans=0;
    rep(i,s.size()) {
        ch += s.at(i);
        if (ch == s.substr(i+1, i+1) && 2*(i+1) != s.size()) {
            ans = max(ans, 2*(i+1));
        }
    }
    ct(ans);
}

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

using namespace std;

const int MAX_N = 300;
 
int n, cnt;
int in[MAX_N][MAX_N];
int s[MAX_N][MAX_N];
 
void cp_in(){
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < n ; j++){
            s[i][j] = in[i][j];
        }
    }
}
 
void dfs(int y, int x, bool bit)
{
    if (bit) {
        if (n <= x || n <= y) return;
        cnt++;
        int nx = x + 1;
        int ny = y + 1;
     
        if (0 <= nx && nx < n && 0 <= ny && ny < n && s[ny][nx] == 1) {
            dfs(ny, nx, bit);
        }
    } else {
        if (x < 0 || n <= y) return;
        cnt++;
        int nx = x - 1;
        int ny = y + 1;
         
        if (0 <= nx && nx < n && 0 <= ny && ny < n && s[ny][nx] == 1) {
            dfs(ny, nx, bit);
        }
    }
}
 
int main()
{
    char ch;
    while (cin >> n, n) {
        int a = 0, b = 0, c = 0, d = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cin >> ch;
                in[i][j] = ch - '0';
            }
        }
        for (int i = 0; i < n; i++) {
            cnt = 0;
            for (int j = 0; j < n; j++) {
                if (in[i][j] == 1) {
                    cnt++;
                    a = max(a, cnt);
                } else {
                    cnt = 0;
                }
            }
        }
         
        for (int i = 0; i < n; i++) {
            cnt = 0;
            for (int j = 0; j < n; j++) {
                if (in[j][i] == 1) {
                    cnt++;
                    b = max(b, cnt);
                } else {
                    cnt = 0;
                }
            }
        }
 
        cp_in();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cnt = 0;
                if (s[i][j] == 1) dfs(i, j, 1);
                c = max(c, cnt);
            }
        }
         
        cp_in();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cnt = 0;
                if (s[i][j] == 1) dfs(i, j, 0);
                d = max(d, cnt);
            }
        }    
        cout << max(max(a, b), max(c, d)) << endl;
    }
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll x, a, b; cin >> x >> a >> b;
    if(a >= b) cout << "delicious" << endl;
    else if(b-a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
}

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

using namespace std;

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

    string s1, s2;
    cin >> s1 >> s2;

    int m = s1.length(), n = s2.length();

    s1 = " " + s1;
    s2 = " " + s2;

    vector<vector<int>> dp(m + 1, vector<int>(n + 1));

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (s1[i] == s2[j])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    vector<char> lcs(dp[m][n]);
    int i = m, j = n, idx = dp[m][n];

    while (i > 0 && j > 0) {
        if (s1[i] == s2[j]) {
            lcs[--idx] = s1[i--];
            j--;
        } else if (dp[i - 1][j] > dp[i][j - 1]) {
            i--;
        } else {
            j--;
        }
    }

    for (auto& c : lcs) cout << c;

    return 0;
}


Measured memory_bytes: 38504
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) > (b) ? (b) : (a))
#define INF 100000000000000 // 10^14
#define endl printf("\n")

int dsc(const void *a, const void *b){
  long long *A = (long long *)a, *B = (long long *)b;
  if(*A > *B) return -1;
  if(*B > *A) return  1;
  return 0;
}

int
main(int argc, char *argv[])
{
  int x[3], k;
  scanf("%d%d%d%d", &x[0], &x[1], &x[2], &k);
  long long a[3][1000];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < x[i]; j++){
      scanf("%lld", &a[i][j]);
    }
  }

  qsort(a[0], x[0], sizeof(long long), dsc);
  
  long long bc[1000005]; int c = 0;
  for(int i = 0; i < x[1]; i++){
    for(int j = 0; j < x[2]; j++){
      bc[c++] = a[1][i] + a[2][j];
    }
  }

  qsort(bc, c, sizeof(long long), dsc);

  //  for(int i = 0; i < x[0]; i++) printf("%lld ", a[0][i]); endl;
  //  for(int i = 0; i < c; i++) printf("%lld ", bc[i]); endl;
  

  long long *y; int d = 0;
  y = malloc(sizeof(long long) * min(c, k) * x[0]);
  for(int i = 0; i < min(c, k); i++){
    for(int j = 0; j < x[0]; j++){
      y[d++] = a[0][j] + bc[i];
    }
  }
  qsort(y, d, sizeof(long long), dsc);

  for(int i = 0; i < k; i++) printf("%lld\n", y[i]);
  
  
  return 0;
}


Measured memory_bytes: 54904
n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 100
p = lambda x, y: x * y >= 0
po = lambda x, y: abs(x + y) + 1 if p(x, x + y) else 0
popo = lambda x, y: -1 * x // abs(x) if p(x, x + y) else x + y


if a[0] == 0:
    s = [1, -1]
    tmpAns = [1, 1]
    for (_s, _ans) in zip(s, tmpAns):
        for i in range(1, n):
            _ans +=  po(_s, a[i])
            _s = popo(_s, a[i])
        ans = min((ans, _ans))
else:
    s = [a[0], -1 * a[0] // abs(a[0])]
    tmpAns = [0, abs(a[0]) + 1]
    for (_s, _ans) in zip(s, tmpAns):
        for i in range(1, n):
            _ans +=  po(_s, a[i])
            _s = popo(_s, a[i])
        ans = min((ans, _ans))

print(ans)


Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
  int N;
  cin >> N;
  vector<int> h(N);
  rep(i, N) cin >> h[i];
  h.push_back(0);
  int ans = 0;
  rep(i, N)
  {
    if (h[i] > h[i + 1])
    {
      ans += h[i] - h[i + 1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>

namespace rika
{
  template <typename T>
  class edge
  {
  public:
    int to;
    T cost;
    
    edge() = default;
    edge(const edge<T>&) = default;
    edge(edge<T>&&) = default;
    edge& operator =(const edge<T>&) = default;
    edge& operator =(edge<T>&&) = default;

    ~edge() = default;

    edge(int _to, T _cost) : to(_to), cost(_cost) {}
  };
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
namespace rika
{
  namespace internal
  {
    template <typename TValue, typename TGraph>
    std::pair<TValue, int> visit(int from, int v, const TGraph &g)
    {
      auto r = std::make_pair(TValue(), v);
      try
      {
      for(auto it = g[v].begin(); it != g[v].end(); ++it)
      {
        if(it->to == from)
          continue;
        auto r2 = visit<TValue>(v, it->to, g);
        if(r2.first + it->cost >= r.first)
          r = std::make_pair(r2.first + it->cost, r2.second);
      }
      }
      catch(const std::out_of_range& e)
      {
        exit(v > 0 ? 1 : 0);
      }
      return r;
    }
  }

  template <typename TValue, typename TGraph>
  TValue tree_diameter(const TGraph &g)
  {
    using namespace internal;
    auto r1 = visit<TValue>(-1, 0, g);
    auto r2 = visit<TValue>(-1, r1.second, g);
    return r2.first;
  }
}

#include<bits/stdc++.h>
using namespace std;
using namespace rika;
int main()
{
  int N;
  cin >> N;
  vector<vector<edge<int>>> g(N * 10);
  for(int i = 0; i < N - 1; i++)
  {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(edge<int>(t, w));
    g[t].push_back(edge<int>(s, w));
  }
  cout << tree_diameter<int>(g) << endl;
}

Measured memory_bytes: 35360
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    priority_queue<int> q;
    rep(i, 0, N) {
        int a;
        cin >> a;
        q.push(a);
    }
    
    rep(i, 0, M) {
        int v = q.top(); q.pop();
        q.push(v / 2);
    }
    int sum = 0;
    while (sz(q)) {
        sum += q.top(); q.pop();
    }
    cout << sum << endl;
    return (0^_^0);
}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000005];
int main()
{
    int  n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++)
    {
       cin>>a[i];
    }
    int  ans=1e9;
    for(int i=1;i<=k;i++)
    {
        if(i==1)
            ans=min(ans,n-(a[1]+n-a[k]));
        else
        ans=min(ans,n-(a[i]-a[i-1]));
    }
    cout<<ans;
return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
#include <random>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

void solve(void){

	string s;
	cin >> s;
	int ans = 0, l=(int)s.size();
	rep(l-1, i)
	{
		ans += s[i] != s[i+1];
	}

	cout << ans << endl;


}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();
		String[] array = s.split(" ");

		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
		int c = Integer.parseInt(array[2]);

		if (c >= a && c <= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

ll pow(ll n, int m){
  if(!m) return 1;
  ll ret = pow(n, m/2);
  ret *= ret;
  return (m&1) ? ret*n : ret;
}

template <class F, class T>
void convert(const F &f, T &t){
  stringstream ss;
  ss << f;
  ss >> t;
}

int N;
string S[110];
int P[110];

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

  cin >> N;
  rep(i,N) cin >> S[i] >> P[i];

  vi ind(N);
  rep(i, N) ind[i] = i;
  sort(&ind[0], &ind[N], [](int i1, int i2) {
      if (S[i1]==S[i2]) return P[i1] > P[i2];
      return S[i1] < S[i2];
  });

  rep(i,N) cout << ind[i]+1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(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(nullptr);
    int a; cin >> a;
    int L = a/100;
    int R = a%100;
    if(1<=L&&L<=12){
        if(1<=R&&R<=12) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    } else {
        if(1<=R&&R<=12) cout << "YYMM" << endl;
        else cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
A,B,C,X,Y = map(int,input().split())
if A+B <= C*2:
    print(A*X+B*Y)
    exit()
if (X>Y and A>=C*2) or (Y>X and B>=C*2):
    print(C*2*max(X,Y))
    exit()
price = min(X,Y)*C*2
if X >= Y:
    print(price+(X-Y)*A)
else:
    print(price+(Y-X)*B)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define s32 long long
#define mod 1000000007
using namespace std;
int n, k;
s32 s[110][50010], block[110][50010], ans;
int F() {
	register int x = 0, ch = getchar(), f = 0;
	while(!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
int main() {
	n = F(), k = F(); int r = sqrt(n) + 1; s[0][1] = 1;
    for(register int i = 0; i < k; i++) {
        for(register int j = 1; j < r; j++) s[i][j] = (s[i][j] + s[i][j - 1]) % mod;
        for(register int j = r - 2; j > 0; j--) block[i][j] = (block[i][j] + block[i][j + 1]) % mod;
        for(register int j = 1; j < r; j++) {
            block[i + 1][j] = s[i][j] * (n / j - n / (j + 1));
            if(n / j == j) block[i + 1][j] = 0;
            block[i + 1][j] %= mod;
        }
        for(register int j = 1; j < r; j++) s[i + 1][j] = block[i][j] + s[i][r - 1], s[i + 1][j] %= mod;
    }
    ans = 0;
    for(register int i = 1; i <= r; i++) ans = (ans + block[k][i] + s[k][i]) % mod;
    printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 83456
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
//ツ暗ェツ牌ツ嘉つヲツづゥ
//ツ禿アツ牌ツ個クツづァツつキ
//ツ全ツ探ツ催オ
int func(int t[],int pre){
	if(pre==0)
	return 1;
	for(int i=0;i<10;i++){
		if(t[i]>=3){
			t[i]-=3;
			if(func(t,pre-3))
				return 1;
			t[i]+=3;
		}else if(t[i]>=1&&t[i+1]>=1&&t[i+2]>=1){
			t[i]-=1;t[i+1]-=1;t[i+2]-=1;
			if(func(t,pre-3))
				return 1;
			t[i]+=1;t[i+1]+=1;t[i+2]+=1;
		}
	}
	return 0;
}
//0 1 2 3 4 5 6 7 8 9 0 0
//1 2 3 4 5 6 7 8 9 10 11 12
void solve(int t[]){
	int now=0,ans[9],w[11];
	for(int i=0;i<11;i++)
	w[i]=t[i];
	for(int i=0;i<9;i++){
		if(t[i]+1>4)
		continue;
		t[i]++;
		for(int j=0;j<9;j++){
			if(t[j]>1){
				t[j]-=2;
				if(func(t,12)){
					ans[now++]=i+1;
					t[j]+=2;
					break;
				}
				t[j]+=2;
			}
		}
		t[i]--;
		for(int g=0;g<11;g++)
		t[g]=w[g];
	}
	
	
	if(now>0)
	cout<<ans[0];
	else cout<<0;
	for(int i=1;i<now;i++)
	cout<<' '<<ans[i];
	cout<<endl;
}
int main(){
	int t[11];
	string s;
	while(cin>>s){
		memset(t,0,sizeof(t));
		for(int i=0;i<(int)s.size();i++)
			t[s[i]-'0'-1]++;
		solve(t);
	}
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;

int N,M;
int cx,cy,dx,dy;
char G[1010][1010];
bool vis[1010][1010];
int dir[4][2] = {-1,0,1,0,0,1,0,-1};
struct node
{
	int x,y,w;
	bool operator <(const node &o) const{
		return w > o.w;
	}
};
priority_queue<node> q;
int solve(){
	q.push({cx,cy,0});
	while(q.size()){
		node cur = q.top();q.pop();
		int x = cur.x,y = cur.y,w = cur.w;
		if(x == dx && y == dy) return w;
		if(vis[x][y]) continue;
		vis[x][y] = 1;
		for(int i = 0;i<4;i++){
			int nx = x + dir[i][0];
			int ny = y + dir[i][1];
			if(nx< 1 || nx > N || ny <1 || ny>M || G[nx][ny] == '#') continue;
			q.push({nx,ny,w});
		}
		for(int i = -2;i<=2;i++){
			for(int j = -2;j<=2;j++){
				int nx = x + i;
				int ny = y + j;
				if(nx< 1 || nx > N || ny <1 || ny>M || G[nx][ny] == '#') continue;
				q.push({nx,ny,w+1});
			}
		}
	}
	return -1;
}
int main(){
	// debug;
	ios;

	cin>>N>>M>>cx>>cy>>dx>>dy;
	for(int i =1;i<=N;i++){
		cin>>(G[i]+1);
	}
	cout<<solve();
	
	return 0;
}


Measured memory_bytes: 8124
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
#define MAXN 100000
int N,M;
struct node{
    int u,v,id,dir;
}Edge[MAXN+5];
vector<node> G[MAXN+5];
vector<pair<int,int> > ans;

int out[MAXN+5];
int dep[MAXN+5];
int faID[MAXN+5];
bool dfs(int u,int fa,int d){
    out[u]=0;
    dep[u]=d;
    for(int i=0;i<int(G[u].size());i++){
        int v=G[u][i].v,k=G[u][i].id;
        if(v!=fa&&dep[v]<dep[u]){
            Edge[k].dir=Edge[k].u==u;
            faID[v]=k;
            if(out[v]==-1){
                if(!dfs(v,u,d+1))
                    out[u]++,ans.push_back(make_pair(u,v));
                else
                    out[v]++,ans.push_back(make_pair(v,u));
            }
            else
                out[u]++,ans.push_back(make_pair(u,v));
        }
    }
    if(out[u]%2){
        int f=faID[u];
        Edge[f].dir=!Edge[f].dir;
        return 1;
    }
    return 0;
}

int main(){
    scanf("%d%d",&N,&M);
    int cnt=0;
    for(int i=1;i<=M;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back((node){u,v,i,0});
        G[v].push_back((node){v,u,i,0});
        Edge[i]=(node){u,v,i,0};
    }
    memset(out,-1,sizeof out);
    dfs(1,-1,1);
    if(out[1]%2)
        return puts("-1"),0;
        /*
    for(int i=1;i<=M;i++){
        if(Edge[i].dir==1)
            print<int>(Edge[i].u,' '),print<int>(Edge[i].v,'\n');
        else
            print<int>(Edge[i].v,' '),print<int>(Edge[i].u,'\n');
    }
    */
    for(int i=0;i<ans.size();i++) printf("%d %d\n",ans[i].first,ans[i].second);
}


Measured memory_bytes: 23028
#include <stdio.h>

int main(void) {
    int r,g,b;
    scanf("%d %d %d",&r,&g,&b);
    if ((g * 10 + b) % 4 == 0) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N = int(input())
H = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0] for _ in range(N)]

dp[0][0] = H[0][0]
dp[0][1] = H[0][1]
dp[0][2] = H[0][2]

for i in range(1, N):
    t = i-1
    a = H[i][0]
    b = H[i][1]
    c = H[i][2]
    dp[i][0] = max(dp[t][1] + a, dp[t][2] + a)
    dp[i][1] = max(dp[t][0] + b, dp[t][2] + b)
    dp[i][2] = max(dp[t][0] + c, dp[t][1] + c)

print(max(dp[N-1]))

Measured memory_bytes: 47388
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
    int n,q;
    while(1){
        cin >> n >> q;
        if(!n && !q)break;
        vector<int> date(100000,0);
        int cou=0,m;
        for(int i=0;i<n;i++){
            cin >> m;
            for(int j=0;j<m;j++){
                scanf("%d",&date[cou++]);
            }
        }
        sort(date.begin(),date.begin()+cou);
        int dacou = 1,mada=0,day;
        for(int i=1;i<=cou;i++){
            //cout << date[i-1] << " ";
            if(date[i]==date[i-1]){
                dacou++;
            }else{
                if(mada < dacou){
                    mada = dacou;
                    day = date[i-1];
                }
                dacou = 1;
            }
        }
      //  date.erase(date.begin(),date.end());
        if(mada<q)cout << "0\n";
        else cout << day << endl;
    }
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> v(3);

int main()
{
    REP(i,3) {
        int tmp;
        cin>>tmp;
        v[i] = tmp;
    }
    SORT(v);
    int ans = v[0] + v[1] + v[2] * 10;
    cout<<ans<<endl;

    return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  vector<int> maxvs(n, -1);
  vector<int> minvs(n, INT_MAX);
  int maxv = INT_MIN;
  int minv = INT_MAX;
  for (int i = 0; i < n; i++) {
    minv = min(minv, v[i]);
    minvs[i] = minv;
  }
  int res = INT_MIN;
  for (int i = n-2; i >= 0; i--) {
    maxv = max(maxv, v[i+1]);
    res = max(res, maxv-minvs[i]);
  }
  cout << res << endl;
}



Measured memory_bytes: 5224
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n = int(input())
s = input()
x = 0
ans = 0
for i in range(len(s)):
    if s[i] == "I":
        x+=1
    else:
        x-=1
    ans = max(ans,x)
print(ans)

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

int main(){
  string S; cin >> S;
  int c1=0,c2=0;

  for(int i=0; i<S.size(); i++){
    if(S[i]=='0') c1++;
    else c2++;
  }

  cout << min(c1,c2)*2 << endl;
  return 0;
}

Measured memory_bytes: 512
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            if (h + w) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')

        print()
    print()

Measured memory_bytes: 9024
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int X, Y, ans = 0 ;
  cin >> X >> Y ;
  for(int i=0;i<(X+1);i++){
    if((2*i+4*(X-i)) == Y ){
      cout << "Yes" << endl ;
      return 0 ;
    }
  }
  cout << "No" << endl ;
  return 0 ;
}  

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mp make_pair
#define mm(a) memset(a,-1,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define endl "\n"
#define ld long double
#define mod 1000000007
#define BRAHAMASTRA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    BRAHAMASTRA
    ll t; t=1;
  
    while(t--)
    {
        ll n; cin >>n;
        if(n>=30)cout<<"Yes\n";
        else cout<<"No";
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, M, Q;
	cin >> N >> M >> Q;
	int imos[510][510];
	memset(imos, 0, sizeof(imos));

	rep(i, 0, M) {
		int L, R;
		cin >> L >> R;
		imos[L][R]++;
	}

	rep(i, 1, N + 1) rep(j, 1, N + 1) {
		imos[i][j] += imos[i - 1][j];
	}

	rep(i, 1, N + 1) rep(j, 1, N + 1) {
		imos[i][j] += imos[i][j - 1];
	}

	rep(i, 0, Q) {
		int p, q;
		cin >> p >> q;
		cout << imos[q][q] - imos[p - 1][q] - imos[q][p - 1] + imos[p - 1][p - 1] << endl;
	}

}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e9+9;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
const int N = 2e5+9;
// ll a[N];
const int B = 10;
int oc[B], oc2[B][B], oc3[B][B][B];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    // const int B = 10;
    // set<int> f[B];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < B; j++) {
            if(oc[j]) {
                for(int k = 0; k < B; k++) {
                    if(oc2[k][j]) {
                        oc3[k][j][s[i]-'0'] = 1;
                    }
                }
            }
        }
        for(int j = 0; j < B; j++) {
            if(oc[j]) {
                oc2[j][s[i]-'0'] = 1;
            }
        }
        oc[s[i]-'0'] = 1;
    }
    int ans = 0;
    for(int i = 0; i < B; i++) {
        for(int j = 0; j < B; j++) {
            for(int k = 0; k < B; k++) {
                ans += oc3[i][j][k];
            }
        }
    }
    cout << ans << "\n";



    return 0;
    
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
    int n;
    cin >> n;
    if(n==3 || n==5 || n==7){
        cout << "YES" << endl;
        return 0;
    }else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 764
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];


        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        StringBuilder sb = new StringBuilder();

        for(int i = n - 1; i >= 0; i -= 2){
            sb.append(a[i]).append("\n");
        }
        if(n % 2 == 0){
            for(int i = 0; i < n; i += 2){
                sb.append(a[i]).append("\n");
            }
        }else{
            for(int i = 1; i < n; i += 2){
                sb.append(a[i]).append("\n");
            }
        }
        System.out.println(sb.toString());

    }
}


Measured memory_bytes: 71820
import math
s = input()
S = s.split()

A = int(S[0])
B = int(S[1])
H = int(S[2])
M = int(S[3])

Hang = H*30 + M*0.5
Mang = M*6

if abs(Hang-Mang) > 180:
    Difang = 360 - abs(Hang - Mang) 
else:
    Difang = abs(Hang - Mang)

Answ= A**2 + B**2 - 2*A*B*(math.cos(math.radians(Difang)))
print(math.sqrt(Answ))

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

int main() {
  int N;
  vector<int> V;

  cin >> N;
  for(int i=0;i<N;i++){
    int buf;
    cin >> buf;
    V.push_back(buf);
  }
  for(int i=0;i<N;i++){
    int buf;
    cin >> buf;
    V[i] -= buf;
  }

  int max=0;
  for(int i=0;i<N;i++){
    if(V[i]>0){
      max += V[i];
    }
  }

  cout << max << endl;

  return 0;
}

Measured memory_bytes: 256
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 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

s = input()
n = input()
if s == n[:-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9976
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<int,int> date;
signed main(){
  int k;
  vector<int> a;
  cin>>k;
  for(int i=1;i<10;i++){
    a.push_back(i);
  }
  int o;
  for(int i=0;i<k;i++){
    o=a[i];
    while(true){
      if(o<10) break;
      o%=10;
    }
    if(date[a[i]*10+o-1]!=1&&o!=0) a.push_back(a[i]*10+o-1),date[a[i]*10+o-1]=1;
    if(date[a[i]*10+o]!=1) a.push_back(a[i]*10+o),date[a[i]*10+o]=1;
    if(date[a[i]*10+o+1]!=1&&o!=9) a.push_back(a[i]*10+o+1),date[a[i]*10+o+1]=1;
  }
  sort(a.begin(),a.end());
  cout<<a[k-1]<<"\n";
}
    

Measured memory_bytes: 23280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef unsigned long long ll;


int main(){
  string S, T;
  int seni['z'-'a'+1] ={0};
  int seni2['z'-'a'+1]={0};
  cin >> S;
  cin >> T;

  int ans = 1;
  for(int i = 0; i < S.length(); i++){
    if(seni[S[i]-'a']){
      if(seni[S[i]-'a'] != T[i]){
        ans = 0;
      }
    }
    if(seni2[T[i]-'a']){
      if(seni2[T[i]-'a'] != S[i]){
        ans = 0;
      }
    }
    if(seni[S[i]-'a']==0){
      seni[S[i]-'a'] = T[i];
    }
    if(seni2[T[i]-'a']==0){
      seni2[T[i]-'a'] = S[i];
    }
    
  }

  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<endl;
  }

  return 0;
}



Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
const int N=2e3+5;
int n;
vector<int>v;
int32_t main(){
	IOS;
	
	//code
	string str;
	cin>>str;
	
	//cout<<str[0]<<endl;
	int sum=0, flag=0, sum2=0, flag2=0;
	reverse(str.begin(), str.end());
	str= str+"0";
	for(int i=0;i<str.length()-1;i++){
		//cout<<sum<<endl;
		if(str[i]>'9'){
			str[i+1]++;
			continue;
		}
		if(str[i]>'5' && str[i]<='9'){
			sum+= ('9'-(str[i])+1);
			str[i+1]++;
			
			
		}
		else if(str[i]=='5'){
			if(str[i+1]>='5' && str[i+1]<='9'){
				sum+= ('9'-(str[i])+1);
				str[i+1]++;
			}
			else
				sum+=(str[i]-'0');
		}
		else{
			sum+=(str[i]-'0');

		}
	}
	/*for(int i=0;i<str.length()-1;i++){
		cout<<sum2<<endl;
		if(str[i]>='5' && str[i]<='9'){
			sum2+= ((str[i]-'0')+1);
			sum2+= (('9'-str[i+1])+1);
		}
		else{
			sum2+=(str[i]-'0');
			if(i==str.length()-2)
				flag2=1;
		}
	}*/
	
		sum+= (str[str.length()-1]-'0');

	
	cout<< sum <<endl;
	//code
	return 0;
}

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


int main()
{
    auto judge = [&](const std::string& a) {
        bool ans;
        if (a == "#") {
            ans = 1;
        } else {
            ans = 0;
        }
        return ans;
    };
    int h,
        w,
        k_input;
    std::cin >> h >> w >> k_input;
    std::array<std::string, 6> T = {};
    std::array<std::array<std::string, 6>, 6> S = {};
    std::array<std::array<int, 6>, 6> N = {};
    int ans_last = 0;
    //std::array<std::array<int, 7>, 7> N = {};
    for (int i = 0; i < h; ++i) {
        std::cin >> T.at(i);
        for (int j = 0; j < T[i].size(); ++j) {
            S[i][j] = T[i].substr(j, 1);
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < T[i].size(); ++j) {
            N[i][j] = judge(S[i][j]);
        }
    }
    for (int i = 0; i < static_cast<int>(std::pow(2, h)); ++i) {
        for (int j = 0; j < static_cast<int>(std::pow(2, w)); ++j) {
            //ここで列のサイクル
            int number_black = 0;
            for (int k = 0; k < h; ++k) {
                for (int l = 0; l < w; ++l) {
                    if (N[k][l] == 1 && (i / static_cast<int>(std::pow(2, k))) % 2 == 1 && (j / static_cast<int>(std::pow(2, l))) % 2 == 1) {
                        number_black += 1;
                    }
                }
            }
            if (number_black == k_input) {
                ++ans_last;
            }
        }
    }
    std::cout << ans_last << std::endl;
    return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int mxN = 1009;
ll a[mxN][3];

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

	ll mx = -1e18;

	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}

	for(int bit = 0; bit < (1 << 3); bit++) {
		vector<ll> tot(n);
		for(int i = 0; i < 3; i++) {
			if(1&bit>>i) {
				for(int j = 0; j < n; j++) {
					tot[j] += a[j][i];
				}
			} else {
				for(int j = 0; j < n; j++) {
					tot[j] -= a[j][i];
				}
			}
		}
		sort(tot.rbegin(), tot.rend());
		ll now = 0;
		for(int i = 0; i < m; i++) {
			now += tot[i];
		}
		chmax(mx, now);
	}
	cout << mx << endl;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}



int main() {
    ll N, M;
    cin >> N >> M;
    V<ll> A(N);
    for(ll &e : A) cin >> e;
    sort(ALL(A));
    map<ll, ll> change;
    for(ll i = 0; i < M; i++) {
        ll B, C;
        cin >> B >> C;
        change[-C] += B;
    }
    ll ans = 0;
    for(ll e : A) {
        if(change.empty()) {
            ans += e;
            continue;
        }
        auto ite = change.begin();
        ll num = -ite->first;
        if(num <= e) {
            ans += e;
            continue;
        }
        ans += num;
        ite->second--;
        if(ite->second == 0) change.erase(ite);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7296
import numpy as np

A,B,M = map(int,input().split())
a = input().split()
b = input().split()

num = int(min(a)) + int(min(b))

for _ in range(M):
    m1,m2,m3 = map(int,input().split())
    res = int(a[m1-1])+int(b[m2-1]) - m3
    num = min(num,res)

print(num)

Measured memory_bytes: 26652
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <queue>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll x,y;
    cin >> x >> y;
    int i=0,ans=0;
    while(x<=y){
        x*=2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main(){
        stack<int> c;
        while(1){
                string s;
                cin >> s;
                if(cin.eof()) break;
                if(s == "+" || s == "-" || s == "*"){
                        int x2 = c.top();
                        c.pop();
                        int x1 = c.top();
                        c.pop();
                        if(s == "+")c.push(x1+x2);
                        if(s == "-")c.push(x1-x2);
                        if(s == "*")c.push(x1*x2);
                } else {
                        c.push(stoi(s));
                }
        }
        while(!c.empty()){
                cout << c.top() << endl;
                c.pop();
        }

        return 0;
}

Measured memory_bytes: 1204
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 1e6 + 10;
const ll LOG = 22;
ll n, sum, xr;
ll A[MXN], B[MXN];
string s;
bool C(ll n, ll r){
    return (n || !r);
}
bool shd(ll n, ll r){
    for(int i = 0; i < LOG; i ++){
        if(!C((n >> i) & 1LL, (r >> i) & 1LL)) return 0;
    }
    return 1;
}
bool C_parity(ll n, ll r){
    return n == (r | (n - r));
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n >> s;
    for(int i = 0; i < n; i ++) A[i] = s[i] - '0' - 1, B[i] = A[i] / 2;
    for(int i = 0; i < n; i ++){
        if(shd(n - 1, i) && A[i] % 2) xr = xr ^ 1;
    }
    if(xr) return cout << 1, 0;
    for(int i = 0; i < n; i ++) if(A[i] == 1) return cout << 0, 0;
    for(int i = 0; i < n; i ++){
        if(C_parity(n - 1, i)) xr = xr ^ (B[i]);
    }
    cout << (xr ? 2 : 0);
    return 0;
}
/*!
    Be careful who you share your weaknesses with.
    Some people can't wait for the opportunity to use them against you!!
*/
//! N.N


Measured memory_bytes: 16924