akhauriyash/Code-Regression huggingface dataset:
string = list(input())
times = int(input())
#a = [int(i) for i in range(0,5)]
#print(a)
for i in range(times):
    order = input().split()
    #print(order)
    if order[0] == "replace":
        replace_string = order[3]
        #print(string)
        count = 0
        for j in range(int(order[1]), int(order[2]) + 1):
            string[j] = replace_string[count]
            count += 1
            #print(count)
        #print(string)
    elif order[0] == "reverse":
        #print(string)
        reverse_string = string[int(order[1]):int(order[2]) + 1]
        reverse_string.reverse()
        #for j in range(int(order[1]), int(order[2]) + 1):
        #    string[j] = reverse_string[j]
        string = string[:int(order[1])] + reverse_string + string[int(order[2])+1:]
        #print(j)
        #print(string)
        #string[int(order[1]):int(order[2]) + 1].reverse()
        #print(string)
        #string[int(order[1]):int(order[2])] = string[int(order[1]):int(order[2])].reverse()
    elif order[0] == "print":
        #print(string)
        print("".join(string[int(order[1]):int(order[2]) + 1]))
        #print(string)

Measured memory_bytes: 7688
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] str = line.split(" ");
        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);
        System.out.println(x+(y/2));
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

ll N;
ll A[100010];

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

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

  ll suf=0;
  rep(i,N-1){
    (suf+=mod_pow(i+2,mod-2))%=mod;
  }
  ll prf=1;
  ll res=0;
  rep(i,N){
    res+=(prf+suf)*A[i]%mod;
    res%=mod;
    suf=(suf-mod_pow(N-i,mod-2)+mod)%mod;
    prf=(prf+mod_pow(i+2,mod-2))%mod;
  }

  rep(i,N)(res*=(i+1))%=mod;
  cout<<res<<endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair

const int maxn = 4e5 + 10, INF = 0x3f3f3f3f;
const ll MOD = 1000000007LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};


