akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<numeric>
#include<iomanip>
#include<cmath>
using namespace std;

typedef long long ll;
const double EPS = 0.00001;
#define Equals(a,b) abs(a-b) < EPS

ll getcombination(int a, int b){
    ll ret = 1;
    for(int i = 0; i < b; i++){
        ret *= (a-i);
        ret /= (i+1);
    }
    return ret;
}

int main(){
    int n, a, b;
    ll v;

    cin >> n >> a >> b;
    vector<ll> value(n);
    map<ll, int> appear;

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

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

    ll accum = accumulate(value.begin(), value.begin() + a, 0ll);
    map<ll, int> used;
    for(int i = 0; i < a; i++)  used[value[i]]++;

    double maxave = accum / (double)a;
    ll ans = 1;

    for(auto x : used){
        ans *= getcombination(appear[x.first], used[x.first]);
    }

    for(int i = a; i < b; i++){
        if(Equals(value[i],maxave)){
            used[value[i]]++;
            ll tmp = 1;
            for(auto x : used){
                tmp *= getcombination(appear[x.first], used[x.first]);
            }
            ans += tmp;
        }else{
            break;
        }
    }

    cout << fixed << setprecision(7) << maxave << endl << ans << endl;

    return 0;
}

Measured memory_bytes: 256
M, K = map(int, input().split())

if K == 0:
    print(*(list(range(2 ** M)) + list(range(2 ** M - 1, -1, -1))))
else:
    if M <= 1:
        print(-1)
    elif K.bit_length() > M:
        print(-1)
    else:
        index = 0
        used = [False] * (2 ** M)
        ans = []
        for _ in range(2 ** (M-2)):
            while index < 2 ** M and used[index]:
                index += 1
            A = index
            C = index ^ K
            used[index] = True
            used[index^K] = True
            while index < 2 ** M and used[index]:
                index += 1
            B = index
            D = index ^ K
            used[index] = True
            used[index^K] = True
            ans += [A, C, B, D, C, A, D, B]
        print(*ans)
            

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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    int n, x;
    cin >> n;

    vector<int> v;
    REP(_, n) { cin >> x; v.pb(x); }

    vector<int> gcd1, gcd2;
    REP(i, n) {
        if (i == 0) {
            gcd1.pb(v[i]);
            gcd2.pb(v[n - i - 1]);
        } else {
            gcd1.pb(__gcd(gcd1[i - 1], v[i]));
            gcd2.pb(__gcd(gcd2[i - 1], v[n - i - 1]));
        }
    }

    int ans = 1;
    REP(i, n) {
        if (i == 0) {
            ans = max(ans, gcd2[gcd2.size() - 2]);
        } else if (i == n - 1) {
            ans = max(ans, gcd1[gcd1.size() - 2]);
        } else {
            ans = max(ans, __gcd(gcd1[i - 1], gcd2[n - 2 - i]));
        }
    }
    cout << ans << endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 1912
#include <iostream>
#include <string>
#define Nmax 100000
using namespace std;

int p[Nmax];
string s[Nmax];
int que[Nmax];
bool ac[Nmax];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> s[i];
	}

	int penanum = 0;
	int acnum = 0;
	for (int i = 0; i < m; i++) {
		if (s[i] == "WA") {
			if (ac[p[i] - 1]) {

			}
			else
			{
				que[p[i] - 1]++;
			}
		}
		else
		{
			if (ac[p[i] - 1]) {
				//penanum += que[p[i] - 1];
			}
			else
			{
				penanum += que[p[i] - 1];
				ac[p[i] - 1] = true;
				acnum++;
			}
		}
	}
	cout << acnum << " " << penanum << endl;
	return 0;
}

Measured memory_bytes: 6528
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable long mod = 10^^9 + 7;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);

    int x = chain(iota(1, n + 1), a).reduce!"a ^ b";
    int L = a.countUntil(x).to!int, R = a.retro().countUntil(x).to!int;

    auto f = new long[](n + 2), fv = new long[](n + 2);

    f[0] = fv[0] = 1L;
    iota(1, n + 2).each!(i => (f[i] = i * f[i - 1] % mod));
    fv[n + 1] = powmod(f[n + 1], mod - 2, mod);
    iota(1, n + 1).retro().each!(i => (fv[i] = (i + 1) * fv[i + 1] % mod));

    long binom(int n, int k) {
        return f[n] * fv[k] % mod * fv[n - k] % mod;
    }

    foreach (k ; 1 .. n + 2) {
        long ans = binom(n + 1, k);

        if (k - 1 <= L + R) ans -= binom(L + R, k - 1);
        if (ans < 0) ans += mod;

        writeln(ans);
    }

}


long powmod(long x, long y, long mod) {
    return y > 0 ? powmod(x, y>>1, mod)^^2 % mod * x^^(y&1) % mod : 1L;
}


