akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>

int main() {
  std::string str;
  std::getline(std::cin, str);

  for(int i = 0; str[i] != '\0'; ++i) {
    if(isupper(str[i])) {
      str[i] = tolower(str[i]);
    }
    else if(islower(str[i])) {
      str[i] = toupper(str[i]);
    }
  }

  std::cout << str << std::endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

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

const int MAXN = 2031;
const int INF = 1000000000;

struct Key
{
	int mask, x;
	
	Key(int mask, int x) : mask(mask), x(x) {}
};
ll ans[1 << 13];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<Key> v;
	v.reserve(n);
	for (int i = 0; i < (1 << n); i++)
		ans[i] = INF;
	
	for (int i = 0; i < m; i++)
	{
		int x, b;
		int mask = 0;
		cin >> x >> b;
		for (int j = 0; j < b; j++)
		{
			int t;
			cin >> t;
			mask |= (1 << (t - 1));
		}
		v.emplace_back(mask, x);
		ans[mask] = min(ans[mask], x);
	}
	
	ans[0] = 0;
	for (int i = 0; i < (1 << n); i++)
	{
		for (auto& key : v)
		{
			ans[i | key.mask] = min(ans[i | key.mask], ans[i] + key.x);
		}
	}
	
	if (ans[(1 << n) - 1] == INF)
	{
		cout << "-1";
	} else 
	cout << ans[(1 << n) - 1];

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(void){
	int n,w,i,j,wt;
	cin >> n >> w;
	int x[n][2];
	for(i=0;i<n;i++){
		cin >> x[i][0] >> x[i][1];
	}
	int v[n+1][100001]; //番号、重さ
  	for(i=0;i<100001;i++){
    	v[0][i] = 0;
    }
	for(i=0;i<n;i++){
		for (wt=1;wt<=w;wt++){
			if(x[i][1]<=wt){
				v[i+1][wt] = max(v[i][wt],x[i][0]+v[i][wt - x[i][1]]);
			}else{
				v[i+1][wt]= v[i][wt];
			}

		}
	}
	cout << v[n][w] << endl;
  return 0;
}


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

int main () {
    int n;
    std::vector<long> xs;
    std::cin >> n;
    xs.resize(n);

    for (int i =0 ; i < n ;i++) {
	std::cin >> xs.at(i);
    }

    std::sort(xs.begin(), xs.end());
    
    long a = 0;
    long b = 0;
    int i;
    for (i = xs.size()-1; i > 0; i--) {
	if (xs.at(i-1) == xs.at(i)) {
	    a = xs.at(i);
	    break;
	}
    }
    for (i=i-2; i > 0; i--) {
	if (xs.at(i-1) == xs.at(i)) {
	    b = xs.at(i);
	    break;
	}
    }

    std::cout << a*b << std::endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
 
using namespace std;
 
const int N = 2e5;
int r[N];
 
int main()
{
    int n;
 
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> r[i];
 
    int maxval = INT_MIN;
    int minval = r[0];
    for(int i=1; i<n; i++) {
        maxval = max(maxval, r[i] - minval);
        minval = min(minval, r[i]);
    }
 
    cout << maxval << endl;
 
    return 0;
}


Measured memory_bytes: 3916
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	string s;
	string front = "";

	cin >> s;
	int q;
	cin >> q;
	int re = 0;

	for (int i = 0;i < q;i++) {
		int t;
		cin >> t;
		if (t == 1) {
			re++;
		}
		else {
			int f;
			char c;
			cin >> f >> c;
			if (re % 2 == 0) {
				if (f == 1) {
					front = c + front;
				}
				else {
					s += c;
				}
			}
			else
			{
				if (f == 1) {
					s += c;
				}
				else {
					front = c + front;
				}
			}
		}
	}
	s = front + s;

	if (re % 2 == 1) {
		reverse(s.begin(), s.end());
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 4120
#include <stdio.h>

int main(void)
{
	double x1, y1, x2, y2, x3, y3, xp, yp;
	double a, b, c, d;
	double ab, ac, ap, aby, acy, apy;
	double an, an2, an3;
	int x, y;
	
	while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
		
		ab = x2 - x1;
		aby = y2 - y1;
		ac = x3 - x1;
		acy = y3 - y1;
		ap = xp - x1;
		apy = yp - y1;
		d = (ab * acy) - (ac * aby);
		b = ab;
		ab = acy / d;
		ac = (ac * (-1)) / d;
		aby = (aby * (-1)) / d;
		acy = b / d;
		
		an = (ab * ap) + (ac * apy);
		an2 = (aby * ap) + (acy * apy);
		

		if (an >= 0 && an2 >= 0 && (an + an2) <= 1) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 612
n, m=map(int, input().split())
a=[]
b=[]
g=[]
for i in range(n):
  g.append([])
for i in range(m):
  ai, bi=map(int, input().split())
  ai-=1
  bi-=1
  g[ai].append(bi)
  g[bi].append(ai)
  a.append(ai)
  b.append(bi)
used=[]
for i in range(n):
  used.append(False)
dame1=0
dame2=0
def dfs(x):
  used[x]=True
  for y in g[x]:
    if (dame1==x and dame2==y) or (dame1==y and dame2==x):
      continue
    if not used[y]:
      dfs(y)
  return
ans=0
for i in range(m):
  for j in range(n):
    used[j]=False
  dame1=a[i]
  dame2=b[i]
  dfs(a[i])
  if not used[b[i]]:
    ans+=1
print(ans)

Measured memory_bytes: 3064
def func(x,y):
    return x if x < y else y

class LazySegmentTree():
    def __init__(self, n):
        n_ = 1
        c_ = 0
        while n_ < n:
            n_ *= 2
            c_ +=1

        self.lv = c_
        self.n = n_
        self.arr = [2**31-1] * (2*self.n-1)
        self.lazy = [None] * (2*self.n-1)

    #伝播区間
    def getidx(self, l, r):
        L = (l + self.n) >> 1
        R = (r + self.n) >> 1
        lc = 0 if l & 1 else (L & -L).bit_length()
        rc = 0 if r & 1 else (R & -R).bit_length()
        for i in range(self.lv):
            if rc <= i:
                yield R
            if L < R and lc <= i:
                yield L
            L >>= 1; R >>=1

    #伝播
    def propagate(self,*ids):
        for i in reversed(ids):
            v = self.lazy[i-1]
            if v is None:
                continue
            self.lazy[2*i-1] = self.arr[2*i-1] = self.lazy[2*i] = self.arr[2*i] = v
            self.lazy[i-1] = None

    #[l, r] をxで更新
    def update(self,l,r,x):
        #[l, r)に変更
        r+=1
        *ids, = self.getidx(l,r)
        self.propagate(*ids)

        L = self.n + l; R = self.n + r
        while L < R:
            if R & 1:
                R -=1
                self.lazy[R-1] = self.arr[R-1] = x
            if L & 1:
                self.lazy[L-1] = self.arr[L-1] = x
                L += 1
            L >>= 1; R >>= 1

        for i in ids:
            self.arr[i-1] = func(self.arr[2*i-1], self.arr[2*i])

    #[l, r]のクエリに答える
    def query(self,l,r):
        #[l, r)に変更
        r+=1
        self.propagate(*self.getidx(l,r))
        L = self.n + l; R = self.n + r

        s = 2**31-1
        while L < R:
            if R & 1:
                R -=1
                s = func(s, self.arr[R-1])
            if L & 1:
                s = func(s, self.arr[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

#0-indexed なので1-からのときは−１する
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
sg=LazySegmentTree(n)
for _ in range(q):
    l=list(map(int,input().split()))
    if l[0]==0:
        c,s,t,x=l
        sg.update(s,t,x)
    else:
        c,i=l
        print(sg.query(i,i))



Measured memory_bytes: 11328
/**
    * @Author:Monk78
    * @Topic:I-Coins
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second;
#define F first;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lf",&n)
#define pl(n) printf("%lf",n)
#define vpshVar() int main()
vpshVar(){
    ll N;
    cin>>N;
    double prob;
    //dp means i head so far.........
    vector<double>dp(N+1);
    dp[0]=1;
    dp.assign(N+1,0);
    dp[0]=1;
    for(ll coin=1;coin<=N;coin++){
        sl(prob);
        for(ll i=coin;i>=0;i--){
            dp[i]=(i==0 ? 0:dp[i-1]*prob)+dp[i]*(1-prob);
        }
    }
    double ans=0;
    for(ll head=0;head<=N;head++){
        ll tail=N-head;
        if(head>tail){
            ans+=dp[head];
        }
    }
    printf("%.10lf",ans);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<ii, int> iii;
typedef vector<iii> viii;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vi V(h), V2(h);
    for (int i = 0; i < h; ++i) {
        int maxi = 0, mini = w+2;
        for (int j = 0; j < w; ++j) {
            char c;
            cin >> c;
            if (c == '#') {
                maxi = j;
                mini = min(mini, j);
            }
        }
        V[i] = maxi;
        V2[i] = mini;
    }
    for (int i = 0; i < h-1; ++i) {
        if (V[i] > V2[i+1]) {
            cout << "Impossible\n";
            return 0;
        }
    }
    cout << "Possible\n";
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(int[]);
    auto b = readln.split.to!(int[]);

    foreach (i ; 0 .. N) {
        if (a[i] != b[i] && b[i] >= (a[i] + 1) / 2) {
            writeln(-1);
            return;
        }
    }

    auto d = new long[][](50 + 1, 50 + 1);
    fillAll(d, infl);
    foreach (i ; 0 .. 51) d[i][i] = 0;
    foreach (i ; 1 .. 51) {
        foreach (j ; 1 .. i + 1) {
            chmin(d[i][i % j], 1L << j);
        }
    }

    foreach (i ; 0 .. 51) {
        foreach (j ; 0 .. 51) {
            foreach (k ; 0 .. 51) {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    auto s = new long[](N);
    foreach (i ; 0 .. N) {
        s[i] = 1L << a[i];
    }

    auto f = new bool[](N);

    long ans;

    foreach (_ ; 0 .. N) {
        int im;
        long cm;

        foreach (i ; 0 .. N) {
            if (f[i]) continue;
            long cst = infl;
            foreach (j ; 0 .. 51) {
                if (s[i] & 1L << j) {
                    chmin(cst, d[j][b[i]]);
                }
            }
            if (cm < cst) {
                cm = cst;
                im = i;
            }
        }

        f[im] = true;
        ans |= cm;

        foreach (i ; 0 .. N) {
            foreach (j ; 0 .. 51) if (s[i] & 1L << j) {
                foreach (k ; 1 .. 51) if (cm & 1L << k) {
                    s[i] |= 1L << (j % k);
                }
            }
        }
    }

    writeln(ans);
}






void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int pos = 0;
        int ans[] = new int[n];
        Arrays.fill(ans, Integer.MAX_VALUE);
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int add = a[i];
            if (min >= add) {
                min = add;
                ans[pos] = add;
                pos++;
                continue;
            }
            // int max = -1;
            // int maxpos = -1;
            for (int j = 0; j < pos; j++) {
                if (ans[j] < add) {
                    // max = ans[j];
                    // maxpos = j;
                    ans[j] = add;
                    if (j == pos - 1) {
                        min = add;
                    }
                    break;
                }
            }
            /*
             * if (min > add) { min = add; } if (maxpos != -1) { ans[maxpos] = add; } else {
             * ans[pos] = add; pos++; }
             */
        }
        System.out.println(pos);
        sc.close();
    }
}


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


#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
using namespace std;


int main()
{
	int t;
	cin >>t;
	array<array<int,10>, 10> ba;
	rep(i,10) rep(j,10) cin >>ba[i][j];
	
	vector<vector<array<int, 2>>> mdl={
		{{0,0},{1,0}, {1,-1}, {1,1},{2,0}},
		{{0,0},{1,1},{0,1},{0,2},{1,0},{1,2},{2,0},{2,1},{2,2}},
		{{0,0},{2,0},{1,-1},{1,0},{1,1},{2,-2},{2,-1},{2,1},{2,2},
		 {3,-1},{3,0},{3,1},{4,0}}
	};
	
	int gk=0;
	rep(i,10) rep(j,10) gk+=ba[i][j];
	
	vector<int> cnd;
	rep(a,t+1) rep(b,t+1) rep(c,t+1){
		if(a+b+c==t && 5*a + 9*b + 13*c == gk){
		
			string s = string(a, '0') + string(b, '1') + string(c, '2');
			do {
				auto wa = ba;
				vector<int> ans;
				bool ok=1; 
				rep(i,t){
					if(!ok) break;
					int my,mx;
					rep(y,10) rep(x,10) if(wa[y][x]>0){my=y; mx=x; y=100; break;}
					ans.push_back(my*100+mx);
					int cr=s[i]-'0';
					
					for(auto r: mdl[cr]) if(ok){
						int ny=r[0]+my, nx=r[1]+mx;
						if(ny<0 || ny>=10 || nx<0 || nx>=10){ ok=0; break;}
						if(wa[ny][nx] >0 ) wa[ny][nx]--;
						else if(wa[ny][nx] <1 ){ ok=0; break;}
					}
				}
				bool ng=0;
				rep(y,10) rep(x,10) if(wa[y][x] !=0) ng=1;
				//rep(y,10) rep(x,10) printf("%d%s",wa[y][x],(x==9? "\n":" "));
				if(!ng){
					rep(i,t){
						printf("%d %d %d\n", 
							ans[i]%100 + mdl[s[i]-'0'][1][1],
							ans[i]/100 + mdl[s[i]-'0'][1][0],
							s[i]-'0'+1);
					}
					return 0;
				}
			} while ( next_permutation(s.begin(), s.end()) );
		}
	}
	return 0;
}

Measured memory_bytes: 3304
import java.io.PrintWriter;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    PrintWriter out = new PrintWriter(System.out);

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

    void run() {
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        StringBuilder sb = new StringBuilder();

        Map<Integer, Integer> map = new HashMap<>();

        for (int i=0; i<n; i++) {
            if (!map.containsKey(arr[i])) {
                map.put(arr[i], 1);
            } else {
                int tmp = map.get(arr[i]);
                map.put(arr[i], tmp+1);
            }
        }

        long[] combi = new long[n+1];

        for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
            int key = entry.getKey();
            long val = entry.getValue();
            combi[key] = (long)val*(val-1)/2;
        }

//        out.print(map);
//        out.flush();

        long ans = 0;

        long sum = 0;

        for (int i=0; i<n+1; i++) {
            sum += combi[i];
        }

        for (int i=0; i<n; i++) {
            int tmp = arr[i];
            long tmpAns = map.get(tmp);
            long diff = (long)(tmpAns)*(tmpAns-1)/2-(long)(tmpAns-1)*(tmpAns-2)/2;
            sb.append((sum-diff)+"\n");
        }


        out.print(sb.toString());
        out.flush();

    }

}


Measured memory_bytes: 102624
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	string s, t;
	cin >> s >> t;
	string ans="z";
	ans[0]++;
	for (int i = 0; i<int(s.size()) - int(t.size()) + 1; i++)
	{
		string r = s;
		bool f = true;
		for (int j = 0; j < t.size(); j++)
		{
			if (t[j] != s[i + j] && s[i + j] != '?')f = false;
			else r[i + j] = t[j];
		}
		for (int j = 0; j < s.size(); j++)if (r[j] == '?')r[j] = 'a';
		if (f)ans = min(ans, r);
	}
	if (ans == "{")printf("UNRESTORABLE\n");
	else cout << ans << endl;
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char a,b;
    cin>>a>>b;
    if(a==b)cout<<'H'<<endl;
    else cout<<'D'<<endl;
}

