akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.ci", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;

	int i;
	for (i = 0; i < n; ++i){
		getline (cin, str );
		vector <double> cx (2, 0.0);
		vector <double> cy (2, 0.0);
		vector <double> r  (2, 0.0);
		stringstream ss(str);
		ss >> cx[0] >> cy[0] >> r[0] >> cx[1] >> cy[1] >> r[1];

		double d = sqrt ( (cx[1] - cx[0])*(cx[1] - cx[0]) + (cy[1] - cy[0])*(cy[1] - cy[0]) );
		if (d >= 0 && d < fabs (r[1] - r[0])){
			if (r[0] > r[1]){ // B in A
				cout << "2" << endl;
			}else if (r[0] < r[1]){ // A in B
				cout << "-2" << endl;
			}else{ // if (r[0] == r[1])
				cout << "1" << endl;
			} // end if
		}else if ( ( d >= fabs(r[1] - r[0]) ) && ( d <= r[0] + r[1] ) ){
			cout << "1" << endl;
		}else{
			cout << "0" << endl;
		} // end if
	} // end for
		
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>

using namespace std;

class DisjointSet
{
	public:
		vector<int> rank,p;
		
		DisjointSet(){}
		DisjointSet(int size)
		{
			rank.resize(size, 0);
			p.resize(size, 0);
			for(int i=0; i<size; i++)makeSet(i);
		}
		
		void makeSet(int x)
		{
			p[x]=x;
			rank[x]=0;
		}
		
		bool same(int x,int y)
		{
			return findSet(x)==findSet(y);
		}
		
		void unite(int x,int y)
		{
			link(findSet(x),findSet(y));
		}
		
		void link(int x,int y)
		{
			if(rank[x]>rank[y])
			{
				p[y]=x;
			}
			else
			{
				p[x]=y;
				if(rank[x]==rank[y])
				{
					rank[y]++;
				}
			}
		}
		
		int findSet(int x)
		{
			if(x!=p[x])
			{
				return findSet(p[x]);
			}
			return p[x];
		}
};


int main()
{
	int n,a,b,q;
	
	int t;
	cin>>n>>q;
	
	DisjointSet ds=DisjointSet(n);
	
	for(int i=0;i<q;i++)
	{
		cin>>t>>a>>b;
		if(t==0)ds.unite(a,b);
		else if(t==1)
		{
			if(ds.same(a,b))cout << 1 <<endl;
			else cout << 0 <<endl;
		}
	}
}


Measured memory_bytes: 3184
/*#pragma GCC optimize("Ofast") 
#pragma GCC target("avx,avx2,fma") 
#pragma GCC optimization("unroll-loops") */

#include<bits/stdc++.h>   
#include<tr1/unordered_map>
#define ll long long int   
#define pb push_back
#define mkp make_pair 
#define mod 1000000007 
#define maxn 100001 
#define ff first
#define ss second
using namespace std;    


int main(){    
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);     
  float n,x,t; 
  cin>>n>>x>>t; 
  cout<<int(ceil((n/x))*t);
  return 0;
}


