akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    while (cin >> n && n) {
        vector<int> p(n), j(n - 1);
        int sump = 0;
        long long ans = 0;
        for (int i = 0; i < n; ++i) {
            cin >> p[i];
            sump += p[i];
            ans += p[i];
        }
        ans *= n;
        for (int i = 0; i < n - 1; ++i) {
            cin >> j[i];
        }
        sort(j.rbegin(), j.rend());
        int now = 0;
        while (now < n - 1) {
            if (sump < j[now] * (n - now - 1)) {
                ans -= sump;
                ans += j[now] * (n - now - 1);
                sump += j[now];
                ++now;
            } else {
                break;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 3404
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int sum[300030] = { 0 }, sum1[300030] = { 0 };
int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			sum[i + 1]++;
		}
		sum[i + 1] += sum[i];
	}
	sum[n + 1] += sum[n];
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'E') {
			sum1[i + 1]++;
		}
		sum1[i + 1] += sum1[i + 2];
	}
	sum1[0] += sum1[1];
	int ans = 1000000007;
	for (int i = 1; i <= n; i++) {
		if (ans > sum[i - 1] + sum1[i + 1]) {
			ans = sum[i - 1] + sum1[i + 1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6104
#include<iostream>
using namespace std;
int N;
int main() {
  cin >> N;
  if(N>=64) cout << 64;
  else if(N>=32) cout << 32;
  else if(N>=16) cout << 16;
  else if(N>=8) cout << 8;
  else if(N>=4) cout << 4;
  else if(N>=2) cout << 2;
  else if(N>=1) cout << 1;
  else cout << 0;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N,i;
  scanf("%d",&N);
  int P[N];
  for(i=0;i<N;i++){
    scanf("%d",&P[i]);
  }
  int max=P[0];
  int j=1;
  for(i=1;i<N;i++){
    if(max>=P[i]){
      max=P[i];
      j++;
    }
  }
  printf("%d",j);
  return 0;
}
  


Measured memory_bytes: 896
S = input()[::-1]
List = ["maerd", "remaerd", "esare", "resare"]
while True:
    if len(S) == 0:
          print("YES")
          break
    if S[0:7] in List:
        S = S[7:]
    elif S[0:6] in List:
        S = S[6:]
    elif S[0:5] in List:
        S = S[5:]
    else:
        print("NO")
        break

Measured memory_bytes: 3188
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSumOfGcdOfTuplesEasy solver = new CSumOfGcdOfTuplesEasy();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSumOfGcdOfTuplesEasy {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();

            long total = 0;
            for (int i = 0; i < k; i++) {
                for (int j = 0; j < k; j++) {
                    for (int l = 0; l < k; l++) {
                        total += gcd(i + 1, j + 1, l + 1);
                    }
                }
            }

            out.println(total);
        }

        private int gcd(int a, int b, int c) {
            return gcd(gcd(a, b), c);
        }

        private int gcd(int a, int b) {
            while (b > 0) {
                int tmp = b;
                b = a % b;
                a = tmp;
            }

            return a;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 33040
using System;

namespace ALDS1_5_C
{
    class Program
    {
        class Point
        {
            public double x;
            public double y;
            public Point(double x,double y)
            {
                this.x = x;
                this.y = y;
            }
        }
        static void Koch(int n,Point a,Point b)
        {
            if (n == 0)
            {
                return;
            }

            Point s=new Point(0,0);
            Point t = new Point(0, 0);
            Point u = new Point(0, 0);
            double th = Math.PI * 60 / 180;

            s.x = (2 * a.x + b.x) / 3;
            s.y = (2 * a.y + b.y) / 3;
            t.x = (a.x + 2 * b.x) / 3;
            t.y = (a.y + 2 * b.y) / 3;
            u.x = (t.x - s.x) * Math.Cos(th) - (t.y - s.y) * Math.Sin(th) + s.x;
            u.y = (t.x - s.x) * Math.Sin(th) + (t.y - s.y) * Math.Cos(th) + s.y;

            Koch(n - 1, a, s);
            Console.WriteLine(s.x+" "+s.y); 
            Koch(n - 1, s, u);
            Console.WriteLine(u.x+" "+u.y);
            Koch(n - 1, u, t);
            Console.WriteLine(t.x+" "+t.y);
            Koch(n - 1, t, b);
        }


        static void Main(string[] args)
        {
            int n = getint();

            Point a = new Point(0,0);
            Point b = new Point(100, 0);

            Console.WriteLine(a.x+" "+a.y);
            Koch(n, a, b);
            Console.WriteLine(b.x+" "+b.y);
        }
        public static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
    }
}

Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

#define MAX(a, b) a = max(a, b)

vector<int> dp(N, 0), graph[N];
vector<bool> vis(N, false);

void dfs(int cur)
{
    if(vis[cur]) return;
    vis[cur] = true;

    for(int i : graph[cur])
    {
        if(!vis[i]) dfs(i);
        dp[cur] = max(dp[i] + 1, dp[cur]);
    }
}

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

    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
    }

    for(int i = 1; i <= n; i++)
        if(!vis[i]) dfs(i);

    int answer = 0;
    for(int i = 1; i <= n; i++)
        MAX(answer, dp[i]);

    cout << answer;
    return 0;
}

Measured memory_bytes: 8192
#include "bits/stdc++.h"

using namespace std;
const int dx[] = { -1,0,1,0 };
const int dy[] = { 0,-1,0,1 };
const int ddx[] = { 0,1,1,  0,2, 1,-1,-2, 2, 2, -2,-2,1,-1,1,-1,2,2,-2,-2 };
const int ddy[] = { 2,1,-1,-2,0, 1, 1, 0,2, -2,  2,-2,2,2, -2,-2, 1,-1,1,-1 };


int main() {
	int H, W;
	cin >> H >> W;
	int ch, cw, dh, dw;
	cin >> ch >> cw >> dh >> dw;
	ch--; cw--; dh--; dw--;
	vector<string> S(H);
	for (int n = 0; n < H; ++n) {
		cin >> S[n];
	}

	vector<vector<int>> D(H, vector<int>(W, 1e9));//回数
	priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>> > q;
	q.push(make_pair(0, make_pair(ch, cw)));
	D[ch][cw] = 0;

	while (!q.empty()) {
		int x = q.top().second.first;
		int y = q.top().second.second;
		int z = q.top().first;
		q.pop();
		if (D[x][y] < z) continue;
		if (x == dh && y == dw) {
			cout << D[dh][dw] << endl;
			return 0;
		};
		//範囲内かつ0を4セット
		for (int l = 0; l < 4; ++l) {
			int x1 = x + dx[l];
			int y1 = y + dy[l];
			if ((0 <= x1) && (H > x1) && (0 <= y1) && (W > y1) && ('.' == S[x1][y1])) {
				if (D[x1][y1] > D[x][y]) {
					D[x1][y1] = D[x][y];
					pair<int, pair<int, int>> p = make_pair(D[x1][y1], make_pair(x1, y1));
					q.emplace(p);
				}
			}
		}
		//範囲内かつ0を20セット
		for (int l = 0; l < 20; ++l) {
			int x1 = x + ddx[l];
			int y1 = y + ddy[l];
			if ((0 <= x1) && (H > x1) && (0 <= y1) && (W > y1) && ('.' == S[x1][y1])) {
				if (D[x1][y1] > D[x][y]) {
					D[x1][y1] = D[x][y] + 1;
					pair<int, pair<int, int>> p = make_pair(D[x1][y1], make_pair(x1, y1));
					q.emplace(p);
				}
			}
		}
	}
	if (1e9 == D[dh][dw]) {
		cout << -1 << endl;
	}
	else {
		cout << D[dh][dw] << endl;
	}
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    ll h,w;
    cin >> h >> w;
    ll d[10][10];
    rep(i,0,10) rep(j,0,10){
        cin >> d[i][j];
    }

    rep(k,0,10){
        rep(i,0,10){
            rep(j,0,10){
                d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
            }
        }
    }

    ll ans = 0;
    rep(i,0,h){
        rep(j,0,w){
            ll a;
            cin >> a;
            if(a != -1) ans += d[a][1];
        }
    }

    cout << ans << endl;

    

    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	copy_n(istream_iterator<string>(cin), h, s.begin());
	vector<vector<int>> cnt(h + 1, vector<int>(w + 1));
	for(int i = 1; i <= h; ++ i){
		for(int j = 1; j <= w; ++ j){
			cnt[i][j] = cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1] + s[i - 1][j - 1] - '0';
		}
	}
	auto sum = [&](int x, int y, int xx, int yy){
		return cnt[xx][yy] - cnt[x][yy] - cnt[xx][y] + cnt[x][y];
	};
	vector<int> cur{0};
	int res = numeric_limits<int>::max();
	for(int mask = 0; mask < 1 << h - 1; ++ mask){
		cur.resize(1);
		for(int bit = 0; bit < h - 1; ++ bit){
			if(mask & 1 << bit){
				cur.push_back(bit + 1);
			}
		}
		cur.push_back(h);
		auto test = [&](int i, int j){
			for(int t = 1; t < int(cur.size()); ++ t){
				if(sum(cur[t - 1], i, cur[t], j) > k){
					return false;
				}
			}
			return true;
		};
		int cur_res = __builtin_popcount(mask) - 1;
		bool ok = true;
		for(int i = 0; i < w; ){
			int j = i;
			while(j < w && test(i, j + 1)){
				++ j;
			}
			if(i == j){
				ok = false;
				break;
			}
			++ cur_res;
			i = j;
		}
		if(ok) ctmin(res, cur_res);
	}
	cout << res;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int N, M;
int P[1000];
vector<int> D;

int main() {
  while (cin >> N >> M) {
    if (N == 0 && M == 0) break;
    for (int i=0; i<N; i++) cin >> P[i];

    D.clear();
    D.push_back(0);
    for (int i=0; i<N; i++) {
      D.push_back(P[i]);
      for (int j=0; j<N; j++) {
        D.push_back(P[i] + P[j]);
      }
    }

    sort(D.begin(), D.end());
    int ans = 0;
    for (auto x : D) {
      int t = x + *(upper_bound(D.begin(), D.end(), M - x) - 1);
      if (t <= M) ans = max(ans, t);
    }
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 7060
n=int(input())
h=list(map(int, input().split()))
def split(p):
    res=[]
    tmp=[]
    for pi in p:
        if pi==0:
            if len(tmp)>0:
                res.append(tmp)
                tmp=[]
        else:
            tmp.append(pi)
    if len(tmp)>0:
        res.append(tmp)
    return res
        
def D(p):
    global cnt
    m=min(p)
    cnt+=m
    p=[pi-m for pi in p]
    s=split(p)
    for si in s:
        D(si)
cnt=0
D(h)
print(cnt)

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		char[] alphabet = {'A' , 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M' , 'N', 'O', 'P', 'Q' , 'R', 'S', 'T', 'U', 'V', 'W', 'X','Y','Z'};
		String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		int[] freqArr = new int[alphabet.length];
		String S = sc.nextLine();
		for (int i = 0; i < 4; i++) {
			freqArr[alpha.indexOf(S.charAt(i))]++;
		}
		int cnt = 0;
		for(int i : freqArr){
			if(i >= 2){
				cnt++;
			}
			if(cnt >= 2){
				System.out.println("Yes");
				System.exit(0);
			}
		}
		System.out.println("No");
	}


static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

		public double nextDouble(String x)
		{

			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}


	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main()

{
	int m,n,k,sum;
	cin>>m >>n;
	vector<int>p;
	for(int i=0; i<n;i++)
	{
		cin>>k;
		p.push_back(k);
	}
	for(int i=0;i<n;i++)
	{
		sum+=p.back();
		p.pop_back();
	}
	if(sum>=m)
	cout<<"Yes";
	else
	cout<<"No";
}


Measured memory_bytes: 892
# AtCoder Beginners Selection  Some Sums 解けなかった
N,A,B = map(int,input().split())
ans = 0
for i in range(1,N+1):
    moji = str(str(i).zfill(4))
    sumsomes = int(moji[0])+int(moji[1])+int(moji[2])+int(moji[3])
    if (sumsomes >= A) and (sumsomes <= B):
        ans += i
print(ans)

Measured memory_bytes: 9100
def difftemp_with_a(height_i):
    return abs((t - height_i * 0.006) - a)

n = int(input())
t, a = [int(x) for x in input().split()]
height = [int(x) for x in input().split()]
print(height.index(min(height, key = difftemp_with_a)) + 1)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int cur = 1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a != cur) ans++;
    else cur++;
  }
  if (ans == n) puts("-1");
  else cout << ans << endl;
  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

void solve(int N,int L,vi& a) {
    // cerr << N << " "<< L << " " << a << endl;
    int last = -1;
    rep(i, N-1) {
        if (a[i] + a[i+1] >= L) {
            last = i; break;
        }
    }
    if (last == -1) {
        cout << "Impossible" << endl;
        return;
    }
    cout << "Possible" << endl;
    for (int i=0; i<last; ++i) {
        printf("%d\n", 1+i);
    }
    for (int i=N-2; i>last; --i) {
        printf("%d\n", 1+i);
    }
    printf("%d\n", 1+last);
}

int main() {
    int N, L; cin >> N >> L; // 2-1e5, 1e9
    read_cr();
    vi a(N); // 1e9
    loadvec(a, N);
    solve(N,L,a);
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<int> S(N);
    string ans = "Three";
    rep(i, N) {
        string s;
        cin >> s;
        if(s=="Y") ans = "Four";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long k,ans,x;
  ans=0;
  cin>>k;
  for(long i=1; i<k+1; i++){
    for(long j=1; j<k+1; j++){
      for(long h=1; h<k+1; h++){
        x=gcd(i,j);
        x=gcd(x,h);
        ans=ans+x;
      }
    }
  }
  cout<<ans;
}

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

int main(void) {
    long long N;
    cin >> N;
    vector< long long > A(N), left(N + 1), right(N + 1);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    left[0] = 0;
    right[N] = 0;
    for (int i = 0; i < N; ++i) {
        left[i + 1] = max(left[i], A[i]);
        right[N - 1 - i] = max(right[N - i], A[N - 1 - i]);
    }
    for (int i = 0; i < N; ++i) {
        printf("%lld\n", max(left[i], right[i + 1]));
    }
    return 0;
}


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

using namespace std;

void input(int& N, int& M, int& K,
	   vector<int>& deskA, vector<int>& deskB)
{
  int a, b;
  cin >> N >> M >> K;
  deskA.resize(N + 1, 0);
  deskB.resize(M + 1, 0);
  for (int i = 1; i <= N; i++){
    cin >> a;
    deskA[i] = deskA[i - 1] + a;
  }
  for (int i = 1; i <= M; i++){
    cin >> b;
    deskB[i] = deskB[i - 1] + b;
  }
}

void findans(int& N, int& M, int& K,
	     vector<int>& deskA, vector<int>& deskB, 
	     int& maximum)
{
  for (int i = 0; i <= N; i++)
    if (K - deskA[i] >= 0)
      for (int j = max(maximum - i, 0); j <= M; j++)
	if (K - deskA[i] - deskB[j] >= 0){
	  if (i + j > maximum)
	    maximum = i + j;
	}
	else
	  break;
    else
      break;
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, K, maximum = 0;
  vector<int> deskA, deskB;
  input(N, M, K, deskA, deskB);
  findans(N, M, K, deskA, deskB, maximum);
  cout << maximum << '\n';
  return 0;
}


Measured memory_bytes: 4764
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
int fil[200008];
int cnt[200008];int a[200008];
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int n,m;cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i+1];cnt[a[i+1]]++;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j>i-cnt[i];j--) 
		{
			if(j>0)fil[j]++; //else fil[i]++;
		}
	}int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(0==fil[i]) ans++;
	}
	while(m--)
	{
		int q,w;cin>>q>>w;cnt[a[q]]--;cnt[w]++;if(a[q]==w)
		{
			cout<<ans<<endl;continue;
		}
		if(w-cnt[w]+1>0)
		{
			fil[w-cnt[w]+1]++;if(fil[w-cnt[w]+1]==1) ans--;
		}
		if(a[q]-cnt[a[q]]>0)
		{
			fil[a[q]-cnt[a[q]]]--;if(fil[a[q]-cnt[a[q]]]==0) ans++;
		}
		a[q]=w;
		//for(int i=1;i<=n;i++) cout<<fil[i]<<" ";cout<<endl;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007LL;

int N, K;
vector<int> G[100005];
ll ret;

ll kai[100005];

void init(){
  kai[0] = 1;
  ll b = 1;
  REP(i,1,100005){
    b *= i;
    b %= MOD;
    kai[i] = b;
  }
}
ll extgcd(ll a, ll b, ll &x, ll &y){
  ll d = a;
  if(b!=0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll mod_inverse(ll a, ll m){
  ll x, y;
  extgcd(a, m, x, y);
  return (m+x%m)%m;
}
ll mod_perm(ll n, ll k, ll m){
  if(n<0) return 0;
  if(n-k<0) return 0;
  if(k == 0) return 1;
  return (kai[n] * mod_inverse(kai[n-k], MOD))%MOD;
}

void dfs(int v, int p){
  ll M = 1;
  if(p!=-1) M++;
  //cerr << v << " " << K-M << " " << G[v].size() - ((p==-1)?0:1) << " " << mod_perm(K-M, G[v].size() - ((p==-1)?0:1), MOD) << endl;
  ret *= mod_perm(K-M, G[v].size() - ((p==-1)?0:1), MOD);
  ret %= MOD;
  rep(i,G[v].size()){
    if(G[v][i] == p) continue;
    dfs(G[v][i], v);
  }
}

int main(){
  init();
  cin >> N >> K;
  rep(i,N-1){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int mx = 0;
  int mx_i = 0;
  rep(i,N){
    if(mx < G[i].size()){
      mx = G[i].size();
      mx_i = i;
    }
  }
  mx_i=0;

  if(mx+1 > K){
    cout << 0 << endl;
    return 0;
  }

  ret = 1;
  dfs(mx_i, -1);
  ret *= K;
  ret %= MOD;
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    vector<int> x(3);
    rep(i,3) cin >> x[i];
    sort(all(x));
    int e = 0, o = 0;
    rep(i,3){
        if (x[i] % 2 == 0) e++;
        else o++;
    }
    
    int ans = 0;
    if (e == 1 && o == 2){
        rep(i,3) if (x[i] % 2 != 0) x[i]++;
        ans++;
    }else if (e == 2 && o == 1){
        rep(i,3) if (x[i] % 2 == 0) x[i]++;
        ans++;
    }
    ans += (x[2]-x[0])/2;
    ans += (x[2]-x[1])/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

int main() {
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += a[i] * a[j];	
		}
	}
	cout << sum << endl;
	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vl h(n);
  REP(i,n) cin >> h[i];
  RREP(i,n-1){
    if(h[i]>h[i+1]+1){
      cout << "No" << endl;
      return 0;
    }
    CHMIN(h[i],h[i+1]);
  }
  cout << "Yes" << endl;
  return 0;
}


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

void solve() {
    int N;
    cin >> N;
    vector<pair<int, int>> alien;
    rep(i, 1 << N) {
        int a;
        cin >> a;
        alien.push_back(make_pair(i, a));
    }
    int ans = 0;
    rep(i, 1 << N) {
        rep(j, N) {
            if ((i & 1 << j) != 0) {
                if (alien[i ^ 1 << j].second > 0) {
                    if (alien[i].second == 0) {
                        cout << -1 << endl;
                        return;
                    } else alien[i].second = 2;
                }
            }
        }
        if (alien[i].second == 1) ++ ans;
    }
    cout << ans << endl;
}

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



    solve();

    return 0;
}


Measured memory_bytes: 11200
while True:
  m, f, r = map(int, input().split())
  if m == -1 and f == -1 and r == -1:
    break
  elif m == -1 or f == -1:
    print("F")
  elif m + f >= 80:
    print("A")
  elif m + f >= 65:
    print("B")
  elif m + f >= 50:
    print("C")
  elif m + f >= 30:
    if r >= 50:
      print("C")
    else:
      print("D")
  else:
    print("F")




Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#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 RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp);
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, m; cin >> n >> m;
    vi x(n), y(n);
    vi xs, ys;
    REP(i, n) {
        cin >> x[i] >> y[i];
        xs.push_back(x[i]);
        ys.push_back(y[i]);
    }
    sort(ALL(xs));
    sort(ALL(ys));
    xs.erase(unique(ALL(xs)), xs.end());
    ys.erase(unique(ALL(ys)), ys.end());

    int H = ys.size(), W = xs.size();
    vvi s(H+1, vi(W+1));
    REP(i, n) {
        int X = lower_bound(ALL(xs), x[i]) - xs.begin();
        int Y = lower_bound(ALL(ys), y[i]) - ys.begin();
        ++s[Y+1][X+1];
    }
    REP(i, H) {
        REP(j, W) {
            s[i+1][j+1] += s[i+1][j] + s[i][j+1] - s[i][j];
        }
    }

    vi sx(m), sy(m), tx(m), ty(m);
    REP(i, m) {
        int sX, sY, tX, tY;
        cin >> sX >> sY >> tX >> tY;
        sx[i] = lower_bound(ALL(xs), sX) - xs.begin();
        tx[i] = lower_bound(ALL(xs), tX+1) - xs.begin();
        sy[i] = lower_bound(ALL(ys), sY) - ys.begin();
        ty[i] = lower_bound(ALL(ys), tY+1) - ys.begin();
    }

    REP(i, m) {
        int ans = s[ty[i]][tx[i]] - s[ty[i]][sx[i]] - s[sy[i]][tx[i]] + s[sy[i]][sx[i]];
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 108692
#include<bits/stdc++.h>
using namespace std;
string st;
const int mo=1e9+7;
long long l,f[100007][4];
inline long long qp(int x,int y){
	long long t=1,tt=x;while(y){if(y&1)t=(t*tt)%mo;tt=(tt*tt)%mo;y>>=1;}return t;
}
int main(){
	ios::sync_with_stdio(false);cin>>st;l=st.length();f[0][0]=1;
	for(int i=0;i<l;i++){
		if(st[i]=='C'||st[i]=='?'){
			f[i+1][0]=(f[i+1][0]+f[i][0])%mo;
			f[i+1][1]=(f[i+1][1]+f[i][1])%mo;
			f[i+1][2]=(f[i+1][2]+f[i][2])%mo;
			f[i+1][3]=(f[i+1][3]+f[i][2]+f[i][3])%mo;
		}
		if(st[i]=='B'||st[i]=='?'){
			f[i+1][0]=(f[i+1][0]+f[i][0])%mo;
			f[i+1][1]=(f[i+1][1]+f[i][1])%mo;
			f[i+1][2]=(f[i+1][2]+f[i][1]+f[i][2])%mo;
			f[i+1][3]=(f[i+1][3]+f[i][3])%mo;
		}
		if(st[i]=='A'||st[i]=='?'){
			f[i+1][0]=(f[i+1][0]+f[i][0])%mo;
			f[i+1][1]=(f[i+1][1]+f[i][0]+f[i][1])%mo;
			f[i+1][2]=(f[i+1][2]+f[i][2])%mo;
			f[i+1][3]=(f[i+1][3]+f[i][3])%mo;
		}
	}
	cout<<f[l][3]<<endl;return 0;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
using namespace std;
const long long N = 1e9 + 7;
typedef long long ll;
map <char,int> ma;
int a[110];
int main()
{
	int n;
	ll sum = N;
	cin >> n;
	for(int i = 0;i < n;i++)
        cin >> a[i];
    for(int i = 1 ;i <=100;i++)
    {
        ll num = 0;
        for(int j = 0;j < n;j++)
        {
            num += (i - a[j]) * (i - a[j]);

        }
        if(num < sum )
            sum = num;
    }
    cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
var
	N,i,j:Longint;
	ans:int64;
begin
	read(N);
	j:=round(sqrt(N));
	if j*j>N then dec(j);
	for i:=1 to j do inc(ans,(N div i)*(N div i+1)*i-i*i*i);
	writeln(ans);
end.

Measured memory_bytes: 1332
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> cnt(N, 0);
	for (int i = 0; i < K; ++i) {
		int d; cin >> d;
		while (d--) {
			int a; cin >> a;
			++cnt[--a];
		}
	}
	int res = 0;
	for (int i = 0; i < N; ++i)
		if (cnt[i] == 0)
			++res;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
//hash base 177013

template <typename T> void max_self(T& a,T b)
{
	a=max(a,b);
}

bool row_col(pair<int,int> p)
{
	if(p.first==0||p.second==0)
		return 1;
	return 0;
}

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		string a,b;
		cin>>a>>b;
		int n=a.size();
		int m=b.size();
		pair<int,pair<int,int>> dp[n+2][m+2];
		fi(0,n+2)
		{
			fj(0,m+2)
			{
				dp[i][j]={INT_MIN,{INT_MIN,INT_MIN}};
			}
		}
		dp[0][0]={0,{0,0}};
		fi(0,n)
		{
			fj(0,m)
			{
				if(a[i]==b[j])
				{
					max_self(dp[i+1][j+1],{dp[i][j].first+1,{i,j}});
				}
					
				max_self(dp[i+1][j],{dp[i][j].first,{i,j}});
				max_self(dp[i][j+1],{dp[i][j].first,{i,j}});
			}
		}
		pair<int,pair<int,int>> ans={0,{0,0}};
		fi(0,n+2)
		{
			fj(0,m+2)
			{
				max_self(ans,{dp[i][j].first,{i,j}});
			}
		}
		
		string c;
		pair<int,int> curr=ans.second;
		while(!row_col(curr))
		{
			int i=curr.first;
			int j=curr.second;
			pair<int,int> prev=dp[i][j].second;
			if(prev==make_pair(i-1,j-1))
			{
				c+=a[i-1];
			}
			curr=prev;
		}
		reverse(c.begin(),c.end());
		cout<<c<<'\n';
		
	}
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 5e5 + 5;
int n, q, a[mxn], lst[mxn], ans[mxn];
vector <pair <int, int> > qry[mxn];

struct BIT {
	int s[mxn];
	void upd(int x, int v) { for (++ x; x < mxn; x += x & -x) s[x] += v; }
	int qry(int x) { int ans = 0; for (++ x; x; x -= x & -x) ans += s[x]; return ans; }
} bit;

int main() {
	scanf("%d %d", &n, &q);
	rep(i, n) scanf("%d", &a[i]), -- a[i];
	rep(i, q) {
		int l, r;
		scanf("%d %d", &l, &r);
		-- l; -- r;
		qry[l].pb(mp(r, i));
	}
	rep(i, n) lst[i] = n;
	for (int i = n - 1; ~i; -- i) {
		bit.upd(lst[a[i]], -1); bit.upd(lst[a[i]] = i, +1);
		rep(j, qry[i].size()) ans[qry[i][j].second] = bit.qry(qry[i][j].first);
	}
	rep(i, q) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 33152
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;

 int main()
 {
   for(int i=1;i<=9;i++)
   {
     for(int j=1;j<=9;j++)
     {
       cout<<i<<"x"<<j<<"="<<(i*j)<<endl;        
     }        
   }
   //while(1);      
   return 0;    
 }
 
 

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

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

use std::cmp::{max, min};

fn main() {
  let n = read::<i64>();
  let mut red = vec![];
  let mut blue = vec![];
  let mut ans = 0;

  for _ in 0..n {
    let a = read::<i64>();
    let b = read::<i64>();
    red.push(vec![a, b])
  }
  for _ in 0..n {
    let a = read::<i64>();
    let b = read::<i64>();
    blue.push(vec![a, b])
  }

  blue.sort_by_key(|x| x[0]);
  red.sort_by_key(|x| -x[1]);

  for (i, v) in blue.iter().enumerate() {
    // let mut dib = i;
    let mut dir = -1 as i64;
    for (ii, iv) in red.iter().enumerate() {
      if iv[1] < v[1] && iv[0] < v[0] {
        dir = ii as i64;
        ans += 1;
        break;
      }
    }
    if dir != -1 {
      red.remove(dir as usize);
    }
  }

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

Measured memory_bytes: 4352
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let mut d: Vec<u32> = parse_line().unwrap();
    let _m: usize = parse_line().unwrap();
    let mut t: Vec<u32> = parse_line().unwrap();
    let mut ans = "YES";

  	d.sort();
  	t.sort();
    for &ti in &t {
        if let Some(idx) = d.iter().position(|&x| x == ti) {
            d.remove(idx);
        } else {
            ans = "NO";
            break;
        }
    }
    println!("{}", ans);
}


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

int main(){
int n;cin>>n;
vector<int>a(n+2);
for(int i=1;i<=n;i++)cin>>a[i];
int dist=0;
for(int i=1;i<=n+1;i++)dist+=abs(a[i]-a[i-1]);
for(int i=1;i<=n;i++){
int d1,d2,d3;
d1 = abs(a[i]-a[i-1]);
d2 = abs(a[i+1]-a[i]);
d3 = abs(a[i+1]-a[i-1]);
cout<<dist-d1-d2+d3<<endl;
}
return 0;
}

Measured memory_bytes: 1664
a,b=map(int,input().split())
c=0
for s in range(a,b+1):
    flag = 1
    for i in range(len(str(s))//2+1):
        if str(s)[i]!=str(s)[-i-1]:
            flag = 0
            break
    if flag:
        c += 1
print(c)

Measured memory_bytes: 2940
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

const n,k=parseMap(split(readline()))
const p=parseMap(split(readline()))
const c=parseMap(split(readline()))
function main()
    ans=maximum(c)
    for i in 1:n
        now::Int=i
        score::Vector{Int}=[]
        while true
            now=p[now]
            push!(score,c[now])
            if now==i
                break
            end
        end
        res,len=0,length(score)
        for j in 1:min(k,len)
            res+=score[j]
            ans=max(ans,res)
        end
        if k>len
            res,tmp=(k÷len-1)*sum(score),k-(k÷len-1)*len
            score,len=vcat(score,score),len*2
            ans=max(ans,res)
            for j in 1:min(tmp,len)
                res+=score[j]
                ans=max(ans,res)
            end
        end
    end
    println(ans)
end
main()

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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i, n) {
    cin >> a[i];
    a[i] *= -1;
  }
  vector<int> s;
  rep(i, n){
    int p = lower_bound(s.begin(), s.end(), a[i]+1) - s.begin();
    if(p == s.size()) s.push_back(a[i]);
    else s[p] = a[i];
  }
  cout << s.size() << endl;
  return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B;
    cin >> A >> B;

    if (A >= 13) {
        cout << B << endl;
    } else if (A >= 6) {
        cout << B/2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int fGrade(int x)
{
if(x>=1800) return 1;
else if(x>=1600) return 2;
else if(x>=1400) return 3;
else if(x>=1200) return 4;
else if(x>=1000) return 5;
else if(x>=800) return 6;
else if(x>=600) return 7;
else return 8;
}

int main(void)
{
  int x;
  (void)scanf("%d", &x);
  printf("%d", fGrade(x));
  return 0;
}


Measured memory_bytes: 1732
a,b,t,i,N;
main(){
    long c=0;
    for(scanf("%d",&N);N--;c+=t,i++){
        scanf("%d",&t);
        a=i&&a<t?a:t;
        b=i&&b>t?b:t;
    }
    printf("%d %d %ld\n",a,b,c);
}

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

using namespace std;
typedef long long ll;
int L[1000];
int n, x;
int main(){
    cin >> n >> x;
    for(int i=0; i<n; i++) cin >> L[i];
    int cnt=0;
    int d=0;
    while(cnt<n){
        d += L[cnt];
        if( d > x ) break;
        cnt++;
    }
    cout << cnt+1 << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int a , b , c ;
    cin >> a >> b >> c ;
    if(b/a > c)cout << c ;
    else cout << b/a ;




























return 0 ;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys

MOD = 2  # type: int

def solve(N: int, A: "List[int]"):
    ans = set()
    for i in range(N,0,-1):
        c = 0
        for j in range(2,N + 1):
            if i * j <= N:
                if i*j in ans:
                    c += 1
            else:
                break

        if A[i-1] == 0:
            if c % 2 == 1:
                ans.add(i)
        else:
            if c % 2 == 0:
                ans.add(i)

    print(len(ans))
    if len(ans):
        print(" ".join([str(i) for i in ans]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 23236
/* DSL1_A: Disjoint Set */

#include <iostream>

class UnionFindTree {
    int *parents;

    public:
        UnionFindTree(int n) {
            parents = new int[n];
            for (int i = 0; i < n; i++)
                parents[i] = i;
        }

        ~UnionFindTree() {
            delete [] parents;
        }

        void unite(int x, int y) {
            parents[ find(x) ] = find(y);
        }

        int find(int x) {
            if (parents[x] == x)
                return x;
            else
                return parents[x] = find( parents[x] );
        }

        bool is_grouped(int x, int y) {
            return find(x) == find(y);
        }
};

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

    int n, q;
    std::cin >> n >> q;

    UnionFindTree uft(n);

    int command, x, y;
    for (int i = 0; i < q; i++) {
        std::cin >> command >> x >> y;
        switch (command) {
            case 0:
                uft.unite(x, y);
                break;
            case 1:
                bool same = uft.is_grouped(x, y);
                std::cout << ( same ? 1 : 0 ) << "\n";
                break;
        }
    }

    return 0;
}

Measured memory_bytes: 1308
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>
#include <complex>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

template<typename T>
void dft(vector<complex<T>>& f, bool inv=false) {
  int n = (int)f.size();
  //printf("size:%d, n:%d\n", sz(f), n);
    if (n==1) return;

    vector<complex<T>> f0, f1;
    for (int i = 0; i < n/2; i++) {
        f0.push_back(f[i*2]);
        f1.push_back(f[i*2+1]);
    }
    dft<T>(f0, inv), dft<T>(f1, inv);

    complex<T> now = 1.0, zeta = polar(1.0, 2.0 * acos(-1) / n);
    if (inv) zeta = 1.0 / zeta;
    for (int i = 0; i < n; i++) {
        f[i] = f0[i % (n/2)] + f1[i % (n/2)] * now;
        now *= zeta;
    }
    return;
}

template<typename T>
vector<long long> multiply(vector<T> f, vector<T> g) {
    int n = 1;
    while (n < (int) f.size() + (int)g.size() + 1) n *= 2;
    f.resize(n), g.resize(n);
    
    vector<complex<T>> ff(n, 0), gg(n, 0), fg;
    for (int i = 0; i < f.size(); i++) {
        ff[i] = f[i];
        gg[i] = g[i];
    }
    dft<T>(ff, false);
    dft<T>(gg, false);
    
    for (int i = 0; i < n; i++) fg.push_back(ff[i] * gg[i]);
    dft<T>(fg, true);
    
    vector<long long> res;
    for (int i = 0; i < n; i++) res.push_back((long long)(fg[i].real()/n+0.5));
    
    
    return res;
}


int main(void) {
    int n;
    ll m;
    cin >> n >> m;
    vector<double> A1(100005, 0), A2(100005, 0);
    for(int i=1; i<=n; i++) {
        int a;
        cin >> a;
        A1[a]++;
        A2[a]++;
    }
    
    vector<long long> C = multiply<double>(A1, A2);
    
    ll mm = 0;
    for(int i=sz(C)-1; i>=0; i--) {
      if (C[i]==0) continue;
      
      ans += i*C[i];
      mm += C[i];
      if (mm>=m) {
        ans -= (mm-m)*i;
        break;
      }
    }
  
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 29872