Measured memory_bytes: 3604
use proconio::input;

fn main() {
    input! {
        n: usize,
    }

    if n % 2 == 1 {
        println!("0");
        return;
    }

    let mut count = 0;

    let mut denom = 10;

    while denom <= n {
        count += n/denom;
        denom *= 5;
    }

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


Measured memory_bytes: 2112
N = int(input())
L = [0] * (404040)
A = map(int, input().split())
ans = 0
for i, a in enumerate(A):
    ia = i - a
    if ia >= 0:
        ans += L[ia]
    ai = a + i
    if ai < 404040:
        L[ai] += 1
print(ans)


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

int main() {
  string s, t;

  cin >> s;
  cin >> t;

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  if (s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long double ld;
using namespace std;

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

    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n - 1);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (ll i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (ll i = 0; i < n - 1; i++) {
        cin >> c[i];
    }

    ll total = 0;

    for (ll i = 0; i < n; i++) {
        total += b[a[i] - 1];
        if (a[i] == a[i - 1] + 1) {
            total += c[a[i - 1] - 1];
        }
    }

    cout << total;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
const int INFN = 1e9+7;
const int MAXC = 3;
const int MAXN = 1e5+5;
int C[MAXN][MAXC];
int dp[MAXN][MAXC];
int N;

int solve() {
  for (int j = 0; j < MAXC; ++j) {
    dp[0][j] = 0;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < MAXC; ++j) {
      int nxt = (j + 1) % MAXC;
      int prv = (j + 2) % MAXC;
      dp[i][j] = std::max(dp[i-1][nxt], dp[i-1][prv]) + C[i][j];
    }
  }
  return *std::max_element(dp[N], dp[N] + MAXC);
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < MAXC; ++j) {
      scanf("%d", &C[i][j]);
    }
  }
  printf("%d\n", solve());
  return 0;
}

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    vector<string> s(n);
    rep(i,0,n) cin >> s[i];
    int alpha[26] = {};
    rep(i,0,s[0].size()){
        alpha[s[0][i]-'a']++;
    }
    rep(i,0,n){
        int tmp[26] = {};
        rep(j,0,s[i].size()){
            tmp[s[i][j]-'a']++;
        }
        rep(j,0,26){
            alpha[j] = min(alpha[j],tmp[j]);
        }
    }
    rep(i,0,26){
        rep(j,0,alpha[i]){
            cout << (char)('a'+i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]

graph = [[] for i in range(n)]
for a, b in info:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

cnt4 = 0
cnt6 = 0
for i in range(n):
    if len(graph[i]) % 2 == 1:
        print("No")
        exit()
    elif len(graph[i]) == 4:
        cnt4 += 1
    elif len(graph[i]) >= 6:
        cnt6 += 1

def solve():
    v4 = []
    for i in range(n):
        if len(graph[i]) == 4:
            v4.append(i)

    v0 = v4[0]
    v1 = v4[1]
    
    used = [False] * n
    used[v0] = True
    stack = [(v0, -1)]
    while stack:
        v, prv_v = stack.pop()
        for nxt_v in graph[v]:
            if prv_v == nxt_v:
                continue
            if nxt_v == v1:
                continue
            if used[nxt_v]:
                return True
            used[nxt_v] = True
            stack.append((nxt_v, v))
    return False

if cnt6 >= 1:
    print("Yes")
elif cnt4 >= 3:
    print("Yes")
elif cnt4 == 2:
    if solve():
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 74328
object Main extends App {
  val src = io.Source.stdin.getLines.map(_.split(",").map(_.head)).toList
  val org = ('A' to 'C').toList

  def func(org: List[Char], ope: Array[Char]) = {
    org.updated(org.indexOf(ope(0)), ope(1)).updated(org.indexOf(ope(1)), ope(0))
  }
  println((org /: src)(func).head)
}

Measured memory_bytes: 45108
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323


#define TST 0

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int x,y;
    cin >> x >> y;
    int b_2 = y - 2*x;
    if(b_2 % 2 == 0 && b_2 >= 0){
        int b = b_2/2;
        if(b > x){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

#if TST==1

#endif
}



Measured memory_bytes: 3596
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b,c=map(int,input().split())
if a<=c<=b or a>=c>=b:
    print("Yes")
else:
    print("No")

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

#define int long long

signed main() {
    string s;
    cin >> s;
    if(s[0]=='9'||s[1]=='9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  if (a == "a")
  {
    cout << "a" << endl;
  }
  else if (a >= "a"s)
  {
    cout << "a" << endl;
  }
  else
  {
    cout << "A" << endl;
  }
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    long long sum=0;
    int n;
    long long a[200100];
    cin>>n;
    REP(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    long long s1=0;
    long long ans=1e18;
    for(int i=0;i<n-1;i++){
        s1+=a[i];
        long long s2=sum-s1;
        long long sa=s1-s2;
        if(sa<0)sa*=-1;
        ans=min(ans,sa);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
     
int main(void){
  int a,b;
  char str[16];
  char op;
     
  scanf("%d%s%d",&a,str,&b);
  op=str[0];
  while(op!='?'){
    printf("%d\n",op=='+'?a+b:op=='-'?a-b:op=='*'?a*b:a/b);
    scanf("%d%s%d",&a,str,&b);
    op=str[0];
  }
  return 0;
}

Measured memory_bytes: 1032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OthloKyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            /* 101*/
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var sum = 0;
            foreach(var i in a)
            {
                sum += i;
            }
            Console.WriteLine(sum / a.Count());


        }
    }
}

Measured memory_bytes: 9608
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int dp[3010][3010];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,d,half=inv(2);
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int i=a;i<=c;i++){
        for(int j=b;j<=d;j++){
            if(i<c){
                dp[i+1][j]+=dp[i][j]*j;
                dp[i+1][j]%=mod;
            }
            if(j<d){
                dp[i][j+1]+=dp[i][j]*i;
                dp[i][j+1]%=mod;
            }
            if(i<c&&j<d){
                dp[i+1][j+1]-=dp[i][j]*i*j%mod;
                dp[i+1][j+1]+=mod;
                dp[i+1][j+1]%=mod;
            }
        }
    }
    cout<<dp[c][d]<<endl;
    return 0;
}

Measured memory_bytes: 74164
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;

int n;
char s[1000005];
int a[1000005];

signed main(){
	scanf("%d",&n);--n;
	scanf("%s",s); 
	for(int i=0;i<=n;i++)a[i] = s[i]-'1';
	int ans=0;
	for(int i=0;i<=n;i++){
		if((n&i) == i)ans = (ans+a[i])%2;
	}
	if(ans)return puts("1"),0;
	else{
		int fg = 1;
		for(int i=0;i<=n;i++)if(a[i] == 1)fg=0;
		if(!fg)puts("0");
		else{
			int x=0;
			for(int i=0;i<=n;i++)a[i] >>= 1;
			for(int i=0;i<=n;i++)
				if((n&i) == i)x = (x+a[i])%2;
			if(x)return puts("2"),0;
			else puts("0");
		}
	}

	return 0;
}



Measured memory_bytes: 5120
import math
import numpy as np

n = int(input())
a_list = list(map(int, input().split()))
a_list2 = sorted([a - (i + 1) for i, a in enumerate(a_list)])

s_cand = []
b_cand = [math.floor(sum(a_list2) / n), math.ceil(sum(a_list2) / n), int(np.median(a_list2))]

for b in b_cand:
    s = 0
    for a in a_list2:
        s += int(abs(a - b))
    s_cand.append(s)
    
print(min(s_cand))

Measured memory_bytes: 34204
lines=readlines(open("/dev/fd/0"))
function input()
  shift!(lines)
end
int(s::String)=parse(Int,s)
int(s::SubString{String})=parse(Int,s)
int(s::Array{SubString{String},1})=map(int,s)
function main()
  f=2^60
  a,b,q=input()|>split|>int
  s=[int(input())for i in 1:a]
  unshift!(s,-f)
  push!(s,f)
  t=[int(input())for i in 1:b]
  unshift!(t,-f)
  push!(t,f)
  for x in[int(input())for i in 1:q]
    m=f
    i=searchsortedlast(s,x)
    j=searchsortedlast(t,x)
    for v in s[i:i+1]
      for w in t[j:j+1]
        m=min(m,abs(x-v)+abs(v-w),abs(x-w)+abs(w-v))
      end
    end
    println(m)
  end
end
main()

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

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    if(a.back() == b.front() && b.back() == c.front()){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
sum = 0
for i in range(len(A)):
    if i == len(A)-1:
        break
    if A[i] > A[i+1]:
        sum += A[i] - A[i+1]
        A[i+1] = A[i]
print(sum)

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

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

int main() {
	int n; cin >> n;
	long long sum = 0;
	rep(i,n)rep(j,n)rep(k,n) {
		sum += gcd(gcd(i+1,j+1),k+1);
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 3728
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
/*

*/
int main()
{
    stack<char> sta;
    stack<char> ans;
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        switch(S[i]){
            case '0': sta.push(S[i]); break;
            case '1': sta.push(S[i]); break;
            case 'B': if(!sta.empty()){sta.pop(); break;}
        }
    }
    while(!sta.empty()){
        ans.push(sta.top());
        sta.pop(); 
    }
    while(!ans.empty()){
        cout << ans.top();
        ans.pop();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)

typedef pair<int, int> P;



int main() {
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i <= n; i++) {
        string tmp = to_string(i);
        if(tmp.size()%2 == 1) ans++;
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;



int main()
{
	int round;
	int n;
	int distance = 0;

	cin >> round >> n;
	vector<int> point(n);


	for (int i = 0; i < n; i++) {
		cin >> point[i];
		if (i > 0 && point[i] - point[i - 1] > distance) {
			distance = point[i] - point[i - 1];
		}
	}

	if (round - point[n - 1] + point[0] > distance) {
		distance = round - point[n - 1] + point[0];
	}

	printf("%d", round - distance);
	

	return 0;
}

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

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define ff first
#define ss second
#define err stderr
#define out stdout

typedef long long int ll;
typedef long double ld;
typedef short int sh;

inline void readI(int *i)
{
	register int t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=(t*znak);
}
inline void readUI(int *i)
{
	register int t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*i=t;
}
inline void readL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	int znak=1;
	if (z=='-')
	{
		znak*=-1;
	}
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
		if (z=='-')
		{
			znak=-1;
		}
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=(t*znak);
}
inline void readUL(ll *l)
{
	register ll t=0;
	register char z=getchar();
	while ((z<'0') || ('9'<z))
	{
		z=getchar();
	}
	while (('0'<=z) && (z<='9'))
	{
		t=(t<<3)+(t<<1)+z-'0';
		z=getchar();
	}
	*l=t;
}
inline void writeL(ll l)
{
	if (l==0)
	{
		putchar(48);
	}
	else
	{
		if (l<0)
		{
		   l*=-1;
		   putchar(45);
		}
		int _tab[21];
		int wsk=0;
		while (l>0)
		{
			++wsk;
			_tab[wsk]=(l%10)+48;
			l/=10;
		}
		for (int j=wsk; j>=1; --j)
		{
			putchar(_tab[j]);
		}
	}
}
inline void writeS(string s)
{
	int l=s.length();
	for (int i=0; i<l; ++i)
	{
		putchar(s[i]);
	}
}
inline void space()
{
	putchar(32);
}
inline void endl()
{
	putchar(10);
}

#define debug if(0)
#define debug2 if(1)
#define debug3 if(1)
#define debug4 if(1)

int n, wsk, nowy;
ll pot[125];
ll k, wynik;
ll M[55][55][125];
ll P=(1e9)+7;

void pomnoz(int a, int b, int c)
{
	debug
	{
		fprintf (err, "a=%d b=%d c=%d\n", pot[a], pot[b], pot[c]);
	}
	wynik=0;
	for (int i=1; i<=n; ++i)
	{
		for (int j=1; j<=n; ++j)
		{
			for (int k=1; k<=n; ++k)
			{
				M[i][j][c]+=M[i][k][a]*M[k][j][b];
				M[i][j][c]%=P;
			}
			wynik+=M[i][j][c];
			debug
			{
				fprintf (err, "i=%d j=%d M[i][j][c]=%lld\n", i, j, M[i][j][c]);
			}
			wynik%=P;
		}
	}
}
int main()
{
	readUI(&n);
	readUL(&k);
	for (int i=1; i<=n; ++i)
	{
		for (int j=1; j<=n; ++j)
		{
			readUL(&M[i][j][0]);
			wynik+=M[i][j][0];
		}
	}
	pot[0]=1;
	while ((pot[wsk]<<1)<=k)
	{
		pot[wsk+1]=(pot[wsk]<<1);
		pomnoz(wsk, wsk, wsk+1);
		++wsk;
	}
	nowy=wsk;
	while (wsk>=0)
	{
		if (pot[wsk]+pot[nowy]<=k)
		{
			pot[nowy+1]=pot[nowy]+pot[wsk];
			pomnoz(wsk, nowy, nowy+1);
			++nowy;
		}
		--wsk;
	}
	fprintf (out, "%lld\n", wynik);
	return 0;
}
/*
*/




Measured memory_bytes: 2944
# Dice and Coin
n, k = map(int, input().split())

ans = 0
for i in range(1, n + 1):
    tmp, cnt = i, 0
    while tmp < k:
        tmp *= 2
        cnt += 1
    ans += (1 / n) * (1 / 2) ** cnt
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

ll f(ll n){
  if(n%4 == 0) return n;
  if(n%4 == 1) return 1;
  if(n%4 == 2) return n^1;
  return 0;
}

int main(int argc, const char * argv[]) {
  ll A, B; cin >> A >> B;
  cout << (f(B)^f(A)^A) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a[3],i;
   for(i=0;i<3;i++)
    cin>>a[i];
   sort(a,a+3);
   if(a[0]+a[1]==a[2]) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    return 0;
}






Measured memory_bytes: 3556
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
void build(){

}
map<int,int> M;
void init(){
  int n = getint(); while( n -- )
    M[ getint() ] ++;
}
void solve(){
  int m = getint(); while( m -- ){
    int x = getint();
    auto it = M.find( x );
    if( it == M.end() or it->second == 0 ){
      puts( "NO" );
      Bye;
    }
    it->second --;
  }
  puts( "YES" );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 9600
#include <cstdio>
#include <cmath>
using namespace std;
#define EPS 1e-10

int main() {
  int n, m;
  double v, u, s, t;
  while (1) {
    scanf("%d", &n);
    if (!n) break;
    --n;
    s = u = 0.;
    for (int i=0; i<n; i++) {
      scanf("%lf", &v);
      u += v;
      s += sin(v*M_PI/180.);
    }
    s += sin((360.-u)*M_PI/180.);
    scanf("%d", &m);
    --m;
    t = u = 0.;
    for (int i=0; i<m; i++) {
      scanf("%lf", &v);
      u += v;
      t += sin(v*M_PI/180.);
    }
    t += sin((360.-u)*M_PI/180.);
    if (s > t + EPS) {
      puts("1");
    } else if (s < t - EPS) {
      puts("2");
    } else {
      puts("0");
    }
  }
  return 0;
}

Measured memory_bytes: 1076
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int main(){

	int N,d,sum = 0,tmp;
	scanf("%d %d",&N,&d);

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		if(tmp > d){
			sum += tmp-d;
		}
	}

	if(sum == 0){
		printf("kusoge\n");
	}else{
		printf("%d\n",sum);
	}

	return 0;
}

Measured memory_bytes: 2760
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int a[502][502];
int f[502][502];
int p[250000];

int main() {
    int n, ans = 0, i, j;
    queue<pair<int, int>> q;
    
    scanf("%d", &n);
    
    for (i = 0; i < n * n; i++) scanf("%d", &p[i]);
    
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            a[i][j] = min({i - 1, j - 1, n - i, n - j});
            f[i][j] = 1;
        }
    }
    
    for (i = 0; i < n * n; i++) {
        int x, y;
        
        p[i]--;
        
        x = p[i] / n + 1;
        y = p[i] % n + 1;
        
        ans += a[x][y];
        f[x][y] = 0;
        
        q.push(make_pair(x, y));
        
        while (!q.empty()) {
            int x = q.front().first;
            int y = q.front().second;
            
            q.pop();
            
            for (j = 0; j < 4; j++) {
                int nx = x + dx[j];
                int ny = y + dy[j];
                int c = a[x][y];
                
                if (f[x][y] == 1) c++;
                
                if (a[nx][ny] > c) {
                    a[nx][ny] = c;
                    q.push(make_pair(nx, ny));
                }
            }
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 6168
#include <stdio.h>
#include <vector>
 
typedef long long ll;
using namespace std;

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

void solve()
{
    int n;
    scanf("%d", &n);
    if (n == 3) {
        printf("2 5 63\n"); return;
    }
    vector<int> z;
    int i;
    for (i = 1; i < 15000; i++) {
        if (gcd(i, 15000) > 1) {
            z.push_back(i);
            z.push_back(30000 - i);
            if ((int)z.size() >= n-1) break;
        }
    }
    if (n % 2) z.push_back(15000);

    for (i = 0; i < (int)z.size(); i++) {
        printf("%d", z[i]);
        if (i < (int)z.size() - 1) printf(" ");
    }
    printf("\n");

    return;
}

int main(int argc, char* argv[])
{
    solve();

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	vvll dp(SZ(S), vll(4, 0));//=>0:XXX 1:AXX 2:ABX 3:ABC
	REP(i, SZ(S)) {
		if (i != 0) {
			REP(j, 4)dp[i][j] = dp[i - 1][j];

			switch (S[i])
			{
			case 'A':
				dp[i][1] += dp[i - 1][0];
				dp[i][1] %= MOD;
				break;
			case 'B':
				dp[i][2] += dp[i - 1][1];
				dp[i][2] %= MOD;
				break;
			case 'C':
				dp[i][3] += dp[i - 1][2];
				dp[i][3] %= MOD;
				break;
			default:
				REP(j, 4) {
					dp[i][j] *= 3;
					dp[i][j] %= MOD;
				}
				REP(j, 3) {
					dp[i][j + 1] += dp[i - 1][j];
					dp[i][j + 1] %= MOD;
				}
			}
		}
		else {
			dp[0][0] = 1;
			if (S[0] == 'A')dp[0][1] = 1;
			if (S[0] == '?') {
				dp[0][0] = 3;
				dp[0][1] = 1;
			}
		}
	}
	cout << dp[SZ(S) - 1][3] << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 7624
#include <atcoder/all>
#include <bits/stdc++.h>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

using S = ll;

ll op(ll a, ll b) { return max(a, b); }

ll e() { return 0; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }
    ll num = 300000 + 100;

    atcoder::segtree<S, op, e> st(num);

    rep(i, n) {
        st.set(a[i], st.prod(max(0LL, a[i] - k), min(a[i] + k + 1, num)) + 1);
    }

    cout << st.all_prod() << endl;
    return 0;
}



Measured memory_bytes: 16108
#include<bits/stdc++.h>
using namespace std;
long long n,k,sum1,sum2,ans;
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	n=read();
	k=read();
	if (k==0)
	{
		ans=n*n;
		printf("%lld\n",ans);
		return 0;
	}
	for (int i=1;i<=n;++i)
	{
		if (i<=k) continue;
		sum1=i-k;
		ans+=n/i*sum1;
		sum2=k-1;
		if (n%i-sum2<=0) continue;
		ans+=n%i-sum2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int  n = sc.nextInt();
    int[] order = new int[n];
    String out = "";
    for(int i = 1; i <= n; i++){
      order[sc.nextInt() - 1] = i;
    } 
    for(int i = 0; i < n; i++){
    System.out.println(order[i]);
    }
  }
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++)
    {
        cin >> l.at(i);
    }
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    int goukei=0;
    for (int i = 0; i < k; i++)
    {
        goukei += l.at(i);
    }
    cout << goukei << endl;
}


Measured memory_bytes: 256