Measured memory_bytes: 3728
#include "bits/stdc++.h"
using namespace std;

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

	if (s.at(0) == s.at(1) && s.at(1) != s.at(2) && s.at(2) == s.at(3)) {
		cout << "Yes" << endl;
	}
	else if (s.at(0) == s.at(2) && s.at(1) != s.at(2) && s.at(1) == s.at(3)) {
		cout << "Yes" << endl;
	}
	else if (s.at(0) == s.at(3) && s.at(1) != s.at(3) && s.at(1) == s.at(2)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    #define maxsiz 1000000
    #define F first
    #define S second
    #define fr(i,k,n) for(int i = k ; i < n ; i++ )
    #define mp(a,b) make_pair(a,b)
    #define pb(a) push_back(a)
    #define printvect(a,n) fr(i,0,n) cout << a[i] << " " ;
    #define point pair<int,int>
    #define pii pair<int,int>
    #define pib pair<int,bool>
    #define arr vector<int> 
    #define vectin(a,n) fr(i,0,n) { cin >> a[i] ; }
    typedef unsigned long long int ull;
     
    int main()
    {
    	string s;
    	ull n;
    	cin >> s >> n ;
     
    	ull k = n ; 
    	fr(i,0,s.length())
    	{
    		if( k >= (int)('z'-s[i])+1 )
    		{
    			k = k - ((int)('z'-s[i]) + 1)%26 ;
    			s[i] = 'a';
    		}
    		// cout << s << k << endl ;
    	}
    	
    	int a = (int)(s[s.length()-1]-'a') ;  
    	a = (a+k%26)%26 ;
    	s[s.length()-1] = (char)('a'+a) ;
    	cout << s << endl ;
    }

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//考察としては2点でできる最小の長方形からどんどん点を増やして大きくしてけばいい
//難しいのは実装だと思うから頑張ろう
int main(){
    ll LLINF = numeric_limits<ll>::max();
    int n,k;
    cin>>n>>k;
    vector<ll> x(n),y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    ll ans=LLINF;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
        for(int ii=0;ii<n;ii++){
        for(int jj=0;jj<n;jj++){
            ll
               xl=min(x[i],x[ii]),xr=max(x[i],x[ii]),
               yd=min(y[j],y[jj]),yu=max(y[j],y[jj]);
            int c=0;
               for(int k=0;k<n;k++){
                   if(xl<=x[k]&&x[k]<=xr&&yd<=y[k]&&y[k]<=yu) c++;
               }
            if(c==k) {ans=min(ans,(xr-xl)*(yu-yd));
            
            }
        }
    }
        }}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define inf 0x3f3f3f3f
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define mem(a,val) memset(a,val,sizeof(a))
#define mkp make_pair
#define all(n) (n).begin(),(n).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int a[]={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 x;
	cin>>x;
	cout<<a[x-1]<<endl;

}

Measured memory_bytes: 3568
#include<stdio.h>
#include<math.h>
int main(void)
{
    int a,b,sum;
    double y;
    scanf("%d",&a);
    scanf("%d",&b);
    if(b<10) sum=a*10+b;
    else if(b<100)sum=a*100+b;
    else sum=a*1000+b;
    y=sqrt((double)sum);
    if(y-(int)y)printf("No");
    else printf("Yes");
    return 0;
}


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){
return a<b?a:b;
}
template <typename T> 

