akhauriyash/Code-Regression huggingface dataset:
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, k;
    cin >> n >> k;
    vector<int> h_s(n);
    rep(i, n)
    {
        cin >> h_s[i];
    }

    constexpr int INF = 1000'000'001;
    vector<int> dp(n, INF);
    dp[0] = 0;
    FOR(i, 1, n - 1)
    {
        FOR(j, max(0, i - k), i - 1)
        {
            chmin(dp[i], dp[j] + abs(h_s[i] - h_s[j]));
        }
    }
    cout << dp[n - 1] << '\n';

    return 0;
}


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

int main(){
 int i,j,the,that,this,slen,co;
 char str[81],*sthe="the",*sthat="that",*sthis="this";

 while(fgets(str,80,stdin)!=NULL){
  slen=strlen(str);
  for(i=0;i<26;i++){
   the=that=this=0;
   for(j=0,co=0;j<slen;j++){
     if(isalpha(str[j])) str[j]=str[j]!='z'?(int)str[j]+1:'a';
    if(sthe[the]==str[j])
     if(the==1) co=1;
     else the++;
    else the=0;
    if(sthat[that]==str[j])
     if(that==2) co=1;
     else that++;
    else that=0; 
    if(sthis[this]==str[j])
     if(this==2) co=1;
     else this++;
    else this=0;
   }
   if(co) printf("%s",str);
  }
 }
 return 0;
}

Measured memory_bytes: 0
import Control.Applicative

bubble :: [Int] -> ([Int], Int, Bool)
bubble []         = ([],  0, False)
bubble (x:[])     = ([x], 0, False)
bubble (x1:x2:xs) =
    let (ys, c, flag) = if x1 > x2
                           then bubble (x1:xs)
                           else bubble (x2:xs)
    in if x1 > x2
          then (x2:ys, c+1, True)
          else (x1:ys, c,   flag)

bubbleSort :: Int -> [Int] -> (Int, [Int])
bubbleSort n nums =
    let (sorted, c, flag) = bubble nums
    in if flag
          then bubbleSort (n + c) sorted
          else (n, sorted)

