akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bitset>

uint64_t f(uint64_t x) {
    uint64_t ret = 0ul;
    uint64_t i = 1ul;

    ret = (x % 4ul) == 1ul || (x % 4ul) == 2ul;
    while(i < 64ul) {
        if((x & (1ul << i)) && ((x & 1ul) == 0ul)) ret |= (1ul << i);
        i++;
    }

    return ret;
}

int main(void) {

    // for(int i=0; i<16; i++) {
    //     std::cout << i << "\t" << std::bitset<8>(i) << "\t" << std::bitset<8>(f(i)) << "\n";
    // }

    uint64_t A, B;

    std::cin >> A >> B;

    uint64_t fA = f(A - 1ul);
    uint64_t fB = f(B);

//    std::cout << "f(A-1):" << fA << ", f(B):" << fB << "\n";

    std::cout << (fB ^ fA) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>

using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

int main() {
    //std::ifstream in("in01.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    std::string s, t;
    std::cin >> s >> t;
    
    long long ans = 0;
    int n = s.length();
    bool flag = true;
    
    vector<std::set<int>> chlist;
    chlist.resize(26);
    
    for (int i = 1; i <= 2*n; i++) {
        int ch = s[(2*n - i) % n] - 'a';
        chlist[ch].insert(2*n - i + 1);
    }
    vector<vector<long long>> dp;
    ndarray(dp, 26, 2*n+1);
    for (int ch = 0; ch < 26; ch++) {
        auto itr = chlist[ch].upper_bound(0);
        if (itr == chlist[ch].end()) {
            dp[ch][0] = -1;
        } else {
            dp[ch][0] = *itr;
        }
    }
    for (int next = 1; next <= 2*n; next++) {
        for (int ch = 0; ch < 26; ch++) {
            auto itr = chlist[ch].upper_bound(next);
            if (itr == chlist[ch].end()) {
                dp[ch][next] = -1;
            } else {
                dp[ch][next] = *itr - next;
            }
        }
    }
    int next = 0;
    for (auto ch : t) {
        long long add = dp[ch - 'a'][next];
        if (add == -1) {
            flag = false;
            break;
        } else {
            ans += add;
        }
        next = (next + add - 1) % n + 1;
        //std::cout << add << ", " << next << ", " << ans << std::endl;
    }
    
    if (flag) {
        std::cout << ans << std::endl;
    } else {
        std::cout << -1 << std::endl;
    }
    
    
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    bool l1 = false;
    bool l2 = false;
    for(int i=0; i<s.size(); i++) {
        if(l1 == false) {
            if(s[i] == 'C') {
                l1 = true;
                continue;
            }
        } else {
            if(s[i] == 'F'){
                l2 = true;
                break;
            }
        }
    }
    
    if(l2) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define SUM(a,b) (a+b);
int main(void){
    int i,n,c=0;double m,a,o,res[10000];
    while (1){
        m=0,o=0;
        scanf("%d",&n);int ary[n];
        if (!n){break;}
        for(i=0;i<n;i++){scanf("%d",&ary[i]);m=SUM(m,ary[i]);};m/=(double)n;
        for(i=0;i<n;i++){o=SUM(o,pow(ary[i]-m,2))};o/=(double)n;
        res[c]=sqrt(o);c++;
    }
    for(i=0;i<c;i++){printf("%lf\n",res[i]);}
    return 0;
}
    


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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
//int choose2(ll x){
	//	return x*(x-1)/2;}
int main() {
	int N,X,Y;
	
	
	
	cin >> N >> X>>Y;
	vector<int> A(N);
	rep(i, N)A[i] = 0;
	
	rep(i, N - 1) {
		for (int j = i + 1;j < N;j++) {
			int tmp1 = j - i;
			if (i <= X - 1 && j >= Y - 1)tmp1 = j - i - Y + X + 1;
			if (i <= X - 1 && j<Y - 1 && j>X - 1)tmp1 = min(j - i, X + Y - i - j - 1);
			if (j >= Y - 1 && i<Y - 1 && i>X - 1)tmp1 = min(j - i, i + j - X - Y + 3);
			if(j<Y - 1 && j>X - 1&& i<Y - 1 && i>X - 1)tmp1 = min(j - i, i - X+1+ Y-j);
			A[tmp1 - 1]++;
		}
	}
			rep(i,N-1)cout << A[i]<<endl;
	
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC68 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k = I()
n = 50
ans = [i for i in range(n)]
d,m = divmod(k,n)
for i in range(n):
    ans[i] += d
    if n - i <= m:
        ans[i] += 1
print(n)
print(*ans)


Measured memory_bytes: 38256
#include <stdio.h>
int main(void){
     int n, money=100000; 
     scanf("%d", &n);
    for(int i=1; i<=n; i++){
        money *= 1.05;
        if(money%1000 != 0){
            money = money/1000*1000 +1000;
        }
    }
    printf("%d\n", money);
    return 0;
}



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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	cin>>s;
	int n=s.size()+1;
	vector<ll> a(n,0);
	
	rep(i,n){
		if(s[i]=='<')a[i+1]=a[i]+1;
	}
	repr(i,n-1,1){
		if(s[i-1]=='>')a[i-1]=max(a[i-1],a[i]+1);
	}

	// for(auto x:a)cout<<x<<" ";
	// cout<<endl;

	cout<<accumulate(all(a),0LL)<<endl;
	return 0;
}


Measured memory_bytes: 4740
s=input()
x=["eraser","erase","dreamer","dream",]
t=[]
flag=0
for i in range(4):
    if x[i] in s:
        s=s.replace(x[i],"1")
S=len(s)

for j in range(S) :
    if s[j]!="1":
        print("NO")
        flag+=1
        break

if flag==0:
    print("YES")

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

int main() {
  int a[4],k;
  for(int i=0; i<5; i++){
    cin >> a[i];
  }
  cin >> k;
  
  if(a[4]-a[0]>k)
    cout << ":(" <<endl;
  else
    cout << "Yay!" <<endl;
}


Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
inline bool 
operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
vector<int> 
string_to_vector_int(const string& input){vector<int> out(input.length());rep(i,input.length()){out[i] = (int)(input[i]-'0');} return out;}
template<class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(cmap.begin(),cmap.end(),[&cmap](T x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
tryple_map(const vector<A>& v,const function<B(A,A,A)>& func){vector<B> v_(v.size()-2);rep(i,v.size()-2){ v_[i]=func(v[i+2],v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const B& (*func)(A)){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,B (*func)(A,A)){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
tryple_map(const vector<A>& v,B (*func)(A,A,A)){vector<B> v_(v.size()-2);rep(i,v.size()-2){ v_[i]=func(v[i+2],v[i+1],v[i]); }return v_;}

int twosame(int a,int b){return a==b;}
int tryple_same(int a,int b,int c){return a==b and b==c;}
int integer_sumnation(int a,int b){return a+b;}

ll n,k,a,b,c,d,x;
vector<ll>v;
string s;
void input(){
    cin>>n>>a>>b;
}
void src(){
    cout<< min(b,a*n);
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	int p[a], q[b], r[c];
	for(int i = 0; i < a; i++) {
		cin >> p[i];
	}
	for(int i = 0; i < b; i++) {
		cin >> q[i];
	}
	for(int i = 0; i < c; i++) {
		cin >> r[i];
	}
	sort(p, p + a);
	sort(q, q + b);
	sort(r, r + c);
	reverse(p, p + a);
	reverse(q, q + b);
	reverse(r, r + c);
	priority_queue<int, vi, greater<int>> q1, q2;
	for(int i = 0; i < x; i++) {
		q1.push(p[i]);
	}
	for(int i = 0; i < y; i++) {
		q2.push(q[i]);
	}
	for(int i = 0; i < c; i++) {
		if(r[i] < q1.top() && r[i] < q2.top()) {

		}
		else if(r[i] < q1.top() && r[i] > q2.top()) {
			q2.pop();
			q2.push(r[i]);
		}
		else if(r[i] > q1.top() && r[i] < q2.top()) {
			q1.pop();
			q1.push(r[i]);
		}
		else {
			if(q1.top() < q2.top()) {
				q1.pop();
				q1.push(r[i]);
			}
			else {
				q2.pop();
				q2.push(r[i]);
			}
		}
	}
	int ans = 0;
	while(!q1.empty()) {
		ans += q1.top();
		q1.pop();
	}
	while(!q2.empty()) {
		ans += q2.top();
		q2.pop();
	}
	cout << ans;

	return 0;
}

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

using namespace std;

#define ll long long
#define mod 1000000007

const ll INF = 1e11;

void solve(){

    ll k; cin >> k;
    ll ans = 0;
    ll val = 0;
    vector<bool> vis (k, false);
    while(1){
        ++ans;
        val *= 10;
        val += 7;
        val %= k;
        if(val == 0){ cout << ans; break;}
        if(vis[val]){ cout << -1; break;}
        vis[val] = true;
    }

    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long n,ans=0;
    cin >> n;
    
    rep(i,1,n+1){
    	long t=i,count=0;
    	while(t>0){
    		t/=10;
            count++;
    	}
      if(count%2==1) ans++;
    }
    cout << ans << endl;
}    


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    int ans;
    if (s == "SAT")
    {
        ans = 1;
    }
    if (s == "FRI")
    {
        ans = 2;
    }
    if (s == "THU")
    {
        ans = 3;
    }
    if (s == "WED")
    {
        ans = 4;
    }
    if (s == "TUE")
    {
        ans = 5;
    }
    if (s == "MON")
    {
        ans = 6;
    }
    if (s == "SUN")
    {
        ans = 7;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m;
int a[2000],b[2000];

int bfs(int i,int s){
  if(s==0)return 1;
  if(i>=n) return 0;
  if(bfs(i+1,s)||bfs(i+1,s-a[i]))return 1;
  return 0;
}

int  main(){

  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  cin>>m;
  for(int i=0;i<m;i++)cin>>b[i];

  for(int i=0;i<m;i++){
    if(bfs(0,b[i]))cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;

}

Measured memory_bytes: 1164
import java.util.*;
public class Main {

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

        boolean[] thirtyone = new boolean[31];

        for (int i=0;i<28;i++){
            thirtyone[sc.nextInt()] = true;
        }
        for (int i=1;i<31;i++){
            if(!thirtyone[i]){
                System.out.println(i);
            }
        }
    }
}

Measured memory_bytes: 17244
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int A[n];

	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}

	int q, b, e, t;

	cin >> q;

	for (int j = 0; j < q; j++) {
		cin >> b >> e >> t;

		for (int k = 0; k < e - b; k++) {
			swap(A[b + k], A[t + k]);
		}
	}

	for (int l = 0; l < n; l++) {
		if (l == 0) cout << A[l];
		else cout << " " << A[l];
	}
	cout << endl;
}




Measured memory_bytes: 3092
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int limit = 100005;
using edge = struct {int to; long long cost;};

int n;
vector<edge> tree[limit];
vector<long long> dist;

void dfs(int v, long long d = 0, int p = -1){
    dist[v] = d;
    for(auto &e : tree[v]) {
        if(e.to == p) continue;
        dfs(e.to, d + e.cost, v);
    }
}

vector<long long> calcDist(int s){
    dist = vector<long long>(n);
    dfs(s);
    return dist;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
	int q, k;
	cin >> q >> k;
	--k;
	vector<ll> distK = calcDist(k);
	rep(i,q){
		int x, y;
		cin >> x >> y;
		--x; --y;
		ll ans = distK[x] + distK[y];
		cout << ans << endl;
	}
    return 0;
}


Measured memory_bytes: 15104
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in); 
		int n=in.nextInt();
		String a=in.nextLine();
		while(n--!=0)
		{
			char ch[] = in.nextLine().toCharArray();
			for(int i=0 ; i<ch.length-6; i++)
			{
				if(ch[i]=='H'&&ch[i+1]=='o'&&ch[i+2]=='s'&&ch[i+3]=='h'&&ch[i+4]=='i'&&ch[i+5]=='n'&&ch[i+6]=='o')
				{
					ch[i+6]='a';	
				}
			}
			System.out.println(ch);
		}
	}
}

Measured memory_bytes: 12000
import atexit
import io
import sys

buff = io.BytesIO()
sys.stdout = buff


@atexit.register
def write():
    sys.__stdout__.write(buff.getvalue())

n = input()
v = map(int, raw_input().split())
c = map(int, raw_input().split())
arr = []
ans = 0
for i in xrange(n):
	arr.append(v[i]-c[i])
arr.sort(reverse = True)
for i in xrange(n):
	if arr[i] > 0:
		ans += arr[i]
	else:
		break
print ans

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

int main(){
    string S;
    cin >> S;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<3;j++){
            if(S[i]==S[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<pair<int64_t, int64_t>> XY(N);
  vector<int64_t> X(N);
  vector<int64_t> Y(N);
  rep(i, N) {
    int64_t x, y;
    cin >> x >> y;
    XY[i] = {x, y};
    X[i] = x;
    Y[i] = y;
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());

  int64_t answer = INT64_MAX;
  for (int xi = 0; xi < N - 1; ++xi) {
    for (int xj = xi + 1; xj < N; ++xj) {
      for (int yi = 0; yi < N - 1; ++yi) {
        for (int yj = yi + 1; yj < N; ++yj) {
          int count = 0;
          for (int k = 0; k < N; ++k) {
            if ((X[xi] <= XY[k].first && XY[k].first <= X[xj]) &&
                (Y[yi] <= XY[k].second && XY[k].second <= Y[yj]))
              ++count;
          }
          if (K <= count) {
            int64_t area = abs(X[xi] - X[xj]) * abs(Y[yi] - Y[yj]);
            answer = min(answer, area);
          }
        }
      }
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5]){
    	cout<<"Yes"<<endl;
    }
    else{
    	cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
  int N, ans, l;
  cin >> N;
  ans=1;
  vector<int> H(N);
  for (int i=0; i<N; i++) {
    cin >> H[i];
  }
  if (N>=2) {
    for (int j=1; j<N; j++) {
      l=0;
      for (int k=0; k<j; k++) {
        if (H[k]<=H[j]) {
          l=l+1;
        }
      }
      if (l==j) {
        ans=ans+1;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3560
#include<stdio.h>
int main()
{
	int n,i,j;
	scanf("%d",&n);
	long int b[n]={0};
	long int a[n]={0};
	for(i=0;i<n;i++)
	{
		scanf("%ld",&a[i]);
	}
		for(i=n-1,j=0;i>=0;i=i-2,j++)
		{
			b[j]=a[i];
			if(i!=0)
			b[n-j-1]=a[i-1];
			
		}
		for(i=0;i<n;i++)
		{
			printf("%ld ",b[i]);
		}
		return 0;
 } 

Measured memory_bytes: 5248
N = int(input())
A = [*map(int, input().split())]

Y = 1000
buy, sell = [], []
for i in range(N):
  if not buy:
    buy.append(A[i])
  elif not sell:
    if A[i] <= buy[-1]:
      buy[-1] = A[i]
    else:
      sell.append(A[i])
  else:
    if A[i] >= sell[-1]:
      sell[-1] = A[i]
    else:
      div, mod = divmod(Y, buy.pop())
      Y = sell.pop() * div + mod
      buy.append(A[i])
if buy and sell and buy[-1] < sell[-1]:
    div, mod = divmod(Y, buy.pop())
    Y = sell.pop() * div + mod
print(Y)

Measured memory_bytes: 9224
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

const long long MOD = 1e9 + 7;
const int MAXN = 21;
int a[MAXN][MAXN];
// dp[i][mask] is the number of ways to make i pairs using [0..i] men and mask women.
long long dp[MAXN][1<<MAXN];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	
	for (int j = 0; j < n; j++) {
		if (a[0][j]) dp[0][1<<j] = 1;
	}
	
	for (int i = 0; i < n-1; i++) {
		for (int j = 0; j < (1<<n); j++) {
			if (dp[i][j] == 0) continue;
			for (int k = 0; k < n; k++) {
				if (!(j & (1<<k)) && a[i+1][k]) {
					dp[i+1][j|(1<<k)] += dp[i][j];
					dp[i+1][j|(1<<k)] %= MOD;
				}
			}
		}
	}

	cout << dp[n-1][(1<<n)-1] << endl;
}


Measured memory_bytes: 307456
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    string s;
    ll c=0;
    cin>>s;
    if(s.size()%2 != 0){
        cout<<"No"<<endl;
        return 0;
    }
    rep(i,s.size()-1){
        if(s[i]=='h' && s[i+1]=='i'){
            c++;
            i++;
            }
        }
    if(c==s.size()/2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int H,W,T;
string s[10];

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M);
  for(int i(0);i<M;i++){
    cin>>A[i];
  }
  sort(A.rbegin(),A.rend());
  int num[10] = {0,2,5,5,4,5,6,3,7,6};
  map<int,int> ma;
  set<int> honsuu;
  for(int i(0);i<M;i++){
    ma[num[A[i]]] = max(ma[num[A[i]]],A[i]);
    honsuu.insert(num[A[i]]);
  }
  int dp[10001] = {0}; //iを作るのに必要な最大個数
  for(auto m:honsuu){
    dp[m] = 1;
  }
  for(int i(0);i<=N;i++){
    for(auto m:honsuu){
      if(i-m >= 0 && dp[i-m] != 0){
        if(dp[i-m] + 1 >= dp[i]){
          dp[i] = dp[i-m] + 1;
        }
      }
    }
  }

  vector<int> ans;
  int now = N;
  while(dp[now] != 1){
    for(int i(0);i<M;i++){
      if(dp[now] - dp[now-num[A[i]]] == 1){
        ans.push_back(A[i]);
        now = now - num[A[i]];
        break;
      } 
    }
  }
  ans.push_back(ma[now]);

  sort(ans.rbegin(),ans.rend());
  for(int i(0);i<int(ans.size());i++){
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

x = sum(B)
for a,b in zip(A,A[1:]):
    if b == a+1:
        x += C[a-1]

print(x)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int k, x;
    cin >> k >> x;
    // vector<int> ans;
    for(int i = x-(k-1); i <= x+(k-1); i++) {
        if (i >= -1e6 && i <= 1e6) {
            cout << i << " ";
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) os << exchange(dlm, " ") << x;
  return os;
}
struct Graph{
  size_t time,time2;
  using seen_t=int32_t; using ver_t=size_t;
  const seen_t NO=-1; vector<seen_t> seen,finished;
  vector<vector<ver_t>> edge; vector<ver_t> prev;
  Graph(size_t n): time(0), time2(0), seen(n,NO), finished(n,NO), edge(n), prev(){}
  bool dfs(ver_t frm, ver_t par){
    // pre
    seen[frm]=time++; prev.push_back(frm);
    for(const auto& to:edge[frm]){
      if(to!=par){
      if(seen[to]==NO && dfs(to,frm)) return true;
      else if(finished[to]==NO){
        prev.erase(begin(prev),find(begin(prev),end(prev),to));
        return true;
      }
      }
    }
    // post
    finished[frm]=time2++; prev.pop_back();
    return false;
  }
};
int32_t main(){
  size_t n; cin>>n;
  Graph g(n);
  for(size_t i=0; i<n; ++i){
    size_t s,t; cin>>s>>t; --s; --t;
    g.edge[s].push_back(t); g.edge[t].push_back(s);
  }
  g.dfs(0,0);
  // cout<<g.prev<<'\n';
  sort(begin(g.prev),end(g.prev));
  size_t q; cin>>q;
  for(size_t i=0; i<q; ++i){
    size_t a,b; cin>>a>>b; --a; --b;
    cout<<(
      binary_search(begin(g.prev),end(g.prev),a)
      &&binary_search(begin(g.prev),end(g.prev),b)
      ?2:1)<<'\n';
  }
}


Measured memory_bytes: 14228
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  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{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "YES\n";
  int d = a%b;
  if (d == 0) {
    if (c) ans = "NO\n";
  }
  else {
    if (c%gcd(d, b)) ans = "NO\n";
  }
  cout << ans;
}



Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
  vll a(3);
  rep(i,0,3) cin >> a[i];

  sort(all(a));

  print((a[2] - a[1]) + (a[1] - a[0]));


  return 0;
}




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

using namespace std;

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

  int time_once = 100 * (N - M) + 1900 * M;
  double p_ok = pow(0.5, M);
  double p_ng = 1.0 - p_ok;

  cout << p_ok * time_once * (p_ng / p_ok + 1) / p_ok << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--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 CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,q;
vi g[125252];
int f[125252][10];
int color[125252];
pair<pii,pii> queries[125252];

const int B = 500;

bool used[125252];
int cnt[125252][10];
vi gg[125252];

void gyudfs(int p,int bef,int par){
  if(used[p]){
    if(p!=0)gg[par].push_back(p);
    par = p;
  }
  cnt[par][color[p]]++;
  for(int to : g[p])if(to!=bef){
    gyudfs(to,p,par);
  }
}

void baadfs(int p,int bef,int par){
  if(used[p]){
    par = p;
  }
  color[p] = f[par][color[p]];
  for(int to : g[p])if(to!=bef){
    baadfs(to,p,par);
  }
}

int countdfs(int p,int x,int y){
  int ret = 0;
  FOR(i,x,y+1)ret += cnt[p][i];
  for(int to : gg[p]){
    ret += countdfs(to,x,y);
  }
  return ret;
}

void changedfs(int p,int x,int y){
  if(x!=y){
    cnt[p][y] += cnt[p][x];
    cnt[p][x] = 0;
  }
  // update f
  REP(i,10)if(f[p][i]==x){
    f[p][i] = y;
  }
  for(int to : gg[p]){
    changedfs(to,x,y);
  }
}

int main(){
  scanf("%d%d",&n,&q);
  REP(i,n-1){
    int u,v;
    scanf("%d%d",&u,&v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  REP(i,q){
    int t,r,x,y;
    scanf("%d%d%d%d",&t,&r,&x,&y);
    queries[i] = make_pair(pii(t,r),pii(x,y));
  }
  int qhead = 0, qtail = 0;
  while(qtail < q){
    qtail += B;
    CHMIN(qtail, q);
    // init
    REP(i,n)REP(j,10)f[i][j] = j,cnt[i][j]=0;
    REP(i,n)used[i]=false, gg[i].clear();
    // shukuyaku
    FOR(i,qhead,qtail){
      int r=queries[i].first.second;
      used[r] = true;
    }
    used[0] = true;
    // REP(i,n)used[i]=true;
    gyudfs(0,-1,0);
    // query
    FOR(i,qhead,qtail){
      int t=queries[i].first.first;
      int r=queries[i].first.second;
      int x=queries[i].second.first;
      int y=queries[i].second.second;
      if(t==1){
        // count
        int ans = countdfs(r,x,y);
        printf("%d\n",ans);
      }else{
        // change
        changedfs(r,x,y);
      }
    }
    // modosu
    baadfs(0,-1,0);
    qhead = qtail;
  }
  return 0;
}

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

int main() {
    int A, B;
    std::cin >> A >> B;

    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        std::cout << "Possible\n";
    } else {
        std::cout << "Impossible\n";
    }

    return 0;
}


Measured memory_bytes: 256
//Name: Electro-Fly
//Level: 2
//Category: 数学
//Note: 

/**
 * それぞれの座標軸について周期を求め、最小公倍数を取ればよい。
 * 周期は a^k ≡ 1 (mod m) となる最小の k>1 だが、これはシミュレーションで求められる。
 *
 * オーダーは O(M)。
 */
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;

int period(int a, int m) {
    vector<int> p(m, -1);
    int cur = a % m;
    for(int i = 0; i < m; ++i) {
        if(p[cur] >= 0) return i - p[cur];
        p[cur] = i;
        cur = (cur * a) % m;
    }
    assert(false);
}

long long lcm(long long a, long long b) {
    if(a < b) swap(a, b);
    long long prod = a * b;
    while(b) {
        const long long tmp = a % b;
        a = b;
        b = tmp;
    }
    return prod / a;
}

bool solve() {
    int a1, m1, a2, m2, a3, m3;
    cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3;
    if(!a1 && !m1 && !a2 && !m2 && !a3 && !m3) return false;

    const int p1 = period(a1, m1);
    const int p2 = period(a2, m2);
    const int p3 = period(a3, m3);
    cout << lcm(p1, lcm(p2, p3)) << endl;

    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1320
#[warn(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        l: usize,
    }

    let ans = (l * l * l) as f64 / 27 as f64;

    // let mut ans = 0f64;
    // let l = l * 10;

    // for x in 0..l+1 {
    //     for y in 0..l-x+1 {
    //         let z = (l - x - y) as f64 / 10.0;
    //         let x = x as f64 / 10.0;
    //         let y = y as f64 / 10.0;
    //         ans = ans.max(x * y * z);
    //     }
    // }

    println!("{}", ans);
}


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



void solve(long long N, std::vector<long long> a){
    double dp[N+1][N+1][N+1] ={};
    int num[3] = {};
    for(int i=0;i<N;i++){
        num[a[i]-1]++;
    }

    for(int k=0;k<=N;k++){
        for(int j=0;j<=N;j++){
            for(int i=0;i<=N;i++){
                if(i+j+k ==0){
                    dp[i][j][k] = 0;
                    continue;
                }
                if(i+j+k >N){
                    continue;
                }
                double exp = 1;
                // cerr << "i=" << i<<"j=" <<j << "k=" <<k << endl;
                if(i>0){
                    exp += (dp[i-1][j][k] * i/(double)N) ;
                }
                if(j>0){
                    exp += (dp[i+1][j-1][k] * j/(double)N) ;
                }
                if(k>0){
                    exp += (dp[i][j+1][k-1] * k/(double)N);
                }
                // cerr << "finish" << endl;
                dp[i][j][k] = exp *(double) N /(i+j+k);
            }
        }
    }
    // cerr << "out" << endl;
    cout << setprecision(10)<<dp[num[0]][num[1]][num[2]] << endl;

  

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 213376
import java.util.*;

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

    int n = sc.nextInt();
    double[] x = new double[n];
    double[] y = new double[n];
    double d1 = 0;
    double d2 = 0;
    double d3 = 0;
    double di = 0;

    for(int i = 0; i < n; i++){
      x[i] = sc.nextDouble();
    }

    for(int i = 0; i < n; i++){
      y[i] = sc.nextDouble();
    }

    for(int i = 0; i < n; i++){
      d1 += Math.abs(x[i] - y[i]);
    }

    for(int i = 0; i < n; i++){
      d2 += Math.pow(x[i] - y[i], 2);
    }

    for(int i = 0; i < n; i++){
      d3 += Math.pow(Math.abs(x[i] - y[i]), 3);
    }

    for(int i = 0; i < n; i++){
      if(Math.abs(x[i] - y[i]) > di){
        di = Math.abs(x[i] - y[i]);
      }
    }

    System.out.println(d1);
    System.out.println(Math.sqrt(d2));
    System.out.println(Math.cbrt(d3));
    System.out.println(di);
  }
}



Measured memory_bytes: 29008
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
const int MAX=100000;

vector<int> G[MAX];
int n;
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;

void dfs(int current,int prev)
{
	prenum[current]=lowest[current]=timer++;
	visited[current]=true;
	int next;
	
	for(int i=0;i<G[current].size();i++)
	{
		next=G[current][i];
		if(!visited[next])
		{
			parent[next]=current;
			dfs(next,current);
			lowest[current]=min(lowest[current],lowest[next]);
		}
		else if(next!=prev)
		{
			lowest[current]=min(lowest[current],prenum[next]);
		}
	}
	
	return;
}

void art_points()
{
	for(int i=0;i<n;i++)visited[i]=false;
	timer=1;
	dfs(0,-1);//0==root
	
	set<int> ap;
	int np=0,p;
	for(int i=1;i<n;i++)
	{
		p=parent[i];
		if(p==0)np++;
		else if(prenum[p]<=lowest[i])ap.insert(p);
	}
	if(np>=2)ap.insert(0);
	for(auto it:ap)cout<<it<<endl;
	
	return;
}

int main()
{
	int m;cin>>n>>m;
	int s,t;
	for(int i=0;i<m;i++)
	{
		cin>>s>>t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	art_points();
	return 0;
}

Measured memory_bytes: 6944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int n4 = n / 1000;
		int n3 = (n - (n4 * 1000)) / 100;
		int n2 = (n - (n4 * 1000) - (n3 * 100)) / 10;
		int n1 = n - (n4 * 1000) - (n3 * 100) - (n2 * 10);
		String message = "No";
		if(n4 == n3 && n3 == n2) {
			message = "Yes";
		} else if(n3 == n2 && n2 == n1) {
			message = "Yes";
		}
		System.out.println(message);
	}
}

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


N = int(input())
arr_a = list(map(int, input().split()))

ret = [ -1 for x in range(len(arr_a)) ]
for i in range(len(arr_a)):
    ret[arr_a[i]-1] = i+1

print(" ".join([ "{0:d}".format(x) for x in ret ]))

Measured memory_bytes: 18376
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<cstring>
//#include<unordered_map>
using namespace std;
#define ll long long 
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7;

const int maxn=100;

int a[maxn];

int b[maxn];

int c[maxn]; 

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	for(int i=1;i<=n;i++)
		cin>>b[i];
	
	for(int i=1;i<n;i++)
		cin>>c[i];
	
	ll int ans=0;
	
	for(int i=1;i<=n;i++)
	{
		if(i==1)
			ans+=b[a[i]];
		else
		{
			ans+=b[a[i]];
			if(a[i]-1==a[i-1])
			{
				ans+=c[a[i-1]];
		//		cout<<c[a[i-1]]<<endl;
			}
		}
	}
	
	cout<<ans<<endl;
	
		
	return 0;
 } 

Measured memory_bytes: 256
import bisect
n = int(input())
L = sorted(((map(int,input().split()))))
#print(L)
cnt = 0
for i in range(n):
  for j in range(i+1,n):
    num = L[i] + L[j]
    b = bisect.bisect_left(L, num)
    #print(L[i], L[j], b, cnt)
    if b-1 > j:
      cnt += b-1-j
print(cnt)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  string s, t;
  cin >> s >> t;
  char sc = 'z', tc = 'a';
  int n = s.length(), m = t.length();
  for(int i = 0; i < n; i++){
    sc = min(sc, s[i]);
  }
  for(int i = 0; i < m; i++){
    tc = max(tc, t[i]);
  }
  //cout << sc << " " << tc << endl;
  if(sc < tc) {
    cout << "Yes\n";
  }else if(tc == sc && n < m){
    for(int i = 0; i < n; i++){
      if(s[i] == t[i]){
        continue;
      }else{
        cout << "No\n";
        return 0;
      }
    }
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,h[100005],dp[100005];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++)
		scanf("%d",&h[i]);
	dp[0] = 0;
	for (int i=1;i<n;i++){
		dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
		int m = i+1;
		if (m>k+1) m=k+1;
		for (int j=2;j<m;j++) {
			int tmp = dp[i-j] + abs(h[i]-h[i-j]);
			if (dp[i]>tmp)  dp[i]=tmp;
		}
	}
	printf("%d",dp[n-1]);
	return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let h: usize = read();
    let w: usize = read();
    let mut map: Vec<Vec<i64>> = vec![vec![0; 10]; 10];
    let mut ans = 0;

    for i in 0..10 {
        for j in 0..10 {
            let item: i64 = read();
            map[i][j] = item;
        }
    }

    let mut cnt: Vec<i64> = vec![0; 10];
    for _ in 0..h * w {
        let item: i64 = read();
        if item >= 0 {
            cnt[item as usize] += 1;
        }
    }

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                map[i][j] = min(map[i][j], map[i][k] + map[k][j]);
            }
        }
    }

    for i in 0..cnt.len() {
        let ci = cnt[i];
        ans += map[i][1] * ci;
    }
    println!("{}", ans);
}


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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e16;

using namespace std;

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

    int N, M;
    scanf("%d %d", &N, &M);

    vector<int> A(N);
    vector<Pii> BC(M);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &A[i]);
    }
    for (int i = 0; i < M; ++i) {
        scanf("%d %d", &(BC[i].second), &(BC[i].first));
    }

    sort(A.begin(), A.end());

    sort(BC.rbegin(), BC.rend());

    ll sum = 0;
    int cnt = 0;

    for (int i = 0; i < M && cnt < N; ++i) {
        int replaceable = distance(A.begin(), lower_bound(A.begin(), A.end(), BC[i].first)) - cnt;
        if (replaceable <= 0) break;
        int replace = min(replaceable, BC[i].second);
        sum += (ll)BC[i].first * replace;
        cnt += replace;
    }

    for (int i = cnt; i < N; ++i) {
        sum += (ll)A[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main() {
	int a[26] = {};

	string str;
	while (getline(cin, str)) {
		if (cin.eof()) break;
		for (int i = 0; i < str.size(); i++) {
			char c = tolower(str[i]);
			if (isalpha(c)) a[c - 'a']++;
		}
	}

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

	return 0;
}



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

int main() {
  int n;
  cin >> n;
  long to=0;
  vector<long>x(n),y(n);
  rep(i,n){
    cin>>x.at(i);
    to+=x.at(i);
    y.at(i)=to;
  }
  long ch=500000000000000;
  rep(i,n){
    ch=min(ch,abs(to-y.at(i)*2));
  }  
  cout<<ch<<endl;  
}






Measured memory_bytes: 3456
from math import radians, sin, cos, sqrt
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for theta in range(3600):
	ansx, ansy = 0, 0
	e = [cos(radians(theta/10)), sin(radians(theta/10))]
	for x, y in a:
		pr = x * e[0] + y * e[1]
		if pr > (1e-10):
			ansx += x
			ansy += y
	ans = max(ans, sqrt(ansx**2+ansy**2))
print(ans)

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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
 {
	string s;
	cin>>s;
	map<string,string> m;
	m["Sunny"]="Cloudy";
	m["Cloudy"]="Rainy";
	m["Rainy"]="Sunny";
	cout<<m[s];
	return 0;
}

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

using namespace std;

typedef long long LL;

LL n,m,a[4],b[4],f[5000*5000+10];

int main(){
	scanf("%lld%lld%lld%lld%lld%lld%lld",&n,a+1,a+2,a+3,b+1,b+2,b+3);
	for (LL i=n;~i;--i){
		f[i]=i;
		for (LL j=1;j<=3;++j)
			if (i+a[j]<=n) f[i]=max(f[i],f[i+a[j]]+b[j]-a[j]);
		m=max(m,f[i]);
	}
	memset(f,0,sizeof f);
	for (LL i=m;~i;--i){
		f[i]=i;
		for (LL j=1;j<=3;++j)
			if (i+b[j]<=m) f[i]=max(f[i],f[i+b[j]]+a[j]-b[j]);
		n=max(n,f[i]);
	}
	printf("%lld\n",n);
	
	return 0;
}
			

Measured memory_bytes: 195584
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    A,B = LMIIS()
    #A:1.08 B:1.1
    from math import ceil,floor
    # print(A/0.08,B/0.1)
    # print(ceil(A/0.08),ceil(B/0.1))
    # A_min = ceil(A/0.08)
    # A_max = ceil((A+1)/0.08)-1
    # B_min = ceil(B/0.1)
    # B_max = ceil((B+1)/0.1)-1
    # print(A_min,A_max,B_min,B_max)
    for i in range(1,100000):
        if floor(i *0.08) == A and floor(i *0.1) == B:
            print(i)
            return
    print(-1)

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = ll(1e18)+1;

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

	vector<ll> p(n);

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

	ll ma = 0;

	rep(i,k) {
		ma += p[i];
	}

	ll Max = ma;

	rep(i, n-k) {
		ma += p[i+k];
		ma -= p[i];
		Max = max(Max, ma);
	}

	Max += k;
	double e = Max;
	cout << fixed << setprecision(8) << e/2 << endl;
	return 0;
}

Measured memory_bytes: 4836
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=1e9+7;
vector<int> G1[200005],G2[200005];
int groad[200005],grail[200005];
map<pii,int> ids;
bool vis[200005];
void dfs(int v,int cur,const vector<int> G[],int res[]){
	vis[v]=true;
	res[v]=cur;
	rep(k,G[v].size()){
		int u=G[v][k];
		if(vis[u])continue;
		dfs(u,cur,G,res);
	}
}
int main(){
	int n,m1,m2,x,y;
	scanf("%d%d%d",&n,&m1,&m2);
	rep(k,m1){
		scanf("%d%d",&x,&y);x--;y--;
		G1[x].push_back(y);
		G1[y].push_back(x);
	}
	rep(k,m2){
		scanf("%d%d",&x,&y);x--;y--;
		G2[x].push_back(y);
		G2[y].push_back(x);
	}
	int sz1=0,sz2=0;
	memset(vis,false,sizeof(vis));
	rep(k,n)if(!vis[k])dfs(k,sz1++,G1,groad);
	memset(vis,false,sizeof(vis));
	rep(k,n)if(!vis[k])dfs(k,sz2++,G2,grail);
	rep(k,n)ids[MP(groad[k],grail[k])]++;
	rep(k,n)printf("%d ",ids[MP(groad[k],grail[k])]);
	return 0;
}

Measured memory_bytes: 28160
import itertools

N, M = map(int, input().split())
target_switches = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))


answer_count = 0
for switches in itertools.product((0, 1), repeat=N):
    on_count = 0
    for j in range(M):
        count = 0
        for i in range(N):
            if (switches[i] == 1) and (i + 1 in target_switches[j][1:]):
                count += 1
                
        if count % 2 == p[j]:
            on_count += 1
    
    if on_count == M:
        answer_count += 1

print(answer_count)

Measured memory_bytes: 9068