int main(){
// freopen("C:\Users\Administrator\Desktop\in.txt","r",stdin);
// freopen("C:\Users\Administrator\Desktop\out.txt","w",stdout);
ll a,b,c,k;
cin>>a>>b>>c>>k;
ll res;
if (k & 1) {
cout<<b - a<<endl;
} else cout<<a - b<<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
bool pp(string s)
{
    string t=s;
    reverse(s.begin(),s.end());
    return s==t;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      int a[3][3];
      REP(i,3)
      {
          REP(j,3)
          cin>>a[i][j];
      }
      int n;
      cin>>n;
      while(n--)
      {
          int b;
          cin>>b;
          REP(i,3)
          {
              REP(j,3)
              {
                  if(a[i][j]==b)
                  {a[i][j]=0;break;}
              }
          }
      }
      for(int i=0;i<3;i++)
      {
          if(a[i][0]==0 && a[i][1]==0 && a[i][2]==0)
          return cout<<"Yes\n",0;
          else if(a[0][i]==0 && a[1][i]==0 && a[2][i]==0)
        return cout<<"Yes\n",0;
      }
      if(a[0][0]==0 && a[1][1]==0 && a[2][2]==0)
      return cout<<"Yes\n",0;
      if(a[0][2]==0 && a[1][1]==0 && a[2][0]==0)
      return cout<<"Yes\n",0;
      cout<<"No";

  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
#define INF 2147483647 // 2^31-1
 
vector<int> value; // ノードの値を持つ配列
int N;             // 葉の数
 
void update(int i, int x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = min(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の min を計算しなおす
    }
}
 
int query(int a, int b, int k, int l, int r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                         // に完全に含まれる
    else {
        int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        int c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return min(c1, c2); // 左右の子の値の min を取る
    }
}
 
int main(void) {
    int n, q;
    cin >> n >> q;
    N = 1;
    while (N < n) N *= 2; // 葉の数を計算（n以上の最小の2冪数）
 
    value = vector<int>(2 * N - 1, INF);
 
    for (int j = 0; j < q; j++) {
        int c;
        cin >> c;
        if (c == 0) {
            // update(i, x)
            int i, x;
            cin >> i >> x;
            update(i, x);
        } else {
            // find(s, t)
            int s, t;
            cin >> s >> t;
            cout << query(s, t + 1, 0, 0, N) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 5000
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-07-29 16:20:16 +0900
# LastModified: 2020-07-29 16:30:22 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from itertools import accumulate


def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    s = [(x+1)/2 for x in p]
#    print(s)
    s = list(accumulate(s))
    s.insert(0, 0)
    ans = 0
#    print(s)
    for i in range(n-k+1):
        ans = max(ans, s[i+k]-s[i])
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 33172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

//64D
// a + b * c + d
// a * b + c * d
// 133 + 32 * 3 + 4


int main(void) {
	int n;
	string s;
	cin >> n >> s;
	//[trueL,trueR)が正しい文字列
	ll trueL = 0;
	ll trueR = 1;
	ll rParren = 0;
	ll lParren = 0;
	ll dMin = 0;
	ll d = 0;
	rep(i, 0, s.size()) {
		if (s[i] == '(') {
			dMin = min(dMin, ++d);
		}
		else {
			dMin = min(dMin, --d);
		}
	}
	rep(i, 0, -dMin)s.insert(s.begin(), '(');
	rep(i, 0, d - dMin)s.insert(s.begin() + s.size(), ')');
	cout << s << endl;
	
}

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

int main(){
    int N,K;cin>>N>>K;
    vector<long double> sai(N);
    for(int i=0;i<N;i++){
        long double k;cin>>k;
        sai.at(i)=(1+k)/2;
    }
    long double maxi=0;
    long double sum=0;
    for(int i=0;i<K;i++)sum+=sai.at(i);
    maxi=sum;
    int k=0;
    for(int i=K;i<N;i++){
        sum=sum+sai.at(i)-sai.at(k);
        maxi=max(sum,maxi);
        k++;
    }
    cout<<fixed<<setprecision(10)<<maxi<<endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
struct team{
	int p;
	int w[11];
	int num;
	int cnt;
	void init(int n){
		p=cnt=0;
		num=n;
		for(int i=0;i++<10;)w[i]=0;
	}
	bool operator<(team a)
	{
		if(cnt!=a.cnt)return cnt<a.cnt;
		else if(p!=a.p)return p>a.p;
		else return num>a.num;
	}
};
int t,p,r;
main()
{
	while(cin>>t>>p>>r,t)
	{
		team a[55];
		for(int i=0;i++<t;)a[i].init(i);
		for(int i=0;i<r;i++)
		{
			int T,P,M;string s;
			cin>>T>>P>>M>>s;
			if(s=="WRONG")
			{
				a[T].w[P]++;
			}
			else
			{
				a[T].cnt++;
				a[T].p+=a[T].w[P]*1200+M;
			}
		}
		sort(a+1,a+t+1);
		for(int i=t;i>0;i--)cout<<a[i].num<<" "<<a[i].cnt<<" "<<a[i].p<<endl;
	}
}


Measured memory_bytes: 3124
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<bitset>
#include<string>
#include<cstring>
#include<fstream>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
using namespace std;
int n,x,sum;
bitset<2000007>f;
int main(){
    cin>>n;
    f[0]=1;
    for(register int i=1;i<=n;i++){
        cin>>x;
        f|=f<<x;
        sum+=x;
    }
    for(register int i=(sum+1)/2;i<=sum;i++)if(f[i]){
		cout<<i<<endl;
		return 0;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf(x) scanf("%d",&x)
int inf = (1e9) + 7;



int main(){
	int n, m;
	cin >> n >> m;
	int c;
	cin >> c;
	int cnt[10005];
	int aux;
	int ans[105][105];
	for (int i = 0; i < c; ++i)
	{
		sf(cnt[i]);
	}

	int up_or_down = 0;
	int col = 0;
	int row = 0;
	for (int i = 0; i < c; ++i)
	{
		for (int k = 0; k < cnt[i]; ++k)
		{
			ans[row][col] = i+1;
			if(row == 0 and up_or_down){
				col++;
				up_or_down = 0;
			}
			else if(row == n-1 and !up_or_down)
			{
				col++;
				up_or_down = 1;
			}
			else if(up_or_down)
				row--;
			else
				row++; 
		}
	}

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int n;
vector<vector<int>> g;

ll dp[200000], dp2[200000];

void dfs(int v, int p) {
    for(auto u : g[v]) {
        if(u == p) {
            continue;
        }
        dfs(u, v);
    }
    dp[v] = dp2[v] = 1;
    for(auto u : g[v]) {
        if(u == p) {
            continue;
        }
        (dp[v] *= dp2[u]) %= MOD;
        (dp2[v] *= dp[u]) %= MOD;
    }
    (dp[v] += dp2[v]) %= MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    g.resize(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].emplace_back(b - 1);
        g[b - 1].emplace_back(a - 1);
    }
    dfs(0, -1);
    cout << dp[0] << endl;
}

Measured memory_bytes: 12800
n,k,s = map(int,input().split())

u = []
if n == k:
    for i in range(n):
        u.append(s)
else:
    if s%2==0:
        for i in range(k+1):
            u.append(int(s/2))
        for i in range(n-k-1):
            u.append(10**9-1)
    else:
        if s==1:
            for i in range(k):
                u.append(1)
            for i in range(n-k):
                u.append(10**9)
        else:
            if k%2==0:
                u.append(int((s-1)/2))
                for i in range(int(k/2)):
                    u.append(int((s+1)/2))
                    u.append(int((s-1)/2))    
                for i in range(n-k-1):
                    u.append(10**9)
            else:
                for i in range(int((k+1)/2)):
                    u.append(int((s+1)/2))
                    u.append(int((s-1)/2))  
                for i in range(n-k-1):
                    u.append(10**9)
print(' '.join(map(str,u)))

Measured memory_bytes: 15152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
	ll t;
	cin>>t;
	if(t==0)
	{
		cout<<1<<"\n";
	}
	else if(t==1)
	{
		cout<<0<<"\n";
	}
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e5+5;

int solve(vector<PII> A)
{
    sort(ALL(A));
    map<PII,int> cnt;
    const int n = A.size();
    FOR(i,0,n) FOR(j,i+1,n) {
        const int a = A[i].first  - A[j].first;
        const int b = A[i].second - A[j].second;
        if (a || b)
            cnt[PII(a,b)]++;
    }
    int ans = n;
    FOR_ALL(x,cnt)
        ans = min(ans, n - x->second);
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        vector<PII> A(n),B(n);
        FOR(i,0,n) {
            int x,y; cin >> x >> y;
            A[i] = PII(x,y);
            B[i] = PII(y,x);
        }
        const int a = solve(A);
        const int b = solve(B);
        cout << min(a,b) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
use std::io::{self, BufRead};

fn parin(s: &[u8]) -> bool {
  let n = s.len();
  for i in 0..(n/2) {
    if s[i as usize] != s[(n-1-i) as usize] {
      return false;
    }
  }
  true
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let s = lines.next().unwrap().unwrap();
  let bytes = s.as_bytes();
  let n = bytes.len();
  let ans = if parin(bytes) && parin(&bytes[0..((n-1)/2)]) && parin(&bytes[((n+1)/2)..n]) { "Yes" } else { "No" };
  println!("{}", ans);
}

Measured memory_bytes: 4352
#include <cstdio>

using namespace std;

int main() {
  int N;
  scanf("%d", &N);

  int A[N];
  int max = 0;
  int max_2nd = 0;

  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
    if (max <= A[i]) {
      max_2nd = max;
      max = A[i];
    } else if (max_2nd <= A[i]) {
      max_2nd = A[i];
    }
  }

  for (int i = 0; i < N; ++i) {
    if (A[i] == max) {
      printf("%d\n", max_2nd);
    } else {
      printf("%d\n", max);
    }
  }

  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
tree<P,null_type,less<P>,rb_tree_tag,tree_order_statistics_node_update>tr;


int a[200000];

signed main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%d",&a[i]);
		tr.insert(P(a[i],i));
	}
	rep(i,n){
		tr.erase(P(a[i],i));
		int l=0,r=1000000000;
		int A=n/2;
		while(l!=r){
			int t=(l+r)/2;
			if(tr.order_of_key(P(t,INT_MAX))>=A)r=t;
			else l=t+1;
		}
		printf("%d\n",l);
		tr.insert(P(a[i],i));
	}
}

Measured memory_bytes: 15488
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, A, B; cin >> n >> A >> B;
  cout << min(A, B) << " " << max(0, min(A, n) - max(0, n-B)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;

  vector<int> dp(n);
  vector<int> h(n);

  REP(i, n) {
    cin >> h[i];
  }

  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  FOR(i, 2, n) {
    dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]),
        dp[i - 1] + abs(h[i - 1] - h[i]));
  }

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

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
const int N = 2e5+10;
ll a[N];
ll b[N];
ll n;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    quickread();
    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i] >> b[i];
    }
    sort(a+1, a+n+1);
    sort(b+1, b+n+1);
    ll res;
    if(n % 2) {
        res = b[(n+1)/2] - a[(n+1)/2] + 1;
    } else {
        res = b[n/2+1] + b[n/2]-a[n/2+1]-a[n/2] +1;
    } 
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6784
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = Array(m) { 0 }
    val mask = Array(m) { 0 }
    for (i in 0 until m) {
        a[i] = sc.nextInt()
        val b = sc.nextInt()
        var tmp = 0
        for (j in 0 until b) {
            val c = sc.nextInt() - 1
            tmp += 1.shl(c)
        }
        mask[i] = tmp
    }
    val size = 1.shl(n)
    val dp = Array(m + 1) { Array(size) { 1000000000 } }
    dp[0][0] = 0
    for (i in 0 until m) {
        for (j in 0 until size) {
            dp[i + 1][j] = dp[i][j]
        }
        for (j in 0 until size) {
            dp[i + 1][j or mask[i]] = Math.min(dp[i + 1][j or mask[i]], dp[i][j] + a[i])
        }
    }
    val v = dp[m][size - 1]
    println(if (v == 1000000000) -1 else v)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 168796
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define fix cout<<fixed<<setprecision(20);
const int maxn=(int)1e6+5;

long long a[maxn],cnt[maxn];
long long sum[maxn];
int n,m;
bool check(int x){  
    int tot=0;
    int y=0;
    rep(i,1,n)y=x-a[i],tot+=cnt[y>0?y:0];
    return tot>=m;
}
signed main(){
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;rep(i,1,n)cin>>a[i];
    //sort(a+1,a+1+n);
    rep(i,1,n){cnt[a[i]]++;sum[a[i]]+=a[i];}
    for(int i=200000;i>=0;i--)cnt[i]+=cnt[i+1],sum[i]+=sum[i+1];
    long long l=1-1,r=200000+1;
    while(l<=r){
        int mid=l+r>>1;
        if(check(mid))l=mid+1;
        else r=mid-1;
    }
    debug(r);
    long long ans=0,tot=0;
    int y=0;
    rep(i,1,n)y=max(0ll,r-a[i]),ans+=sum[y]+a[i]*cnt[y],tot+=cnt[y];
    
    ans-=r*(tot-m);
    
    cout<<ans<<endl;
}



/* 
n^2 的数据里取前k大，
数据的构造方法是数列两两取和
Ai<1e5
二分所有选的数的下界的最小值x。满足 bi>x 的bi数量小于等于m的最大值

5 3
10 14 19 34 33
68+67=135

9 14
1 3 3 5 5 21 24 34 110 
wa cnt 数组下届是0 not 1
 */

Measured memory_bytes: 9984
# include <iostream>
using namespace std;
const int N=100006;
int a[N];
int n,m,p,f;
int gcd (int x,int y)
{
	if (x%y==0)
	return y;
else return gcd (y,x%y);
}
void work (void)
{
	int i,t;
	if (p>=m&&f==0)
	{
		i=2;
		t=a[1];
		while (i<=n)
		{
			t=gcd (t,a[i]);
			if (t==1)
			break;
			i++;
		}
		if (m%t==0)
		f=1;
	}
	if (f==1)
	cout<<"POSSIBLE";
else cout<<"IMPOSSIBLE";
}
int main (void)
{
	int i;
	cin>>n>>m;
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
		if (a[i]==m)
		{
			f=1;
			break;
		}
		if (a[i]>p)
		p=a[i];
	}
	work ();
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



string s,t,u;
long long int a,b;
int main() {
	cout << fixed << setprecision(18);
	cin>>s;
	for(int i=0;i<s.length();i++){
		s[i]='x';
	}
	cout<<s;
} 

Measured memory_bytes: 256
#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>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int A, B;

  cin >> A >> B;
  int ans = B;
  if (A >= 6 && A <= 12) ans /= 2;
  else if(A <= 6) ans = 0;

  cout << ans << endl; 
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

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

int main()
{
  vector<string> prefix = {"w", "", "k", "s", "t", "n", "h", "m", "y", "r"};
  int table[256] = {};
  table['T'] = 0;
  table['L'] = 1;
  table['U'] = 2;
  table['R'] = 3;
  table['D'] = 4;
  string s;
  cin >> s;
  stringstream ss;
  int id = 0;
  for (const auto& c : s){
    if (isdigit(c)) id = c - '0';
    else {
      int g = table[c];
      if (id == 0 && g == 2){
        ss << "nn";
      }
      else {
        ss << prefix[id] << "aiueo"[g];
      }
    }
  }
  cout << ss.str() << endl;
  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 1208
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	string s;
	cin >> s;
	long long ans = 0;
	long long cnt = 0;
	REP(i, s.length()) {
		if (s[i] == 'S')cnt++;
		else {
			if (cnt != 0) {
				ans += 2;
				cnt--;
			}
		}
	}
	cout << s.length() - ans << endl;
	return 0;
}

Measured memory_bytes: 832
#include<stdio.h>
int main()
{
    int a,b,x,y;
    scanf("%d %d",&a,&b);
    if(a>=0 && a<=23 && b>=0 && b<=23)
    {
        x=a+b;
        if(x>23)
        {
            y=x-24;
            printf("%d",y);
        }
        else
            printf("%d",x);
    }
    else
        return 0;


}

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

int main(){
  int N;
  cin>>N;
  vector<vector<int>> G(N);
  vector<pair<int,int>> vp;
  for(int i=1;i<N;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a,b);
  }

  int K=0;
  map<pair<int,int>,int> I;
  vector<int> cs(N,0); // color of edge between its parent

  vector<int> used(N,0);
  queue<int> que;
  used[0]=1;
  que.emplace(0);
  while(!que.empty()){
    int v=que.front();que.pop();
    if(K<(int)G[v].size()) K=G[v].size();
    int cur=1;
    for(int u:G[v]){
      if(used[u]) continue;
      if(cur==cs[v]) cur++;
      cs[u]=I[make_pair(u,v)]=I[make_pair(v,u)]=cur++;
      used[u]=1;
      que.emplace(u);
    }
  }

  cout<<K<<endl;
  for(auto p:vp) cout<<I[p]<<endl;
  return 0;
}


Measured memory_bytes: 20084
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

def d(a, b):
    sum = 0
    for i in range(D):
        sum += (a[i]-b[i])**2

    return sum**0.5

cnt = 0

for i in range(N-1):
    for j in range(i+1, N):
        if d(X[i], X[j]).is_integer():
            cnt += 1

print(cnt)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cstring>
#include <list>
#include <queue>
#include <numeric>
#include <map>
#include <set>
using namespace std;

char m2[101][101], m3[101][101];
void f(int r, int c) {
    for (int i=0; i<r; ++i) {
        for (int j=0; j<c; ++j) {
            cout<<m3[i][j];
        }
        cout<<'\n';
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int r, c, r1=0, c1=0;
    cin>>r>>c;
    for (int i=0; i<r; ++i) {
        vector<char> t(c);
        bool ok=1;
        for (int j=0; j<c; ++j) {
            char ch;
            cin>>ch;
            t[j]=ch;
            if (ch=='#') {
                ok=0;
            }
        }
        if (!ok) {
            for (int j=0; j<c; ++j) {
                m2[r1][j]=t[j];
            }
            ++r1;
        }
    }
    for (int j=0; j<c; ++j) {
        vector<char> t(r1);
        bool ok=1;
        for (int i=0; i<r1; ++i) {
            t[i]=m2[i][j];
            if (t[i]=='#') {
                ok=0;
            }
        }
        if (!ok) {
            for (int i=0; i<r1; ++i) {
                m3[i][c1]=t[i];
            }
            ++c1;
        }
    }
    f(r1, c1);
    return 0;
}

Measured memory_bytes: 256
import sys, math

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

n, a, b = read_int()
M = pow(10, 9) + 7
sys.setrecursionlimit(300000)

def solve():
    ans = (pow(2, n, M) - 1) - kai(n, 0, a) * pow(kai(a, 0, a), M - 2, M) - kai(n, 0, b) * pow(kai(b, 0, b), M - 2, M)
    return ans % M

def kai(n, i, m):
    if i == m:
        return 1
    return (n * kai(n - 1, i + 1, m)) % M

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 181236
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var s, t string
	fmt.Fscan(r, &s)
	fmt.Fscan(r, &t)

	if s == t[:len(t)-1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

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

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 1824
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int f[2][7],a[7][2]={
	{1,3},
	{2,0},
	{1,1},
	{4,5},
	{6,3},
	{5,5},
	{4,4}
};
int main(){
	string s;cin>>s;
	int*p=f[0],*q=f[1];
	p[0]=1;
	for(char c:s){
		memset(q,0,sizeof(f[0]));
		for(int i=0;i<7;i++)
			for(int j=0;j<2;j++)
				if(c=='0'+j||c=='?')
					(q[a[i][j]]+=p[i])%=mod;
		swap(p,q);
	}
	cout<<(p[3]+p[5])%mod<<"\n";
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	
 
 
using namespace std;
 
 
typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 	
/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+10;
const ll inf = 1e9;
 

map<string,ll> m;
int main(){
	fastio;
	ll n;
	string s;
	cin>>n;
	f(i,0,n) cin>>s,m[s]++;
	cout<<"AC" <<" x "<<m["AC"]<<endl;
	cout<<"WA" <<" x "<<m["WA"]<<endl;
	cout<<"TLE" <<" x "<<m["TLE"]<<endl;
	cout<<"RE" <<" x "<<m["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>

int main() {
	int n;
	float a, b, c, d, e, f, g, h;
	scanf("%d", &n);
	for (int i = 0; i < n;i++){ 
		int Bool = 0;
		scanf("%f %f %f %f %f %f %f %f", &a, &b, &c, &d, &e, &f, &g, &h);
		if (a == c || e == g) {
			if (a == c && e == g)Bool = 1;
		}
		else {
			if ((b - d) / (a - c) == (f - h) / (e - g))Bool = 1;
		}
		if (Bool == 1) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
}



Measured memory_bytes: 1980
#include<bits/stdc++.h>
using  namespace std;
#define pb push_back
#define M 1000000007
typedef long long int ll;


void solve(){

	ll n, d, x, y, cnt = 0;
	cin >> n >> d;
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		if(x*x + y*y <= d*d)
			cnt++;
	}
	cout << cnt << endl;
}	

int main(){

	int t;
	// cin >> t;
	t = 1;
	for(int q = 0; q < t; q++){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    int n,m;cin>>n;
    vector<ll>a,b;
    ll k;
    bool flag = true;
    fol(i,n){
        cin>>k;
        a.pb(k);
    }
    sort(a.begin(),a.end());
    cin>>m;
    fol(i,m){
        cin>>k;
        b.pb(k);
    }
    sort(b.begin(),b.end());
    auto itr = a.begin();
    fol(i,m){
        vector<ll>::iterator li = lower_bound(itr,a.end(),b[i]);
        if(li==a.end()||*li!=b[i]) {flag = false;break;}
        itr = ++li;
    }
    if (flag) cout <<"YES"<<endl;
    else cout <<"NO" <<endl;
}

int main(){
//option:-std=c++0x
    solve();
    return 0;
}


Measured memory_bytes: 4848
// AOJ Volume 1 Problem 0158 Collatz's Problem


#include <stdio.h>

int main(void)
{
    int n;
    int times;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        times = 0;
        while (n != 1){
            if (n % 2 == 0){
                n /= 2;
            }
            else {
                n = n * 3 + 1;
            }
            times++;
        }
        printf("%d\n", times);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double w = x/a ; //水の面積
    double bottle = a*b;
    double angle;
    if(2*w<=bottle)  //45度以下
    {
        double y = 2*w/b;
        angle = 90-atan2(y,b) * 360/(2*M_PI);
    }
    else{
        double e = 2*w/a-b;
        angle = 90-atan2(a,b-e) * 180/M_PI;
    }

    printf("%.10lf",angle);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for( int i=a; i<b; i++)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<pii>vpi;
vector<vvll> dp(3001,vvll(3001,vll(2)));
ll solve(ll L,ll R,bool turn,ll diff,vll &A){
    ll n = A.size();
    for(ll i=0;i<n;i++){
        dp[i][i][0] = A[i];
        dp[i][i][1] = -A[i];
    }
    ll delta = 1;
    ll x,y;
    while(delta < n){
        x = 0;
        y = delta;
        while(y<n){
            dp[x][y][0] = max(dp[x+1][y][1]+A[x],dp[x][y-1][1]+A[y]);
            dp[x][y][1] = min(dp[x+1][y][0]-A[x],dp[x][y-1][0]-A[y]);
            x++;y++;
        }
        delta++;
    }
    // for(ll i =0;i<n;i++){
    //     for(ll j =0;j<n;j++){
    //         if(j<i){
    //             cout<<"\t ";
    //         }
    //         else{
    //             cout<<"("<<dp[i][j][0]<<","<<dp[i][j][1]<<") ";
    //         }
    //     }
    //     cout<<"\n";
    // }
    return dp[L][R][turn];
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n;
    cin>>n;
    vll A(n);
    for(ll i =0;i<n;i++){
        cin>>A[i];
    }
    cout<<solve(0,n-1,0,0,A)<<"\n";
}

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

using namespace std;

int solve(vector<int> vec) {
    int ans = 0;
    int count = 0;
    for (const auto &e : vec) {
        if (e != count+1)
            ++ans;
        else
            ++count;
    }

    if (count != 0)
        return ans;
    else
        return -1;
}

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; ++i)
        cin >> vec.at(i);
    cout << solve(vec);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).length())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_value(aint(a))
#define maxin(a) *max_value(aint(a))
#define X first
#define Y second
#define fiint(a, x) memset(a, x, lengthof(a))
#define pb push_back
#define pf push_front
#define mp make_pair
#define aint(v) v.begin(), v.end()
#define raint(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(aint(v), (int)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
const int M = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
    start();
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = a[0];
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < mx)ans += (mx - a[i]);
        mx = max(mx, a[i]);
    }
    cout << ans << el;
    return 0;
}

Measured memory_bytes: 5200
#!/usr/bin/python3
# -*- coding: utf-8 -*-
ss = input()
s = []
for i in range(0, len(ss)):
    s.append(ss[i])
n = int(input())
mae_list = []
usiro_list = []
flag = 1
for i in range(0, n):
    q_list = list(map(str, input().split()))
    if len(q_list) == 1:
        flag *= -1
    else:
        if (q_list[1] == "1" and flag == 1) or (q_list[1] == "2" and flag == -1):
            mae_list.append(q_list[2])
        else:
            usiro_list.append(q_list[2])
if flag == 1:
    if len(mae_list) > 0:
        mae_list.reverse()
        print(''.join(mae_list), end="")
    print(''.join(s), end="")
    if len(usiro_list) > 0:
        print(''.join(usiro_list), end="")
else:
    if len(usiro_list) > 0:
        usiro_list.reverse()
        print(''.join(usiro_list), end="")
    s.reverse()
    print(''.join(s), end="")
    if len(mae_list) > 0:
        print(''.join(mae_list), end="")
print()

Measured memory_bytes: 6228
using System;

class Program
{
    static void Main()
    {
        int input = int.Parse(Console.ReadLine());
        int remainder = 0;

        int h = input / 3600;
        remainder = input % 3600;
        int m = remainder / 60;
        int s = remainder % 60;

        Console.WriteLine("{0}:{1}:{2}", h, m, s);
    }
}

Measured memory_bytes: 9096
A, B, C, X, Y = map(int, input().split())
C *= 2
if X == Y:
    print(min(C * X, A * X + B * Y))
if X > Y:
    print(min(C * X, C * Y + A * (X - Y), A * X + B * Y))
if X < Y:
    print(min(C * Y, C * X + B * (Y - X), A * X + B * Y))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    string revS = S;
    reverse(S.begin(), S.end());
    int cnt = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != revS[i])
        {
            cnt++;
        }
    }
    cout << cnt / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
using namespace std;
typedef long long ll;
const int MN=1e5+5;
int n,a[MN],c[MN][2];
int main(){
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1;i<=n;i++)c[a[i]][i&1]++;
	reg int mx1=0,smx1=0,mx2=0,smx2=0;
	for(reg int i=1;i<=MN-5;i++){
		if(c[mx1][1]<c[i][1])smx1=mx1,mx1=i;
		else if(c[smx1][1]<c[i][1])smx1=i;
		if(c[mx2][0]<c[i][0])smx2=mx2,mx2=i;
		else if(c[smx2][0]<c[i][0])smx2=i;
	}
	reg int ans;
	if(mx1!=mx2)ans=n-c[mx1][1]-c[mx2][0];
	else ans=min(n-c[mx1][1]-c[smx2][0],n-c[smx1][1]-c[mx2][0]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int A[n];
    for(int i=0; i<n; i++){
        cin>>A[i];
    } 
    int c=0;
    for(int j=1; j<n-1; j++){
        if ((A[j-1]-A[j])*(A[j]-A[j+1])>0){
            c=c+1;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
es = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]
gr = [[] for i in range(N)]
for i,(a,b) in enumerate(es):
    gr[a].append((b,i))
    gr[b].append((a,i))

ans = 0
for i in range(M):
    visited = [0] * N
    stack = [0]
    while stack:
        v = stack.pop()
        visited[v] = 1
        for to,e in gr[v]:
            if visited[to]: continue
            if i==e: continue
            stack.append(to)
    if sum(visited) < N:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
def I(): return int(input())


def main():
    K = I()
    if K % 2 == 0 or K %  5 == 0:
        print(-1)
        exit()
    if K % 7 == 0:
        K = 9*K//7
    else:
        K = 9*K
    amari = 1
    for i in range(10**6):
        amari = amari*10 % K
        if amari == 1:
            print(i+1)
            exit()
    print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 62280