T Max(T a,T b){
return a>b?a:b;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	ll n,k;cin>>n>>k; vl a(n); repi(i,n) cin>>a[i];
	vl dp(n,inf);
	dp[0]=0;
	for(int i=0;i<n;++i)  {for(int j=1;j<=k&&i+j<n;++j) dp[i+j]=Min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
	
	//db(dp[i]);
	}
	db(dp[n-1]); 
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define in insert
#define sz(x) ((in)(x).size())
using namespace std;
const int N = 1e5 + 123;


void read_file()
{
    freopen("text.in","r",stdin);
    freopen("text.out","w",stdout);
}

void solve()
{
    int a,b;
    scanf("%d%d", &a, &b);
    int sub = a-b;
    int sum = a + b;
    int mult = a * b;
    printf("%d\n", max(sub,max(sum,mult)));
}

int main()
{
    solve();
    //cerr << printf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
    return (0);
}




Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>

using namespace std;

typedef struct map<string, int> Mymap;

void disp(Mymap &obj, int cn) {
  Mymap::iterator p;
  for(p=obj.begin(); p!=obj.end(); ++p) {
    if((p->first).length()==cn)
      cout << p->first << " " << p->second << endl;
  }
}


int main() {
  int num;
  Mymap val;

  // input
  scanf("%d", &num);
  for(int i=0; i<num; i++) {
    string tmpS;
    cin>>tmpS;
    int tmpI;
    cin>>tmpI;
    if(val.find(tmpS)==val.end()) {
      val.insert(make_pair(tmpS, tmpI));
    }
    else {
      val[tmpS]+=tmpI;
    }
  }
  // sort不要

  // output
  for(int i=1; i<6; i++) {
    disp(val, i);
  }
}

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

int main()
{
	int n, y;
	cin >> n >> y;
	y /= 1000;
	int a, b, c;
	a = b = c = -1;
	for(auto i = 0; i <= n; ++i){
		if(i * 10 > y) break;
		for(auto j = 0; j <= n - i; ++j){
			if(i * 10 + j * 5 > y) break;
			if(i * 10 + j * 5 + n - i - j == y){
				a = i;
				b = j;
				c = n - i - j;
				break;
			}
		}
		if(a != -1) break;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

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

int main(){
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for(int i = 0; i < N; i++){
        std::cin >> a[i];
    }
    
    std::sort(a.begin(), a.end());

    std::cout << a[N - 1] - a[0] << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main() 
{
    int n,mi=INF,sum;
    cin>>n;
    int x[n],a[n][100]={0};
    rep(i,n){
        cin>>x[i];
        rep(j,100)a[i][j]=(x[i]-j-1)*(x[i]-j-1);
    }
    rep(j,100){
        sum=0;
        rep(i,n)sum+=a[i][j];
        if(mi>sum)mi=sum;
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 256
from itertools import product
H, W = map(int, input().split())
S = [["."] * (W + 2)]
for _ in range(H):
    s = ["."] + list(input()) + ["."]
    S.append(s)
S.append(["."] * (W + 2))

ans = []
deltas = list(product((0, 1, -1), (0, 1, -1)))
del deltas[0]


def count(S, i, j):
    if i <= 0 or i >= H + 1 or j <= 0 or j >= W + 1:
        return "error"
    c = 0
    for d_i, d_j in deltas:
        if S[i + d_i][j + d_j] == "#":
            c += 1
    return c


def print_grid(G):
    for i in range(len(G)):
        print("".join(G[i]))
    return


for i in range(1, H + 1):
    ans_row = []
    for j in range(1, W + 1):
        if S[i][j] == "#":
            ans_row.append("#")
        else:
            ans_row.append(str(count(S, i, j)))
    ans.append(ans_row)

# print_grid(S)
print_grid(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

int n, i, x, y;
int sg[maxN];
vector<int> list[maxN];

void dfs(int node, int root) {
    for (auto to : list[node]) {
        if (to == root) continue;
        dfs(to, node);
        sg[node] ^= 1 + sg[to];
    }
}

int main()
{
 //   freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i < n; i++) {
        scanf("%d%d", &x, &y);
        list[x].pb(y);
        list[y].pb(x);
    }

    dfs(1, 0);
    if (sg[1])
        printf("Alice");
    else
        printf("Bob");


    return 0;
}


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

int main()
{
    int a, b, c; //入力
    int x, y, z; //一時格納用

    cin >> a >> b >> c;

    if (a > b)
    {
        x = b, y = a;
        a = x, b = y;
    }
    if (b > c)
    {
        y = c, z = b;
        b = y, c = z;
    }
    if (a > b)
    {
        x = b, y = a;
        a = x, b = y;
    }

    cout << a << " " << b << " " << c << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#include <sstream>
#include <fstream>
ifstream ifs;
void init(string s){ifs.open(s);}
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while(getline(ss, buffer, sep)) v.push_back(buffer);
    return v;
}
ll read(){
  string str;
  getline(ifs, str);
  return stoll(str);
}
string read_str(){
  string str;
  getline(ifs, str);
  return str;
}
vector<ll> read_vec(){
  string str;
  getline(ifs, str);
  std::vector<ll> num;
  vector<string> data = split(str, ' ');
  for(int i=0;i<data.size();i++) num.push_back(stoll(data[i]));
  return num;
}
vvl read_mat(ll h){
  string str;
  vvl num = vv(h, 0, 0, ll);
  for(int i=0;i<h;i++){
    getline(ifs, str);
    vector<string> data = split(str, ' ');
    for(int j=0;j<data.size();j++) num[i].push_back(stoll(data[j]));
  }
  return num;
}
//-------------------------------------------------------------------

int main(int argc, char const *argv[]) {
  init("1.in");
  ll n;std::cin >> n;
  //n = read();
  vector<ll> p(n); //p = read_vec();
  re(i, n) std::cin >> p[i];
  sort(p.begin(), p.end());
  ll r = p[n-1];
  ll t = 0;
  re(i, n-1) {
    if(min(t, r-t)<=min(p[i], r-p[i])) t = p[i];
  }
  std::cout << r << " " << t << '\n';
  return 0;
}


Measured memory_bytes: 1024
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, = gi()
a = gi()
print("YNEOS"[len(set(a)) != n::2])

Measured memory_bytes: 26576
N, M, X = map(int, input().split())

C = []
A = []
for i in range(N):
    line = list(map(int, input().split()))
    C.append(line[0])
    A.append(line[1:])

ans = -1

# 1冊目を買う/買わない、...、N冊目を買う/買わない
# 選び方は2**N通り
for i in range(1 << N):

    study = [0] * M
    cost = 0

    # 買った本にはビットが立っている
    # ex. 011 なら１、2冊目を買って3冊目を買わない
    for j in range(N):

        # j+1冊目を買った場合(j=0,1,...,N-1)
        if (i >> j) & 1:
            cost += C[j]

            # j+1冊目による理解度向上
            for m in range(M):
                study[m] += A[j][m]

    # 全ての理解度がX以上の場合
    if min(study) >= X:
        if ans == -1:
            ans = cost
        else:
            ans = min(ans, cost)

print(ans)


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

using namespace std;

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

    stack <char> st;

    st.push(S[0]);
    for(int i = 1; i<S.length(); i++){
        if (!st.empty()){
            if (st.top() != S[i]) st.pop();
            else st.push(S[i]);
        }else st.push(S[i]);
    }

    cout << S.length() - st.size();
    return 0;
}



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

void dfs(int c, int p, vector<vector<int>> &g, vector<int> &cst){
    cst[c]+=cst[p];
    for(int i=0;i<g[c].size();i++){
        if(g[c][i]==p) continue;
        dfs(g[c][i], c, g, cst);
    }
}

int main(){
    // freopen("i.txt", "r", stdin);
    // freopen("o.txt", "w", stdout);
    int v,q;
    cin>>v>>q;
    vector<vector<int>> g(v+1);
    vector<int> cst(v+1, 0);
    int a,b;
    for(int i=1;i<v;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        cin>>a>>b;
        cst[a]+=b;
    }
    dfs(1, 0, g, cst);
    for(int i=1;i<cst.size();i++)
        cout<<cst[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int k,a,b;
  cin >> k >> a >>b;//a=1円交換レート
  ll bis=1;
  int money=0;
  rep(i,k){
    if (money>0){
      money--;
      bis+=b;
    }
    else if(bis>=a && a<b &&(b-a)>2 &&(k-i)>1){
      money++;
      bis-=a;
    }
    else {
      bis++;
    }
  }
  cout << bis <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>

using namespace std;

const double PI = 3.141592653589;

int main(int argc, char **argv)
{
	double x;
    cin>>x;
    cout.setf(ios::fixed);
    cout<<setprecision(6)<<PI*x*x;
    cout<<' ';
    cout<<setprecision(6)<<2*PI*x;
    
    //cin>>x;
	return 0;
}

Measured memory_bytes: 3252
#include<stdio.h>

int main(void)

{

   int W,H,x,y,r;

   scanf("%d %d",&W,&H);

   scanf("%d %d",&x,&y);

   scanf("%d",&r);

   if(W >= x+r && 0<= x-r && H >= y+r && 0 <= y-r)

   {

      printf("Yes\n");

   }

   else

   {

      printf("No\n");

   }

   return 0;

}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<bool> b(n);
  for (int i = 0; i < k; i++) {
    int d; cin >> d;
    for (int j = 0; j < d; j++) {
      int t; cin >> t;
      b[t - 1] = 1;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cnt += !b[i];
  }
  cout << cnt << '\n';
}


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

int main(void){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> vec(n);
    for(int i=0;i<n;i++) cin >> vec[i].first >> vec[i].second;
    sort(vec.begin(),vec.end());

    int now = 0;
    ll yen = 0;
    while(m>0){
        m--;
        yen += vec[now].first;
        if(--vec[now].second == 0) now++;
    }
    cout << yen << endl;


}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, 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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n;
	cin >> n;
	Vi D1(n), D2(n);
	rep(i, n) {
		cin >> D1[i] >> D2[i];
	}

	Vb J(n, false);
	rep(i, n) {
		if (D1[i] == D2[i]) J[i] = true;
	}

	int t = 0;
	rep(i, n) {
		if (J[i]) t++;
		else t = 0;
		if (t == 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3628
def actual(a, b, c, k):
    x_a = min(a, k)

    k -= x_a

    x_b = min(b, k)
    k -= x_b

    x_c = k  # min(c, k)

    score = x_a - x_c

    return score
                
A, B, C, K = [int(x) for x in input().split()]

print(actual(A, B, C, K))

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll f[1000005], fi[1000005];

ll comb(int r, int c) {
    if (r < c) return 0;
    return f[r] * fi[c] % MOD * fi[r - c] % MOD;
}

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

    if (n == 2) {
        cout << 1 << endl;
        return 0;
    } else if (n == 3) {
        cout << 4 << endl;
        return 0;
    }

    f[0] = 1;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;

    fi[n] = modpow(f[n], MOD - 2);
    for (int i = n; i > 0; i--) {
        fi[i - 1] = fi[i] * i % MOD;
    }

    ll ans = 0, prv = 0;
    for (int i = 1; i < n; i++) {
        ll cur = comb(i - 1, n - 1 - i) * f[i] % MOD * f[n - 1 - i] % MOD;
        (ans += (cur + MOD - prv) * i % MOD) %= MOD;
        prv = cur;
    }
    cout << ans << endl;
    return 0;
}

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

#define SWAP(a, b) { int x=(a); (a)=(b); (b)=x; }

double left(double x, double y, double r) { return x-r; }
double right(double x, double y, double r) { return x+r; }
double bottom(double x, double y, double r) { return y-r; }
double top(double x, double y, double r) { return y+r; }

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if(left(x,y,r) < 0 || bottom(x,y,r) < 0
		|| right(x,y,r) > W || top(x,y,r) > H)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll t1[6],t2[6];
int main(){
    ll n,m,ans=1e9;
    cin>>n>>m;
    rep(i,0,m)cin>>t1[i]>>t2[i];
    ll m1=powl(10,n),m2=powl(10,n-1);
    if(n==1)m2=0;
    rep(i,m2,m1){
        string t3=to_string(i);
        bool t4=true;
        rep(i,0,m){
            if(t1[i]>n)t4=false;
            char x=t3[t1[i]-1];
            ll y=x-'0';
            if(y!=t2[i])t4=false;
        }
        if(t4){ans=i;break;}
    }
    if(ans==1e9)cout<<-1;
    else cout<<ans;
}


/*
char r[9][9];
ll p[9][9];
vector<ll> tpos,ypos;
int main(){
    ll pi,pj;
    bool tate=true,yoko=true,ans=true;
    rep(i,0,8){
        tate=true;
        rep(j,0,8){
            cin>>r[i][j];
            if(r[i][j]=='Q')tate=false;
        }
        if(tate)tpos.pb(i);
    }
    rep(i,0,8){
        yoko=true;
        rep(j,0,8){
            if(r[j][i]=='Q')yoko=false;
        }
        if(yoko)ypos.pb(i);
    }
    if(tpos.size()!=5||ypos.size()!=5)ans=false;

    if(!ans)cout<<"No Answer";
    else{
    rep(i,0,5){
      rep(j,0,5){
        rep(k,0,5){
          rep(l,0,5){
            rep(m,0,5){
                tate=true;
                pi=i,pj=pos[0];
                if(p[pi][pj]>0)tate=false;
                rep(x,0,8)if(r[pi][x]=='Q'||p[pi][k]==100)tate=false;
                rep(x,0,8)if(r[x][pj]=='Q'||p[x][pj]==100)tate=false;
                pi=i-1,pj=j-1;
                while(pi>=0&&pj>=0){p[pi][pj]++;pi--;pj--;}
                pi=i+1,pj=j+1;
                while(pi<8&&pj<8){p[pi][pj]++;pi++;pj++;}
                pi=i-1,pj=j+1;
                while(pi>=0&&pj<8){p[pi][pj]++;pi--;pj++;}
                pi=i+1,pj=j-1;
                while(pi<8&&pj>=0){p[pi][pj]++;pi++;pj--;}
            }
          }
        }
      }
    }
    }

    rep(i,0,8){
      rep(j,0,8){
        cout<<p[i][j];
      }
      cout<<endl;
    }
}*/

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            //List<Integer> list = new ArrayList<>();
            int[] array = new int[N];
            for (int i = 0; i < N; i++) {
                array[i] = in.nextInt();
            }
            //List<Integer> answerList = list.stream().sorted().collect(Collectors.toList());
            int[] answerArray = Arrays.stream(array).sorted().toArray();
            int[] swapArray = Arrays.copyOf(array, N);

            if (Arrays.equals(answerArray, swapArray)) {
                out.println("YES");
                return;
            }

            for (int i = 0; i < N; i++) {
                int tmpNum = array[i];
                for (int j = i + 1; j < N; j++) {
                    swapArray[i] = swapArray[j];
                    swapArray[j] = tmpNum;
                    if (Arrays.equals(answerArray, swapArray)) {
                        out.println("YES");
                        return;
                    }
                    swapArray[j] = swapArray[i];
                    swapArray[i] = tmpNum;
                }
            }
            //System.out.println("NO");
            out.println("NO");
        }

    }
}



Measured memory_bytes: 28624
import java.io.*;
 
class Main{
    public static void main(String[] args) throws java.io.IOException {
 
        BufferedReader input = new BufferedReader(new InputStreamReader(
                System.in));
        StringBuilder str = new StringBuilder();
 
        int i = 0;
 
        while (true) {
            i++;
            String tmp = input.readLine();
            int x = Integer.parseInt(tmp);
 
            if (x == 0)
                break;
 
            str.append("Case " + i + ": " + x + "\n");
 
        }
 
        System.out.print(str);
 
    }
}

Measured memory_bytes: 27124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
using namespace std;
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<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//pow(x,n) == x^n
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

string s;
cin >> s;
int count = 0;
if(s.length()%2 == 0){
    rep(i,s.length()/2){
        if(s[i] != s[s.length()-1-i]) count++;
    }
}else{
    rep(i,s.length()/2){
        if(s[i] != s[s.length()-1-i]) count++;
    }
}
cout << count << endl;


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    counter = 0
    for c1, c2 in zip(S, S[::-1]):
        if c1 != c2:
            counter += 1
    print(counter//2)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
def nyu():
    num1,num2 = input().split()
    num1 = int(num1)
    num2 = int(num2)
    return num1,num2

def check(num1,num2):
    sum = num1*num2
    
    if sum %2 != 0:
        print("Odd")
    else :
        print("Even")

a,b= nyu()
check(a,b)




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

using namespace std;

int main(){
    int a[3];
    for(int i = 0;i < 3;i++){
        cin >> a[i];
    }
    sort(a, a+3);
    if(a[0] == a[1] && a[1] != a[2]){
        cout << "Yes";
    }
    else if(a[0] != a[1] && a[1] == a[2]){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}


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



struct F{
    int number;
    string name;
    int score;
};

bool comp(F a,F b){
    if(a.name == b.name) return a.score > b.score;
    else return a.name < b.name;
}

int main() {
    int n;
    cin >> n;
    vector<F> v(n);

    for(int i = 0; i < n; ++i){
        v[i].number = i + 1;
        cin >> v[i].name >> v[i].score;
    }

    sort(v.begin(),v.end(),comp);

    for(int i = 0; i < n; ++i){
        cout << v[i].number << endl;
    }
}


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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>>a[i];
  
  int ans=0;
  for (auto d : a){
    int t_ans=0;
    while (d%2==0){
      d/=2;
      t_ans+=1;
    }
    ans+=t_ans;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
#endif

	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a.begin(),a.end());

	ll count=0;

	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			int sum=a[i]+a[j];

			auto it=lower_bound(a.begin(),a.end(),sum);

			if(it==a.end())
			{
				count+=n-j-1;
			}
			else
			{
				int ind=it-a.begin();
				count+=ind-j-1;
			}


		}
	}

	cout<<count<<endl;

	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int a[5010];
bool b[5010];
int main()
{
	int n,k;
	int sum=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=min(a[i],k);
		sum+=a[i];
	}
	sort(a+1,a+n+1);
	b[0]=1;
	for(int i=n;i>=0;i--)
	{
		bool f=0;
		for(int j=k-1;j>=k-sum&&j>=0;j--)
			if(b[j])
			{
				f=1;
				break;
			}
		if(!f)
		{
			cout<<i;
			return 0;
		}
		for(int j=k;j>=a[i];j--)
			if(b[j-a[i]]==1)
				b[j]=1;
		sum-=a[i];
	}
	return 0;
}


Measured memory_bytes: 256
s = input()
k = int(input())

A = []
for i in range(len(s)):
    for j in range(k):
        if i+j+1 > len(s):
            continue
        tmp = s[i:i+j+1]
        A.append(tmp)

A = sorted(list(set(A)))
print(A[k - 1])

Measured memory_bytes: 5068
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
#define ll long long
int n;
string ss;
vector<int> now;
ll ans;
void dfs(int cur)
{
    if(cur==n-1)
    {
        now.push_back(n-1);
        ll pre=0; int last=-1;
        for(int i=0;i<(int)now.size();i++)
        {
            for(int pos=last+1;pos<=now[i];pos++)
                pre=pre*(ll)10+(ll)(ss[pos]-'0');
            last=now[i]; ans+=pre; pre=0;
        }
        now.pop_back();
        return;
    }
    dfs(cur+1);
    now.push_back(cur);
    dfs(cur+1);
    now.pop_back();
    return;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>ss;
    n=(int)ss.length();
    dfs(0);
    cout<<ans<<'\n';
    return 0;
}


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

int main()
{
   int a ,b  ;
   cin >> a >> b ;
   int ans = 0;
   int sum = a+b ;

  if(sum % 2== 0 ){
      ans = sum / 2;
      cout << ans << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
    return 0;
}


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

namespace AtCoderMake.ABC167
{
    class ABC167A
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            if (s==t.Substring(0,t.Length-1))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 25796
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int DP[1005][(1<<13)];

int main() {
  for(int i=0;i<1005;++i) {
    for(int j=0;j<(1<<13);++j) {
      DP[i][j] = inf;
    }
  }
  int N, M;
  cin>>N>>M;
  int a[M], b[M];
  vector<vector<int> > c(M);
  int tmp;
  for(int i=0;i<M;++i) {
    cin>>a[i]>>b[i];
    for(int j=0;j<b[i];++j) {
      cin>>tmp;
      tmp--;
      c[i].push_back(tmp);
    }
  }
  tmp = 0;
  for(int i=0;i<c[0].size();++i) {
    tmp += (1<<(c[0][i]));
  }
  DP[0][0] = 0;
  DP[0][tmp] = a[0];
  for(int i=0;i<M-1;++i) {
    for(int j=0;j<(1<<N);++j) {
      if(DP[i][j]==inf) continue;
      DP[i+1][j] = min(DP[i+1][j], DP[i][j]);
      tmp = j;
      for(int k=0;k<c[i+1].size();++k) {
        if((tmp&(1<<c[i+1][k]))==0) tmp += (1<<c[i+1][k]);
      }
      DP[i+1][tmp] = min(DP[i+1][tmp], DP[i][j]+a[i+1]);
    }
  }
  if(DP[M-1][(1<<N)-1]==inf) cout<<-1<<endl;
  else cout<<DP[M-1][(1<<N)-1]<<endl;
}


Measured memory_bytes: 35832
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(), (a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//
int main() {
	int N;
	cin >> N;
	Vec< string > S(N);
	Vec< int > P(N);
	for_(i,0,N) cin >> S[i] >> P[i];
	Vec< int > id(N);
	iota(allof(id), 0);
	sort(allof(id), [&](int i, int j) {
		if (S[i] < S[j]) return true;
		if (S[i] == S[j]) return P[i] > P[j];
		return false;
	});
	for_(i,0,N) cout << id[i] + 1 << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(abs(a-b)+abs(b-c), min(abs(b-c)+abs(c-a), abs(c-a)+abs(a-b))) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int n, k;
	cin >> n >> k;
	ll res = 0;
	ll curr = n / k;
	res += (ll)curr * curr * curr;
	if(k == 1){
			cout << res << endl;
			return 0;
	}
	if(n == 1){
			cout << 0 << endl;
			return 0;
	}
	if(k % 2 == 0){
			curr = max((n - k / 2) / k + 1, 0);
			res += (ll)curr * curr * curr;
	}
	cout << res << endl;
	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int max = 0, min = 123, tmp;
  REP(i, 5) {
    tmp = read();
    chmax(max, tmp);
    chmin(min, tmp);
  }
  int k = read();
  if (max - min <= k)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int ans(int prev,int i,vector<vector<int>>&v,vector<vector<int>>&dp){
    if(i>=v.size())return 0;
    if(dp[i][prev+1]!=-1)return dp[i][prev+1];
    int res = INT_MIN;
    for(int j=0;j<3;j++){
        if(j!=prev)res = max(res,v[i][j]+ans(j,i+1,v,dp));
    }
    return dp[i][prev+1]=res;
}
int main(){
    int n;
    cin>>n;
    vector<vector<int>>v(n,vector<int>(3));
    for(int i=0;i<n;i++)
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    
    vector<vector<int>>dp(n,vector<int>(4,-1));
    cout<<ans(-1,0,v,dp);
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n;
    stack<int> a;
    
    cin >> n;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        a.push(x);
    }
    cout << a.top();
    a.pop();
    while(!a.empty()){
        cout << " " << a.top();
        a.pop();
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3092
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


A, P = map(int, input().split())
print((A * 3 + P) // 2)


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define reg(i,a,b) for(ll i=a;i<=b;i++)
#define reh(i,a,b) for(int i=a;i>b;i--)
#define in(x) scanf("%d",&x)
#define fro freopen("D:\\testdata.in", "r", stdin)
#define il inline
#define lson(q) q<<1
#define rson(q) q<<1|1
using namespace std;
typedef long long ll;
const int mx=2e9;
int ans;

int main() {
	int a,b,t;
	scanf("%d%d%d",&a,&b,&t);
	for (int i=1;i*a<=t;++i) {
	    ans+=b;
	}
	printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> H(N);
    REP(i, N) {
        cin >> H[i];
    }
    int m = H[0];
    REP(i, N) {
        if (m - 1 > H[i]) {
            cout << "No" << endl;
            return 0;
        }
        amax(m, H[i]);
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    long long u = 1LL << 60;
    long long k = 0;
    long long ans = 0;
    while(u > 0){
        int one = 0;
        int zero = 0;
        for(int i = 0; i < N; i++) ((A[i] & u) ? one : zero)++;
        // cout << u << " " << zero << " " << one << endl;
        if(zero > one && k + u <= K){
            k += u;
            ans += zero * u;
        }else{
            ans += one * u;
        }
        u >>= 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int x=sc.nextInt();
		int y=sc.nextInt();
  		int[] a=new int[n-1];
  		int e=0;
  		int m=0;
  
  		for(int c=1;c<=n;c++){
        for(int d=c+1;d<=n;d++){
        	if(c<=x&&y<=d){
            	a[(d-y)+1+(x-c)-1]++;
            }else if(c<=x&&d<=x){
            	a[d-c-1]++;
            }else if(c<=x&&x<d){
            	 e=(x-c)+1+(y-d);
               m=Math.min(e,(d-c));
              a[m-1]++;
            }else if(c>=y&&d>=y){
            	a[d-c-1]++;
            }else if(c>x&&d<=y){
            	e=(c-x)+1+(y-d);
                m=Math.min(e,(d-c));
              	a[m-1]++;
            }else{
            	e=(c-x)+1+(d-y);
                m=Math.min(e,(d-c));
              	a[m-1]++;
            }
        }
        }

  
  		for(int ans:a){
        System.out.println(ans);
        }
    }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main(){
    int r,g,b,n; cin >> r >> g >> b >> n;
    int count = 0;
    int m = n;
    vector<int> B(m + 1);
    rep(i,m + 1) B[i] = i * b;

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            if(binary_search(B.begin(), B.end(), n - r * i - g * j)){
                count++;
                //cout << i << " " << j << " " << (n - r * i - g * j) / b << endl;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using ll = long long;
using namespace std;

const long long MOD = 1000000007;
const ll LINF = 1LL << 50;


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> hn(100010, 0);
  vector<ll> dp(100010, LINF);
  
  REP(n,N) cin >> hn.at(n);

  dp.at(0) = 0;
  for (int n = 1; n < N; n++){
    chmin(dp.at(n), dp.at(n-1)+abs(hn.at(n)-hn.at(n-1)));
    for (int m = n-K; m < n; m++){
      if (m >=0) chmin(dp.at(n), dp.at(m)+abs(hn.at(n)-hn.at(m)));
    }
  }

  cout << dp.at(N-1) << endl;

}


Measured memory_bytes: 1792