void scan(T...)(ref T args) {
    string[] 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);
        }
    }
}

Measured memory_bytes: 5564
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

long long A[100000];
long long cum_sum[100000];
bool can_absorb_all(int i, int N){
    int last_tried = 0;
    long long cur_size = A[i];
    for(last_tried = 0; last_tried < N; last_tried++){
        if(last_tried == i){
            continue;
        }
        if(A[last_tried] > 2 * cur_size){
            break;
        }
        cur_size += A[last_tried];
    }
    if(last_tried < N){
        return false;
    }
    return true;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    cum_sum[0] = A[0];
    for(int i = 1; i < N; i++){
        cum_sum[i] = cum_sum[i - 1] + A[i];
    }

    sort(A, A + N);
    int left = 0;
    int right = N - 1;
    if(can_absorb_all(left, N)){
        cout << N << endl;
        return 0;
    }
    while(left < right - 1){
        int mid = (left + right) / 2;
        if(can_absorb_all(mid, N)){
            right = mid;
        } else {
            left = mid;
        }
    }
    cout << N - left - 1 << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main() {
    int i, j, h, w;
    
    while(1){
        scanf("%d %d",&h,&w);
        if((h+w)==0) break;
        
        for(i = 1; i <= h; i++){
            for(j = 1; j <= w; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
    
}


Measured memory_bytes: 2052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N;
    static int H;
    static int A;
    static int[] B;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        H = sc.nextInt();
        A = -1;
        B = new int[N];
        for (int i = 0; i < N; i++) {
            A = Math.max(sc.nextInt(), A);
            B[i] = sc.nextInt();
        }

        System.out.println( solve() );
    }

    private static int solve() {
        Arrays.sort(B);

        int hp = H;
        int ans = 0;
        for (int i = N-1; i >= 0; i--) {
            int b = B[i];
            if( b > A ) {
                hp -= b;
                ans++;
                if( hp <= 0 ) return ans;

            } else {
                break;
            }
        }

        int q = hp / A;
        int r = hp % A;
        ans += q;
        if( r > 0 ) ans++;
        return ans;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

int main() {
	int d,n;cin>>d>>n;
	int ans=1;
	for(int i=0;i<d;i++){
		ans*=100;
	}
	ans*=n;
	if(n==100){
		ans/=100;
		ans*=101;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
input()
a=list(map(int,input().split()))
b=sorted(a)
c=0
for i in range(len(a)):
 x=a.index(b[i])
 j=0
 while x>i:
  j+=1
  y=a.index(b[x])
  c+=a[y]
  a[x],a[y]=a[y],a[x]
  x=y
 c+=min(b[i]*j,b[i]*2+b[0]*(j+2))
print(c)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,nu,an=0;
cin>>n;
for(int i=1;i<=n;i+=2){
  nu=0;
for(int j=1;j<=i;j++){
  if(i%j==0) nu++;
}
if(nu==8){
	an++;
}
}
cout<<an<<endl;return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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


int main(){
ll a,b,c,d;
cin>>a>>b>>c>>d;
if(abs(a-c)>d&&(abs(a-b)>d||abs(b-c)>d)){
    cout<<"No"<<endl;
}else{
    cout<<"Yes"<<endl;
}
}









Measured memory_bytes: 256
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n=sc.nextInt(),q=sc.nextInt();
        String s=sc.next();
        int[] AC=new int[n+1];
        for (int i = 1; i < n; i++) {
            if(s.charAt(i-1)=='A'&&s.charAt(i)=='C'){
                AC[i]=1;
            }
        }
        for (int i = 1; i < n + 1; i++) {
            AC[i]+=AC[i-1];
        }
        for (int i = 0; i < q; i++) {
            int l=sc.nextInt(),r=sc.nextInt();
            int k=0;
            //if(l-2>=0&&s.charAt(l-1)=='C'&&s.charAt(l-2)=='A')k++;
            if(r<n&&s.charAt(r-1)=='A'&&s.charAt(r)=='C')k++;
            out.println(max(0,AC[r]-AC[l-1]-k));
        }
    }
}
/*
8 3
ACACTACG
3 7
2 3
2 6

 */

Measured memory_bytes: 76208
#include<bits/stdc++.h>
#define ll long long
#define p5 10005
using namespace std;
int ln1,ln2;
int grd[p5+2][p5+2];
char st[p5][p5],s1[p5+2],s2[p5+2];
void print(int i,int j)
{
    if(i==0 || j==0)
        return ;
    if(st[i][j]=='c')
    {
        print(i-1,j-1);
        printf("%c",s1[i-1]);
    }
    else if(st[i][j]=='u'){
        print(i-1,j);
    }
    else{
        print(i,j-1);
    }
}
void fun()
{
    for(int i=0;i<=ln1;i++){
        grd[i][0]=0;
    }
    for(int i=0;i<=ln2;i++){
        grd[0][i]=0;
    }
    for(int i=1;i<=ln1;i++){
        for(int j=1;j<=ln2;j++){
            if(s1[i-1]==s2[j-1]){
                grd[i][j]=grd[i-1][j-1]+1;
                st[i][j]='c';
            }
            else if(grd[i-1][j]>=grd[i][j-1]){
                grd[i][j]=grd[i-1][j];
                st[i][j]='u';
            }
            else{
                grd[i][j]=grd[i][j-1];
                st[i][j]='l';
            }
        }
    }
}
int main()
{
    int x,y;
    scanf("%s",&s1);
    scanf("%s",&s2);
    ln1=strlen(s1),ln2=strlen(s2);
    fun();
    print(ln1,ln2);
    return 0;
}
/*
abzc
axbycz
*/


Measured memory_bytes: 151168
#include<vector>
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  int a[n+1]={};
  for(int i = 0;i < n;++i){
    int b;
    cin >> b;
    a[b]++;
  }
  sort(a,a+n+1);
  int sum  = 0,n2 = 0;
  for(int i = 1;i < n + 1;++i){
    if(a[i] > 0){
      ++n2;
    }
  }
  if(n2 <= k){
    cout << 0 <<endl;
    return 0;
  }
  for(int i = 1;i < n + 1;++i){
    if(a[i] > 0){
      sum += a[i];
      --n2;
      if(n2<=k) break;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cstring>
#include <istream>
#include<cmath>
#include<map>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
int main()
{
	int n, i; 
	while (cin >> n)
	{
		for (i = n; i >= 1; i--)
		{
			if (sqrt(i) - (int)sqrt(i) == 0)
				break;
		}
		cout << i << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import math,numpy, collections

n = int(input())
ans = n
cnt = 0
for i in range(n+1):
    cnt = 0
    x = i
    while x >0:
        cnt += x%6
        x = x//6
    y = n-i
    while y >0:
        cnt += y%9
        y = y//9
    ans = min(ans,cnt)

print(ans)

Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;vector<int>A['   '];int N,M,S['   '],B,L,R,I,X;void U(int z,int u){while(z<=N)S[z]+=u,z+=z&-z;}int main(){cin>>M>>N;for(I=1;I<=M;I++)cin>>L>>R,A[R-L+1].push_back(L);for(L=1;L<=N;L++){B=M;for(I=L;I<=N;I+=L){R=0,X=I;while(X)R+=S[X],X-=X&-X;B+=R;}for(int u:A[L])U(u,1),U(u+L,-1),M--;cout<<B<<endl;}}

Measured memory_bytes: 53888
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,ans;
    cin>>N;
	ans=0;
    map<double,int>memo;
    REP(i,N){
        int a;cin>>a;
      	memo.insert(make_pair(-a-0.000001*i,i));
    }
    vector<vector<int>>dp(N+1,vector<int>(N+1,0));
    int k=0;
    for(auto it=memo.begin();it!=memo.end();it++){
        k++;
        int loc=it->second;
        int rs=N-1-loc;
        int ls=loc;
      	int value=it->first*(-1);
        for(int i=0;i<=k;i++){
            if(i==0) dp[k][0]=dp[k-1][0]+value*(rs-k+1);
            if(i==k) dp[k][k]=dp[k-1][k-1]+value*(ls-k+1);
            if(i!=0&&i!=k) dp[k][i]=max(dp[k-1][i-1]+value*(ls-i+1),dp[k-1][i]+value*(rs-k+1+i));
        }
    }
    REP(i,N+1){
        ans=max(dp[N][i],ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 34676
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    long long  n,ans=0,a;
    cin>>n;
    int A[1000000],B[1000000];
    for(int i=0;i<n+1;i++) cin>>A[i];
    for(int i=0;i<n;i++) cin>>B[i];
    for(int i=0;i<n;i++){
        if(A[i]>0 && B[i]>0){
            a=min(A[i],B[i]);
            B[i]-=a;
            ans+=a;
        }
        if(B[i]>0 && A[i+1]>0){
            a=min(A[i+1],B[i]);
            A[i+1]-=a;
            ans+=a;
        }
    }

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

Measured memory_bytes: 6400
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll x;
	cin>>x;
	ll ans = x/11LL *2LL;
	int rest = x%11LL;
	if(rest > 0)ans++;
	if(rest > 6)ans++;
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string a, b, c;

int main(void) {
  // Here your code !
  cin >> a >> b >> c;

  if (a.back() == b[0] && b.back() == c[0]) {
    printf("YES\n");
  }
  else {
    printf("NO\n");
  }

  return 0;
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n,m; cin >> n >> m;
    vector<pair<ll,ll> > v;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    ll ans = 0;
    ll cnt = 0;
    rep(i,n){
        if(cnt + v[i].second < m){
            ans += v[i].first * v[i].second;
            cnt += v[i].second;
        }else{
            ans += v[i].first * (m - cnt);
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        n: i32,
        m: usize,
        a: [i32; m],
    }

    let remain = n - a.iter().sum::<i32>();
    println!("{}", if remain >= 0 { remain } else { -1 })
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

#define MAX 2000005

const int MOD = 1e9 + 7;

long long inverse(long long a) {
    long long ret = 1;
    for (int b=MOD-2; b>0; b/=2) {
        if (b % 2) ret = ret * a % MOD;
        a = a * a % MOD;
    }
    return ret;
}

long long fact[MAX], inv[MAX];

long long choose(int n, int k) {
    return fact[n] * inv[k] % MOD * inv[n-k] % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    fact[0] = inv[0] = 1;
    for (int i=1; i<MAX; i++) {
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = inverse(fact[i]);
    }

    long long ret = 0;
    for (int i=1; i<=r2-r1+1; i++)
        ret = ((ret + choose(r1 + c2 + i, r1 + i) - choose(r1 + c1 + i - 1, r1 + i)) % MOD + MOD) % MOD;

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 34780
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int time = 0, temp = a;
    if(a < 0){
        for(temp = a; temp < 0; temp++) {
            time += c;
        }
        temp = 0;
        time += d;
    }
    for(; temp < b; temp++){
            time += e;
    }
    cout << time << endl;
    
}


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

int main() {
  int n=0, a=0, ans=1000000000, ta=0;
  cin >> n;
  
  for (int i=0; i<n; i++) {
    cin >> a;
    
    ta = 0;
    
    while (a%2 == 0) {
      a /= 2;
      ta++;
    }
    
    if (ans > ta) ans = ta;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    char S[1000]={};
    scanf("%s",S);
    int w;
    scanf("%d",&w);
    int i=0;
    while(S[i]!='\0'){
        if(i%w==0){
            printf("%c",S[i]);
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

const int MD = 1e9 + 7;

int main() {
  int n,k; cin >> n >> k;
  vector<int>a(n,0);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>>dp(n + 1, vector<int>(k + 1, 0));
  function<long long(int, int)>solve = [&](int i, int k) -> long long {
    if (i == n && k == 0) {
      return 1;
    } else if (i == n && k) {
      return 0;
    }
    if (dp[i][k] != -1) {
      return dp[i][k];
    }
    long long nways = 0;
    for (int bal = 0; bal <= a[i]; bal++) {
      if (k - bal < 0) {
        break;
      }
      nways = (nways + solve(i + 1, k - bal))%MD;
    }
    //cout << i << " " << k << " " << nways << endl;
    return dp[i][k] = nways;
  };
  // dp[i][j] = num ways to distribute j candies among first i people
  // dp[i][j] = Sigma{bal = 0; bal <= a[i]}(dp[i-1][j-bal])
  dp[0][0] = 1;
  vector<vector<int>>prefix(n + 1, vector<int>(k + 1, 0));
  prefix[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
    prefix[i][0] = 1;
  }
  for (int i = 1; i <= k; i++) {
    prefix[0][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      int right = prefix[i-1][j];
      int left = 0;
      if (j - a[i-1] - 1 >= 0) 
        left = prefix[i-1][j - a[i-1] - 1];
      dp[i][j] = (dp[i][j]%MD + ((right - left + MD) % MD)) % MD;
      prefix[i][j] = (prefix[i][j-1]%MD + dp[i][j]%MD) % MD;
      // for (int bal = 0; bal <= a[i-1]; bal++) {
      //   if (j - bal < 0) break;
      //   dp[i][j] = (dp[i][j] + dp[i-1][j - bal])%MD; 
      // }
    }
  }
  cout << dp[n][k] << endl;
  //cout << "solve ?" << endl;
  //long long ans = solve(0, k);
  //cout << ans << endl;
  return 0;
}

Measured memory_bytes: 79736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    double r;
    cin >> r;
    // output
    cout << 3 * pow(r, 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    while(k--)
    {
        if(a>=b)
            b*=2;
        else if(b>=c)
            c*=2;
    }

    if(a<b and b<c)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    exit(0);
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
const int N=1e5+5;
struct Edge {
    int u,v,w;
    bool operator < (const Edge &b) const {
        return w<b.w;
    }
};
std::vector<Edge> g;
int par[N],n,x[N],y[N],t[N];
int fd(int x) {
    return par[x]==x?x:par[x]=fd(par[x]);
}
void init() {
    for(int i=1;i<=n;i++) par[i]=t[i]=i;
}
bool cmpx(int a,int b) {
    return x[a]<x[b];
}
bool cmpy(int a,int b) {
    return y[a]<y[b];
}
int main() {
    scanf("%d",&n);init();
    for(int i=1;i<=n;i++) scanf("%d%d",x+i,y+i);
    std::sort(t+1,t+1+n,cmpx);
    for(int i=2;i<=n;i++) g.push_back((Edge){t[i],t[i-1],x[t[i]]-x[t[i-1]]});
    init();std::sort(t+1,t+1+n,cmpy);
    for(int i=2;i<=n;i++) g.push_back((Edge){t[i],t[i-1],y[t[i]]-y[t[i-1]]});
    std::sort(g.begin(),g.end());
    long long ans=0;
    for(auto &v:g) {
        int l=fd(v.u),r=fd(v.v);
        if(l==r) continue;
        ans+=v.w;par[l]=r;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6388
#include <stdio.h>

int x, y;

int main(void)
{
	int i = 0;

	while (1) {
		scanf("%d %d", &x, &y);



		if (x == 0 && y == 0) {
			break;
		}

		if (x > y) {
			printf("%d %d\n", y, x);
		}
		else {
			printf("%d %d\n", x, y);
		}


		i++;
	}


	return 0;
}

Measured memory_bytes: 600
import math, sys

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, H = map(int,input().split())
    A = [0 for k in range(N)]
    B = [0 for k in range(N)]
    for k in range(N):
        a, b = map(int,input().split())
        A[k] = a
        B[k] = b
    A = sorted(A)[::-1]
    m = A[0]
    B = sorted(B)[::-1]
    c = 0
    for e in B:
        if e > m:
            c += 1
            H -= e
            if H <= 0:
                print(c)
                exit(0)
        else:
            break
    print(c+math.ceil(H/m))
if __name__ == '__main__':
    main()


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

int main(){
    int n,tmp;
    cin >> n;
    vector<int> a(n);

    for(int i=0;i<n;i++) a.at(i) = 0;

    for(int i=1;i<n;i++){
        cin >> tmp;
        a.at(tmp-1)++;
    }

    for(int i=0;i<n;i++) cout << a.at(i) << endl;

}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll H,W,K;
  cin>>H>>W>>K;
  
  vector<vector<char>>s(H,vector<char>(W));
  vector<vector<ll>>ans(H,vector<ll>(W));
  
  rep(i,H){
    rep(j,W){
      cin>>s[i][j];
    }
  }
  ll num=1;
rep(i,H){
  rep(j,W){
if(s[i][j]=='#'){
ans[i][j]=num;
  num++;
}
  }
}
  
 
  //横から
rep(i,H){
  rep(j,W){
    if(s[i][j]=='#'){    
if(j+1<=W-1){//右
  ll now=j+1;
while(s[i][now]!='#'){
ans[i][now]=ans[i][j];
  now++;
  if(now>=W){
break;
  }

}
}      

   if(j-1>=0){//左
  ll now=j-1;
while(s[i][now]!='#'){
ans[i][now]=ans[i][j];
  now--;
  if(now<0){
break;
  }

}
}
    }
  }
}

  
//処理　横に全てゼロになっているものの処理
  rep(i,H){
    rep(j,W){
if(ans[i][j]==0){
if(i-1>=0){
  ll now2=i-1;
  bool flag=true;
  while(ans[now2][j]==0){
    now2--;
    if(now2<0){
      flag=false;
break;
    }
  }
if(flag){
ans[i][j]=ans[now2][j];
}
}

else{
  ll now3=i+1;
 while(ans[now3][j]==0){
now3++;
 }
ans[i][j]=ans[now3][j];
  
}

}
    }
  }
  
  
  rep(i,H){
    rep(j,W){
cout<<ans[i][j]<<" ";
    }
    cout<<endl;
  }
}

      

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N;
double p[3000];
double dp[3000][3000] = {0}; //dp[i][j]においてiはcoinの枚数、jは表の数を表す   
int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> p[i];
    }
    dp[1][1] = p[1];
    dp[1][0] = 1 - p[1];
    if(N == 1){
        cout << p[1] << endl;
        return 0;
    }
    for(int i = 2; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(j >= 1) dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
            else dp[i][j] = dp[i-1][j]*(1-p[i]);
            //cout << "dp[" << i << "][" << j << "]=" << dp[i][j] << " ";
        }
    }
    //cout << endl;
    double ans = 0.00;
    for(int i = N/2+1; i <= N; i++){
        ans += dp[N][i];
    }
    cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 70528
package main

import (
  "fmt"
  "math"
)

func main() {
  var a,b,h,m float64
  // var angle, ans float64
  fmt.Scanf("%f %f %f %f", &a, &b, &h, &m)

  // hの値で分岐
  // angle = calcAngle(h, m)
  // ans = calcAns(float64(a), float64(b), angle)
  // fmt.Println(ans)

  fmt.Println(math.Sqrt(a*a + b*b - 2*a*b*math.Cos(diff(360*(h/12)+30*(m/60), 360*(m/60))*math.Pi/180)))
}

func diff(a, b float64) float64 {
	if a > b {
		return a - b
	}
	return b - a
}

func calcAngle(h, m int) (ans float64) {
  hAngle := h * 30 + 30 * m / 60
  mAngle := m * 6
  if hAngle > mAngle {
    ans = float64(hAngle - mAngle)
  } else {
    ans = float64(mAngle - hAngle)
  }
  return ans
}

func calcAns(a float64, b float64, angle float64) (ans float64) {
  cos := math.Cos(angle * math.Pi / 180)
  ans = math.Sqrt(a*a+b*b-2*a*b*cos)
  return ans
}

Measured memory_bytes: 1824
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, p;
  cin >> n >> p;
  if (p == 2 || p == 5) {
    string str;
    cin >> str;
    vector<int> S(n);
    ll ans = 0;
    for (int l = 0; l < n; ++l) {
      if ((str[n-l-1] - '0') % p == 0) ans += n-l;
    }
    cout << ans << endl;
    return 0;
  }
  string str;
  cin >> str;
  vector<int> S(n+1,0);
  int ten = 1;
  for (int i = 1; i <= n; ++i) {
    S[i] = ((str[n-i] - '0') * ten) % p;
    S[i] += S[i-1];
    S[i] %= p;
    ten *= 10; ten %= p;
  }
  vector<int> cnt(p);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[S[i]];
    cnt[S[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1428
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
3
0 0 2 0 1 1 1 -1
0 0 1 1 0 1 1 0
0 0 1 1 1 0 0 1

output:
1.0000000000 0.0000000000
0.5000000000 0.5000000000
0.5000000000 0.5000000000
"""

import sys


class Segment(object):
    __slots__ = ('source', 'target')

    def __init__(self, source, target):
        self.source = complex(source)
        self.target = complex(target)


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def get_cross_point(s1, s2):
    base_vector = s2.target - s2.source
    d1 = abs(cross(base_vector, s1.source - s2.source))
    d2 = abs(cross(base_vector, s1.target - s2.source))
    t = d1 / (d1 + d2)
    cross_point = s1.source + (s1.target - s1.source) * t
    print('{real:.10f} {imag:.10f}'.format(real=cross_point.real, imag=cross_point.imag))

    return None


def solve(_lines):
    for line in _lines:
        line = tuple(map(int, line))
        p0, p1, p2, p3 = (x + y * 1j for x, y in zip(line[::2], line[1::2]))
        s1, s2 = Segment(p0, p1), Segment(p2, p3)
        get_cross_point(s1, s2)

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    l_num = int(_input[0])
    lines = map(lambda x: x.split(), _input[1:])

    solve(lines)

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

using ll = long long;
using pi = pair<int, int>;

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

    string s, t;
    cin >> s >> t;
    int res = 1e9 + 7, n = s.size(), m = t.size();
    for(int i=0; i<n; i++) {
        if(i < m-1) continue;
        int curr = 0;
        for(int j=i-m+1, k=0; j<=i; j++, k++) {
            if(t[k] != s[j]) curr++;
        }
        res = min(res, curr);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3616
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np


# なんこか入力
n,d = map(int, input().split())

# n行の複数列ある数値を二次元配列へ。x[n][?]
x = [[int(i) for i in input().split()] for i in range(n)] 
#print(x)
answer = 0
for j in range(n):
    for i in range(j):
        dist2 = 0
        for k in range(d):
            dist2 += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k])
#            print(dist2)
        dist = math.sqrt(dist2)
#        print(dist)
#        if dist.is_integer() == "True" :
        if round(dist)*dist == dist2:
            answer += 1

print(answer)


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

const int N = 1e5 + 10;
int n, K, ans, c1, c2;
char s[N];

int main() {
    cin >> n >> K;
    scanf("%s", s + 1);
    int tot = 0;
    rep(i, 1, n) {
        if (s[i] == 'L') {
            if (i > 1 && s[i - 1] == 'L') tot++;
        } else {
            if (i < n && s[i + 1] == 'R') tot++;
        }
    }
    s[0] = '#';
    rep(i, 1, n) {
        if (s[i] != s[i - 1]) {
            if (s[i] == 'L') c1++; else c2++;
        }
    }
    // printf("%d %d\n", c1, c2);
    if (c1 == c2) {
        --c2;
        ans = min(c2, K) * 2;
        K -= c2;
        if (K > 0) {
            ans++;
        }
    } else {
        c1 = min(c1, c2);
        ans = min(c1, K) * 2;
    }
    printf("%d\n", ans + tot);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){
    if(b==0)
    return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;base%=mod;
        pow/=2;
    }return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}

const int M = 2e5 + 5;


int main(){

    int n;
    si(n);

    cout<<(n + 1)/2;

}



Measured memory_bytes: 256
L, R = map(int,input().split())
b = 2018
if R - L >= 2019:
  print(0)
else:
  L = L % 2019
  R = R % 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      if b > (i * j) % 2019:
        b = (i * j) % 2019
  print(b)

Measured memory_bytes: 3060
#include<iostream>
#include<set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)

#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#include<vector>
#define elif else if
typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 200005
ll N,Q;




int main(){
    cin>>N>>Q;
    string str;
    cin>>str;
    
    // rep(i,N){
    //     cout<<str[i]<<endl;
    // }

    // rep(i,idx.size())cout<<idx[i]<<endl;
    // cout<<idx.size()<<endl;
    ll t[TENFIVE] = {0};
    rep1(i,N){
        if(str[i] =='C' && str[i-1]== 'A' ){
            t[i] = t[i-1]+1;
        }else{
            t[i] = t[i-1];
        }
    }
    
    rep(i,Q){
        ll l,r;
        cin>>l>>r;

        cout<< t[r-1] - t[l-1] << endl;
    }


    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 1000000000
#define MAX_N 100005
using namespace std;

int main(){
    int n,m,c[21];
    int dp[21][50001];
    
    cin>>n>>m;
    rep(i,0,m)cin>>c[i];
    rep(i,0,m+1)rep(j,0,n+1)dp[i][j]=INF;
    rep(i,0,m+1)dp[i][0]=0;
    
    rep(i,0,m){
        rep(j,0,n+1){
            if(j<c[i])dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=min(dp[i][j],dp[i+1][j-c[i]]+1);
        }
    }
 
    cout<<dp[m][n]<<endl;
    
    return 0;
}

Measured memory_bytes: 7200
#include <iostream>
#include <cstdlib>
#include <set>
#include <algorithm>
#include <iterator>

using namespace std;
int main()
{
    int n, m, tmp;
    set<int> a, b, result;
    cin >> n;
    for (int i=0; i<n; ++i){
        cin >> tmp;
        a.insert(tmp);
    }
    cin >> m;
    for (int i=0; i<m; ++i){
        cin >> tmp;
        b.insert(tmp);
    }
    set_difference(a.begin(), a.end(), b.begin(), b.end(), inserter(result, result.end()));
    for (auto itr=result.begin(); itr != result.end(); ++itr){
        cout << *itr << endl;
    }
}


Measured memory_bytes: 31224
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

// 累積和
struct cumulative_sum {
    using lint = long long int;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint &operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int n, k;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    cin >> n >> k;
    cumulative_sum cum(n);
    for (int i = 0; i < n; i++) {
        lint p;
        cin >> p;
        cum[i] = p + 1;
    }
    cum.build();
    lint ans = 0;
    for (int i = 0; i <= n - k; i++) {
        chmax(ans, cum.query(i, i + k));
    }
    cout << setprecision(10) << ((double)ans) / 2 << endl;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define MAXN 1000
#define MAXM 2000
#define MO 1000000007
#define LL long long
int n,m;
LL x,sum,ans;
struct node
{
	int u,v,len;
}line[MAXM+5];
bool cmp(node a,node b)
{
	return a.len<b.len;
}
int bits[MAXM+5],dif[MAXM+5];
void Pre()
{
	bits[0]=1;
	for(int i=1;i<=m;i++)
		bits[i]=2LL*bits[i-1]%MO;
}
int fa[MAXN+5],deep[MAXN+5],val[MAXN+5];
int FindSet(int x)
{
	if(fa[x]==0) return x;
	return fa[x]=FindSet(fa[x]);
}
bool used[MAXM+5];
vector<int>G[MAXN+5],W[MAXN+5];
void Build(int u,int pa)
{
	deep[u]=deep[pa]+1;
	fa[u]=pa;
	for(int i=0;i<G[u].size();i++)
		if(G[u][i]==pa)
			val[u]=W[u][i];
		else Build(G[u][i],u);
}
int Find_max(int u,int v)
{
	if(deep[u]<deep[v])
		swap(u,v);
	int ret=0;
	while(deep[u]>deep[v])
	{
		ret=max(ret,val[u]);
		u=fa[u];
	}
	while(u!=v)
	{
		ret=max(ret,max(val[u],val[v]));
		u=fa[u],v=fa[v];
	}
	return ret;
}
int main()
{
	scanf("%d%d%lld",&n,&m,&x);
	Pre();
	for(int i=0;i<m;i++)
		scanf("%d%d%d",&line[i].u,&line[i].v,&line[i].len);
	sort(line,line+m,cmp);
	for(int i=0;i<m;i++)
	{
		int u=FindSet(line[i].u);
		int v=FindSet(line[i].v);
		if(u!=v)
		{
			sum+=line[i].len;
			used[i]=1;
			fa[u]=v;
			G[line[i].u].push_back(line[i].v);
			G[line[i].v].push_back(line[i].u);
			W[line[i].u].push_back(line[i].len);
			W[line[i].v].push_back(line[i].len);
		}
	}
	x-=sum;
	if(x<0)
	{
		printf("0\n");
		return 0;
	}
	Build(1,0);
	int cnt=0;
	for(int i=0;i<m;i++)
		if(!used[i])
		{
			int x=Find_max(line[i].u,line[i].v);
			dif[++cnt]=line[i].len-x;
		}
	sort(dif+1,dif+1+cnt);
	if(x==0)
		ans=(bits[m]-2LL*bits[m-n+1]+2LL*MO)%MO;
	for(int i=1;i<=cnt;i++)
		if(dif[i]==x)
		{
			ans+=2LL*bits[cnt-i];
			ans%=MO;
		}
	printf("%lld\n",ans);
}

Measured memory_bytes: 512
////////////////////////////////////////////////
//  ********  *      *    *******    * *      //                 :
//  *         *      *   *       *   *   *    //     64 BITS     C     64 BITS
//  *****     *      *  *         *  *     *  //                 +
//  *         *      *  ***********  *     *  //:  16 - 6 - 2020 +   16 - 6 - 2020 :
//  *         *      *  *         *  *   *    //                 1
//  *         ********  *         *  * *      //     64 BITS     7     64 BITS
////////////////////////////////////////////////                 :
#define ll long long
#define ui unsigned int
#define ud unsigned double
#define mp make_pair
#define pii pair<int,int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pdi pair<double,int>
#define pb push_back
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
const double pi = acos(-1.0);
int main()
{
    int d;
    scanf("%d", &d);
    if (d % 2 != 0){
        cout<<abs((d/2)+1)<<"\n";
    }
    else{
        cout<<abs(d/2)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
N = input()
N = int(N)

A = input().split()
B = input().split()
C = input().split()

ans = 0
tmp = -1
if 2<=N and N<=20:
    if 1<=len(A) and len(A)<=N:
        for a in A:
            
            if int(a) == tmp+1:
                # print(C[tmp-1])
                ans += int(C[tmp-1])
            # print(a)
            
            b = int(B[int(a)-1])
            if not(1<=b and b<= 50):
                exit()
            else:
                # print(b)
                ans += b

            tmp = int(a)
        print(ans)

            

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

using namespace std;

string YES = "YES", NO = "NO";
int main() {
    int n, k;
    cin >> n >> k;
    int m = ceil((1.0 * n) / 2);
    if (k <= m)
    {
        cout << YES;
    }
    else
    {
        cout << NO;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n;
  cin >> n;
  vint ans(4,0);
  rep(i,n){
    char s;
    cin >> s;
    if(s == 'P') ans[0] = 1;
    if(s == 'W') ans[1] = 1;
    if(s == 'G') ans[2] = 1;
    if(s == 'Y') ans[3] = 1;
  }
  int count = 0;
  rep(i,4){
    if(ans[i] == 1) count++;
  }
  if(count == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
}

Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
arr = Array.new(m, 0)
n.times do
  k = gets.chomp.split.map(&:to_i)
  k[1, k[0]].each do |ki|
    arr[ki-1] += 1
  end
end

count = 0 
arr.each do |ai|
  if ai == n
    count += 1
  end
end

puts count

Measured memory_bytes: 1788
#include <stdio.h>
 
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0){
      break;
    }
    for(i=0; i<H; i++){
      for(j=0; j<W; j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2056
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		var hs=new Dictionary<string,int>();
		long[] a=new long[10];

		for(int i=0;i<s[2];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			for(int j=-2;j<1;j++){
				for(int k=-2;k<1;k++){
					if(q[0]+j>0&&q[1]+k>0&&q[0]+j<s[0]-1&&q[1]+k<s[1]-1){
						if(hs.ContainsKey((q[0]+j)+" "+(q[1]+k))){hs[(q[0]+j)+" "+(q[1]+k)]++;}
						else{hs.Add((q[0]+j)+" "+(q[1]+k),1);}
					}
				}
			}
		}
		foreach(KeyValuePair<string,int> e in hs){a[e.Value]++;}
		a[0]=(s[0]-2)*(s[1]-2)-a[1]-a[2]-a[3]-a[4]-a[5]-a[6]-a[7]-a[8]-a[9];
		for(int i=0;i<10;i++){Console.WriteLine("{0}",a[i]);}
	}
}

Measured memory_bytes: 99720
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    if ( k >= n ) {
        cout << 0 << endl;
        return 0;
    }
    sort(h.begin(), h.end());
    ll ans = 0;
    rep(i, n - k) {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792