akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int n;
  int ans = 0;
  bool hoge = true;
  string str[105];
  cin >> n;
  FOR(i,n){
    cin >> str[i];
    FOR(j,i){
      if(str[i] == str[j]) hoge = false;
    }
    if(i){
      int blen = str[i-1].length();
      if(str[i-1][blen-1] != str[i][0]) hoge = false;
    }
  }
  if(hoge) cout <<"Yes\n";
  else cout << "No\n";
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
from collections import Counter
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)

rec = []
squ = []

for a in A:
    if 2 <= C[a]:
        rec.append(a)
    if 4 <= C[a]:
        squ.append(a)
rec = list(set(rec))
squ = list(set(squ))
# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = max(squ)**2

if len(rec) < 2:
    print(s)
else:
    rec.sort(reverse=True)
    print(max(s, rec[0]*rec[1]))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
#define SoArrt(a, n) sort(a, a + n);
#define SoArrtR(a, n) sort(a, a + n, std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll a, b;

	cin >> a >> b;

	if ((a < 0) ^ (b < 0) == 1) {
		Out("Zero");
	} else {
		if (0 < a) {
			Out("Positive");
		} else {
			int neg;
			
			if (b < 0) neg = Abs(a) - Abs(b) + 1;
			else neg = Abs(a);

			if (neg % 2 == 0) Out("Positive");
			else Out("Negative");
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
  vector<int>K;
  int sum=0;
  for(int i=0;i<n;i++){
      int x;
      cin>>x;
      sum=sum+x;
      K.push_back(x);
      
  }
 
  int y=0;
  int c=0;
  int min=sum;
  for(int j=0;j<n-1;j++){
     y=y+K[j];
     c =sum-y;
     int x=y-c;
     if(x<0){
         x=-x;
     }
     if(x<min){
         min=x;
     }

     
  }


   cout<<min; 
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){

	int i,n;
	int array[100];
	cin >> n;

	for(i=0;i<n;i++){
		cin >> array[i];
	}
	for(i=n-1;i>=0;i--){
		cout << array[i];
		if(i==0)break;
		cout << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
int main(){

  int a,i,minj,A[100],c,count,j;
  scanf("%d",&a);
  for(i=0;i<a;i++)scanf("%d",&A[i]);
  
  for (i=0;i<a;i++){
    minj = i;
    for (j=i;j<=a-1;j++){
      if (A[j] < A[minj]){
        minj = j;
      }
    }
    if(minj!=i){
	c=A[i];
	A[i]=A[minj];
	A[minj]=c;
	count++;
    }
    
  }
  for(i=0;i<a;i++){
    if(i!=a-1)printf("%d ",A[i]);
    else printf("%d\n%d\n",A[i],count);
  }

}



Measured memory_bytes: 2760
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007

int main(){
    int N; cin >> N;
    vector<vector<int>> dp(N, vector<int>(3));
    for(int i=0; i<N; i++){
        int a, b, c; cin >> a >> b >> c;
        if(i==0){
            dp[i][0] = a;
            dp[i][1] = b;
            dp[i][2] = c;
        }else{
            dp[i][0] = max(dp[i-1][1]+a, dp[i-1][2]+a);
            dp[i][1] = max(dp[i-1][0]+b, dp[i-1][2]+b);
            dp[i][2] = max(dp[i-1][0]+c, dp[i-1][1]+c);
        }
    }
    cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 5760
N, W = map(int, input().split())
wv = []
for _ in range(N):
    wv.append(tuple(map(int, input().split())))
w0, v0 = wv[0]
L = (N+1) * 3
dp = [[-1] * L for _ in range(N + 1)]
dp[0][0] = 0
for w,v in wv :
    for k in range(N-1, -1,  -1):
        for t in range(len(dp[k])):
            if dp[k][t] >= 0:
                dp[k+1][t+w-w0] = max(dp[k][t] + v, dp[k+1][t + w - w0])
ans = 0
for k in range(N+1):
    if w0 * k  > W : continue
    ans = max(max(dp[k][:max(min(L, W - w0 * k + 1), 0)]), ans)
print(ans)


Measured memory_bytes: 3468
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N, L;
    read(N, L);

    vector<string> s(N);
    rep(i, N) read(s[i]);

    sort(all(s));
    string ans = "";
    rep(i, N) ans += s[i];

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> combination_table(int N) {
  vector<vector<long long>> C(N+1,vector<long long>(N+1));
  for (int i = 0; i <= N; i++) {
    C[i][0] = 1;
    C[i][i] = 1;
    for (int j = 1; j < i; j++) {
      C[i][j] = C[i-1][j-1]+C[i-1][j];
    }
  }
  return C;
}
int main() {
  int N,A,B,X=0,Y=0;
  cin >> N >> A >> B;
  if (A > B)  {
    cout << "0\n0";
    return 0;
  }
  long long v[N],answer=0;
  double average=0;
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v,v+N,greater<long long>());
  for (int i = 0; i < A; i++) {
    average += v[i];
    Y += v[A-1] == v[i];
  }
  for (int i = 0; i < N; i++) {
    X += v[A-1] == v[i];
  }
  average /= A;
  cout.precision(20);
  cout << fixed << average << endl;
  vector<vector<long long>> C = combination_table(N);
  if (v[0] == v[A-1]) {
    for (Y = A; Y <= B; Y++) {
      answer += C[X][Y];
    }
  } else {
    answer += C[X][Y];
  }
  cout << answer;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep( i, n ) for( int ( i ) = 0; ( i ) < ( n ); ( i )++ )
#define repr( i, n ) for( int ( i ) = ( n ); ( i ) >= 0; ( i )-- )
#define FOR( i, m, n ) for( int ( i ) = ( m ); ( i ) < ( n ); ( i )++ )
#define all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;

int main( void ){
	
	lint n, l, max, sum;
	
	max = 0;
	
	sum = 0;
	
	cin >> n;
	
	rep(i,n){
		cin >> l;
		if( max < l ){
			max = l;
		}
		sum += l;
	}
	
	if( max < sum - max ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;
const double PI=3.14159265359;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    set<int> s;
    int cur=1;
    while(1){
        if(s.find(n)!=s.end()){
            cout<<cur;
            return 0;
        }
        s.insert(n);
        n=n%2?3*n+1:n/2;
        cur++;
    }
    
    
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll X[100005];

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    REP(i, N) {
        cin >> X[i];
    }

    ll ans = 0;
    REP(i, N - 1) {
        ans += std::min(B, A * (X[i + 1] - X[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <limits.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vp;
int n,m;
int a[200005];
int aindex[200005];
ll ans=0;
int main(int argc,char const* argv[])
{
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
      a[i]--;
      aindex[a[i]]=i;
    }
  set<int> rig,lef;
  rig.insert(n);
  lef.insert(1);
  for(int i=0;i<n;i++)
    {
      int r=*(rig.upper_bound(aindex[i]))-aindex[i];
      int l=*(lef.upper_bound(-aindex[i]))+aindex[i];
      rig.insert(aindex[i]);
      lef.insert(-aindex[i]);
      ans+=(ll)l*r*(i+1);
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c,d; cin >> a >> b >> c >> d;
  
  if((abs(a-b) <= d && abs(c-b) <= d) || abs(c-a) <= d){ cout <<"Yes" << endl;}
  else{ cout << "No" << endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUGLOCAL
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;+--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);+--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define MP make_pair
#define PB push_back
#define SS stringstream
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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



int main() {
	int a[3];
	for(;;){
		memset(a,0,sizeof(a));
		rep(i,6)a[i%3]+=in();
		if(a[0]+a[1]+a[2]==0)break;
		if((a[0]==0&&a[1]%3==2&&a[2]%3==2)
			||(a[1]==0&&a[2]%3==2&&a[0]%3==2)
			||(a[2]==0&&a[0]%3==2&&a[1]%3==2)
			||(a[0]%3==0&&a[1]%3==1&&a[2]%3==2)
			||(a[0]%3==0&&a[1]%3==2&&a[2]%3==1)
			||(a[0]%3==1&&a[1]%3==0&&a[2]%3==2)
			||(a[0]%3==1&&a[1]%3==2&&a[2]%3==0)
			||(a[0]%3==2&&a[1]%3==0&&a[2]%3==1)
			||(a[0]%3==2&&a[1]%3==1&&a[2]%3==0)){
			cout<<(a[0]+a[1]+a[2])/3-1<<endl;
		}else{
			cout<<(a[0]+a[1]+a[2])/3<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(){
    int a[100] = {0};
    int i;
    int x;
    
    for(i=1;i<=28;i++){
        scanf("%d\n",&x);
        a[x] = 1;
    }
    for(i=1;i<=30;i++){
        if(x==-1&&a[i] == 0){
            printf("%d\n",i);
            break;
        }
        else if(a[i] == 0){
            printf("%d\n",i);
            x = -1;
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;


vector<int> G[1<<17];
vector<int> f(1<<17,-1);
vector<P> m(1<<17,mp(0,0));
bool ff;

P dfs(int v,int u,int l,int r,bool k){
    int ll=l,rr=r;
    if(~f[v]){
        if(f[v] < ll || rr < f[v]) ff = true;
        if(k != (f[v]&1)) ff = true;
        ll = f[v];
        rr = f[v];
    }
    for (int i = 0; i < G[v].size(); i++) {
        if(G[v][i] == u) continue;
        P p = dfs(G[v][i],v,ll-1,rr+1,k^1);
        p.sc++,p.fs--;
        if(p.sc < ll || rr < p.fs) ff = true;
        else{
            ll = max(ll,p.fs);
            rr = min(rr,p.sc);
        }
    }
    if(~f[v] && (f[v] < ll || rr < f[v])) ff = true;
    if(k){
        if(ll%2==0){
            ll++;
        }
        if(rr%2==0){
            rr--;
        }
    }
    else{
        if(ll%2){
            ll++;
        }
        if(rr%2){
            rr--;
        }
    }
    if(rr < ll) ff = true;
    return m[v] = mp(ll,rr);
}

void dfs1(int v,int u,int s){
    if(m[v].fs <= s+1 && s+1 <= m[v].sc) f[v] = s+1;
    else if(m[v].fs <= s-1 && s-1 <= m[v].sc) f[v] = s-1;
    for (int i = 0; i < G[v].size(); i++) {
        if(G[v][i] == u) continue;
        dfs1(G[v][i],v,f[v]);
    }
}


int main(){
    int n;cin >> n;
    for (int i = 0; i < n-1; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    int k;cin >> k;
    P s;
    for (int i = 0; i < k; i++) {
        int v,p;cin >> v >> p;
        v--;
        f[v] = p;
        s = mp(v,p);
    }
    dfs(s.fs,-1,s.sc,s.sc,s.sc&1);
    if(ff){
        puts("No");
        return 0;
    }
    else{
        puts("Yes");
        dfs1(s.fs,-1,s.sc);
        for (int i = 0; i < n; i++) {
            cout << f[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 18048
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
#define testcases ll t; cin>>t; while(t--)

using namespace std;

int z,l=0,n,m;
vector<vector<int>> e(100001);
vector<int> dp(100001,-1);

int dfs(int ind)
{
    if(dp[ind]!=-1) return dp[ind];
    if(e[ind].size()==0) return 0;

    int ans=0;
    for(int i=0;i<e[ind].size();i++) ans=max(ans,1+dfs(e[ind][i]));
    dp[ind]=ans;
    return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>m;

    for(int i=0;i<m;i++)
    {
        int x,y;cin>>x>>y;
        e[x].pb(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(dp[i]==-1) ans=max(ans,dfs(i));
        else ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define pii pair<int, int>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define in insert
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, s, e) FOR(i, e, s) cout << a[i] << ' '



using namespace std;

int main()
{
    set<char> odd, ev;
    odd.in('R'); odd.in('U'); odd.in('D');
    ev.in('L'); ev.in('U'); ev.in('D');
    string s; cin >> s;
    int n = s.size();
    int fl = 1;
    FOR(i, n + 1, 1)
    {
        if(i % 2)
        {
            if(odd.count(s[i - 1]) == 0)fl = 0;
        }
        else
            if(ev.count(s[i - 1]) == 0)fl = 0;
    }
    if(fl)cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	void solve() {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		S = S.replace("2017","2018");
		System.out.println(S);
	}

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int N = 18;

int n, m, k, u, v, x, y, t, a, b;
int ans[1<<N];
pii dp[1<<N];

pii f(pii i, pii j){
	if (j.first>i.first) swap(i, j);
	return {i.first, max(i.second, j.first)};
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=0; i<(1<<n); i++) cin>>dp[i].first;
	for (int j=0; j<n; j++) for (int i=(1<<n)-1; i; i--) if (i&(1<<j)) dp[i]=f(dp[i], dp[i^(1<<j)]);
	for (int i=1; i<(1<<n); i++) cout<<(ans[i]=max(dp[i].first+dp[i].second, ans[i-1]))<<'\n';
	
	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>

using namespace std;

void finish()
{
    cout << "Yes" << endl;
    exit(0);
}

int n, m;
string str;
vector< vector<int> > gr, color;

void dfs(int u, int col)
{
    char nxtch = (col == 3 || col == 0) ? 'A' : 'B';
    int nxtcol = (col + 1) % 4;

    for (int v : gr[u]) {
        if (str[v] != nxtch) continue;
        if (color[v][nxtcol] == 2) continue;
        if (color[v][nxtcol] == 1) finish();
        color[v][nxtcol] = 1;
        dfs(v, nxtcol);
    }

    color[u][col] = 2;
}

signed main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    cin >> str;
	gr.resize(n);
	for (int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v; --u; --v;
        gr[u].push_back(v);
        gr[v].push_back(u);
	}

	color.assign(n, vector<int>(4, 0));

    for (int u = 0; u < n; ++u) {
        if (str[u] == 'A') {
            if (!color[u][0] && !color[u][1]) {
				color[u][0] = 1;
				dfs(u, 0);
            }
        } else {
            if (!color[u][2] && !color[u][3]) {
				color[u][2] = 1;
				dfs(u, 2);
            }
        }
    }

    cout << "No" << endl;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s, t;
  cin >> s >> t;

  int sz = s.size(), tz = t.size();
  set<string> st;
  for (int i = 0; i < sz; i++) {
    int l = 0, r = 0;
    while (r < tz && r + i < sz && (s[r + i] == '?' || s[r + i] == t[r])) r++;
    if (r - l != tz) continue;
    string w = "";
    for (int j = 0; j < sz; j++) {
      char ch = s[j] == '?' ? 'a' : s[j];
      if (j < i) w += ch;
      else if (j < i + tz) w += t[j - i];
      else w += ch;
    }
    st.insert(w);
  }
  cout << (st.size() ? *st.begin() : "UNRESTORABLE") << endl;

  return 0;
}

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

const long long MAX_V = 101010;
const long long INF = 1LL<<50;

struct edge {
    long long to;
    long long cost;
};

// <最短距離, 頂点の番号>
using P = pair<long long, long long>;

vector<edge> G[MAX_V];

void Dijkstra(long long s, vector<long long> &d) {
    
    // 最短距離が小さい順番に取り出す
    // 始点の情報とそこへの最短距離（始点なら $0$ ）をpushする
    priority_queue<P, vector<P>, greater<P> > que;
    
    d[s] = 0; // 始点ｓから頂点sへの最短経路の長さは0である
    
    que.push(P(0, s));
    
    
    while (!que.empty()) {
        
        P p = que.top(); // キューの先頭要素（最短距離の一番小さいもの）を取り出す。
        que.pop();
        
        long long v = p.second;
        
        
        //記録済み最短距離より, 取り出した要素に入っている距離情報のほうが大きい場合
        // ここで打ち切って先頭要素を取り出す操作に戻る
        
        if (d[v] < p.first) continue;  // ??????????
        
        // 移動できる頂点を走査する
        for (int i=0; i<G[v].size(); ++i) {
            
            edge e = G[v][i];
            
            // 最短距離が更新できるものがあれば、距離を更新する
            if (d[e.to] > d[v] + e.cost) {
                
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to)); // 頂点への距離、頂点の情報をキューにpushする
            }
            
        }
        
    }
    
}  


int main(){
    int V, E, r;
    cin >> V >> E >> r;
    
    for (int i = 0; i < E; i++){
        long long a, b, c;
        cin >> a >> b >> c;
        edge e = {b, c};
        G[a].push_back(e);
    }
    
    vector<long long> d(MAX_V, INF);
    
    Dijkstra(r, d);
    
    for (int i = 0; i < V; i++){
        
        if (d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
        
    }
    
    return 0;
}


Measured memory_bytes: 19648
n, m = map(int, input().split())
H = tuple(map(int, input().split()))

tower = [True for i in range(n)]

for idx in range(m):
    a, b = map(int, input().split())
    if H[a - 1] > H[b - 1]:
        tower[b - 1] = False
    elif H[a - 1] == H[b - 1]:
        tower[b - 1] = False
        tower[a - 1] = False
    else:
        tower[a - 1] = False

ans = 0
for t in tower:
    if t:
        ans += 1

print(ans)


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

const int maxN = 2e5 + 10;

int n;
int a[maxN], answer[maxN];

int main() {
 //   freopen("input.in", "r", stdin);
  //  freopen("output.out", "w", stdout);

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

    int low = 1, high = n, id = 0;
    for (int i = n; i > 0; --i) {
        if (id) {
            answer[high--] = a[i];
        } else {
            answer[low++] = a[i];
        }
        id = 1 - id;
    }
    for (int i = 1; i <= n; ++i) printf("%d ", answer[i]);

    return 0;
}


Measured memory_bytes: 3712
def f(x):
    return int(x)-1
n, k = map(int, input().split())
a = list(map(f, input().split()))
town = 0
i=0
l = [-1] * n
while True:
    if l[town] != -1:
        j = l[town]
        break
    i += 1
    l[town] += i
    town = a[town]
    # print(town,l)
# print(town)
if k >= i:
    k = (k - j) % (i - j) + j
print(l.index(k)+1)


Measured memory_bytes: 32328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int D = scanner.nextInt();
        int[][] X = new int[N][D];
        for(int j = 0; j < N; j++) {
            for (int i = 0; i < D; i++) {
                X[j][i] = scanner.nextInt();
            }
        }

        int count = 0;
        for(int k = 0; k < N; k++) {
            for(int j = k; j < N; j++) {
                if(k == j) continue;
                int tmp = 0;
                for (int i = 0; i < D; i++) {
                    tmp += (X[k][i] - X[j][i]) * (X[k][i] - X[j][i]);
                }
                double ans = Math.sqrt((double) tmp);
                if (ans == (int) ans) count++;
            }
        }


        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
 
int main()
{
    int a = 0;
    int h=0,m=0,s=0;
    scanf("%d", &a);

    if(86400 < a)
    {
    	return 1;
    }

    h = a / 3600;
    m = (a % 3600) / 60;
    // m = (a - h*3600)/60;
    s = (a % 3600) % 60;
    // s = a - h*3600 - m*60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

const int dw[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dh[] = {0, 1, 1, 1, 0, -1, -1, -1};

vector<vector<int>> to;
vector<vector<int>> seen;

int W, H;

void dfs(int a, int b) {
    seen[a][b] = 1;
    rep(i, 8) {
        int nh = a + dh[i], nw = b + dw[i];
        if (nh < 0 || H <= nh || nw < 0 || W <= nw) continue;
        if (seen[nh][nw]) continue;
        if (to[nh][nw] == 0) continue;
        dfs(nh, nw);
    }
}

void solve(int w, int h) {
    to = vector<vector<int>>(h, vector<int>(w));
    seen = vector<vector<int>>(h, vector<int>(w, 0));
    rep(i, h) rep(j, w) cin >> to[i][j];
    int ans = 0;
    rep(i, h) rep(j, w) if ((!seen[i][j]) && (to[i][j] == 1)) {
        dfs(i, j);
        ans++;
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (true) {
        cin >> W >> H;
        if (W == 0 && H == 0) break;
        solve(W, H);
    }
    return 0;
}


Measured memory_bytes: 3344
// Confessions of a Dangerous Mind

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 2e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 3e-16;

/*
	Keep moving forward. Take the Leap of Faith
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
    long long k, a, b; cin >> k >> a >> b;
    
    long long x = b / k, y = (a - 1) / k;
    
    x -= y;
    
    cout << (x ? "OK" : "NG");
    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i,n) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	map<string, ll> mp;
	rep(i,n) {
		mp[s[i]]++;
	}
	ll ans=0;
	for(auto& i : mp) {
		ans += i.second * (i.second-1) / 2;
	}
	cout << ans << endl;
  return 0;
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}


struct Line
{
    ll m,b;
    ll get(ll x)
    {
        return m*x+b;
    }
};

struct ConvexHull
{
    int size;
    vector<Line> hull;
    ConvexHull(int maxSize)
    {
        hull=vector<Line>(maxSize+1);
        size=0;
    }
    bool isBad(int l1,int l2,int l3)
    {
        double left=1.0*(hull[l3].b-hull[l1].b)/(hull[l1].m-hull[l3].m);
        double right=1.0*(hull[l1].b-hull[l2].b)/(hull[l2].m-hull[l1].m);
        return left<right;
    }
    void addLine(ll m,ll b)
    {
        hull[size++]=Line{m,b};
        while(size>2&&isBad(size-3,size-2,size-1))
        {
            hull[size-2]=hull[size-1];
            --size;
        }
    }
    ll query(ll x)
    {
        int l=0,r=size-1;
        while(l<r)
        {
            int m=(l+r)/2;
            if(hull[m].get(x)>=hull[m+1].get(x))
                l=m+1;
            else
                r=m;
        }
        return hull[l].get(x);
    }
};

const int N=2e5+7;
ll n,c,h[N],dp[N];

int main(){
	n=input(),c=input();
	for(int i=1;i<=n;i++){
		h[i]=input();
	}

	ConvexHull t(N);
	dp[1]=0;
	t.addLine(-2*h[1],h[1]*h[1]+dp[1]);

	for(int i=2;i<=n;i++){
		dp[i]=t.query(h[i])+h[i]*h[i]+c;
		t.addLine(-2*h[i],h[i]*h[i]+dp[i]);
	}

	printf("%lld\n",dp[n]);
}

Measured memory_bytes: 6528
#include<stdio.h>
int main()
{
	long long n = 1,i,m;
	scanf("%lld",&m);
	for(i = 1;i <= m;i++)
	{
		n *= i;
		if(n / (1000000000 + 7) > 0)
			n = n % (1000000000 + 7);
	}
	printf("%lld\n",n);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<set>
#include<queue>
using namespace std;

vector<int> v[100000], d(100000);
vector<bool> vis(100000, 0);

void dfs(int x, int dep){
    d[x] = dep;
    vis[x] = true;
    for(int y : v[x]){
        if(!vis[y]) dfs(y, dep+1);
    }
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    a--, b--;
    for(int i = 0; i < n-1; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(a, 0);
    set<int> dist[n+5];
    for(int i = 0; i < n; i++)  if(i != b)  dist[d[i]].insert(i);
    int ans = 0;
    vector<bool> no(n, 0);
    queue<int> aoki;
    aoki.push(b);
    no[b] = true;
    set<int> even, odd;
    even.insert(a);
    while(true){
        // cout << ans << endl;
        // cout << "even ";
        // for(int x : even)   cout << x << " ";
        // cout << endl;
        // cout << "odd ";
        // for(int x : odd)   cout << x << " ";
        // cout << endl;

        for(int x : dist[ans+1]){
            if(no[x]) continue;
            if((ans+1)%2==0)    even.insert(x);
            else                odd.insert(x);
        }

        bool judge = false;
        if((ans+1)%2 == 0)  judge = even.empty();
        else                judge = odd.empty();
        if(judge){
            cout << ans << endl;
            return 0;
        }
        ans++;
        queue<int> naoki;
        while(!aoki.empty()){
            int x = aoki.front();   aoki.pop();
            for(int next : v[x]){
                if(no[next])  continue;
                no[next] = true;
                naoki.push(next);
                if(d[next]%2 == 0)   even.erase(next);
                else                 odd.erase(next);
            }
        }
        if(ans%2 == 1)      judge = odd.empty();
        else                judge = even.empty();
        if(judge){
            cout << ans << endl;
            return 0;
        }
        aoki = naoki;
    }
}

Measured memory_bytes: 19456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

mint perm(int n, int k) {
	if(n < 0) return 0;
	mint res = 1;
	for(int i = n; i > n - k; i--) res *= i;
	return res;
}

mint dfs(vector<vector<int>> &g, int p, int v, int k) {
	mint ans = 1;
	int color = (p == -1) ? k : k-2;
	int children = (p == -1) ? g[v].size() + 1 : g[v].size() - 1;
	ans *= perm(color, children);
	for(auto next_v: g[v]) {
		if(next_v == p) continue;
		ans *= dfs(g, v, next_v, k);
	}
	return ans;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<vector<int>> g(n);
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cout << dfs(g, -1, 0, k).x << endl;
	return 0;
}

Measured memory_bytes: 11520
import numpy as np

dataNum, timeMax = input().strip().split(' ')
dataNum, timeMax = [int(dataNum), int(timeMax)]

cost = [10000]
time = [10000]

"""
for i in range(dataNum):
    A, B = list(map(int, input().strip().split(' ')))   
    cost.append(A)
    time.append(B)

if min(time) > timeMax:
    print('TLE')
else :
    print(min(cost))
"""
for i in range(dataNum):
    A, B = list(map(int, input().strip().split(' ')))   
    if B <= timeMax:
        cost.append(A)
        time.append(B)
    
if min(time) > timeMax:
    print('TLE')
else :
    print(min(cost))


Measured memory_bytes: 12504
o,x,b;
main(a){
  for(scanf("%d");~scanf("%s",&a)&&(a%=9);o=o==3?b=x=!printf("%d\n",x):o){
    for(a-8?b=b*2+1,x+=b>>3&1,b&=7:o++;a<7&&b;b/=2)x+=b&1;
    //if(a%9==6)for(x++,b&=7;b;b/=2)x+=b&1;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    string S;
    cin >> S;
    if ((S[5] == '0' && S[6] > '4') || S[5] == '1')
    {
        cout << "TBD" << endl;
    }
    else
    {
        cout << "Heisei" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX];
int prim(){
  int u,minv,sum;
  int d[MAX],p[MAX],color[MAX];
  int i,j,v;
  for(i =0;i<n;i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
  while(1){
    minv = INFTY;
    u = -1;
    for(i =0;i < n;i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v =0;v < n;v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
        if(d[v] > M[u][v]){
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  sum = 0;
  for(i =0;i < n;i++){
    if(p[i] != -1) sum += M[i][p[i]];
  }
  return sum;
}
int main(){
  int i,j,e;
  scanf("%d",&n);
  for(i =0;i<n;i++){
    for(j =0;j<n;j++){
      scanf("%d",&e);
      if(e == -1) M[i][j] = INFTY;
      else M[i][j] = e;
    }
  }
  printf("%d\n",prim());
  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>
int main(void)
{
   int a, b, r, x;
   int count;
   
   while(scanf("%d %d", &a, &b) != EOF) {
       count = 0;
       if(a == 0 && b == 0) {
       break;
       }
       if(a < b){
      x = b;
      b = a;
      a = x;
      }
       while(b!=0){
           r = a % b;
           a = b;
           b = r;
           count++;
       }
       printf("%d %d\n",a,count);
   }
   
   return(0);
}


Measured memory_bytes: 2048
class point:
    def __init__(self,x,y):
        self.x = x
        self.y = y

if __name__ == '__main__':
    N = int(raw_input())
    red = []
    blue = []
    for i in range(N):
        x,y = map(int, raw_input().split())
        red.append(point(x,y))

    for i in range(N):
        x,y = map(int, raw_input().split())
        blue.append(point(x,y))


    blue = sorted(blue, key=lambda k: k.x)
    red = sorted(red, key=lambda k: k.y, reverse=True)
    red_check = [0] * N
    ans = 0
    for b in blue:
        red_pair = None
        is_check = True
        for i, r in enumerate(red):
            if b.x > r.x and b.y > r.y and is_check and red_check[i] == 0:
                red_pair = r
                is_check = False
                red_check[i] = 1

        if red_pair is not None:
            ans += 1

    print(ans)

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

int main(){
  int a,b,result;
  
  cin >> a >> b;
  double DoubleRes = ( a + b ) / 2.0;
  int intRes = ( a + b ) / 2;
  
  if(DoubleRes-intRes>=0.5){
    result = intRes+1;
  }else{
    result = intRes;
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
# デバッグ用
GBN_DEBUG = False
#GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')

#本体ここから
a,b,c,k = map(int,input().split())

if k <= a:
    print(k)
else:
    k -= a
    if k <= b:
        print(a)
    else:
        k -= b
        print(a-k)


Measured memory_bytes: 9140
#include<stdio.h>
 int main()
 {
 	int a,b,c;
 	scanf("%d %d %d",&a,&b,&c);
 	if ((a==b && c!=a) || (a==c && b!=a) || (b==c && a!=b))
 		printf("Yes");
 	else
 		printf("No");
return 0;
 }

Measured memory_bytes: 128
S = input().strip()
z = 0
o = 0
r = 0
for s in S:
    if s == "0":
        if o > 0:
            o -= 1
            r += 2
        else:
            z += 1
    elif s == "1":
        if z > 0:
            z -= 1
            r += 2
        else:
            o += 1
print(r)


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
  string s;cin >> s;
  string frag = "Good";
  for(int i = 0;i<3;i++){
    if(s.at(i) == s.at(i+1) ){
      frag = "Bad";
    }
  }
  cout << frag << endl;
} 

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

int main() {
  int N;
  cin >> N;
  long long f = 0;
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    f += a - 1;
  }
  cout << f << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
    static int dp[];
    static ArrayList<Integer>arr;
    public static void main (String[] args)
    {
        Scanner in=new Scanner(System.in);
        int a=in.nextInt(),b=in.nextInt();
        ArrayList<Integer>al=new ArrayList<>();
        al.add(0,1);
        for (int i = 0; i <999; i++) {
            if(i!=0)
            al.add(al.get(i-1)+i+1);
        }
        Set<Integer>set=new HashSet<>();
        set.addAll(al);
        for(int i=0;i<499500;i++){
            if(set.contains(i+a) && set.contains(b+i)){
                if(Math.abs(al.indexOf(i+a)-al.indexOf(i+b))==1){
                    System.out.println(i);
                    return;
                }
            }
        }
        System.out.println(1);
    }
}

Measured memory_bytes: 28536
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
int isprime(int);
 
int main(){
 
  int i,x,n,count = 0;
  int *m;
 
  scanf("%d",&n);
  m = malloc(sizeof(int) * n);
  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&m[i]);
      if( isprime(m[i]) == 1)
        {
          count++;
        }
    }
  printf("%d\n",count);
  free(m);
  return 0;
}
 
int isprime(x){
 
int i = 3;
 
if( x == 2) return 1;
if( x  < 2 || x % 2 == 0) return 0;
while ( i <= sqrt(x) )
    {
      if(x % i == 0) return 0;
      i = i +2;
    }
 
return 1;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int ctoi(const char c)
{
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

int main()
{
    int A, B, C; cin >> A >> B >> C;
    int ans = max<int>({
        10*A + B + C,
        A + 10*B + C,
        A + B + 10*C
    });
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

a,b,c,d = I()
while a > 0 and c > 0:
    c -= b
    a -= d

if c <= 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10068
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  string s;
  REP(i,n){
    char c;
    cin >> c;
    s += c;
  }
  REP(i,n){
    if(s[i] == 'Y'){
      cout << "Four" << endl;
      return 0;
    }
  }

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

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

int main() {
  int n;
  cin >> n;
  vector <int> v1(n);
  vector <int> v2(n);
  for (int i = 0; i < n; i++) {
    cin >> v1.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> v2.at(i);
  }
  int64_t ans = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = 0; j < i; j++) {
      tmp += v1.at(j);
    }
    for (int j = i-1; j < n; j++) {
      tmp += v2.at(j);
    }
    if (tmp > ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
}

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

int twoExpNum(int N){
  int result = 0;
  for(;N>0&&(N%2)==0;N/=2)result++;
  return result;
}

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  int result = 0;
  for(size_t i=0;i<N;i++){
    cin>>A[i];
    result += twoExpNum(A[i]);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/7/5 22:51
 */
public class Main {

    final static int MOD = 1000000007;
    static Scanner sc;

    private static int comb(int n, int m) {
        return 1;
    }

    static void getDiv(Map<Integer, Integer> map, int n) {
        int sqrt = (int) Math.sqrt(n);
        for (int i = sqrt; i >= 2; i--) {
            if (n % i == 0) {
                getDiv(map, i);
                getDiv(map, n / i);
                return;
            }
        }
        map.put(n, map.getOrDefault(n, 0) + 1);
    }

    @SuppressWarnings("unchecked")
    private static void solve() {
        int n = nextInt();
        long a[] = new long[n];
        Set<Long> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            set.add(a[i]);
        }
        Arrays.sort(a);
        boolean low = false;
        int i = 1;
        int j = n - 2;
        long ans = a[n - 1] - a[0];
        int u = 0;
        int v = n - 1;

        while (i <= j) {
            if (i == j) {
                ans += Math.max(Math.abs(a[i] - a[u]), Math.abs(a[i] - a[v]));
                break;
            }
            long pre = Math.abs(a[j] - a[u]);
            long rear = Math.abs(a[i] - a[v]);
            if (pre > rear) {
                ans += pre;
                u = j--;
            } else {
                ans += rear;
                v = i++;
            }
            if (a[u] > a[v]) {
                u ^= v;
                v ^= u;
                u ^= v;
            }
        }

        System.out.println(ans);
    }

    static long gcd(long a, long b) {
        if (a < b) {
            a ^= b;
            b ^= a;
            a ^= b;
        }
        while (b != 0) {
            long tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }

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

    private static int nextInt() {
        return sc.nextInt();
    }

    private static long nextLong() {
        return sc.nextLong();
    }

    private static String next() {
        return sc.next();
    }

    private static double nextDouble() {
        return sc.nextDouble();
    }
}

Measured memory_bytes: 66544