akhauriyash/Code-Regression huggingface dataset:
//yewala
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)        (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007 
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;

inline LL moduloMultiplication(LL x, LL y) { return (x%mod * 1LL * y%mod) % mod; }
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}

inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL inv(LL a) { return power(a, mod - 2) % mod; }

int main()
{

	LL a, b, k;
	cin >> a >> b >> k;
	if (a + b <= k)
	{
		cout << 0 << " " << 0 << endl;
	}
	else if (a <= k )
	{
		cout << 0 << " " << b - (k - a) << endl;
	}
	else if (a > k)
	{
		cout << a - k << " " << b << endl;
	}


}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var input = make([]string, 0)

func main() {
	for sc.Scan() {
		in := sc.Text()
		switch len(in) {
		case 2:
			fmt.Println(in)
		case 3:
			fmt.Println(reverse(in))
		}
	}

}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;


int main(void) {

  string s;
  cin >> s;
  if( s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I' ) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0, m = 0;
    cin >> n >> m;
    vector<int> a(m);
    for (int i=0; i<m; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    vector<int> match = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    vector<int> dp(n+1, -1e8);
    dp.at(0) = 0;
    for (int i=1; i<n+1; i++) {
        for (int j=0; j<m; j++) {
            int use = match.at(a.at(j));
            if (i - use < 0) {
                continue;
            }
            else {
                dp.at(i) = max(dp.at(i), dp.at(i-use)+1);
            }
        }
    }
    vector<int> ret;
    while (n > 0) {
        for (int i=0; i<m; i++) {
            int use = match.at(a.at(i));
            if (n - use < 0) continue;
            if (dp.at(n) == dp.at(n-use)+1) {
                ret.push_back(a.at(i));
                n -= use;
                break;
            }
        }
    }
    for (int x : ret) {
        cout << x;
    }
    cout << endl;
    return 0;
}
 

Measured memory_bytes: 384
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	sl := []string{"dream", "dreamer", "erase", "eraser"}

	for len(s) > 0 {
		exists := false
		for _, sfx := range sl {
			if strings.HasSuffix(s, sfx) {
				exists = true
				s = strings.TrimSuffix(s, sfx)
				break
			}
		}
		if !exists {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int ans[]={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};
int main()
{
    int k;
    cin>>k;
    cout<<ans[k-1]<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
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; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "No" << endl;return 0
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N;
    int H[114514],G[114514];
    cin >> N;
    REP(i,N){
        cin >> H[i];
        if(i==0){
            G[0]=H[0];
        }
        if(i!=0){
            G[i]=H[i]-H[i-1];
        }
    }
    RREP(i,N){
        if(i==0)continue;
        if(G[i]<=-2){
            GOODBYE;
        }else if(G[i]==-1){
            G[i]+=1;
            G[i-1]-=1;
        }else if(G[i]==0){
            if(G[i-1]>0){
                G[i]+=1;
                G[i-1]-=1;
            }
        }else{
            
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int s,w;
  cin >> s >> w;
  if(w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

int main() {
    int N;
    cin >> N;
    pii A[N];
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A[i] = pii(a, i);
    }
    sort(A, A + N);
    int odddif = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0 && A[i].second % 2 == 1) {
            odddif++;
        }
    }
    cout << odddif << endl;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

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

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

ll n, k, h[100010], dp[100010];

int main(){
	cin >> n >> k;
	for(int i=1;i<=n;i++){
		cin >> h[i];
	}
	dp[2] = abs(h[1]-h[2]);
	for(ll i=3;i<=n;i++){
		dp[i] = (ll)INF;
		ll st = max((ll)1, i-k); 
		for(ll j=st;j<=i-1;j++){
			ll re = dp[j]+abs(h[i]-h[j]);
			dp[i] = min(dp[i], re);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<vector<P>> d(n,vector<P>(0));
    int a,b,c;
    rep(i,n-1){
        cin>>a>>b>>c;
        a --;b --;
        d[a].emplace_back(b,c);
        d[b].emplace_back(a,c);
    }
    int q,k;
    cin>>q>>k;
    vector<int> x(q),y(q);
    rep(i,q) cin>>x[i]>>y[i];
    k --;
    rep(i,q){x[i]--;y[i]--;}

    vector<in> dp(n,0);
    queue<int> que;
    que.push(k);
    while(!que.empty()){
        a=que.front();
        que.pop();
        for(auto z:d[a]){
            if(dp[z.first]) continue;
            dp[z.first] = (in)dp[a]+(in)z.second;
            que.push(z.first);
        }
    }
    rep(i,q) cout<<dp[x[i]]+dp[y[i]]<<endl;
}

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

int main() {
  int a;
  cin>>a;
  cout<<10-a/200<<endl;
}



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

typedef pair<int, int> Pii;
typedef pair<Pii, string> Pis;

struct Edge {
  int to, cost;  
};

int N, M, K, P;
vector<int> s, t;
vector<int> ss[1000];
vector<int> tt[1000];
vector<Edge> G[1000];

int dij() {
  priority_queue<Pis, vector<Pis>, greater<Pis> > Q;
  map<string, bool> used[N];
  string ini = "";
  string ends = "";
  for ( int i = 0; i < K; i++ ) {
    ini += "0";
    ends += "2";
  }

  for ( int j = 0; j < (int)ss[P].size(); j++ ) {
    if ( ini[ss[P][j]] == '0' ) ini[ss[P][j]] = '1';    
  }
  for ( int j = 0; j < (int)tt[P].size(); j++ ) {
    if ( ini[tt[P][j]] == '1' ) ini[tt[P][j]] = '2';	
  }
  
  Q.push(Pis(Pii(0, P), ini));
  
  while ( !Q.empty() ) {    
    Pis p = Q.top(); Q.pop();    
    int c = p.first.first;
    int n = p.first.second;
    string sta = p.second;
    //cout << n << " " << c << " "  << sta << endl;
    //cout << n << endl;
    if ( sta == ends ) return c;

    if ( used[n][sta] ) continue;
    used[n][sta] = true;

    for ( int i = 0; i < (int)G[n].size(); i++ ) {
      Edge e = G[n][i];
      int to = e.to, cost = e.cost;
      string nxt = sta;      
      for ( int j = 0; j < (int)ss[to].size(); j++ ) {
	if ( nxt[ss[to][j]] == '0' ) nxt[ss[to][j]] = '1';	
      }
      for ( int j = 0; j < (int)tt[to].size(); j++ ) {
	if ( nxt[tt[to][j]] == '1' ) nxt[tt[to][j]] = '2';	
      }
      Q.push(Pis(Pii(c+cost, to), nxt));      
    }
    //cout << n << endl;
  }

  return -1;
}

int main() {
  cin >> N >> M >> K >> P;
  P--;
  
  for ( int i = 0; i < M; i++ ) {
    int x, y, w;
    cin >> x >> y >> w;
    x--; y--;
    G[x].push_back(Edge{y, w});
    G[y].push_back(Edge{x, w}); 
  }
 
  s = vector<int>(K);
  t = vector<int>(K);
  for ( int i = 0; i < K; i++ ) {
    cin >> s[i] >> t[i];
    s[i]--; t[i]--;
    ss[s[i]].push_back(i);
    tt[t[i]].push_back(i);    
  } 
  
  int ans = dij();
  if ( ans == -1 ) cout << "Cannot deliver" << endl;
  else cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 50080
/*
	*	Created By: 'Present_Sir'
	*	Created On: Saturday 22 August 2020 05:57:56 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;
const int N = 1e3+5;

void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cout << " " << to_string(H); 
	debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define db(...)  cout << "[" << #__VA_ARGS__ << "]:" , debug_out(__VA_ARGS__) 
#else
#define db(...)
#endif

int h,w,ch,cw,dh,dw;

vector < vector < char > > v(N, vector < char > (N));
vector < vector < bool > > vis(N, vector < bool > (N, 0)); 

bool valid(int i, int j){
    if(i<0 || j<0 || i>=h || j>=w || v[i][j] == '#'){
        return false;
    }
    return true;
}

void solve(){
    cin>>h>>w;
    cin>>ch>>cw;
    cin>>dh>>dw;
    --dh;
    --dw;
    --ch;
    --cw;
    for(int i=0; i<h; ++i){
        string s;
        cin>>s;
        for(int j=0; j<w; ++j){
            v[i][j] =s[j];
        }
    }
    int dx[] = { 0, 0, -1, 1 };
    int dy[] = { -1, 1, 0, 0 };
    int per[] = { -2, -1, 0, 1, 2 };
    vector < vector < int > > gr(h, vector < int > (w, (int)1e9));
    gr[ch][cw] = 0; 
    priority_queue < pair < int , pair < int, int > > > pq;
    pq.push( { 0, {ch, cw} } );
    //cout<<"!st"<<endl;
    while(!pq.empty()){
        auto top = pq.top().second;
        pq.pop();
        int x = top.first;
        int y = top.second;
        if(!vis[x][y]){
            vis[x][y] = true;
            //db(x,y); 
            for(int i=0; i<4; ++i){
                int nx = x+dx[i];
                int ny = y+dy[i];
                if(valid(nx,ny)){
                    gr[nx][ny] = min(gr[x][y],gr[nx][ny]);
                    pq.push( { -gr[nx][ny] , { nx, ny } } );
                }
            }
            for(int i=0; i<5; ++i){
                for(int j=0; j<5; ++j){
                    if(valid(x+per[i],y+per[j])){
                        int nx = x+per[i], ny = y+per[j];
                        gr[nx][ny] = min(gr[nx][ny], gr[x][y]+1);
                        pq.push( { -gr[nx][ny], { nx, ny } } );
                    }
                }
            }
        }
    }
    cout<<( (gr[dh][dw]>=(1e9))?-1:gr[dh][dw] )<<endl;
}   

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 13952
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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



// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {

  ll N,K;
  cin >> N >> K;

  string S;
  cin >> S;

  vint zeros, ones;
  bool prevzero = true;
  zeros.pb(0);
  ones.pb(0);


  rep(i,N){
    if(prevzero){
      if(S[i]=='0') *(zeros.end()-1)+=1;
      else{ones.pb(1); prevzero=false;}
    }else{
      if(S[i]=='1') *(ones.end()-1)+=1;
      else {zeros.pb(1); prevzero=true;}
    }
  }

  if(S[N-1]=='1') zeros.pb(0);
  ones.pb(0);

  // rep(i,zeros.size()) cout << zeros[i];
  // cout << endl;
  // rep(i,ones.size()) cout << ones[i];
  // cout << endl;

  ll ans = 0;

  if(zeros.size()<=K){cout << N << endl; return 0;}

  // rep(i,K){
  //   ans += ones[i];
  //   ans += zeros[i];
  // }

  ll i;
  for(i=0;i<K;i++){
    ans = ans + ones[i] + zeros[i];
  }
  ans += ones[i];



  ll tmp = ans;
  rep(j, zeros.size()-K){
    // tmp = tmp-zeros[j]+zeros[j+K]  -ones[j-1]+ones[j+K];
    // cout << "tmp before" << tmp << endl;
    // cout << ones[j] << " " << zeros[j] << " " << zeros[j+K] << " " << ones[j+K+1];
    tmp = tmp - ones[j] - zeros[j] + zeros[j+K] + ones[j+K+1];
    // cout << "tmp after" << tmp << endl;

    ans = max(ans, tmp);
  }




  cout << ans << endl;

}

















//


Measured memory_bytes: 1404
# -*- coding: utf-8 -*-
K = int(input())
target_list = [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(target_list[K - 1])

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

#define rep(s, e) for(int i(s); i < e; ++i)

#define N 100

int number_of_exchange(0);
void peek(int[], int);
void swap(int*, int*);
void bubble_sort(int[], int);

int main() {
    int n(0);
    int *A = new int[N];

    cin >> n;

    rep(0, n) {
        cin >> A[i];
    }

    bubble_sort(A, n);
    peek(A, n);
    cout << number_of_exchange << "\n";
    return 0;
}

void peek(int A[], int n) {
    rep(0, n) {
        if(i != 0) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << "\n";
}

void swap(int *a, int *b) {
    int tmp(*a);
    *a = *b;
    *b = tmp;
}

void bubble_sort(int A[], int n) {
    int flag(1);
    while(flag) {
        flag = 0;
        for(int j(n-1); j >= 1; --j) {
            if(A[j] < A[j-1]) {
                swap(A+j, A+(j-1));
                flag = 1;
                number_of_exchange++;
            }
        }
    }
}



Measured memory_bytes: 3120
//
// Created by rajshah9914 on 28/03/20.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  
  char s[100001];
  scanf("%s", s);
  
  int i, j;
  int ans = -1;
  int num = -1;
  int L;
  
  for( i = 0; i < 100001; i++ ){
    if( s[i] == '\0' ) {
      L = i;
      i = 100001;
    }
  }
  
  
  for( i = 0; i < L; i++ ){
    for( j = 1; j <= 2; j++ ){
      if( s[i] == s[i+j] ){
         ans = i+1;
         num = i+j+1;
         j = 3;
         i = 100001;
      }
    }
    
  }
  
  printf("%d %d", ans, num);
  
  
  return 0;

 
}       
       

Measured memory_bytes: 256
c = [None for x in range(3)]
for x in range(3):
  c[x] = list(map(int, input().split()))

ok = True

for x in range(2):
  ok = ok and (c[x][0]-c[x+1][0] == c[x][1]-c[x+1][1] == c[x][2]-c[x+1][2])

for x in range(2):
  ok = ok and (c[0][x]-c[0][x+1] == c[1][x]-c[1][x+1] == c[2][x]-c[2][x+1])

print ("Yes" if ok else "No")
    

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#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;

/*
	For integers x and y, if 1 < y < x, then gcd(x, y) = gcd(y, x%y)
*/
int gcd (int x, int y )
{
	if (x % y == 0 ) return y;

	if (x < y ) swap (x, y );

	return gcd (y, x % y );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.gcd", "r", stdin );
	int a, b;
	scanf ("%d %d", &a, &b );
	int res = gcd (a, b );
	printf ("%d\n", res );
		
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		// 所持しているカードの入力

		ArrayList<HashMap<String, String>> existCards = new ArrayList<>();

		for(int i=0; i<n; i++) {
			HashMap<String, String> card = new HashMap<>();
			card.put("mark", sc.next());
			card.put("rank", sc.next());
			existCards.add(card);
		}

		sc.close();

		// 抜けているカードを割り出す
		ArrayList<HashMap<String, String>> notExistCards = new ArrayList<>();

		// １つづつカードを調べる
		String marks[] = {"S", "H", "C", "D"};
		for(String mark : marks) {
			for(int i=1; i<=13; i++) {
				HashMap<String, String> checkCard = new HashMap<>();
				checkCard.put("mark", mark);
				checkCard.put("rank", String.valueOf(i));
				if(existCards.indexOf(checkCard) == -1) {
					notExistCards.add(checkCard);
				}
			}
		}

		// 出力
		for(HashMap<String, String> card : notExistCards) {
			System.out.print(card.get("mark") + " " + card.get("rank") + "\n");
		}

	}

}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  priority_queue<P,vector<P>,greater<P>> pq;
  for(int i=0;i<n;i++){
    int s,t;cin>>s>>t;
    pq.push(make_pair(t,-s));
  }
  int cnt=0,tot=0;
  while(!pq.empty()){
    P k=pq.top();pq.pop();
    if(tot!=k.first){
      cnt+=k.first-tot;
      tot=k.first;
    }
    cnt+=k.second;
    if(cnt<0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
  }


Measured memory_bytes: 6256
#include <iostream>

using namespace std;

int w, h;
int c[51][51];

bool valid(int i, int j) {
    return (0 <= i && i < h && 0 <= j && j < w);
}

void go(int y, int x) {
    if (c[y][x] == 0) return ;
    c[y][x] = 0;

    for (int i=y-1; i<=y+1; ++i) {
        for (int j=x-1; j<=x+1; ++j) {
            if (valid(i, j)) go(i, j);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);

    while (1) {
        cin >> w >> h;
        if (w == 0 && h == 0) break;

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

        int ans = 0;
        for (int i=0; i<h; ++i) {
            for (int j=0; j<w; ++j) {
                if (c[i][j]) {
                    go(i, j);
                    ans ++;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1304
s = input() #sys.stdin.readlineは最後が改行
t = input() #sys.stdin.readlineは最後が改行

ans= 1000

for i in range(len(s)-len(t)+1):
    tmp = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]: tmp+=1

    ans = min(ans,tmp)

print(ans)


Measured memory_bytes: 67368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll h,w,d;
string table = "RGBY";

int main(){
	cin >> h >> w >> d;
	vector<string> t;
	rep(i,5000){
		string s;
		rep(j,5000){
			if(i%(2*d) < d){
				if(j%(2*d) < d)s += "R";
				else s += "B";
			}
			else{
				if(j%(2*d) < d)s += "G";
				else s += "Y";
			}
		}
		t.push_back(s);
	}
	rep(i,h){
		rep(j,w){
			cout << t[500+i+j][500+i-j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 40448
#include <bits/stdc++.h>
#define ll long long
const ll mod = 1e9 + 7;
using namespace std;
int main(){
    ll n;
    cin >> n;
    ll power = 1;
    for(ll i=1;i<=n;i++) {
        power = power * i;
        power = power % mod;
    }
    cout<<power << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	m := intScanner()
	a := make([]int, m)
	b := make([]int, m)
	for i := 0; i < m; i++ {
		a[i] = intScanner()
		b[i] = intScanner()
		a[i]--
		b[i]--
	}
	u := newUnionFind(n)
	utl := make([]int, m)
	for i := m - 1; i >= 0; i-- {
		if !u.same(a[i], b[i]) {
			utl[i] = u.size(a[i]) * u.size(b[i])
			u.unite(a[i], b[i])
		}
	}
	for i := m - 2; i >= 0; i-- {
		utl[i] = utl[i] + utl[i+1]
	}
	x := n * (n - 1) / 2
	for i := 1; i < m; i++ {
		fmt.Println(x - utl[i])
	}
	fmt.Println(x)
}
type UnionFind struct {
	par []int
}

func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}
func (u UnionFind) root(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}
func (u UnionFind) unite(x, y int) {
	xr := u.root(x)
	yr := u.root(y)
	if xr == yr {
		return
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u UnionFind) same(x, y int) bool {
	if u.root(x) == u.root(y) {
		return true
	}
	return false
}
func (u UnionFind) size(x int) int {
	return -u.par[u.root(x)]
}


Measured memory_bytes: 9216
#include<stdio.h>

int main(){
    int i,j,k,a,n,b,f,r,room[5][4][11];
    signed int v;
    
    for(i=0;i<5;i++){
        for(j=0;j<4;j++){
            for(k=0;k<11;k++){
                room[i][j][k]=0;
            }
        }
    }
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d\n",&b,&f,&r,&v);
        room[b][f][r]+=v;
        
    }
    for(i=1;i<=4;i++){
        for(j=1;j<=3;j++){
            for(k=1;k<=10;k++){
                printf(" %d",room[i][j][k]);
            
            }
            printf("\n");
        }
       if(i<4) printf("####################\n");
        
    }
    return 0;
    
}


Measured memory_bytes: 2052
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<int> dy={-1,0,1,0},dx={0,-1,0,1};
V<int> g[200005];//サイズを変える
 int n,m;//mは辺の数
 V<ll> bfs(int s){
     V<ll> d(n,inf);
     d[s]=0;
     queue<P> q;
     q.emplace(s,-1);//cur par
while(q.size()){
    int cur=q.front().fi,par=q.front().se;
    q.pop();
    for(int v:g[cur]){
        // if(v==par)continue;
        // if(d[v]>d[cur]+1){
        //     d[v]=d[cur]+1;
        //     q.emplace(v,cur);
        // }
        if(d[v]==inf){
            d[v]=cur+1;
            q.emplace(v,cur);
        }
    }
}
    return d;
 }
int main(){
 cin>>n>>m;
for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    g[a-1].push_back(b-1);
    g[b-1].push_back(a-1);
    }
    V<ll> d=bfs(0);
    cout<<"Yes"<<"\n";
    for(ll v:d)if(v)cout<<v<<"\n";
}


Measured memory_bytes: 13928
//OPTIMIZATIONS
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
//#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//OPTIMIZATIONS
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long uu;
typedef long long int lll;
typedef unsigned long long int uuu;
using namespace std;

#define watch(x) cerr << "\n" \
                      << (#x) << " is " << (x) << endl
#define cel(x, y) 1 + ((x - 1) / y)
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const long long int INF = 0x3f3f3f3f3f3f3f3f;

/*
$alil03

URL: url

Solution Begins here
*/

lll power(lll b, lll e)
{
    lll ans = 1;
    for (int i = 0; i < e; i++)
    {
        ans = ((ans % 1000000007) * (b % 1000000007)) % 1000000007;
    }
    return (ans % 1000000007);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lll n;
    cin >> n;
    lll ans = (((power(10, n) % 1000000007) + (power(8, n) % 1000000007) - (2 * power(9, n) % 1000000007)) % 1000000007);
    if (ans < 0)
    {
        cout << ans + MOD;
    }
    else
    {
        cout << ans;
    }
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
    char c = getchar();x = 0;
    int neg = 0;
    for(; ((c<48 || c>57) && c != '-'); c = getchar());
    if(c=='-'){neg = 1;c = getchar();}
    for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/


const int N = 1001;
int main()
{
    long long n,d,m;
    cin >> n >> m >> d;
    if(d == 0) {
        printf("%.10lf\n", (m-1)*1./n);
    }
    else {
        printf("%.10lf\n", 2.*(m-1)*(n-d) / (n*n));
    }
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
a = []
b = []
c = []

for o in range(M):
    a_i, b_i, c_i = list(map(int, input().split()))
    a.append(a_i)
    b.append(b_i)
    c.append(c_i)


cost = [-float('inf') for i in range(N + 1)]
cost[1] = 0
flag = True

for _ in range(N - 1):
    for k in range(M):
        cost[b[k]] = max(cost[b[k]], cost[a[k]] + c[k])

cost_n = cost[N]

def check():
    for l in range(M):
        cost[b[l]] = max(cost[b[l]], cost[a[l]] + c[l])
    if cost[N] > cost_n:
        return 'inf'
    return cost[N]


print(check())


Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            String T = in.next();
            int ans = 0;

            if (S.charAt(0) == T.charAt(0)) ans++;
            if (S.charAt(1) == T.charAt(1)) ans++;
            if (S.charAt(2) == T.charAt(2)) ans++;


            // 出力
            out.println(ans);

        }

    }
}



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

int main(){
    string s;
    cin >> s;
    int ans = s.length()-1;
    for(; ; ans--){
        if(ans % 2 != 0) continue;
        bool isok = true;
        for(int i = 0; i < ans/2; i++){
            if(s[i] != s[ans/2+i]) isok = false;
        }
        if(isok) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

ll gcd(ll a,ll b) {
 ll ret=0;
 if(a*b!=0) ret=__gcd(a,b);
 else ret=max(a,b);
 return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,ans=0,ans_=0;cin>>n;
  lvector v(n,0),R(n+1,0),L(n+1,0);
  rep(i,n) cin>>v[i];
  for(ll i=0;i<n;++i) {
    L[i+1]=gcd(L[i],v[i]);
    R[n-1-i]=gcd(R[n-i],v[n-1-i]);
  }
  rep(i,n) {
    ans_=gcd(R[i+1],L[i]);
    if(ans_>ans) ans=ans_;
  } 
  print(ans);
  return 0;
}


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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
    cout << a << "\n";
}

int main(int argc, const char * argv[]) {

	// source code
    string s;
    cin >> s;
    s.push_back('X');
    string ss;
    for(ll i=0; i < s.size()-1; i++)
    {
        if(s[i]=='A'){
            ss.push_back('A');
        }
        else if(s[i]=='B' && s[i+1]=='C')
        {
            ss.push_back('D');
            i++;
            continue;
        }else
        {
            ss.push_back('X');    
        }
    }
    ll len=0;
    ll cnt=0;
    for(ll i=0; i < ss.size(); i++)
    {
        if(ss[i]=='A')
        {
            cnt++;    
        }else if(ss[i]=='D')
        {
            len+=cnt;
        }else{ //X
            cnt=0;
        }
    }
    
    cout << len << endl;
	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(int args, const char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    cout.tie(NULL);
    int nums, queries;
    cin >> nums >> queries;
    unordered_map<long long, int> inputMap;
    vector<long long> inputVec;
    vector<pair<long long, long long>> queryVec;
    for(int i = 0; i < nums; i++)
    {
        long long tmp;
        cin >> tmp;
        inputVec.push_back(tmp);
    }
    
    for(int i = 0; i < queries; i++)
    {
        long long start, end;
        cin >> start >> end;
        queryVec.push_back(make_pair(start, end));
    }
    
    sort(inputVec.begin(), inputVec.end());
    
    
    for(auto& it:queryVec)
    {
        cout << upper_bound(inputVec.begin(), inputVec.end(), it.second) - lower_bound(inputVec.begin(), inputVec.end(), it.first) << "\n";
    }

    return 0;
}


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

#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> v(N);
    int buf_a = 0;
    string buf_b = "";
    int ans = 0;
    int ansWA = 0;
    for (int i = 0; i < M; i++) {
        cin >> buf_a >> buf_b;
        if (v[buf_a - 1] >= 0) {
          if(buf_b == "WA"){
            v[buf_a - 1] = v[buf_a - 1] + 1;
          }else{
            ansWA +=   v[buf_a - 1];
            v[buf_a - 1] = -1;
            ans++;
          }
        }
    }
    cout << ans << " " << ansWA << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

ll f(pair<string,ll>&x ,pair<string,ll>&y) 
{
	if(x.first == y.first) 
	{
		return x.second>y.second;
	}
	else 
	{
		return x.first<y.first;
	}
}
 
void solve()
{
	ll a,b,t;
	cin>>a>>b>>t;
	ll ans=0,x=a;
	while(x<=t)
	{
		ans+=b;
		x+=a;
	}
	cout<<ans;
	return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int n, N;
vector<int> z;
long long gcd(long long x, long long y) {
	return y ? gcd(y, x % y) : x;
}
bool check() {
	printf("%d\n", z.size());
	long long s = 0;
	if (z.size() != N) {
		return false;
	}
	set<int> fuck(z.begin(), z.end());
	if (z.size() != fuck.size()) {
		printf("dup\n");
		return false;
	}
	for (int i: z) {
		if (i > 30000 || i < 1) {
			return false;
		}
		s += i;
	}
	for (int i: z) {
		if (gcd(i, s - i) == 1) {
			return false;
		}
	}
	return true;
}
int main() {
	cin >> n;
	N = n;
	if (n < 1000) {
		z.push_back(2);
		z.push_back(3);
		z.push_back(25);
		for (int i = 3; i < n; i++) {
			z.push_back((i - 2) * 30);
		}
	} else {
		n -= 3;
		z.push_back(2);
		z.push_back(3);
		z.push_back(25);
		if (n >= 3) {
			n -= 3;
			z.push_back(60 - 2);
			z.push_back(60 - 3);
			z.push_back(60 - 25);
		}
		for (int i = 1; i < 500; i++) {
			for (int j = 1; j < 30; j++) {
				if (gcd(j, 60) == 1) {
					continue;
				}
				if (n >= 2) {
					n -= 2;
					z.push_back(i * 60 + j);
					z.push_back(i * 60 + 60 - j);
				}
			}
		}
		for (int i = 1; i <= 1000; i++) {
			if (n >= 1) {
				n--;
				z.push_back(i * 30);
			}
		}
	}
//	assert(check());
	for (int i = 0; i < z.size(); i++) {
		printf("%d%c", z[i], i == z.size() - 1 ? '\n' : ' ');
	}
//	printf("OK\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll A,B,C;
  cin>>A>>B>>C;
  if(A==7&&B==5&&C==5) {
cout<<"YES"<<endl;
  }
  else if(A==5&&B==7&&C==5) {
cout<<"YES"<<endl;
  }
   else if(A==5&&B==5&&C==7) {
cout<<"YES"<<endl;
  }
  else {
cout<<"NO"<<endl;
  }
}
  

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

int exp(int &pos, string &str){
  int res = 0;
  pos++;

  if(str[pos] >= '0' && str[pos] <= '9'){
    while(str[pos] >= '0' && str[pos] <= '9'){
      res *= 10;
      res += str[pos] - '0';
      pos++;
    }
    res = (res + 1) / 2;
  } else {
    vector<int> v;
    while(str[pos] == '['){
      v.push_back(exp(pos, str));
      pos++;
    }
    sort(v.begin(), v.end());
    for(int i=0;i<(v.size()+1)/2;i++){
      res += v[i];
    }
  }

  return res;
}

int solve(string str){
  int pos = 0;
  return exp(pos, str);
}

int main(){
  int t;
  cin >> t;
  while(t--){
    string str;
    cin >> str;
    cout << solve(str) << endl;
  }
}

Measured memory_bytes: 1288
#include <cstdio>

bool is_alphabet(char data) {
	if ('a' <= data && data <= 'z') {
		return true;
	}
	return false;
}

int main(int argc, char *argv[]) {
	char msg[1000];
	fgets(msg, 500, stdin);
	for (int i = 0; i < 500; i++) {
		if (is_alphabet(msg[i])) {
			msg[i] -= 32;
		}
		if (msg[i] == '\0') {
			break;
		}
	}
	printf("%s", msg);
	
	return 0;
}

Measured memory_bytes: 0
A,B,C = gets.chomp.split.map(&:to_i)
K = gets.to_i
n = 0

while(B<=A) do
  B *= 2
  n += 1
end

while(C<=B) do
  C *= 2
  n += 1
end

if n<=K
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 14284
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(s[i]);
            sb.append(t[i]);
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007
ll ans;

void solve() {
    ll n, i = 1;
    cin >> n;
    while (n ^ 0) {
        n >>= 1;
        ans += i;
        i <<= 1;
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


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

struct node {
  node *nex[26];
  int tot[26];
  int sum;
  node() {
    memset(nex, 0, sizeof(nex));
    memset(tot, 0, sizeof(tot));
    sum = 0;
  }
} *root = new node;

string s[200005];

node *add(string &s) {
  node *cur = root;
  node *old = root;
  for (char c : s) {
    cur->sum++;
    int i = c - 'a';
    if (cur->nex[i] == nullptr)
      cur->nex[i] = new node;
    old = cur;
    cur = cur->nex[i];
  }
  cur->sum++;
  return old;
}

void comp(node *cur) {
  for (int i = 0; i < 26; i++) {
    if (cur->nex[i] == nullptr)
      continue;
    comp(cur->nex[i]);
    cur->tot[i] += cur->nex[i]->sum;
    for (int j = 0; j < 26; j++) {
      if (i == j) continue;
      cur->tot[j] += cur->nex[i]->tot[j];
    }
  }
}

int main() {
#ifdef LOCAL_EXEC
//  freopen("sample.in", "r", stdin);
#else
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#endif

  int n;
  cin >> n;
  node *pre[200005];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    reverse(s[i].begin(), s[i].end());
    pre[i] = add(s[i]);
  }
  comp(root);

  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += pre[i]->tot[s[i].back() - 'a'];
  }

  cout << sum - n << '\n';

	return 0;
}

Measured memory_bytes: 364952
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, Z, W; 
  cin >> N >> Z >> W;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  if(N == 1) cout << abs(W-A[N-1]) << "\n";
  else cout << max(abs(W-A[N-1]), abs(A[N-1]-A[N-2])) << "\n";

  return 0;
}

Measured memory_bytes: 256
n=int(input())
nums=list(map(int,input().split()))
mods=[]
for i in range(n):
  cnt=0
  while nums[i]%2==0:
    nums[i]//=2
    cnt+=1
  mods.append(cnt)
count2=sum(1 for i in mods if i>=2)
count0=sum(1 for i in mods if i==0)
if count2+count0==len(mods):
  if count2>=count0-1:
    print("Yes")
  else:
    print("No")
else:
  if count2>=count0:
    print("Yes")
  else:
    print("No")
  


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;

int p[N],q[N],r[N];
int32_t main()
{
    IOS;
    int x,y;
    cin>>x>>y;
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=a;i++)
    {
        cin>>p[i];

    }
    sort(p+1,p+a+1);
    reverse(p+1,p+a+1);
    for(int i=1;i<=b;i++)
    {
        cin>>q[i];
    }

    sort(q+1,q+b+1);
    reverse(q+1,q+b+1);
    for(int i=1;i<=c;i++)
    {
        cin>>r[i];
    }
    sort(r+1,r+c+1);
    reverse(r+1,r+c+1);
    multiset<int>s;
    int sum=0;
    for(int i=1;i<=x;i++)
    {
        s.insert(p[i]);
       // sum+=p[i];
    }
    for(int i=1;i<=y;i++)
    {
        s.insert(q[i]);
       // sum+=q[i];
    }
  //  cout<<sum<<endl;
    for(int i=1;i<=c;i++)
    {
        int k=*s.begin();
       // cout<<k<<" "<<r[i]<<endl;
        if(r[i]>k)
        {
            s.erase(s.find(k));
            s.insert(r[i]);
        }
    }
    for(auto it:s)
    {
        sum+=it;
    }
    cout<<sum<<endl;



}


Measured memory_bytes: 13696
a = int(input())
b = int(input())
c = int(input())
x = int(input())

n = 0

for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      if i * 500 + j * 100 + k * 50 == x:
        n += 1
        
print(n)

Measured memory_bytes: 3060