akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int n=4;
   char c[4];
   int a[n];
   rep(i,n){
      cin>>c[i];
      a[i]=c[i]-'0';
   }
   
   for(int bit=0;bit<(1<<n);bit++){
      int sum=a[0];
      string s;
      s+=to_string(a[0]);
      for(int i=1;i<n;i++){
         if(bit &(1<<i)){
             sum+=a[i];
             s+='+';
             s+=to_string(a[i]);
         }
         else{
            sum-=a[i];
            s+='-';
            s+=to_string(a[i]);
         }
      }
      if(sum==7){
          cout<<s<<"=7"<<endl;
          return 0;
      }
      
   }


return 0;
}



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

int main() {
  vector<int> a(5);
  int k;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  string ans = "Yay!";
  rep(i,4){
    for(int j=i;j<5;j++){
      if (a[j]-a[i]>k) ans = ":(";
    }
  }
  
  cout << ans << endl;

  return 0;
}


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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
bool prime[1000010];
void sieve(){
	for(int i =1;i <=1000000;i++){
		prime[i]=true;
	}
	prime[1]=false;
	for(int i =2;i*i<=1000000;i++){
		if(prime[i]){
			for(int j =i*i;j<=1000000;j+=i){
				prime[j]=false;
			}
		}
	}
}
int main(){
	int n;
	sieve();
	while(cin>>n,n){
		int ans = 0;
		for(int i =2;i <=n/2;i++){
			if(prime[i]&&prime[n-i]){
				ans++;
			}
			
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2136
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

const int jt = 998244353;
int mii[1 << 18], tms[1 << 18];

struct Node {
	int dt, wp;
	int l, r;
	void inline upd(int x) {
		wp = x;
		dt = 1ll * x * mii[r - l] % jt;
	}
} t[1 << 20];

void inline pd(int now) {
	if(!t[now].wp) return;
	t[now << 1].upd(t[now].wp);
	t[now << 1 | 1].upd(t[now].wp);
	t[now].wp = 0;
}

void inline pu(int now) {
	int len = t[now << 1].r - t[now << 1].l + 1;
	t[now].dt = (1ll * t[now << 1 | 1].dt * tms[len] + t[now << 1].dt) % jt;
}

int n, q;

void inline init(int now = 1, int nl = 1, int nr = n) {
	t[now].l = nl; t[now].r = nr;
	if(nl == nr) return void(t[now].upd(1));
	int m = (nl + nr) >> 1;
	init(now << 1, nl, m);
	init(now << 1 | 1, m + 1, nr);
	pu(now);
}

void inline add(int l, int r, int x, int now = 1, int nl = 1, int nr = n) {
	if(nl >= l && nr <= r) {
		t[now].upd(x);
		return;
	}
	if(nl > r || nr < l) return;
	pd(now);
	int m = (nl + nr) >> 1;
	add(l, r, x, now << 1, nl, m);
	add(l, r, x, now << 1 | 1, m + 1, nr);
	pu(now);
}

int main() {
	scanf("%d%d", &n, &q);
	mii[0] = tms[0] = 1;
	cont(i, n) {
		mii[i] = (10ll * mii[i - 1] + 1) % jt;
		tms[i] = 10ll * tms[i - 1] % jt;
	}
	init();
	cont(i, q) {
		int l, r, d; scanf("%d%d%d", &l, &r, &d);
		l = n + 1 - l; r = n + 1 - r; swap(l, r);
		add(l, r, d);
		printf("%d\n", t[1].dt);
	}
	return 0;
}


Measured memory_bytes: 13616
#include <bits/stdc++.h>
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 all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
#define INF 1e18L+5
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

void minSelf(ll& a, ll b){
  a = min(a, b);
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n; cin >> n;
  vi v(n); for(auto& i: v) cin >> i;
  vvi dp(n, vi(n));
  auto sum = [&](const int& l, const int& r){
    ll res = 0;
    rep(i,l,r+1) res += v[i];
    return res;
  };
  rrep(l, n-1, 0){
    rep(r, l, n){
      if(l == r) dp[l][r] = 0;
      else{
        dp[l][r] = INF;
        ll s = sum(l, r);
        rep(i,l,r){
          minSelf(dp[l][r], dp[l][i] + dp[i+1][r] + s);
        }
      }
    }
  }
  cout << dp[0][n-1];
}


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

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(b>n*a){
    cout<<n*a<<endl;
    return 0;
  }else{
    cout<<b<<endl;
  }
}


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

int main()
{
  string s;
  cin >> s;
  string ans;
  int n = s.size();
  for(int i = 0; i < n; i++){
    if(s[i] == 'B'){
      if(ans.size() > 0){
        ans.pop_back();
      }
    }
    else{
      ans.push_back(s[i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
int N;
  cin>>N;
int ans=0;
int a[N];
  for(int i=0;i<N;i++){
  cin>>a[i];
  if(i%2==0){
  	if(a[i]%2==1){
    ans++;
    }
  }
    
  }
  
 
  
  cout<<ans<<endl;
  
  
}


Measured memory_bytes: 3544
#include <iostream> 
#include <algorithm>

using namespace std;

int main() {
	string st;
	cin >> st;
	string st1 = st.substr(0, 5);
	string st2 = st.substr(6, 7);
	string st3 = st.substr(14, 5);
	cout << st1 << " " << st2 << " " << st3 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,n;
int main()
{
    cin>>a>>n;
    if(a%3==0||n%3==0||(a+n)%3==0) {cout<<"Possible"<<endl;return 0;}
    else cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
#coding: utf-8

N, M = map(int, input().split())

List = []
all_and = []
for i in range(N):
    l = list(map(int, input().split()))
    del l[0]
    List.append(l)

    if i ==0:
        all_and = List[0]
    else:
        all_and = set(all_and) & set(List[i])
        all_and = list(all_and)

#print(all_and)
print(len(all_and))


Measured memory_bytes: 3060
import math


def main():
    K = int(input())
    s = 0
    for i in range(K):
        for j in range(K):
            tmp = math.gcd(i+1, j+1)
            for k in range(K):
                s += math.gcd(tmp, k+1)

    print(s)


if __name__=="__main__":
    main()


Measured memory_bytes: 9124
#include<stdio.h>
int main(void)
{
	int a, b;
	int d=0, r=0;
	double f=0;
	
	scanf("%d %d", &a, &b);
	d=a/b;
	r=a%b;
	f=1.0*a/b;
	
	printf("%d %d %f\n", d, r, f);
	
	
	return 0;
}

Measured memory_bytes: 636
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    x=[list(map(int,readline().split())) for _ in range(n)]
    
    a=[x[i][0] for i in range(n)]
    b=[x[i][1] for i in range(n)]
    a.sort()
    b.sort()
    if n%2==1:
        a_med=a[n//2]
        b_med=b[n//2]
    else:
        a_med=a[n//2-1]+a[n//2]
        b_med=b[n//2-1]+b[n//2]
    print(b_med-a_med+1)

if __name__=="__main__":
    main()

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

int main(){
    long long N;
    cin >> N;

    long long c = N;
    int cnt = 0;
    while(true){
        if(N / 10 == 0) {
            cnt += N % 10;
            break;
        }
        cnt += N % 10;
        N /= 10;
    }

    if(c % cnt == 0) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;

ll dp[1010][20010];

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

    rep(i,1010) rep(j, 20010) dp[i][j] = INF;
    dp[0][0] = 0;

    int h,n;
    cin >> h >> n;
    ll a[n];
    ll b[n];
    rep(i,n) cin >> a[i] >> b[i];
    
    rep(i,n) rep(j,20010)
    {
        if (i==0 && j==0) continue;

        if (i==0)
        {
            if (j-a[i]>=0)
            {
                dp[i][j] = dp[i][j-a[i]]+b[i];
            }
        }
        else
        {
            if (j-a[i]>=0)
            {
                dp[i][j] = min(dp[i-1][j], dp[i][j-a[i]]+b[i]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
        // if (i==j) cout << "koko" << endl;
    }
    // cout << "koko" << endl;
    ll ans = INF;
    REP(i,h,20010) ans = min(ans, dp[n-1][i]);
    cout << ans << endl;
}




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

#define MAX 1001
#define MOD 1000000007
#define FALSE -1
#define TRUE 0

int main(){
	int isPrime[MAX];	for(int i=0;i<MAX;i++)isPrime[i]=TRUE;
	isPrime[0]=isPrime[1]=FALSE;
	for(int i=2;i<=1000;i++){
		if(isPrime[i]){
			for(int j=i+i; j<=1000; j+=i){
				isPrime[j]=FALSE;
			}
		}
	}

	int n;	cin>>n;
	long long ans=1;
	for(int i=2;i<=n;i++){

		long long x=i;
		for(int j=2;j<=x;j++){
			if(isPrime[j]==FALSE) continue;

			while(x%j==0){
				x/=j;
				isPrime[j]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(isPrime[i]>0){
			ans%=MOD;
			ans*=(isPrime[i]+1);
		}
	}
	ans%=MOD;
	cout<<ans<<endl;

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  string s;
  cin>>s;
  reverse(ALL(s));
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 1172
from heapq import heappush,heappop

N = int(input())
array = list(map(int,input().split()))
nega = []
posi = []

for num in array:
  if num >= 0:
    heappush(posi,num)
  else:
    heappush(nega,num*(-1))


if len(nega)%2==0:
  ans = sum(nega) + sum(posi)
else:
  if len(nega)==N:
    max_nega = heappop(nega)
    ans = sum(nega) - max_nega
  else:
    min_posi = heappop(posi)
    max_nega = heappop(nega)
    if min_posi > max_nega:
      ans = sum(nega) + sum(posi) + min_posi - max_nega
    else:
      ans = sum(nega) + sum(posi) - min_posi + max_nega

print(ans)

    


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

int main()
{
    int i,j,x,c=0,n,k,p,q,r;
int a[100000];
    cin>>k>>x;
    p=x-k;
    for(i=p+1;i<=x;i++)


              cout<<i<<" ";



    for(j=x+1;j<=x+(k-1);j++)
cout<<j<<" ";
cout<<endl;

return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;

int N,M,R,Q;

vector<pint>G[111111];

void  dijkstra(int r,vint &dist){
    dist.resize(N);
    fill(all(dist),INF);
    priority_queue<pint,vector<pint>,greater<pint>>que;
    rep(i,N)if(i%R==r)dist[i]=0,que.push({0,i});
    while(que.size()){
        int v,c;
        tie(c,v)=que.top();
        que.pop();
        if(dist[v]<c)continue;
        for(auto &e:G[v]){
            if(dist[e.fi]<=c+e.se)continue;
            dist[e.fi]=c+e.se;
            que.push({dist[e.fi],e.fi});
        }
    }
}

signed main(){
    scanf("%lld%lld%lld%lld",&N,&M,&R,&Q);

    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[b].pb({a,c});
    }

    vector<vint>dist(R);
    rep(i,R)dijkstra(i,dist[i]);

    int ans=0;
    while(Q--){
        int x,y,z;
        scanf("%lld%lld%lld",&x,&y,&z);
        x--;y--;
        int mi=INF;
        rep(i,R)chmin(mi,dist[i][x]+dist[i][y]);
        ans+=max(0ll,z-mi);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 17156
def decode(st, n)
  trans = ->(b) {(a = b - n) < 97 ? 122 - (96 - a) : a}
  st.bytes.map {|b| (b.between?(97, 122) ? trans.(b) : b).chr}.join
end

words = %w(the this that)
table = (0..25).map do |i|
  words.map {|w| w.bytes.map {|b| ((a = b + i) > 122 ? (a - 123 + 97) : a).chr}.join}
end

$<.readlines.each do |st|
  st.chomp!
  n = 0
  table.each_with_index do |ws, i|
    ws.each {|w| n = i if st.include?(w)}
  end
  puts decode(st, n)
end


Measured memory_bytes: 6896
a_list=[]
a_list.append(list(map(int, input().split())))
a_list.append(list(map(int, input().split())))
a_list.append(list(map(int, input().split())))
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j in range(len(a_list)):
    for k in range(len(a_list[j])):
      if a_list[j][k] == b_i:
        a_list[j][k] = -1
    
if ((a_list[0][0]==-1 and a_list[0][1] == -1 and a_list[0][2] == -1) or
    (a_list[1][0]==-1 and a_list[1][1] == -1 and a_list[1][2] == -1) or
    (a_list[2][0]==-1 and a_list[2][1] == -1 and a_list[2][2] == -1) or
    (a_list[0][0]==-1 and a_list[1][0] == -1 and a_list[2][0] == -1) or
    (a_list[0][1]==-1 and a_list[1][1] == -1 and a_list[2][1] == -1) or
    (a_list[0][2]==-1 and a_list[1][2] == -1 and a_list[2][2] == -1) or
    (a_list[0][0]==-1 and a_list[1][1] == -1 and a_list[2][2] == -1) or
    (a_list[0][2]==-1 and a_list[1][1] == -1 and a_list[2][0] == -1)):

  print("Yes")
else:
  print("No")

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
using namespace std;
int n,t;
string a[101];
int main()
{
    cin>>n>>t;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
        cout<<a[i];
    cout<<endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  int N, A, B;
  cin >> N >> A >> B;
  int cnt0, cnt1, cnt2;
  cnt0 = 0;
  cnt1 = 0;
  cnt2 = 0;

  int p;
  rep(i, N){
    cin >> p;
    if(p <= A){
      cnt0++;
    }else if(p <= B){
      cnt1++;
    }else{
      cnt2++;
    }
  }

  cout << min(min(cnt0, cnt1), cnt2) << endl;
  





  return 0;
}


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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<int, null_type,
        less_equal<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
		
typedef tree<int, null_type,
        less<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)

*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	ll n,k;
	cin>>n>>k;
	
	set<ll>s;
	
	s.insert(n);
	
	while(1)
	{
		if(n>=k)
		{
			ll temp=n/k;
			temp*=k;
			n-=temp;
			if(s.find(n)!=s.end()) break;
			s.insert(n);
		}
		else
		{
			n=k-n;
			if(s.find(n)!=s.end()) break;
			s.insert(n);
		}
	}
	
	cout<<*s.begin();
}	

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
void swap (int *x, int *y) {
  int temp;    
  temp = *x;
  *x = *y;
  *y = temp;
}

int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;  

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);  
    quick_sort(array, pivot+1, right);
  }
}

int main(){
  int n;
  scanf("%d ", &n);
  float in[n],d[n+1];
  d[0] = 1;
  for(int i=0;i<n;i++){
	scanf("%f ", &in[i]);
    d[i+1] = 2*d[i];
  }
  quick_sort(in,0,n-1);
  float sum = 0;
  for(int i=0;i<n;i++){
   if(i==0||i==1){
     sum += in[i];
   } else {
     sum = (in[i])*(d[i-1]) + sum ;
   }
  }
  printf("%f", sum/d[n-1]);
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i);
    }
    reverse(a.begin(), a.end());
    for(int i=0; i<n-1; i++){
        cout << a.at(i) << " ";
    }
    cout << a.at(n-1) << endl;
    return 0;
}


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

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i],a[i]=a[i]*1e6+i+1;
    sort(a,a+n);
    rep(i,n) cout<<a[i]%1000000<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
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; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, m, dp[100005];
vii a;

signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> m;
  a.resize(n);
  for (int i = 0; i < m; i++) {
    int t; cin >> t;
    a[t] = 1;
  }
  dp[n] = 1;
  for (int i = n-1; i >= 0; i--) {
    if (a[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1] + dp[i+2]) % MOD;
  }
  cout << dp[0] << endl;
  return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	string s;
	cin>>s;
	if(s=="ABC")
	cout<<"ARC";
	else
	cout<<"ABC";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


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

int main (void) {
    int a, b, c;
    cin >> a >> b >> c;

    int ans;
    if (a == b) {
        ans = c;
    } else if (a == c) {
        ans = b;
    } else {
        ans = a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000, MAX_M = 100000;
int N, M;
int A[MAX_N];
int B[MAX_M], C[MAX_M];

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

  cin >> N >> M;
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i] >> C[i];

  sort(A, A+N);

  vector<Pii> vp;
  rep(i, M) vp.push_back(Pii(C[i], B[i]));  
  sort(all(vp));
  reverse(all(vp));

  int idx = 0;
  for (int i = 0; i < M; ++i) {
      for (int j = 0; j < vp[i].sc; ++j) {
          if (A[idx] > vp[i].fi || idx >= N) goto LOOP_OUT;
          A[idx++] = vp[i].fi;
      }
  }
LOOP_OUT:

  ll ans = 0;
  rep(i, N) ans += A[i];

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 2552
#include<cstdio>
#include<vector>

using namespace std;


void maxHeapify(vector<int>& heap, int i) {
  int left = 2 * i;
  int right = 2 * i + 1;
  int N = (int) heap.size();

  int largest;
  if (left <= N && heap[left] > heap[i]) {
    largest = left;
  }
  else largest = i;
  
  if (right <= N && heap[right] > heap[largest])
    largest = right;

  if (largest != i) {
    swap(heap[i], heap[largest]);
    maxHeapify(heap, largest);
  }
}

void solve(int n) {
  vector<int> heap(n+1);

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

  for (int i = n/2; i >= 1; --i)
    maxHeapify(heap, i);

  for (int i = 1; i <= n; ++i) {
    printf(" %d", heap[i]);
  }
  printf("\n");
}

int main() {

  int n;
  scanf("%d", &n);

  solve(n);
  return 0;
}



Measured memory_bytes: 4164
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int inf=0x3f3f3f3f;
const int Maxn=200000+10;
int f[Maxn],c[Maxn];
int n,m,ans;
int find(int x)
{
	if(f[x]==x)return x;
	return f[x]=find(f[x]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	f[i]=i;
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(find(x)==find(y))continue;
		f[find(x)]=find(y);
	}
	for(int i=1;i<=n;++i)
	++c[find(i)];
	for(int i=1;i<=n;++i)
	if(f[i]==i)ans=max(ans,c[i]);
	printf("%d\n",ans);
	return 0;
}

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
signed main() {
	string S; cin >> S;
	reverse(all(S));
	vector<string> v{ "dream","dreamer","erase","eraser" };
	set<string> st;
	for (auto s : v) {
		reverse(all(s));
		st.insert(s);
	}
	int idx = 0;
	vector<int> ns{ 7,6,5 };
	while (idx < S.size()) {
		bool ok = false;
		for (int x : ns) {
			string s = S.substr(idx, x);
			if (st.count(s)) {
				idx += x;
				ok = true;
				break;
			}
		}
		if(!ok) break;
	}
	cout << (S.size() <= idx ? "YES" : "NO") << endl;
	system("pause");
}

Measured memory_bytes: 760
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int ans = Math.max(a+b,Math.max(a-b,a*b));
    System.out.println(ans);
  }
}

Measured memory_bytes: 32632
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var ans = N / 3;
        Console.WriteLine(ans);
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int D;
   cin >> D;
   if (D == 25) cout << "Christmas" << endl;
   else if (D == 24) cout << "Christmas Eve" << endl;
   else if (D == 23) cout << "Christmas Eve Eve" << endl;
   else if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define ROOP(i,n) for(i=0;i<n;i++)

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdouble(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	char s[30];
	scanf("%s", s);
	int i, count = 0;
	int len = strlen(s);
	for (i = 0; i < 15; i++) {
		s[len + i] = 'o';
	}
	for (i = 0; i < 15; i++) {
		if (s[i] == 'o') {
			count++;
		}
	}
	if (count >= 8) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdouble(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <tuple>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    int ans = k * pow((k-1), (n-1));
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int H = rei();
	int W = rei();
	int N = rei();
	int SH = rei()-1;
	int SW = rei()-1;
	string S1 = res();
	string S2 = res();
	int hf = 0;
	int ht = H-1;
	for(int i=N-1;i>=0;i--){
		if(S2[i] == 'D'){
			hf = max(hf-1,0);
		}
		else if(S2[i] == 'U'){
			ht = min(ht+1,H-1);
		}
		if(S1[i] == 'D'){
			ht--;
			if(hf > ht){
				cout << "NO" << endl;
				return;
			}
		}
		else if(S1[i] == 'U'){
			hf++;
			if(hf > ht){
				cout << "NO" << endl;
				return;
			}
		}
	}
	if(!(hf <= SH && SH <= ht)){
		cout << "NO" << endl;
		return;
	}
	int wf = 0;
	int wt = W-1;
	for(int i=N-1;i>=0;i--){
		if(S2[i] == 'R'){
			wf = max(wf-1,0);
		}
		else if(S2[i] == 'L'){
			wt = min(wt+1,W-1);
		}
		if(S1[i] == 'R'){
			wt--;
			if(wf > wt){
				cout << "NO" << endl;
				return;
			}
		}
		else if(S1[i] == 'L'){
			wf++;
			if(wf > wt){
				cout << "NO" << endl;
				return;
			}
		}
	}
	if(!(wf <= SW && SW <= wt)){
		cout << "NO" << endl;
		return;
	}
	cout << "YES" << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 920
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>

#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define LINF 1000000000000000
#define int long long
using namespace std;
using namespace std::chrono;



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

  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
  
}  






Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n;
	while(cin>>n>>n,n){
		vector<vector<bool> >in(n,vector<bool>(2000));
		int m;
		cin>>m;
		vvi tmp(m,vi(4));
		rep(i,m)rep(j,4)cin>>tmp[i][j];
		rep(i,m)if(!tmp[i][3]){
			for(int j=i-1;j>=0;j--){
				if(tmp[i][1]==tmp[j][1]&&tmp[i][2]==tmp[j][2]){
					loop(k,tmp[j][0]+1,tmp[i][0]+1)in[tmp[i][2]-1][k]=true;	
					break;
				}
			}
		}
		//while(cin>>m,m)cout<<in[0][m]<<endl;
		cin>>m;
		while(m--){
			int a,b,c;
			cin>>a>>b>>c;
			int out=0;
			loop(i,a+1,b+1)if(in[c-1][i])out++;
			cout<<out<<endl;
		}
	}
}

Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
lint gcd(lint a, lint b) {
  if(a < b) {
    swap(a, b);
  }
  while(b > 0) {
    lint r = a % b;
    a = b;
    b = r;
  }
  return a;
}
lint lcm(lint a, lint b) {
    return a * b / gcd(a, b);
}
int main()
{
    lint N, M;
    cin >> N >> M;
    vector<lint> A(N);
    REP(i, N) cin >> A[i];
    vector<lint> div(N, 1);
    REP(i, N) {
        while(A[i]%2 == 0) {
            A[i] /= 2;
            div[i] *= 2;
        }
    }
    FOR(i, 1, N) {
        if(div[i] != div[i-1]) {
            cout << 0 << endl;
            return 0;
        }
    }
    lint alllcm = A[0];
    FOR(i, 1, N){
        alllcm = lcm(alllcm, A[i]);
        if(alllcm * div[0] / 2 > M) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (M / (alllcm * div[0] / 2) + 1) / 2 << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
llong H, W;
int main() {
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1;
		return 0;
	}

	cout << (H * W + 1) / 2;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

    int N,Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<char> alps(Q),LRs(Q);
    int lefout = -1;
    int rigout = N;
    REP(i,Q){
        cin >> alps[i] >> LRs[i];
    }
    
    for(int i=Q-1;i>=0;i--){
        if(LRs[i]=='L'){
            if(s[lefout+1]==alps[i]){
                lefout++;
            }
            if(rigout<N && s[rigout]==alps[i]){
                rigout++;
            }
        }else{
            if(s[rigout-1]==alps[i]){
                rigout--;
            }
            if(lefout>-1 && s[lefout]==alps[i]){
                lefout--;
            }
        }
        
        if(lefout+1==rigout)break;
    }
    
    cout << rigout-lefout-1;
	return 0;
}

Measured memory_bytes: 976
n=int(input())
s1=0
s2=0
s3=list()
s4=list()
s5=list()
for i in range(n):
    a=str(input())
    b=str()
    while a!=b:
        b=a
        a=a.replace(r'()','')
    if len(a)==0:
        continue
    if a[0]=="(" and a[-1]=="(":
        s1+=len(a)
    elif a[0]==")" and a[-1]==")":
        s2+=len(a)
    else:
        x=len(a.replace("(",""))
        y=len(a)-x
        if x<y:
            s3.append([x,y])
        elif x==y:
            s4.append(x)
        else:
            s5.append([x,y])
            
s3.sort(key=lambda x:x[0])
s5.sort(key=lambda x:x[1])

flag=0
limit=s1

if len(s3)!=0:
    for i in range(len(s3)):
        if limit>=s3[i][0]:
            limit=limit-s3[i][0]+s3[i][1]
        else:
            flag=1
            print("No")
            break

x=limit

if len(s4)!=0:
    if limit<max(s4):
        print("No")
        flag=1

limit=s2
if len(s5)!=0:    
    if flag==0:
        for i in range(len(s5)):
            if limit>=s5[i][1]:
                limit=limit-s5[i][1]+s5[i][0]
            else:
                flag=1
                print("No")
                break

if flag==0 and len(s4)!=0:
    if limit<max(s4):
        print("No")
        flag=1

if flag==0 and x==limit:
    print("Yes")
elif flag==0:
    print("No")
        
        
       


Measured memory_bytes: 13216
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int ax,ay,bx,by;
	cin>>ax>>ay>>bx>>by;
	cout<<bx+ay-by<<" "<<by-ax+bx<<" ";
	cout<<ax+ay-by<<" "<<ay-ax+bx<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y,q;

int main(){
  ll ans=0;
  cin >> n >> k>>q;
  vi a(q);
  vi b(n);
  REP(i,q) cin>>a[i];

  REP(i,q){
	  b[a[i]-1]++;
  }


  REP(i,n){
	  if ((b[i]-q+k)<=0){
		  cout<<"No"<<endl;
	  }else
	  {
		  cout<<"Yes"<<endl;
	  }
  }




  return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}

const int N=2010;
struct ED {
	int x,y;
	int ty,id;
}E[N*N];
int res[N*N];
int n,m,head[N],ecnt,mcnt;
struct ed { int to,next; }e[N<<1];
void ad(int x,int  y) {
	e[++ecnt]=(ed){y,head[x]}; head[x]=ecnt;
	e[++ecnt]=(ed){x,head[y]}; head[y]=ecnt;
}
int vis1[N],vis2[N];
int fa[N],dep[N],deg[N];
vector<int> son[N];
void dfs(int u,int last) {
	fa[u]=last,dep[u]=dep[last]+1;
	for(int k=head[u];k;k=e[k].next) {
		int v=e[k].to; if(v==last) continue;
		son[u].PB(v),dfs(v,u);
	}
	deg[u]=son[u].size();
}
void go_mark(int x,int y) {
	if(dep[x]<dep[y]) swap(x,y);
	while(dep[x]>dep[y]) vis2[x]=1,x=fa[x];
	while(x!=y) vis2[x]=vis2[y]=1,x=fa[x],y=fa[y];
}
int LCA(int x,int y) {
	if(dep[x]<dep[y]) swap(x,y);
	while(dep[x]>dep[y]) x=fa[x];
	while(x!=y) x=fa[x],y=fa[y];
	return x;
}
int get_max_dep(int x,int y) { return dep[x]>dep[y] ? x : y; }

set<int> P[N];
queue<int> que;
int main() {
//	freopen("in.txt","r",stdin);
	rd(n),rd(m);
	for(int i=1,x,y;i<n;++i) rd(x),rd(y),ad(x,y);
	dfs(1,0);
	for(int i=1;i<=m;++i) {
		rd(E[i].x),rd(E[i].y);
		E[i].ty=0,E[i].id=i;
		P[E[i].x].insert(i),P[E[i].y].insert(i);
	}
	mcnt=m;
	for(int i=2;i<=n;++i) if(!deg[i]) que.push(i);
	int ans=0;
	while(!que.empty()) {
		int u=que.front(); que.pop();
		if(!vis2[u] && P[u].size()>1) {
			int x=*P[u].begin(); P[u].erase(P[u].begin());
			int y=*P[u].begin(); P[u].erase(P[u].begin());
			int a=E[x].x^E[x].y^u;
			int b=E[y].x^E[y].y^u;
			if(a==b) {
				res[x]=E[x].x!=a,res[y]=E[y].y!=b;
				go_mark(u,a);
				P[a].erase(x),P[b].erase(y);
			}
			else {
				int L=get_max_dep(LCA(u,a),get_max_dep(LCA(u,b),LCA(a,b)));
				go_mark(u,L);
				int k=++mcnt;
				E[k].x=a,E[k].y=b,E[k].ty=0,E[k].id=k;
				E[x].ty=E[k].x!=E[x].x;
				E[y].ty=E[k].y!=E[y].y;
				E[x].id=E[y].id=k;
				P[a].erase(x),P[a].insert(k);
				P[b].erase(y),P[b].insert(k);
			}
		}
		if(vis2[u]) ans+=2;
		else if(!P[u].empty()) ans++;
		while(!P[u].empty()) {
			int x=*P[u].begin(); P[u].erase(P[u].begin());
			int v=E[x].x^E[x].y^u;
//			cerr<<"delete : "<<v<<' '<<u<<endl;
			P[v].erase(x);
			if(v!=fa[u]) {
				int y=++mcnt;
				E[y].x=fa[u],E[y].y=v,E[y].ty=0,E[y].id=y;
				E[x].ty=E[y].y!=E[x].y,E[x].id=y;
				P[v].insert(y),P[fa[u]].insert(y);
			}
		}
		deg[fa[u]]--;
		if(!deg[fa[u]]&&fa[u]!=1) que.push(fa[u]);

//		cout<<"solved : "<<u<<endl;
//		for(int i=1;i<=mcnt;++i) printf("(%d,%d,%d,%d) ",E[i].x,E[i].y,E[i].ty,E[i].id); cout<<endl;
//		for(int i=1;i<=mcnt;++i) cout<<res[i]<<' '; cout<<endl;
				
	}
	printf("%d\n",ans);
	for(int i=mcnt;i>=1;--i) if(E[i].id!=i) res[i]=res[E[i].id]^E[i].ty;
	for(int i=1;i<=m;++i)
		if(res[i]) printf("%d %d\n",E[i].y,E[i].x);
		else printf("%d %d\n",E[i].x,E[i].y);
	return 0;
}

Measured memory_bytes: 27136
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;


const int MAX_M = 15;
int N, H[10];

double dp[2][(1 << MAX_M) + 1];

void solve() {
	int big=0, small=0;
	for (int i = 0; i < 10; i++) {
		if (big < small) swap(big, small);
		if (H[i] < small) {
			printf("NO\n");
			goto JUMP;
		}

		if (H[i] > big) big = H[i];
		else if (H[i] > small) small = H[i];

	}
	printf("YES\n");
JUMP:;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> H[j];
		}
		solve();
	}

	
	return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define X first
#define Y second
using namespace std;

int main(){
	int n = 0;
	cin >> n;
	n++;
	double max = 0, sum = 0;
	double pro = 0, restart = 1;
	int face = 0, allnum = 0;
	while(n--){
		cin >> face >> allnum;
		sum = 0;
		pro = 0;
		restart = 1;
		vector<double> num(allnum, 0);
		vector<double> hope(allnum, 0);
		for(int i = 0; i < allnum; i++){
			cin >> num[i] >> hope[i];
			pro += hope[i];
		}
		restart = 1 - pro;
		while(pro <= 1){
			pro = 0;
			for(int i = 0; i < hope.size(); i++){
				hope[i] += hope[i]*restart;
				pro += hope[i];
			}
			restart = 1-pro+0.00000000001;
		}
		for(int i = 0; i < allnum; i++){
			sum += num[i]*hope[i];
		}
		max = max<sum?sum:max;
	}
	
	cout << (sum==max?"NO":"YES") << endl;
	return 0;
}

Measured memory_bytes: 1232
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	static class Dice{
		Map<Integer,Integer> map=new HashMap<Integer,Integer>();
		int[] dice=new int[7];
	}
	
	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int n=0;
            double sum=0;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	Dice dice1=new Dice();

            	for(int i=0;i<6;i++){
            		dice1.dice[i+1]=Integer.parseInt(str[i]);
            	}
            	
            	line=br.readLine();
            	for(int i=0;i<line.length();i++){
            		if(line.substring(i,i+1).equals("N")){
            			int w=dice1.dice[1];
            			dice1.dice[1]=dice1.dice[2];
            			dice1.dice[2]=dice1.dice[6];
            			dice1.dice[6]=dice1.dice[5];
            			dice1.dice[5]=w;
            		}else if(line.substring(i,i+1).equals("E")){
            			int w=dice1.dice[1];
            			dice1.dice[1]=dice1.dice[4];
            			dice1.dice[4]=dice1.dice[6];
            			dice1.dice[6]=dice1.dice[3];
            			dice1.dice[3]=w;
            		}else if(line.substring(i,i+1).equals("S")){
            			int w=dice1.dice[1];
            			dice1.dice[1]=dice1.dice[5];
            			dice1.dice[5]=dice1.dice[6];
            			dice1.dice[6]=dice1.dice[2];
            			dice1.dice[2]=w;
            		}else if(line.substring(i,i+1).equals("W")){
            			int w=dice1.dice[1];
            			dice1.dice[1]=dice1.dice[3];
            			dice1.dice[3]=dice1.dice[6];
            			dice1.dice[6]=dice1.dice[4];
            			dice1.dice[4]=w;
            		}
            		
            	}
            	System.out.println(dice1.dice[1]);
            	break;
            }
        }
    }

}

Measured memory_bytes: 24484