akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
//ll MOD = 1000000007;
ll MOD = 998244353;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
  gearup;
  int n; cin >> n;
  vl a(n);
  map<int,int> odd,even;
  rep(i,n){
      cin>>a[i];
      if(i&1)odd[a[i]]++;
      else even[a[i]]++;
  }
  vpii o,e;
  for(auto od:odd)o.push_back({od.second,od.first});
  for(auto ev:even)e.push_back({ev.second,ev.first});
  sort(rall(o));
  sort(rall(e));
  ll res = L_INF;
  if(o[0].second != e[0].second)res = n/2-o[0].first+n/2-e[0].first;
  else res = min(n/2-o[1].first+n/2-e[0].first,n/2-o[0].first+n/2-e[1].first);
  out(res);
}


Measured memory_bytes: 6908
#include <bits/stdc++.h>
#define rep(i, n) for (int i{ 0 }; i < n; ++i)

using namespace std;

int main() {
    int d, g;
    cin >> d >> g;
    vector<int> ps(d);
    vector<int> cs(d);

    rep(i, d) cin >> ps[i] >> cs[i];
    // for(auto p :cs) cout <<p;

    int min_cnt{ INT_MAX };
    rep(i, 1 << d) {
        int cnt{ 0 };
        int score{ 0 };
        rep(j, d) if (i >> j & 1) {
            score += ps.at(j) * 100 * (j + 1) + cs.at(j);
            cnt += ps.at(j);
        }
        // cout << "i: " << i << "cnt: " << cnt << "score: " << score << endl;

        for (int j = d - 1; j >= 0; j--) {
            if (score >= g) continue;
            if (i >> j & 1) continue;
            int q = min((int)((g - score) / ((j + 1) * 100)), ps.at(j));
            score += q * 100 * (j + 1);
            cnt += q;
            // cout << "q: " << q << "cnt: " << cnt << "score: " << score << endl;
        }
        // cout << "i: " << i << "cnt: " << cnt << "score: " << score << endl;

        if (score >= g) min_cnt = min(min_cnt, cnt);
    }

    cout << min_cnt << endl;
}


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