main :: IO ()
main = do
    getLine
    nums <- map read . words <$> getLine :: IO [Int]
    let (count, sorted) = bubbleSort 0 nums
    putStrLn $ unwords (show <$> sorted)
    print count



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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H=in();
    int W=in();
    int N=in();
    int a[N];
    REP(i,N){
        cin>>a[i];
    }
    int color[H][W];
    int h;h=0;
    int w;w=0;
    REP(i,N){
        REP(j,a[i]){
            if(w>=W){
                w=0;
                h++;
            }         
            color[h][w]=i+1;
            w++;
        }
    }
    REP(i,H){
        if(i%2==0){
            REP(j,W){
                cout<<color[i][j];
                if(j<W-1)cout<<" ";
            }
            
        }else{
            REP(j,W){
                cout<<color[i][W-j-1];
                if(j<W-1)cout<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
}

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

int64_t min_cost(int step, vector<int> &h, vector<int64_t> &memo) {
  if (step == 1) return 0;
  if (step == 2) return abs(h.at(0) - h.at(1));

  int elem = step - 1;
  int64_t near = abs(h.at(elem) - h.at(elem - 1));
  if (memo.at(elem - 1) != -1) {
    near += memo.at(elem - 1);
  }
  else {
    near += min_cost(step - 1, h, memo);
  }
  int64_t far = abs(h.at(elem) - h.at(elem - 2));
  if (memo.at(elem - 2) != -1) {
    far += memo.at(elem - 2);
  }
  else {
    far += min_cost(step - 2, h, memo);
  }
  return memo.at(elem) = min(near, far);
}

int main() {
  int N;
  cin >> N;
  vector<int64_t> memo(N, -1);
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  
  cout << min_cost(N, h, memo) << endl;
}


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

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

  if(str[0] == str[1] && str[1] != str[2] && str[2] == str[3])
    cout << "Yes" << endl;
  else if(str[0] == str[2] && str[1] != str[2] && str[1] == str[3])
    cout << "Yes" << endl;
  else if(str[0] == str[3] && str[2] != str[3] && str[1] == str[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;
int main() {
  int x;
  cin >> x;
  /*
  if (400 <= x <= 599) {
    cout << "8" << endl;
  } else if (600 <= x <= 799) {
    cout << "7" << endl;
  } else if (800 <= x <= 999) {
    cout << "6" << endl;
  } else if (1000 <= x <= 1199) {
    cout << "5" << endl;
  } else if (1200 <= x <= 1399) {
    cout << "4" << endl;
  } else if (1400 <= x <= 1599) {
    cout << "3" << endl;
  } else if (1600 <= x <= 1799) {
    cout << "2" << endl;
  } else if (1800 <= x <= 1999) {
    cout << "1" << endl;
  }
  */
  for (int i = 0; i < 8; i++) {
    if (400 + i * 200 <= x) {
      if (x < 600 + i * 200) {
        cout << 8 - i << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3632
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt();
			if( n == 0) return;
			for(int i = 0; i < 9; i++){
				int a = in.nextInt();
				n -= a;
			}
			System.out.println(n);
		}
	}

	
}

Measured memory_bytes: 25968
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>


#define fs first
#define sc second

using namespace std;

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

const ll mod = 998244353;
ll fact[210200];
ll invfact[210200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll powMod(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return powMod(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll dp[110][101000];
int w[110], v[110];
ll inf = 1e15 + 7;

int main(){
    int N, W;
    cin >> N >> W;
    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
    }

    for(int i = 0; i < 110; i++){
        fill(dp[i], dp[i]+101000, inf);
    }

    dp[0][0] = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= 101000; j++){
            if(dp[i-1][j] == inf){
                continue;
            }
            dp[i][j+v[i-1]] = min(dp[i-1][j] + w[i-1], dp[i][j+v[i-1]]);
            dp[i][j] = min(dp[i-1][j], dp[i][j]);
        }
    }

    for(int i = 101000 - 1; i >= 0; i--){
        if(dp[N][i] <= W){
            cout << i << endl;
            break;
        }
    }


    return 0;
}


Measured memory_bytes: 88320
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> v;
  for(int i = 1; i <= n; i++){
    int a;
    cin >> a;
    v.emplace_back(a, i);
  }
  sort(v.begin(), v.end());
  for(auto p: v)
    cout << p.second << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false); cin.tie(0)
#define ll              long long int
#define ld              long double
#define mk              make_pair
#define pb              push_back
#define f               first
#define s               second
#define fo(i,a,b)       for(i=a;i<b;i++)
#define foe(i,a,b)      for(i=a;i<=b;i++)
#define all(x)          x.begin(),x.end()
#define vi              vector<int>
#define vl              vector <long long int>
#define pii             pair <int,int>
#define pll             pair <long long int, long long int>
#define vpii            vector< pair<int,int> >
#define vpll            vector < pair <long long int,long long int> >
#define MOD             1000000007
using namespace std;
const int inf = INT_MAX;
const ll inf64 = LLONG_MAX;


int main()
{
    boost;
    string s;
    cin >> s;
    if(s=="ARC")cout << "ABC";
    else cout <<"ARC";
    
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpi;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

const int N = 100005;

int n;
ll a[N];

ll solve() {
    ll sum = a[0], ret = 0; 
    FOR (i, 1, n) {
        if (sum < 0) {
            if (sum + a[i] > 0) sum += a[i];
            else {
                ret += abs((1 - sum) - a[i]);
                sum = 1;
            }
        }
        else {
            if (sum + a[i] < 0) sum += a[i];
            else {
                ret += abs((sum + 1) + a[i]);
                sum = -1;
            }
        }
    }
    return ret;
}

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
    cin >> n;
    FOR (i, 0, n) cin >> a[i];
    ll ans = LLONG_MAX;
    if (a[0] != 0) ans = min(ans, solve());
    ll av = a[0];
    a[0] = 1;
    ans = min(ans, solve() + abs(av - 1));
    a[0] = -1;
    ans = min(ans, solve() + abs(av + 1));
    cout << ans << endl;

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}



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

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> a;
  rep(i,n){
    int b;
    cin >> b;
    a.push(b);
  }
  rep(i,m){
    int tp = a.top();
    tp /= 2;
    a.pop();
    a.push(tp);
  }
  ll ans=0;
  rep(i,n) {
    ans += a.top();
    a.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 3924
// O(n)
#include <iostream>
#include <cstring>
using namespace std;

int n, S, r[20002];
int a[102]; //テァツエツッテァツゥツ催・ツ陳? a[i]テ」ツ?ォテ」ツ?ッ, iテ、ツサツ・テ、ツクツ甘」ツ?ョテヲツ閉ーテ」ツ?古」ツ??」ツ?湘」ツ?、テ」ツ?づ」ツつ凝」ツ?凝ヲツ?シテァツエツ?

int main(){
  while(cin >> n >> S, n || S){
    memset(a, 0, sizeof(a));

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

    //テァツエツッテァツゥツ催・ツ陳古」ツつ津ィツィツ暗ァツョツ?
    for(int i = 100; i >= 0; i--){
      a[i] += a[i + 1];
    }

    int ans = 0;

    for(int i = 0; i < n; i++){
      int rem = max(0, S - r[i] + 1);
      ans += a[rem];

      //ティツ?ェテ・ツ按?」ツ?ィティツ?ェテ・ツ按?」ツ?ョテ」ツδ堙」ツつ「テ」ツ?ッテゥツ卍、テ」ツ??」ツ?ヲテ」ツ?甘」ツ??
      if(r[i] >= rem){
        ans--;
      }
    }

    //(i,j)テ」ツ?ョテ」ツδ堙」ツつ「テ」ツ?ィ(j,i)テ」ツ?ョテ」ツδ堙」ツつ「テ」ツつ津、ツコツ古ゥツ?催」ツ?ァテヲツ閉ーテ」ツ?暗」ツ?ヲテ」ツ??」ツつ凝」ツ?ョテ」ツ?ァ2テ」ツ?ァテ・ツ可イテ」ツつ?
    cout << ans / 2 << endl;
  }
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

string lcs(string& a, string& b) {
    
    int n = a.size(), m = b.size();
    vector memo(n+1, vector<int>(m+1));
 
    for(int i=0; i<n; i++) for(int j=0; j<m; j++) {
        if(a[i] == b[j]) memo[i+1][j+1] = memo[i][j] + 1;
        else memo[i+1][j+1] = max(memo[i][j+1], memo[i+1][j]);
    }
 
    int i=n-1, j=m-1;
    string lcs;
    while(i >= 0 and j >= 0) {
        if(a[i] == b[j]) {
            lcs.push_back(a[i]);
            i--, j--;
        }   
        else memo[i][j+1] > memo[i+1][j] ? i-- : j--;
    }
    reverse(lcs.begin(), lcs.end());
 
    return lcs;
}

int main(){ _

	string a, b; cin >> a >> b;

	cout << lcs(a,b) << endl;

	return 0;
}


Measured memory_bytes: 38448
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
 
#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))32
const ll MOD = 1000000007ll;
 
bool dp1[5002][5000], dp2[5002][5000];
int n, k;
int a[5001], sum[5000];
 
void dfs(int pos, int sum, bool f) {
	if (sum >= k) return;
	
	int npos = pos;
	if (!f) {
		if (dp1[pos][sum]) return;
		dp1[pos][sum] = true;
		npos++;
	}
	else {
		if (dp2[pos][sum]) return;
		dp2[pos][sum] = true;
		npos--;
	}
	
	if (npos == 0 || npos == n + 1) return;
	
	dfs(npos, sum + a[npos], f);
	dfs(npos, sum, f);
}
 
int main() {
	cin >> n >> k;
	REP(i, n) scanf("%d", a + i + 1);
	
	dfs(0, 0, false);
	dfs(n + 1, 0, true);
	
	int ans = n;
	FOR(i, 1, n + 1) {
		if (a[i] >= k) {
			ans--;
			continue;
		}
		
		fill(sum, sum + k, 0);
		REP(j, k) if (dp2[i + 1][j]) sum[j]++;
		FOR(j, 1, k) sum[j] += sum[j - 1];
		
		bool ok = false;
		
		REP(j, k) {
			if (dp1[i - 1][j] && j >= k - a[i]) ok = true;
			if (dp2[i + 1][j] && j >= k - a[i]) ok = true;
		}
		
		if (!ok) {
			REP(j, k) if (dp1[i - 1][j]) {
			int l = k - a[i] - j - 1;
			int r = k - j - 1;
			
			if (l < 0) break;
			
			if (sum[r] - sum[l] >= 1)
				ok = true;
			}
		}
		
		if (ok) ans--;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int sum=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x){
					sum++;
				}
			}
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int max = 0;
		string ans = "No";
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			int a1 = int.Parse(str[0]);
			int a2 = int.Parse(str[1]);
			if(a1==a2){
				max++;
				if(max==3){
					ans = "Yes";
				}
			} else {
				max = 0;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17860
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int h, w;
    cin >> h >> w;
    string s;
    for(int i = 0; i < h; i++){
        cin >> s;
        cout << s << "\n" << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int h,w;
char c[50][50];
int cost[50][50];

int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    rep(i,0,a){
        if(!isdigit(s[i])){
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[a] != '-'){
        cout << "No" << endl;
        return 0;
    }

    rep(i,a+1,a+1+b){
        if(!isdigit(s[i])){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}


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

int main(){
  int i, tmp, n, nn, k, atta = 0;
  cin >> n >> k;
  int d[10];

  for( i=0; i<10; i++ ){
    d[i] = 0;
  }
  for( i=0; i<k; i++ ){
    cin >> tmp;
    d[tmp] = 1;
  }

  int ok;
  while( atta == 0 ){
    nn = n;
    ok = 1;
    while( nn>0 ){
      if( d[nn%10]==1 ){
        ok = 0;
      }
      nn /= 10;
    }
    if( ok==1 ){
      atta=1;
    }
//    cout << n << " " << endl;
    n++;
  }
  cout << n-1;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n;cin>>n;
  vector<double> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  double dp[n][n+1];
  dp[0][0]=1.0-a[0],dp[0][1]=a[0];
  for(int i=1;i<n;i++){
    for(int j=0;j<i+2;j++){
      if(j==0)
        dp[i][j]=(1.0-a[i])*dp[i-1][j];
      else if(j==i+1)
        dp[i][j]=a[i]*dp[i-1][j-1];
      else
 dp[i][j]=(1.0-a[i])*dp[i-1][j]+a[i]*dp[i-1][j-1];
    }
  }
  double ans=0.0;
  for(int i=n/2+1;i<=n;i++)ans+=dp[n-1][i];
  cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 69760
k = int(input())
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(n[k-1])


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

typedef pair<string, int> p_pair;

int main() {
    int n, q;
    queue<p_pair> PQ;

    cin >> n >> q;

    p_pair in_p;
    for(int i = 0; i < n; i++) {
        cin >> in_p.first >> in_p.second;
        PQ.push(in_p);
    }

    int elapsed_time = 0;
    while(!PQ.empty()) {
        if(PQ.front().second > q) {
            p_pair p_tmp;
            p_tmp.first = PQ.front().first;
            p_tmp.second = PQ.front().second - q;
            elapsed_time += q;
            PQ.pop();
            PQ.push(p_tmp);
        }
        else {
            elapsed_time += PQ.front().second;
            cout << PQ.front().first << " " << elapsed_time << endl;
            PQ.pop();
        }
    }
    
    return 0;
}



Measured memory_bytes: 6328
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

typedef long long cat;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	cat sum = 0, a, ans = 0;
	map<cat, int> cnt;
	cnt[0]++;
	for(int i = 0; i < N; i++) {
		cin >> a;
		sum += a;
		ans += cnt[sum];
		cnt[sum]++;
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


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

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    string s;cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1] and s[2]==s[3] and s[0]!=s[2])
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	int k, s;
	int n, m;
	int x, y, z;
	int ans = 0;


	vector<pair<int, int> >c;
	int t[30][100010];
	f(i, 30){
		f(j, 100010)t[i][j] = 0;
	}
	scanf("%d %d", &n, &m);
	f(i, n){
		scanf("%d %d %d", &x, &y, &z);
		c.push_back(make_pair(x - 1, z - 1));
		for (int i = x - 1; i < y; i++){
			if (i == x - 1){
				if (t[z - 1][i] == 3)t[z - 1][i] = 1;
				else t[z - 1][i] = 2;
			}
			else if (i == y - 1){
				if (t[z - 1][i] == 2)t[z - 1][i] = 1;
				else t[z - 1][i] = 3;
			}
else t[z-1][i]=1;
		}
	}

	for (int i = 0; i < c.size(); i++){
		if (t[c[i].second][c[i].first] == 2){
			k = 0;
			f(j, m){
				if (t[j][c[i].first]>0)k++;
			}
			if (k > ans)ans = k;
		}
	}

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

	return 0;
}

Measured memory_bytes: 13048
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  vec a(3);
  For(i,0,3)
    ci(a[i]);
  For(i,0,1000){
    sort(a,a);
    if(a[0]==a[1]&&a[1]==a[2]){
      co(i);
      break;
    }
    else if(a[1]==a[2])
      a[0]+=2;
    else {
      a[0]++;
      a[1]++;
    }
  }
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
  ll K;cin>>K;
  ll ans=0;
  rep(i,K)rep(j,K)rep(k,K){
    ans+=gcd(i+1,gcd(j+1,k+1));
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 3644
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray()[0];
            var tmp = l / 3.0;
            Console.WriteLine(tmp * tmp * tmp);
        }
    }
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  char a,b;
  int x[] = {1,0,0};
  while(scanf("%c,%c\n", &a,&b)==2) {
    swap(x[a-'A'], x[b-'A']);
  }
  REP(i,3)
    if (x[i])
      cout << (char)('A' + i) << endl;

}

Measured memory_bytes: 0
from collections import deque

def bfs():
    d = [[float("inf")] * w for i in range(h)]

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    que = deque([])
    que.append((sx, sy))
    d[sx][sy] = 0

    while que:
        p = que.popleft()
        if p[0] == gx and p[1] == gy:
            break
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx and nx < h and 0 <= ny and ny < w and\
                maze[nx][ny] != "#" and d[nx][ny] == float("inf"):
                que.append((nx, ny))
                d[nx][ny] = d[p[0]][p[1]] + 1

    return d[gx][gy]

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
sx, sy = 0, 0
gx, gy = h - 1, w - 1

# 白いマスを数える
white = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            white += 1

res = bfs()
if 0 < res < float("inf"):
    # 白いマスの数から最短経路でかかるコスト分を引く
    # ゴールを黒いマスに変えることはできないためその分も引く
    print(white - res - 1)
else:
    print(-1)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

struct Edge {
    int u, v, w;
};

int main() {
    int L;
    cin >> L;
    int high_bit;
    for (int i = 0; i <= 20; i++) {
        if ((1 << i) & L) {
            high_bit = i;
        }
    }
    int n = high_bit + 1;
    vector<Edge> e;
    for (int i = 1; i < n; i++) {
        e.push_back({ i, i + 1, 0 });
        e.push_back({ i, i + 1, 1 << (i - 1) });
    }
    int h = (1 << high_bit);
    for (int i = 0; i < high_bit; i++) {
        if ((1 << i) & L) {
            e.push_back({ i + 1 , n, h });
            h += (1 << i);
        }
    }
    printf("%d %lu\n", n, e.size());
    for (auto ed: e) {
        printf("%d %d %d\n", ed.u, ed.v, ed.w);
    }
}


Measured memory_bytes: 3716
#include <stdio.h>
int main(void) {
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 2100
N, K  = map(int, input().split())
H = list(map(int, input().split()))

HH = sorted(H)
for i in range(K):
    if len(HH) == 0:
        break
    HH.pop()

if len(HH) == 0:
    print(0)
else:
    print(sum(HH))


Measured memory_bytes: 26024
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int year = Integer.parseInt(S.substring(0,4));
        int month = Integer.parseInt(S.substring(5,7));
        int day = Integer.parseInt(S.substring(8,10));

        if(year < 2019){
            System.out.println("Heisei");
            return;
        }
        if(month <= 4 && year==2019){
            System.out.println("Heisei");
            return;
        }
//        if(month == 4 && day<=30 && year==2019) System.out.println("Heisei");
        System.out.println("TBD");
    }
}


Measured memory_bytes: 22868
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        ll n;
        cin>>n;
        vec(long double) v(n);
        rep(i,0,n-1) cin>>v[i];
        long double ans=0;
        rep(i,0,n-1)ans+=(1/v[i]);
        ans=(1/ans);
        cout<<setprecision(6)<<fixed<<ans;
        



        cout<<'\n';
    return 0;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
L=N*M+10
mod=10**9+7
table=[1]*(L+3)
t=1
for i in range(1,L+3):
    t*=i
    t%=mod
    table[i]=t
rtable=[1]*(L+3)
t=1
for i in range(1,L+3):
    t*=pow(i,mod-2,mod)
    t%=mod
    rtable[i]=t
ans=0
t=table[N*M-2]*rtable[K-2]*rtable[N*M-K]
for i in range(1,M):
    ans+=N*N*(M-i)*i
    ans%=mod
for i in range(1,N):
    ans+=M*M*(N-i)*i
    ans%=mod
print((ans*t)%mod)

Measured memory_bytes: 42224
from string import ascii_uppercase
h,w = map(int,input().split())
a,b = "",0
for i in range(h):
    s = list(map(str,input().split()))
    for j in range(w):
        if s[j] == "snuke":
            b = ascii_uppercase[j]
            a = i+1
print(b+str(a))

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

int main() {
  string s;
  cin >> s;
  int a , b;
  for ( int i=0 ; i<s.size() ; i++){
    if ( s.at(i) == 'A'){
      a=i ;
      break ;
    }
  }
     for ( int i=0 ; i<s.size() ; i++){
    if ( s.at(i) == 'Z'){
      b=i ;
    }
     }
       cout << b-a+1 <<endl;
}

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

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

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

typedef pair<int,int> p;

bool comp(const p &a,const p &b){
	if(a.first*a.first + a.second*a.second == b.first*b.first + b.second*b.second){
		return a.first < b.first;
	}else{
		return a.first*a.first + a.second*a.second < b.first*b.first + b.second*b.second;
	}
}

int main(){
	int h,w;
	vector<p> table;

	for(int i=1;i<151;i++){
		for(int j=i+1;j<151;j++){
			table.push_back(p(i,j));
		}
	}
	sort(table.begin(),table.end(),comp);

	while(cin>>h>>w){
		if(h==w&&h==0){
			break;
		}
		vector<p>::iterator ans = upper_bound(table.begin(),table.end(),p(h,w),comp);
		cout<<(*ans).first<<" "<<(*ans).second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1328
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if (a == b && b == c) {
        cout << "No" << endl;
    } else if (a == b || b == c || c == a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }        
    return 0;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 256
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n-1,1,-1):
    for j in range(i-1,0,-1):
        x = j - bisect.bisect(l,l[i]-l[j])
        if x>0:
            ans += x

print (ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans = 1;
  int M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  M = H.at(0);
  for (int i = 1; i < N; i++) {
    if (M <= H.at(i)) {
      ans++;
      M = H.at(i); 
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            char[] arr = Console.ReadLine().ToCharArray();
            Array.Sort(arr);
            int min = int.Parse(new string(arr));
            Array.Reverse(arr);
            int max = int.Parse(new string(arr));
            Console.WriteLine(max - min);
        }
    }
}

Measured memory_bytes: 8936
n=int(input())
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(n):
    a[i],b[i],c[i]=map(int, input().split())
dpa=[0 for i in range(n+1)]
dpb=[0 for i in range(n+1)]
dpc=[0 for i in range(n+1)]

for i in range(n):
    dpa[i+1]=max(dpb[i]+a[i],dpc[i]+a[i])
    dpb[i+1]=max(dpa[i]+b[i],dpc[i]+b[i])
    dpc[i+1]=max(dpa[i]+c[i],dpb[i]+c[i])
#print(dpa,dpb,dpc)
print(max(dpa[n],dpb[n],dpc[n]))




Measured memory_bytes: 26888
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct bnode{
	int key;
	struct bnode *parent;
	struct bnode *left;
	struct bnode *right;
}BinNode;

typedef struct btree{
	BinNode *bn;
	BinNode *root;
	int size;
}BinTree;

BinNode initBinNode(int);
void Insert(BinTree *, BinNode *);
void InorderPrint(BinNode *);
void PreorderPrint(BinNode *);

int main(void){
	int m, k;
	char s[10];
	int i;

	BinTree t;
	BinTree *T = &t;
	T->root = NULL;
	T->size = 0;

	scanf("%d", &m);
	T->bn = calloc(m, sizeof(BinNode));
	for (i = 0; i < m; i++){
		scanf("%s", s);
		if (!strcmp(s, "insert")){
			scanf("%d", &k);
			T->bn[T->size] = initBinNode(k);
			BinNode *z = &(T->bn[T->size]);
			T->size++;
			Insert(T, z);
		}
		else if (!strcmp(s, "print")){
				InorderPrint(T->root);
				printf("\n");
				PreorderPrint(T->root);
				printf("\n");
		}
	}

	return 0;
}


BinNode initBinNode(int v){
	BinNode z;
	z.key = v;
	z.parent = NULL;
	z.left = NULL;
	z.right = NULL;

	return z;
}

void Insert(BinTree *T, BinNode *z){
	BinNode *x, *y;

	y = NULL;
	x = T->root;
	while (x != NULL){
		y = x;
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == NULL)
		T->root = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
}

void InorderPrint(BinNode *p){
	if (p != NULL){
		InorderPrint(p->left);
		printf(" %d", p->key);
		InorderPrint(p->right);
	}
}

void PreorderPrint(BinNode *p){
	if (p != NULL){
		printf(" %d", p->key);
		PreorderPrint(p->left);
		PreorderPrint(p->right);
	}
}

Measured memory_bytes: 16236
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,E,F;
  cin >>A>>B>>C>>D;
  if(A<B){E = A;}
  else{E = B;}
  if(C<D){F = C;}
  else{F = D;}
  cout << E+F << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=110;
int n,flag;
char s[maxn],t[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s %s",s,t);
	n=strlen(s);
	for (int i=0;i<n;i++) {
		bool f=1;
		for (int j=i;j<=n+i-1;j++)
			if (s[j-i]!=t[j%n]) {
				f=0; break;
			}
		if (f) {
			flag=1; break;
		}
	}
	if (flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int A, B;
  cin>>A>>B;

  if(B >= A) cout<<"unsafe"<<endl;
  else cout<<"safe"<<endl;

  return 0;
}


Measured memory_bytes: 3640
s = input()
leng = len(s)
ans_a = 0
ans_b = 0

for i in range(leng):
  if (i % 2 == 0 and s[i] == '0') or (i % 2 == 1 and s[i] == '1'):
    ans_a += 1

for i in range(leng):
  if (i % 2 == 0 and s[i] == '1') or (i % 2 == 1 and s[i] == '0'):
    ans_b += 1

print(min(ans_a,ans_b))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double,int> DI;
const int MAX_N = (int)1e5 + 5;

bool cmp(P a, P b){
	return a.second < b.second;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<DI> a(N);
	rep (i, N){
		double g; cin >> g;
		a[i].first = -g;
		a[i].second = i;
	} // end rep
	sort(ALL(a));
	vector<P> rank(N);
	vector<int> same(N + 1, 1);		// ??????????????°???????´??????????

	rank[0].first = 0;
	rank[0].second = a[0].second;	// ???????????????????´?
	for (int i = 1; i < N; ++i){
		rank[i].second = a[i].second;
		if (a[i-1].first == a[i].first){ // ??????
			rank[i].first = rank[i-1].first;
			same[i] = same[i-1] + 1;
		}else{
			rank[i].first = i;
		} // end if
	} // end for

	for (int r = 0; r < N; ++r){
		if (same[r] != 1){
			int l = r;
			for (; same[l] != 1; ++l);
			
			for (int m = r - 1; m < l; ++m){
				same[m] = same[l-1];	
			} // end for
		} // end if
	} // end for
	

	vector<P> res(N);
	rep (i, N){
		res[i].second = rank[i].second;
		if (same[i] == 1){	// ??????????????????
			res[i].first = 3 * (N - 1 - rank[i].first);
		}else{	// ??????????????¨??????
			int curr = (same[i] - 1); // ?????????????????????
			res[i].first = 1 * (same[i] - 1) + 3 * (N - rank[i].first - same[i]);
		} // end if
	} // end rep

	sort(ALL(res), cmp);

	rep (i, N){
		cout << res[i].first << endl;
	} // end rep
	
	return 0;
}

Measured memory_bytes: 6068
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int X, N;
	cin >> X >> N;
	set<int> p;
	rep(i, N) {
		int ptmp;
		cin >> ptmp;
		p.insert(ptmp);
	}
	int ans = X;
	if (p.find(ans) == p.end()) {
		cout << ans << endl;
		return 0;
	}
	int i = 1;
	while (1) {
		ans = X - i;
		if (p.find(ans) == p.end())
			break;
		ans = X + i;
		if (p.find(ans) == p.end())
			break;
		i++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin>>n;
  vector<long long int>v(n);
  map<long long int,int>mp;
  for(int i=0;i<n;i++){
    cin>>v[i];
    mp[v[i]]++;
  }
  if(mp.size()==n){
    cout<<"YES\n";}
  else{
  cout<<"NO\n";
  }
 return 0; 
}

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


void solve() {
	int n;
	cin >> n;
	string s;
	int ac = 0, wa = 0, tle = 0, re = 0;
	for(int i =0  ; i < n; ++i) {
		cin >> s;
		if(s == "AC") ac++;
		else if(s == "TLE") tle++;
		else if(s == "WA")wa++;
		else re++;
		}
		cout << "AC x " << ac << endl;
		cout << "WA x " << wa << endl;
		cout << "TLE x " << tle << endl;
		cout << "RE x " << re << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve(); 
	return 0;
}
 


Measured memory_bytes: 3644