int main() {
	int W, H, C;
	int mi, ma, ans;

	cin >> W >> H >> C;

	mi = min(W, H);
	ma = max(W, H);

	for (int i = 1; i <= mi; i++) {
		if (ma%i == 0 && mi%i == 0) ans = i;
	}

	ans = (W*H) / (ans*ans);
	
	cout << ans *  C<< endl;

	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(){
	int N,K;//ウサギの数//ボートの数//
	cin>>N>>K;
	int boat[50][51]={0};
	int my_boat[51]={0};
	for(int i=0,m;i<K;i++){
		cin>>m;
		for(int j=0,r;j<m;j++){
			cin>>r;
			boat[i][r]=1;
			my_boat[r]=i;
		}
	}
	int R;
	cin>>R;
	int like[51][51]={0};
	for(int i=0,A,B;i<R;i++){
		cin>>A>>B;
		like[A][B]=like[B][A]=1;
	}
	int ans=0;
	for(int i=1;i<=50;i++){
		int flag=0;
		for(int j=1;j<=50;j++){
			if(boat[my_boat[i]][j]*like[i][j])flag++;
		}
		if(flag)ans++;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 1188
#include<iostream>
using namespace std;
int main(){
  int your_num[3][3];
  int num_num=0;
  int bing_num[11];
  int row,col;
  int ans_row[3]{0,0,0};
  int ans_col[3]{0,0,0};
  int ans_naname[2]{0,0};
  int ans;
  string ans_string="No";
  
  for(int i=0;i<3;i++){
      cin >> your_num[i][0]>> your_num[i][1]>> your_num[i][2];
      //cout << your_num[i][0]<< your_num[i][1]<< your_num[i][2]<<endl;
  }
  cin >> num_num;
  for(int i=0;i<num_num;i++){
    cin >> bing_num[i];
    // cout << bing_num[i] <<" "<<endl;
    for(row=0;row<3;row++){
      for(col=0;col<3;col++){
        if(bing_num[i]==your_num[row][col]){
          // cout<<"hit"<<endl;
          your_num[row][col]=0;
        } 
      }
    } 
  }
  
  // calc answer
  for(row=0;row<3;row++){
    for(col=0;col<3;col++){
      ans_row[row]+=your_num[row][col];
      ans_col[col]+=your_num[row][col];
      if(row==col){
        ans_naname[0]+=your_num[row][col];
      }
      if((row+col)==2){
        ans_naname[1]+=your_num[row][col];
      }
    }
  }
  
  for(int i=0;i<3;i++){
    if(ans_row[i]*ans_col[i]==0){
      ans_string="Yes";
    }
  }
  if(ans_naname[0]*ans_naname[1]==0){
     ans_string="Yes";
  }

  // return ans
  cout << ans_string;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



int main() {
	int a, b;
	cin >> a >> b;
	int ans;
	if (a > b)ans = a-1;
	else ans = a ;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    double x, h;

    for(;;){
      x = sc.nextDouble();
      h = sc.nextDouble();
      if(x == 0 && h == 0)break;

      System.out.println(x * x + 2 * Math.sqrt((x / 2.0) * (x / 2.0) + h * h) * x);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 19000
def main():
    n=int(input())
    s=[int(input()) for _ in range(n)]
    sd=0
    a=sum(s)
    mask=1<<a
    for x in s:
        sd=(sd+1)<<x | sd
    for i in range(a):
        if (a-i)%10!=0 and (mask>>i)&sd>0:
           return print(a-i)
    return print(0)

main()


Measured memory_bytes: 9124
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d=b/a;
    if(d>c){
        cout<<c<<endl;
    }else{
        cout<<d<<endl;
    }
    return 0;
}

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

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

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

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n,m,q;
        cin>>n>>m>>q;

        set<pll> st;
        map<ll,ll> row,col;

        for(ll i=0;i<q;i++)
        {
            ll x,y;
            cin>>x>>y;
            st.insert({x,y});
            row[x]++;
            col[y]++;
        }

        vector<ll> mxrow,mxcol;

        ll mxr=0,mxc=0;

        for(auto i:row)
        {
            if(i.ss>mxr)
            {
                mxrow.clear();
                mxrow.pb(i.ff);
                mxr=i.ss;
            }
            else if(i.ss==mxr)
            {
                mxrow.pb(i.ff);
            }
        }

        for(auto i:col)
        {
            if(i.ss>mxc)
            {
                mxcol.clear();
                mxcol.pb(i.ff);
                mxc=i.ss;
            }
            else if(i.ss==mxc)
            {
                mxcol.pb(i.ff);
            }
        }

        ll ans=0;
        ll flag=0;

        for(auto i:mxrow)
        {
            for(auto j:mxcol)
            {
                if(st.find({i,j})==st.end())
                {
                    ans=row[i]+col[j];
                    flag=1;
                    break;
                }
                else if(ans==0)
                {
                    ans=row[i]+col[j]-1;
                }
                
            }

            if(flag)
            break;
        }

        cout<<ans;
    }
}

Measured memory_bytes: 67808
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
#include <bitset>
using namespace std;
typedef int64_t ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef vector<long double> vld;
typedef vector<vld> vvld;
typedef unordered_map<ll, ll> uii;
typedef unordered_map<ll, ll> uuii;
typedef unordered_map<ll, ll> uuuii;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef bitset<64> bs;
const ll LINF = 1e18;
const long double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    
    ll L, R, d; cin >> L >> R >> d;
    
    ll cnt = 0;
    FOR(now, L, R+1){
        if(now % d == 0) cnt++;
    }
    
    cout << cnt << endstr;
    
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
// #define MULTIPLE_TESTS 1

int n;
vector<ll> arr;
void readArray() {
    arr.resize(n);
    for (auto &a: arr) {
        cin >> a;
    }
}

void solve() {
    cin >> n;
    readArray();
    ll res = arr[0];
    for (int i = 0; i < n; ++i) {
        if (arr[i] == 0) {
            cout << 0 << endl;
            return;
        }
    }
    const ll MAX = 1e18;
    for (int i = 1; i < n; ++i) {
        if (arr[i] > int64_t(MAX/res) ) {
            cout << "-1" << endl;
            return;
        }
        res *= arr[i];
    }
    cout << res << endl;
}

int main() {
    FAST_IO;
    int t = 1;
    #ifdef MULTIPLE_TESTS
    cin >> t;
    #endif

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

    return 0;
}

Measured memory_bytes: 3928
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 100005
#define inf 1e9
#define eps 1e-10
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

struct node{int to,id;};
int n,m,U[maxn],V[maxn],ind[maxn],ans[maxn],v1[maxn],v2[maxn],nw[maxn];
vector <node> mp[maxn];
queue <int> q;

inline void dfs(int u)
{
	v1[u]=1;
	for(int i=0;i<mp[u].size();i++)
	{
		node v=mp[u][i];
		if(v1[v.to]) continue;
		v1[v.to]=1; v2[v.id]=1; dfs(v.to);
	}
}

int main()
{
	n=read(); m=read();
	if(m%2==1) {puts("-1"); return 0;}
	for(int i=1;i<=m;i++)
	{
		int u=read(),v=read(); U[i]=u; V[i]=v;
		mp[u].push_back({v,i}); mp[v].push_back({u,i});
	}
	dfs(1);
	for(int i=1;i<=n;i++) mp[i].clear();
	
	for(int i=1;i<=m;i++)
	{
		if(v2[i]==1)
		{
			mp[U[i]].push_back({V[i],i});
			mp[V[i]].push_back({U[i],i}); ind[U[i]]++; ind[V[i]]++; v2[i]=-1;
		}
		else nw[U[i]]^=1;
	}
	
	rep(i,1,n) v1[i]=0;
	rep(i,2,n) if(ind[i]==1) q.push(i),v1[i]=1;
	//rep(i,1,n) cout<<nw[i]<<" "; cout<<endl;
	
	//rep(i,1,n) cout<<v1[i]<<endl;
	while(!q.empty())
	{
		int u=q.front(); q.pop(); //cout<<u<<endl;
		for(int i=0;i<mp[u].size();i++)
		{
			node v=mp[u][i];
			if(v2[v.id]!=-1) continue;
			if(nw[u]==0)
			{
				nw[v.to]^=1;
				if(U[v.id]==u) v2[v.id]=1; else v2[v.id]=0;
			}
			else
			{
				nw[u]^=1;
				if(U[v.id]==u) v2[v.id]=0; else v2[v.id]=1;
			}
			ind[v.to]--; if(ind[v.to]==1) q.push(v.to),v1[v.to]=1;
			//cout<<U[v.id]<<" "<<V[v.id]<<" "<<v2[v.id]<<endl;
		}
	}
	//for(int i=1;i<=m;i++) cout<<v2[i]<<" "; cout<<endl;
	for(int i=1;i<=m;i++)
	{
		if(v2[i]==0) printf("%d %d\n",U[i],V[i]);
		else printf("%d %d\n",V[i],U[i]);
	}
	return 0;
}

Measured memory_bytes: 12160
def main():
    S = input()
    count = 1
    flg = True
    for s in S:
        if count % 2 == 0 and s == 'R':
            print('No')
            exit()
        elif count % 2 == 1 and s == 'L':
            print('No')
            exit()
        count += 1
    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b, x;
    cin >> a >> b >> x;
    if (x >= a && x <= a + b) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = input().split(' ')
count = 0

flag = True
while flag:
    flag = False
    for j in reversed(range(1, n)):
        if int(A[j]) < int(A[j-1]):
            (A[j-1], A[j]) = (A[j], A[j-1])
            count += 1
            flag = True

print(" ".join(A))
print(count)

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back

int main() {
    int a,b;
    cin>>a>>b;
    cout<<a-b+1<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int a;
int b;

int main()
{
    cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;
    if(a > b)
    {
        cout << "Alice";
    }
    else if(a < b)
    {
        cout << "Bob";
    }
    else
    {
        cout << "Draw";
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

int n;
const int maxn = 2e5 + 5;
typedef long long LL;
LL T;
LL t[maxn];
int main(){
    cin >> n >> T;
    LL sum = 0;
    LL nxt = 0;
    for(int i = 1;i <= n;i++){
        scanf("%lld", &t[i]);
        if(nxt >= t[i]){
            sum -= nxt - t[i];
        }
        sum += T;    
        nxt = t[i] + T;
    }
    cout << sum << endl;
    return 0;
}


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

int main_()
{
    int N;
    vector<int> As;
    cin >> N;
    copy_n(istream_iterator<int>(cin), N, back_inserter(As));
    auto as_sort(As);
    partial_sort(as_sort.begin(), as_sort.begin() + 2, as_sort.end(),
                 [](int a, int b) { return a > b; });

    vector<int> outs;
    transform(As.begin(), As.end(), back_inserter(outs),
              [&as_sort](int a) { return (a < as_sort[0] ? as_sort[0] : as_sort[1]); });

    copy(outs.begin(), outs.end(), ostream_iterator<int>(cout, "\n"));
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;

int n, f[N][2];
string s;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> s;
  s = "0" + s;
  n = s.length();
  f[0][0] = s[n - 1] - '0';
  f[0][1] = f[0][0] + 2;
  for (int i = 1; i < n; ++i) {
    f[i][0] = min(f[i - 1][0], f[i - 1][1]) + s[n - 1 - i] - '0';
    f[i][1] = min(f[i - 1][0] - (s[n - i] - '0') + 10 - (s[n - i] - '0'),
                  f[i - 1][1] - (s[n - i] - '0' + 1) + 10 - (s[n - i] - '0' + 1)) + s[n - i - 1] - '0' + 1;
  }
  cout << min(f[n - 1][0], f[n - 1][1]);
  return 0;
}

Measured memory_bytes: 9160
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
using namespace std;
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
signed main(){
    int n; cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    vector<vector<int>>dp(2,vector<int>(n,0LL));
    rep(i,n){
        if(i == 0){
            dp[0][0] = v[i]; dp[1][0] = -INF;
        } else {
            dp[0][i] = max(dp[0][i-1], dp[1][i-1]) + v[i];
            dp[1][i] = max(dp[1][i-1] + 2*v[i-1] - v[i],dp[0][i-1] -2*v[i-1] - v[i]);
        }
    }
    cout << max(dp[0][n-1], dp[1][n-1]) << endl;
}





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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A*B*1 % 2 != 0 || A*B*2 % 2 != 0 || A*B*2 % 2 != 0) 
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second

#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()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int  mp[26][26][26];
bool ok[26][26];

void init(){
  REP(a,26){
    REP(b,26){
      bool tmp[26] = {false};
      ok[a][b] = true;
      REP(c,26){
	int f = (a*c+b)%26;
	if(tmp[f]){
	  ok[a][b] = false;
	  break;
	}
	mp[a][b][c] = f;
      }
    }
  }
}

int main(){
  int n;
  string str;
  getline(cin, str);
  n = atoi(str.c_str());
  init();
  while(n --> 0){
    int len;
    getline(cin, str);
    len = str.size();
    REP(a,26) REP(b,26) if(ok[a][b]){
      string dec = str;
      REP(i,len)
	if(isalpha(dec[i]))
	  dec[i] = mp[a][b][dec[i]-'a'] + 'a';
      //cout << "decoded: " << dec << endl;
      if(dec.find("this") != string::npos ||
	 dec.find("that") != string::npos){
	cout << dec << endl;
	goto end;
      }
    }
  end:;
  }
  return 0;
}

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

int main() {
  ld a,b,c;
  cin >> a >> b >> c;
  ld rad = c * PI / 180;

  ld s, l, h;
  //s = ?;
  l = a + b + powl(a*a + b*b - 2*a*b*cosl(rad), 0.5);
  h = b * sinl(rad);
  s = a * h / 2;

  cout << fixed;
  cout << s << endl;
  cout << l << endl;
  cout << h << endl;
  return 0;
}



Measured memory_bytes: 3600
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include <assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,i=6,j;cin>>n;
	while(n--){
		for(;;i+=5){
			int ok=1;
			for(j=2;j*j<=i;j++){
				if(i%j==0){ok=0;break;}
			}
			if(ok){cout<<i<<" ";i+=5;break;}
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
strs = ["".join(sorted(list(input()))) for _ in range(n)]
ans = {}
cnt = 0
for i in range(n):
  if strs[i] in ans:
    cnt += ans[strs[i]]
    ans[strs[i]] +=  1
  else:
    ans[strs[i]] = 1

print(cnt)

Measured memory_bytes: 19504
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int a,b,c; cin>>a>>b>>c;
    set<int> st;
    st.insert(a); st.insert(b); st.insert(c);
    if (st.size()==2) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s,t;
int main() 
{
	cin>>s;t=s;
	reverse(s.begin(),s.end());
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='b') s[i]='d';
		else if(s[i]=='d') s[i]='b';
		else if(s[i]=='p') s[i]='q';
		else if(s[i]=='q') s[i]='p';
	}
	if(s==t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}

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

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

  int p = -1 , q = -1, r = -1;
  bool a = false;
  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < N + 1 - i; j++) {
      if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
        a = true;
        p = i, q = j, r = N - i - j;
      }
      if (a) break;
    }
    if (a) break;
  }
  cout << p << " " << q << " " << r << endl;
}

Measured memory_bytes: 256
#include <stdio.h> 
int main(void) 
{ 
   int i, j; 
   for (i = 1; i < 10; i++) 
        for (j = 1; j < 10; j++) 
            printf("%dx%d=%d\n", i, j, i * j); 

    return 0; 
} 


Measured memory_bytes: 1988
#include<iostream>
#include<cmath>
#include<algorithm> 
using namespace std;

int main(){
  int N;

  cin >> N;

  int a[N];
  for(int i = 0; i < N; i++) cin >> a[i];

  int ans=0;
  for(int i = 0; i < N-1; i ++){
    for(int j = i; j < N; j++){
      ans = max(abs(a[i]-a[j]), ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

t = [0]*8
t[1] = 1
for i in range(2,n):
  t[i] = i * t[i - 1]

a = 0
l = list(range(1, n+1))
for i in range(n):
  a += l.index(p[i]) * t[len(l) - 1]
  l.remove(p[i])

b = 0
l = list(range(1, n+1))
for i in range(n):
  b += l.index(q[i]) * t[len(l) - 1]
  l.remove(q[i])

print(abs(a - b))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N; cin >> N;
	for (int i = 0; i < N;i++) {
		vector<int> v1(101), v2(101);
		string str1, str2;
		cin >> str1 >> str2;
		for (int j = 0; j < str1.size(); j++) v1[j] = str1[str1.size() - j - 1] - '0';
		for (int j = 0; j < str2.size(); j++) v2[j] = str2[str2.size() - j - 1] - '0';
		for (int j = 0; j < 100;j++) {
			v1[j] += v2[j];
			if (v1[j] >= 10) {
				v1[j] -= 10;
				v1[j + 1]++;
			}
		}
		int dig = 0;
		for (int j = 100; j >= 0; j--) {
			if (v1[j] != 0) {
				dig = j; break;
			}
		}
		if (dig >= 80) cout << "overflow" << endl;
		else {
			for (int j = dig; j >= 0; j--) {
				cout << v1[j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
using ld = long double;
using ml = boost::multiprecision::cpp_int;

namespace NyaGadget
{
#define rep(i, b, e) for (ll i = b; i < e; i++) // repeat
	/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)

	/*** 二次元累積和ライブラリ***/

	struct CumulativeSum2D
	{
		vector<vector<ll>> gsum;

		/**
		@brief 二次元累積和の構築
		@param 二次元配列の行
		@param 二次元配列の列
		@param 二次元配列の値
		@note
		 引数で渡された二次元配列から累積和を構築する。
		**/
		CumulativeSum2D(ll h, ll w, const vector<vector<ll>>& v)
		{	// 0で初期化されたgsum[0][x]とgsum[y][0]も追加して配列を構築
			gsum.resize(h + 1);
			each(i, e, gsum)
				e.resize(w + 1);

			rep(y, 1, h + 1)
			{
				rep(x, 1, w + 1)
					gsum[y][x] = gsum[y - 1][x] + gsum[y][x - 1] - gsum[y - 1][x - 1] + v[y - 1][x - 1];
			}
		}

		/**
		@brief 結果取得関数
		@param ymin 左上y座標
		@param xmin 左上x座標
		@param ymax 左下y座標
		@param xmax 左下x座標
		@note
		 二次元範囲の累積結果をO(1)で出力する。
		 引数は閉区間で与える。
		**/
		ll Result(ll ymin, ll xmin, ll ymax, ll xmax)
		{	// 累積和のgsumは元の座標と1ずつずれているので調整
			ymin++; xmin++; ymax++; xmax++;
			return gsum[ymin - 1][xmin - 1] + gsum[ymax][xmax] - gsum[ymax][xmin - 1] - gsum[ymin - 1][xmax];
		}
	};

#undef rep
#undef fori
#undef each
}

#define all(c) (c).begin(), (c).end()            // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);        // div ceiling
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
#define size(c) ((ll) (c).size())                // collection size
#define sum(b, e) accumulate(all(b, e), 0LL)     // accumulate 
/********** const value **********/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define mod 1000000007                           // 1e9 + 7
#define pi 3.14159265                            // 3.14 ...
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

using namespace NyaGadget;

struct Test
{
	ll money = 0;   // 費用
	ll land = 0;    // 土地の面積
};

int main(void)
{
	ll A1, A2, A3; cin >> A1 >> A2 >> A3;

	if (22 <= A1 + A2 + A3)
		cout << "bust";
	else
		cout << "win";

	return 0;
}


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

int main() {
  string str;
  cin >> str;
  int n = 0, w = 0, s = 0, e = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == 'N') n++;
    if (str.at(i) == 'W') w++;
    if (str.at(i) == 'S') s++;
    if (str.at(i) == 'E') e++;
  }
  string ans = "No";
  if ((n > 0) && (s > 0)) {
    if (((w > 0) && (e > 0)) || ((w == 0) && (e == 0))) {
      ans = "Yes";
    }
  } else if ((w > 0) && (e > 0)) {
    if (((n > 0) && (s > 0)) || ((n == 0) && (s == 0))) {
      ans = "Yes";
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 2018-04-08
 * https://beta.atcoder.jp/contests/abc069/tasks/abc069_b
 */

public class Main {
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        String origin = sc.next();
        String first = origin.substring(0,1);
        String last = origin.substring(origin.length()-1);
        int num = origin.length()-2;
      
        System.out.println(first+num+last);


    }
}


Measured memory_bytes: 21716
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int n,m;
    n=read(), m=read();
    if(m<=2*n) printf("%lld\n",m/2);
    else
    {
        int qwq=m-n*2;
        int t=qwq/4;
        printf("%lld\n",n+t);
    }
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	int x = x2;
	int y = y2;
	for (int i = 0; i < 2; ++i) {
		swap(dx, dy);
		dx = -dx;
		x += dx;
		y += dy;
		cout << x << " " << y << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double theta1 = 2*M_PI*(h*60 + m)/720;
    double theta2 = 2 * M_PI * m / 60; 
    double theta = abs(theta1 - theta2);
    theta = min(theta, abs(2.0*M_PI - theta));

    double c = sqrt(a*a + b*b - 2.0*a*b*cos(theta));

    cout << fixed << setprecision(10) << c << endl;

    return 0;
}

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

int max(int , int ) ;

int main()
{
	string s1,s2,ans;
	cin>>s1>>s2;
	int l1=s1.length();
	int l2=s2.length();
	int dp[l1+1][l2+1] ;
	for(int i=0;i<=l1;i++) dp[i][0]=0;
	for(int j=0;j<=l2;j++) dp[0][j]=0;
	for(int i=1;i<=l1;i++)
	{
		for(int j=1;j<=l2;j++)
		{
			 if(s1[i-1]==s2[j-1]) dp[i][j]=1+dp[i-1][j-1] ;
			else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		//	cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	int i=l1,j=l2;
	while(i!=0 && j!=0)
	{
		while(i!=0 && j!=0)
		{
			if(dp[i][j]==dp[i-1][j]) i--;
			else if(dp[i][j]==dp[i][j-1]) j--;
			else
			{
				i--;
				j--;
				ans=ans+s1[i];
			}
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}
int max(int a, int b)
{
	if(a>=b) return(a);
	return(b);
}

Measured memory_bytes: 35456
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(){
	string s;
	cin >> s;
	for(int i = 0 ; i + 1 < s.size() ; i++){
		if( s[i] == s[i+1] ){
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for(int i = 0 ; i + 2 < s.size() ; i++){
		if( s[i] == s[i+2] ){
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main() {
	long mod = 1e9+7;
	int N;
	cin>>N;
	int A[N];
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	map<int, long>hat;
	long ans = 1;
	hat[-1] = 3;
	for(int i=0;i<N;++i){
		//cout<<i<<" "<<hat[A[i]]<<" "<<hat[A[i]-1]<<endl;
		ans *= hat[A[i]-1]-hat[A[i]];
		ans %= mod;
		hat[A[i]]++;
		if(hat[A[i]]>3 | hat[A[i]]>hat[A[i]-1]) ans*= 0;
	}
	cout<<ans<<endl;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

//最小公倍数
int lcm(int number1,int number2){
	return number1 * number2 / gcd(number1,number2);	
}
 

int main(){
long long A, B, C, D;
cin >> A >> B >> C >> D;
 
long long L = C * D / gcd(C, D);
 
long long sum = (B / C) + (B / D);
 
//cout << sum << endl; 
 
long long sum2 = ((A - 1) / C) + ((A - 1)/ D);
  
long long lc = (B / L) - ((A - 1) / L); 
 
 
//cout << sum2 << endl; 
 
long long ans = (B - A + 1) -((sum - sum2) - lc);
  
 
cout << ans << endl; 
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    token = lines[0].split()
    x = int(token[0])
    a = int(token[1])

    return (x, a)


def solve(x, a):

        
    result = 0
    if x >= a:
        result = 10
    return result




def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
/* ex 9_1
   KKOO */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//スタックに格納するデータの最大数
#define SIZE 100

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    stack str;
    char letter[11], decoy;
    int length;
    //スタックを初期化
    initialize_stack(&str);

    scanf("%s", letter);
    length = strlen(letter);

    for(int i=0; i<length; i++){
        //文字が'0'か'1'であればスタックに挿入
        if(letter[i] == '0' || letter[i] == '1'){
            push(&str, letter[i]);
        }
        //文字が'B'でスタックの中身がnullでなければスタックの中身を取り出す
        //decoyは取り出された値を格納する「おとり」
        else if(letter[i] == 'B' && str.count != 0){
            decoy = pop(&str);
        }
    }

    //スタックはデータが下からたまるので下から出力
    for(int i = SIZE - 1; i >= SIZE - str.count; i--){
        printf("%c", str.data[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1608
def get_int
  gets.chop.to_i
end

def get_ints
  gets.chop.split.map(&:to_i)
end

def get_double
  gets.chop.to_f
end

def get_str
  gets.chop
end

def get_strs
  gets.chop.split
end

def main
  a, b = get_ints
  if a <= 9 and b <= 9
    puts a * b
  else
    puts -1
  end
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ed;
int n, m;
vector<int> G[100009];
bool volt[100009];
int start, fi;
bool dfs(int x)
{
    if(x==fi) return true;
    volt[x]=true;
    for(int sz: G[x])
    {
        if(!volt[sz])
        {
            if(dfs(sz)) return true;
        }
    }
    return false;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int a, b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int jo=0;
    start=-1;
    fi=-1;
    for(int i=1; i<=n; i++)
    {
        if(G[i].size()%2==1)
        {
            cout<<"No"<<endl;
            return 0;
        }
        if(G[i].size()==4)
        {
            if(start==-1) start=i;
            else fi=i;
            jo++;
        }
        if(G[i].size()>4)
        {
            jo=3;
        }
    }
    if(jo>=3)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if(jo!=2)
    {
        cout<<"No"<<endl;
        return 0;
    }
    volt[start]=true;
    for(int sz: G[start])
    {
        if(!dfs(sz))
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


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

int main(){
  long L,R,a=0;
  cin >> L >> R;
  if(L+2019<=R){
    a=1;
  }
  L%=2019;
  R%=2019;
  if(a){
    cout << 0 << endl;
  }
  else{
    if(R<=L){
      cout << 0 << endl;
    }
    else{
      int ans=2019;
      for(int i=L; i<R; i++){
        for(int j=i+1; j<=R; j++){
          ans=min(ans,i*j%2019);
        }
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool a)
{
    if (a == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
    ll n, m;
    cin >> n >> m;
    pair<ll, ll> a[100001];
    ll ans = 0;
    rep(i, 0, n) cin >> a[i].fi >> a[i].se;
    sort(a, a + n);
    rep(i, 0, n)
    {
        if (m <= 0)
            break;
        if (a[i].se <= m)
        {
            ans += a[i].se * a[i].fi;
            m -= a[i].se;
        }
        else
        {
            ans += m * a[i].fi;
            m = 0;
        }
    }
    cout << ans << endl;
}


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


int main() {
	int n, k; cin >> n >> k;
	int ma = (n - 1)*(n - 2) / 2;
	if (ma < k)cout << -1 << endl;
	else {
		vector<pii>res;
		for (int i = 1; i <= n - 1; ++i) {
			res.push_back({ i,n });
		}
		int rem = ma - k;
		int ci = 1, cj = 2;
		for (int i = 0; i < rem; ++i) {
			res.push_back({ ci,cj });
			++cj;
			if (cj == n) {
				++ci;
				cj = ci + 1;
			}
		}
		cout << res.size() << endl;
		for (auto p : res) {
			cout << p.first << " " << p.second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#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);

	ll N;
	cin >> N;

	pair<ll, pair<ll, ll> > p[N];
	ll rsl = 0;
	rep(i, 0, N) {
		ll a, b;
		cin >> a >> b;
		rsl += a;
		p[i] = make_pair(a + b, make_pair(a, b));
	}

	sort(p, p + N);
	reverse(p, p + N);
	rep(i, 0, N) {
		if(i % 2 != 0) {
			rsl -= p[i].first;
		}
	}

	cout << rsl << endl;


}


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if (n < 1000) {
		fmt.Println("ABC")
	} else {
		fmt.Println("ABD")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,b;
int a[60][60],vis[60][60],ans[60][60];
char in;
void dfs(int x,int y,int z)
{
	if(ans[x][y]<=z)return;
	ans[x][y]=z;
	if(x==n&&y==m)return;
	if(y+1<=m&&a[x][y+1]==0&&vis[x][y+1]==0){
		vis[x][y+1]=1;
		dfs(x,y+1,z+1);vis[x][y+1]=0;
	}
	if(y-1>=1&&a[x][y-1]==0&&vis[x][y-1]==0)
	{
		vis[x][y-1]=1;
		dfs(x,y-1,z+1);vis[x][y-1]=0;
	}
	if(x+1<=n&&a[x+1][y]==0&&vis[x+1][y]==0){
		vis[x+1][y]=1;
		dfs(x+1,y,z+1);vis[x+1][y]=0; 
	}
	if(x-1>=1&&a[x-1][y]==0&&vis[x-1][y]==0){
		vis[x-1][y]=1;
		dfs(x-1,y,z+1);vis[x-1][y]=0;
	}
	return;
}
int main()
{
	for(int i=1;i<=50;i++)for(int j=1;j<=50;j++)ans[i][j]=1e9;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>in;
			if(in=='.')a[i][j]=0;
			else {
			b++;a[i][j]=1;	
			}	
		}
	}
	vis[1][1]=1;
	dfs(1,1,1);
	if(ans[n][m]==1e9)cout<<"-1";
	else 
	cout<<n*m-ans[n][m]-b;
	return 0;
}

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

ll n,m;
ll solve(vector<ll>a){
   ll ans=n;
   rep(i,n){
       ans-=a[i];
   }
   return ans<0?-1:ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>m;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    cout<<solve(a)<<endl;
    return 0;
}

Measured memory_bytes: 18772
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0;i<n;i++){
        cin >> h[i];
    }
    long dp[n+5];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i = 2;i<n;i++){
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;


int main(){
    string s;
    vector<int>count(26);

    while(getline(cin,s)){
        for(int i = 0; i < s.size(); i++){
            if('a' <= s[i] && s[i] <= 'z'){
                count[s[i] - 'a']++;
            }
            if('A' <= s[i] && s[i] <= 'Z'){
                s[i]+= 'a'-'A';
                count[s[i] - 'a']++;
            }
        }
    }

    for(int i = 0; i < count.size(); i++){
        cout << (char)('a'+i) << " : "<< count[i] << endl;
    }



}


Measured memory_bytes: 3220