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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<double> x(N);
	vector<double> y(N);
	for (int i=0; i<N; i++)
		cin >>x.at(i) >>y.at(i);
	double S=0.0;
	for (int i=0; i<N; i++)
		for (int j=0; j<N; j++) {
			double X=x.at(i)-x.at(j);
			double Y=y.at(i)-y.at(j);
			S +=sqrt(X*X+Y*Y);
		}
	double NN=N-1;
	cout <<setprecision(10) <<S/N <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[55];
int n,k,temp,s;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	     cin>>a[i];
	   sort(a+1,a+1+n);
	for(int i=1;i<=k;i++)  
	{temp+=a[n-s];s++;}
	cout<<temp<<endl;
	return 0;
}

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

[N, X] = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]

distance = 0
jump_number = 1
for l in L:
    distance += l
    if distance > X:
        break
    else:
        jump_number += 1

print(jump_number)


Measured memory_bytes: 38384
//

//a%b>=k

//a=f*b+k
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL n,K,ans;
void bf()
{
	LL ret=0;
	for(LL i=1;i<=n;i++)
	  for(LL j=1;j<=n;j++)
		if(i%j>=K) ret++;
	cout<<ret<<endl;
}
int main()
{
	cin>>n>>K;
	if(K==0) ans=n*n;
	else
	for(LL b=1;b<=n;b++){
		if(b<=K) continue;
		for(LL i=K;i<=n;i+=b){
			LL j=i+(b-K-1);
			//cout<<i<<' '<<j<<endl;
			if(j>n){
				ans+=(n-i+1); break;
			}
			ans+=(j-i+1);
		}
	}
	//bf();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
package com.example.alds1.eleven

import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        if (n < 1 || n > 100) {
            throw Exception("Unexpected input.")
        }
        val a = Array<IntArray>(n) { IntArray(n) }
        for (i in 0 until n) {
            val u = sc.nextInt()
            val k = sc.nextInt()
            for (j in 0 until k) {
                val v = sc.nextInt()
                a[u - 1][v - 1] = 1
            }
        }
//        for (i in a.indices) {
//            println(a[i].joinToString(" "))
//        }
        val d = BFS(a)
        for (i in d.indices) {
            println("${i + 1} ${d[i]}")
        }
    } catch (e: Exception) {
        println(e)
    }
}

fun BFS(a: Array<IntArray>): IntArray {
    val d = IntArray(a.size) { -1 }
    val q = LinkedList<Int>()
    val v = IntArray(a.size)
    d[0] = 0
    v[0] = 1
    q.add(0)
    while (!q.isEmpty()) {
        val c = q.removeFirst()
        for (i in a.indices) {
            if (a[c][i] == 1 && v[i] == 0) {
                v[i] = 1
                q.addLast(i)
                d[i] = d[c] + 1
            }
        }
    }
    return d
}


Measured memory_bytes: 30056
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>

using namespace std;
char a[20];

int main()
{
	int n;
	scanf("%s",a);
	n = strlen(a);
	for(int i = 0; i < n; i++)
	{
		if(a[i] == ',')
		printf(" ");
		else
		printf("%c",a[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,k;
vvl a;
vl b,c;

int main(){
	cin>>n>>k;
	a=vvl(n);
	ll res=0,t=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		a[x-1].push_back(y);
		res+=y;
	}
	for(int i=0;i<n;i++) if(!a[i].empty()){
		t++;
		int S=a[i].size();
		sort(a[i].rbegin(),a[i].rend());
		for(int j=1;j<S;j++) b.push_back(a[i][j]);
		c.push_back(a[i][0]);
	}
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	res+=t*t;
	int I=0,J=0,S=b.size(),T=c.size();
	for(int i=0;i<n-k;i++){
		bool B=0;
		ll m=INF;
		if(I<S) m=b[I];
		if(J<T&&c[J]+2*t-1<m) m=c[J]+2*t-1,B=1;
		if(!B) I++;
		else J++,t--;
		res-=m;
	}
	cout<<res<<endl;
}

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

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);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int N, ans = 0;
    	Integer[] L;
    	
        void solve(InputReader in, PrintWriter out) {
        	N = in.nextInt();
        	L = new Integer[2*N];
        	for (int i = 0; i < 2*N; ++i) L[i] = in.nextInt();
        	Arrays.sort(L, Comparator.reverseOrder());
        	
        	for (int i = 1; i < L.length; i += 2) {
        		ans += L[i];
        	}
        	
        	out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

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

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

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


Measured memory_bytes: 23380
#include <iostream>

using namespace std;

int chia(int a, int b)
{
    if (a%b!=0) return a/b+1;
    return a/b;
}

int main()
{
    int h,w, n;
    cin >> h >>w >> n;
    if ( h > w && n>=h ) cout << chia(n,h);
    else cout <<chia(n,w);
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

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

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int sc[N];

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int l, r;
    cin >> l >> r;
    sc[l]++;
    sc[r + 1]--;
  }
  for (int i = 1; i <= n; ++i)
    sc[i] += sc[i - 1];
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    if (sc[i] >= m)
      ++res;
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    vector<int> num(N,1);
    vector<bool> exist(N);
    exist[0] = 1;
    for(int i = 0;i < M;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        num[b]++;
        num[a]--;
        if(exist[a]){
            exist[b] = 1;
            if(num[a] == 0)exist[a] = 0;
        }
    }
    int sum = 0;
    for(auto i:exist)sum += i;
    cout << sum << endl;
}

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i,n)rep(j,n)rep(k,n) ans += gcd(i,gcd(j,k));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;
    if (a > b)
    {
        std::cout << "a > b" << std::endl;
    }
    else if (a < b)
    {
        std::cout << "a < b" << std::endl;
    }
    else
    {
        std::cout << "a == b" << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3136
#include<iostream>
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

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

int main() {
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);

    for (i = 1; i <= n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;

    while (head != tail) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0) enqueue(u);
        else {
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 13292
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e9
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a,b,x;
    cin>>a>>b>>x;
    double tans;
    double angle;
   if(x>=a*a*b/2)
   { tans=(double)a*a*a/(2*(a*a*b-x));
    angle=(double)atan(tans);
       angle=(double)90-angle*180.0/PI;}
    else
    {
        tans=(double)a*b*b/2/x;
        angle=(double)atan(tans);
        angle=(double)angle*180.0/PI;}
    
    printf("%.8lf",angle);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <cstring>
#include <set>

#define ll long long
#define ld long double
#define HS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define INF 0x3f3f3f3f3f3f3f3f
#define point complex <double>
#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define mod 1000000007


using namespace std;

int main() {

    HS;
    int n,k;
    cin>>n>>k;
    map < int , int > freq;
    set < int > st;
    vector < int > vec;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        freq[x]++;
        st.insert(x);
    }
    if(st.size()<=k)
        cout << 0 << endl;
    else{
        for(int i=1;i<=200000;i++)
        {
            if(freq[i])
                vec.push_back(freq[i]);
        }
        sort(all(vec));
        ll ans=0;
        int temp=st.size();
        for(int i=0;i<vec.size() && temp!=k;i++)
        {
            ans+=vec[i];
            temp--;
        }
        cout << ans << endl;
    }

   return 0;

}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (c >= a && c <= b ? "Yes" : "No") << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


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

int main()
{
	int K;
	string S;
	cin >> K;
	cin >> S;
	if (S.size() <= K)
	{
		cout << S;
	}
	else
	{
		cout << S.substr(0,K) << "..." << endl;;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin >> N>>A;

  if(N%500 ==0){
    cout << "Yes";
  }else{
    if(N%500 > A){
      cout << "No";
    }else{
      cout <<"Yes";
    }
  }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> std(n), chk(m);

    rep(i, n) cin >> std[i].first >> std[i].second;
    rep(i, m) cin >> chk[i].first >> chk[i].second;

    // 各学生の処理
    rep(i, n){
        // 各チェックポイントのマンハッタン距離を計算
        ll minV = INFLL, minI = -1;
        rep(j, m){
            ll tmp = abs(std[i].first-chk[j].first) + abs(std[i].second-chk[j].second);
            if(minV > tmp){
                minV = tmp;
                minI = j+1;
            }
        }
        cout << minI << endl;
    }
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 2010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,k;

int dp[maxn][maxn][2];

void Work(){
	dp[n+1][0][1]=1;
	RREP(i,n,1){
		RREP(j,n,0)(dp[i+1][j][0]+=dp[i+1][j+1][0])%=mod;
		REP(j,0,n)
			REP(k,0,1){
				(dp[i][j+1][1]+=dp[i+1][j][k])%=mod;
				(dp[i][j][0]+=dp[i+1][j][k])%=mod;
			}
	}
	int ans=dp[1][n-k][0];
	REP(i,1,max(0,n-k-1))ans=(ans<<1)%mod;
	iout(ans);
}

void Init(){
	read(n,k);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 31616
a[1000],s[1000];
i;main(j,n,m,b){
	for(scanf("%d%d",&n,&m);i<n;i++)scanf("%d",a+i);
	for(i=0;i<m;i++){
		for(scanf("%d",&b),j=0;j<n;j++)if(a[j]<=b)break;
		s[j]++;
	}
	for(j=m=i=0;i<n;i++)if(m<s[i])m=s[i],j=i;
	i=!printf("%d\n",j+1);
}

Measured memory_bytes: 604
#include <bitset>
#include <cassert>
#include <functional>
#include <algorithm>
#include <vector>
#include <numeric>
#include <iostream>
using namespace std;

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

class UnionFind {
    vector<int> par, rank;
public:
    explicit UnionFind(int n) : par(n), rank(n, 0) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int i) {
        return (par[i] == i) ? i : (par[i] = find(par[i]));
    }

    void unite(int i, int j) {
        int x = find(i), y = find(j);
        if (x != y) {
            if (rank[x] < rank[y])
                par[x] = y;
            else {
                par[y] = x;
                if (rank[x] == rank[y]) rank[x]++;
            }
        }
    }

    bool same(int i, int j) { return find(i) == find(j); }
};

const int M = 1000000007;

struct edge { int src, dst, w; };

int main() {
    int n, m; cin >> n >> m;
    long long x; cin >> x;
    vector<edge> es;
    for (int i = 0; i < m; i++) {
        edge e; cin >> e.src >> e.dst >> e.w;
        e.src--; e.dst--;
        es.push_back(e);
    }
    sort(es.begin(), es.end(), [](edge lhs, edge rhs) {
            return lhs.w < rhs.w;
        });
    UnionFind uf(n);
    long long wt = 0;
    vector<pair<int, int> > adj[n];
    vector<edge> unused;
    for (edge e : es) {
        const auto [u, v, w] = e;
        if (!uf.same(u, v)) {
            uf.unite(u, v);
            wt += w;
            adj[u].push_back({v, w});
            adj[v].push_back({u, w});
        } else
            unused.push_back(e);
    }

    function<int(int, int, int)> minweight = [&](int u, int v, int p) {
        for (auto [x, w] : adj[u]) {
            if (x == p) continue;
            if (x == v) return w;
            if (int r = minweight(x, v, u); r > 0)
                return max(r, w);
        }
        return -1;
    };
    if (wt == x) {
        int cnt = n-1;
        for (auto [u, v, w] : unused)
            if (w == minweight(u, v, -1)) cnt++;
        cout << modexp(2, m - cnt, M) * (modexp(2, cnt, M) - 2) % M << endl;
    } else {
        int cnt = n-1, alt = 0;
        for (auto [u, v, w] : unused) {
            int w0 = minweight(u, v, -1);
            if (wt + w - w0 < x) cnt++;
            else if (wt + w - w0 == x) alt++;
        }
        cout << modexp(2, m - cnt - alt, M) * 2 * (modexp(2, alt, M) - 1) % M << endl;
    }
}


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

#define ll long long

using namespace std;

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

	int n, q;
	
	cin >> n;
	vector<ll> s(n);

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

	cin >> q;
	vector<ll> t(q);

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

	unique(s.begin(), s.end());
	unique(t.begin(), t.end());

	int cnt = 0;
	int left, right, mid;

	for(int i = 0;i < q;i++) {
		left = 0;
		right = s.size();
		
		while(left <= right) {	
			mid = (left + right) / 2;

			if(s[mid] == t[i]) {
				cnt++;
				break;
			} else if(s[mid] < t[i]) {
				left = mid + 1;
			} else {
				right = mid - 1;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 4100
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int m = sc.nextInt();
        int[] h = new int[n];
        boolean[] bo = new boolean[n];
        int ans = 0;
        for(int i = 0; i < n; i++){
        	h[i] = sc.nextInt();
            bo[i] = true;
        }
        for(int i = 0; i < m; i++){
        	int a = sc.nextInt();
            int b = sc.nextInt();
            if(h[a - 1] <= h[b - 1]){
            	bo[a - 1] = false;
            }
            if(h[a - 1] >= h[b - 1]){
            	bo[b - 1] = false;
            }
        }
        for(int i = 0; i < n; i++){
        	if(bo[i] == true){
            	ans++;
            }
        }
        System.out.println(ans);
	}
}

Measured memory_bytes: 60036
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N;
    scanf("%d", &N);
    int *d = malloc(sizeof(int) * N);
    for(int n=0; n<N; n++){
        scanf("%d", d+n);
    }

    int res = 0;
    for(int ni=0; ni<N; ni++){
        for(int nj=ni+1; nj<N; nj++){
            res += d[ni] * d[nj];
        }
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n;
ll k;
int a[200010];
int tel[200010][80];

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n >> k;
    Forn(i, n) cin >> a[i];
    Forn(i, n) tel[i][0] = a[i];
    for(int j=1; j<80; j++)
    {
        Forn(i, n) tel[i][j] = tel[tel[i][j-1]][j-1];
    }
    int now = 1;
    forn(i, 70)
    {
        if(k&1) now = tel[now][i];
        k>>=1;
    }
    cout << now << endl;
}


Measured memory_bytes: 66928
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int r, D, x;
    cin >> r >> D >> x;
    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vvi g;

int dfs(int I,vi a){
	int res=0,S=a.size();
	bool b=1;
	if(S>=2){
		int sum=0;
		for(int i=0;i<S;i++){
			int M=inf;
			for(int j=0;j<S;j++) if(i!=j){
				int c=g[a[i]][a[j]];
				if(c==0) b=0;
				M=min(M,c);
			}
			sum+=M;
		}
		res=max(res,sum);
	}
	if(b&&S<14){
		for(int i=I;i<n;i++){
			a.push_back(i);
			res=max(res,dfs(i+1,a));
			a.pop_back();
		}
	}
	return res;
}

int main(){
	cin>>n>>m;
	g=vvi(n,vi(n));
	for(int i=0;i<m;i++){
		int u,v,c;
		cin>>u>>v>>c;
		u--;v--;
		g[u][v]=c;
		g[v][u]=c;
	}
	vi a;
	cout<<dfs(0,a)<<endl;
}

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

int main() {
  int H,W;
  cin>>H>>W;
  
  for(int i;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;
  
  for(int i;i<H;i++){

    string s;
    cin>>s;
    cout<<"#"<<s<<"#"<<endl;
  }
  
   for(int i;i<W+2;i++){
    cout<<"#";
  }
  cout<<endl;

  
  

    
 
}




Measured memory_bytes: 256
//============================================================================
// Name        : abc130_c.cpp
// Author      : abb
// Version     :
// Copyright   : [My copyright notice]
// Description : Hello World in C++, Ansi-style
//============================================================================

/*
 C - Rectangle Cutting

 実行時間制限: 2 sec / メモリ制限: 1024 MB

 配点 : 300 点

 問題文
 平面上に長方形があり、4 つの頂点の座標は (0, 0), (W, 0), (W, H), (0, H) です。
 この長方形の内部または周上の点 (x, y) が与えられます。(x, y) を通る直線で長方形を 2 つの部分に分割するとき、
 面積の大きくない方の面積の最大値を求めてください。また、その最大値を達成する分割の方法が複数あるかも判定してください。

 制約

 ・1 <= W, H <= 10^9
 ・0 <= x <= W
 ・0 <= y <= H
 ・入力はすべて整数である
 */

#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

#define rep(i, m, n) for (int i = m; i <= n; ++i)

/**
 * エントリポイント．
 * @return 0.
 */
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << ((double) (w * h) / 2) << " "
			<< (x << 1 == w && y << 1 == h ? 1 : 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
int n;
int main() {
	cin >> n;
	int t = n % 10;
	if (t == 2 || t == 4 || t == 5 || t == 7 || t == 9)puts("hon");
	else if (t == 0 || t == 1 || t == 6 || t == 8)puts("pon");
	else puts("bon");
	return 0;
}

Measured memory_bytes: 3624
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
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...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum[ohara], k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  rep(i, n) sum[a[i]]++;
  rrep(i, 1, 10000) sum[i] += sum[i - 1];

  rep(i, n) {
    rrep(j, i + 1, n) {
      if (i == j) continue;
      // b,c,d;
      b = a[i];
      c = a[j];
      // abs(b-c)<d<b+c
      cnt = sum[b + c - 1] - sum[abs(b - c)];
      if (abs(b - c) < a[i] && a[i] < b + c) cnt--;
      if (abs(b - c) < a[j] && a[j] < b + c) cnt--;
      ans += cnt;
    }
  }
  Cout(ans / 3);
  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll check(vector<ll> v, ll now, ll k) {
	ll n = v.size();
	REP(i, n){
		v[i] %= now;
	}

	sort(ALL(v));
	ll sum = 0;
	ll l = 0, r = n - 1;
	//cout << "check " << now << endl;
	//SHOW1d(v, n);
	while(l < r) {
		while(v[l] != 0){
			//cout << "l r " << l << " " << r << " " << v[l] << " " << v[r] << endl;
			ll tmp = min(v[l], now - v[r]);
			sum += tmp;
			v[l] -= tmp;
			v[r] = (v[r] + tmp) % now;
			if(v[r] == 0){
				r--;
			}
		}
		l++;
	}
	return sum <= k ? now : -1;
}

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

	ll n, k;cin >> n >> k;
	ll sum = 0;
	vector<ll> v(n);
	REP(i, n) {
		cin >> v[i];
		sum += v[i];
	}

	ll ans = 1;
	for(ll i = 1;i * i <= sum;i++){
		if(sum % i == 0){
			ans = max(ans, check(v, i, k));
			ans = max(ans, check(v, sum / i, k));
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll m, n, a[110], poll = 0, sum = 0;
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    poll += a[i];
  }
  for (int i = 0; i < n; ++i)
  {
    if (a[i] * 4 * m >= poll) sum++;
  }

  cout << (m <= sum ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;
public class Main {
	static String S;
	static int p;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		S = sc.next();
		boolean ok = cat();
		if(ok) {
			System.out.println("Cat");
		}
		else {
			System.out.println("Rabbit");
		}
		
		
		
	}
	static boolean cat() {
		return m() &&p == S.length();
	}
	
	static boolean m() {
		//System.out.println(p);
		if(S.length() <= p) return false;
		if(S.charAt(p) != 'm') return false;
		p++;
		return e();
	}
	static boolean e() {
		//System.out.println(p);
		if(S.length() <= p) return false;
		while(S.charAt(p) != 'e') {
			if(!m()) return false;
		}
		p++;
		
		return w();
	}
	static boolean w() {
		//System.out.println(p);
		if(S.length() <= p) return false;
		while(S.charAt(p) != 'w') {
			if(!m()) return false;
		}
		p++;
		return true;
	}

}

Measured memory_bytes: 17324
import math

n = int(input())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]

def check(k,a):
  l = len(a)
  if l == 2:
    if a[0] > a[1]:
      return 2
    else:
      return 1
  for i in range(l):
    if a[i] > k:
      a[i] -= 1
  return (a[0]-1) * math.factorial(l-1) + check(a[0],a[1:l])

print(abs(check(10,p) - check(10,q)))
  

Measured memory_bytes: 9108
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct Info{
	bool operator<(const struct Info &arg) const{
		return end_time < arg.end_time;
	}
	int start_time,end_time;
};

int N;
Info info[NUM];


int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		scanf("%d %d",&info[i].start_time,&info[i].end_time);
	}
	sort(info,info+N);

	int ans = 1;
	int current_time = info[0].end_time;

	for(int i = 1; i < N; i++){
		if(info[i].start_time > current_time){
			ans++;
			current_time = info[i].end_time;
		}
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 4068
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, ~n){
        double x = 1, y = 0;
        for (int i = 0; i < n-1; ++i) {
            double dx = -y/hypot(x, y), dy = x/hypot(x, y);
            x += dx;
            y += dy;
        }
        printf("%.10lf\n%.10lf\n", x, y);
    }
    return 0;
}


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

#define rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fill(x,v) memset(x,v,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x <<": " << x << endl
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;


const int MAX = 3002;
const ll INF = 1LL<<62;

bool exist[30];
vi mayor, menor;

void solve(){
    ll n, k;
    cin >> n >> k;
    ll on  = 0, a;
    rep(i,0,n){
        cin >> a;
        if(a < 0) menor.pb(a);
        if(a > 0) mayor.pb(a);
        if(a == 0) on = 1; 
    }

    ll sobra = k - on;
    ll rpta = 0;
    if(sobra){
        reverse(all(menor));
        ll aux = INF;
        int j;
        ll aux1, aux2;
        for(int i = 0; i <= min(sobra, ll(mayor.size())); i++){
            j = sobra - i;
            if(j > menor.size()) continue;
            aux1 = 0;
            aux2 = 0;
            if(i) aux1 = mayor[i-1];
            if(j) aux2 = menor[j-1]*-1;
            
            if(aux1 > aux2) swap(aux1, aux2);
            aux = min(aux, aux1+aux1+aux2);
        }
        rpta  += aux;
    }
    cout << rpta << endl;

}

int main(){
    fastio;
    int t = 1;
    //cin >> t;
    while(t--) solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  for (int X = 0; X <50000; X++) {
    if (X * 1.08 >= N && X * 1.08 < N + 1) {
      cout << X << endl;
      break;
    }
    if (X == 49999) {
      cout << ":(" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 3030;
int n,k;
bool st[N];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int d;
		cin>>d;
		for(int j=1;j<=d;j++)
		{
			int x;
			cin>>x;
			st[x]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(st[i]==0)
			ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod2=1000000007;
ll mod=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int a,b;cin>>a>>b;
    if(a%2==b%2){
        cout<<(a+b)/2<<endl;
        
    }
    else cout<<"IMPOSSIBLE"<<endl;

}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>

using namespace std;

void solve(int a, int b, int c) {
    if (a <= c && c <= b) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

int main() {
    struct timeval start,end;
    long long span;
    int a,b,c;

    gettimeofday(&start,NULL);

    std::cin >> a >> b >> c;
    solve(a,b,c);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct list{
  int key;
  struct list *next_ptr;
  struct list *prev_ptr;
};
struct list *nil;				/* 番兵 */
void init(){					/* リストの初期化 番兵の設置 */
  nil=malloc(sizeof(struct list));
  nil->next_ptr=nil;
  nil->prev_ptr=nil;
}
void insert(int key){
  struct list *new_list_ptr;
  new_list_ptr=malloc(sizeof(struct list));
  new_list_ptr->key=key;
  //番兵の直後に要素を追加
  new_list_ptr->next_ptr=nil->next_ptr;
  nil->next_ptr->prev_ptr=new_list_ptr;
  nil->next_ptr=new_list_ptr;
  new_list_ptr->prev_ptr=nil;
}
struct list *listsearch(int key){
  struct list *cur_ptr=nil->next_ptr;
  while((cur_ptr!=nil)&&(cur_ptr->key!=key)){
	cur_ptr=cur_ptr->next_ptr;
}
  return cur_ptr;
}
void delete(struct list *t){
  if(t==nil)
	return;
  t->next_ptr->prev_ptr=t->prev_ptr;
  t->prev_ptr->next_ptr=t->next_ptr;
  free(t);
}
void deleteFirst(){
  delete(nil->next_ptr);
}
void deleteLast(){
  delete(nil->prev_ptr);
}
void deleteKey(int key){
  delete(listsearch(key));
}
void printlist(){
  struct list *cur=nil->next_ptr;
  int isf=0;
  while(1){
	if(cur==nil)
	  break;
	if(isf>0)
	  printf(" ");
	++isf;
	printf("%d", cur->key);
	cur=cur->next_ptr;
}
  printf("\n");
}
int main(){
  int n;
  scanf("%d", &n);
  char line[20];
  int i;
  int key;
  init();
  for(i=0; i<n; ++i){
	scanf("%s %d", line, &key);
	if(strcmp(line, "insert")==0){
	  insert(key);
	}
	else if(strcmp(line, "delete")==0)
	  deleteKey(key);
	else if(strcmp(line, "deleteFirst")==0)
	  deleteFirst();
	else if(strcmp(line, "deleteLast")==0)
	  deleteLast();
  }
  printlist();
  return 0;
}



Measured memory_bytes: 32940
import bisect as b


def main():
    A, B, Q = map(int, input().split())
    INF = 10 ** 11
    s_list = [-INF] + [int(input()) for i in range(A)] + [INF]
    t_list = [-INF] + [int(input()) for i in range(B)] + [INF]

    len_s = A + 1
    len_t = B + 1

    for i in range(Q):
        xi = int(input())
        ind_s = b.bisect_left(s_list, xi)
        ws = s_list[ind_s - 1]
        es = s_list[ind_s]

        ind_t = b.bisect_left(t_list, xi)
        wt = t_list[ind_t - 1]
        et = t_list[ind_t]

        dist_list = [
                     xi - min(ws, wt),
                     max(es, et) - xi,
                     xi + es - wt * 2,
                     xi + et - ws * 2,
                     (es * 2) - wt - xi,
                     (et * 2) - ws - xi
                     ]

        print(min(dist_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 12816
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

func main() {
	defer stdout.Flush()

	n := readInt()
	m := readInt()
	X := readInt()
	Y := readInt()
	x := make([]int, n)
	y := make([]int, m)
	xmax := X
	ymin := Y
	for i := range x {
		x[i] = readInt()
		if xmax < x[i] {
			xmax = x[i]
		}
	}
	for i := range y {
		y[i] = readInt()
		if y[i] < ymin {
			ymin = y[i]
		}
	}
	if xmax < ymin {
		println("No War")
	} else {
		println("War")
	}

}

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


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n;
    cin >> n;
    int sum = 0, mn = 100000000;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        sum += x;
        if(x%10) mn = min(mn, x);
    }
    if(sum%10) cout << sum;
    else cout << max(0, sum-mn);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) {
    int i, j, n;
    double nagasa=0;
    int x[8], y[8];
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &x[i]);
        scanf("%d", &y[i]);
    }
    for (i=0; i<n; i++) {
        for (j=0; j<n; j++) {
            if (i != j) {
                nagasa += sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
            }
        }
    }
    printf("%lf", nagasa/n);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>

using namespace std;

void check(double c, int k[][2], int d) {
	if (c >= 1.1) {
		k[0][d]++;
	} else if (c >= 0.6) {
		k[1][d]++;
	} else if (c >= 0.2) {
		k[2][d]++;
	} else {
		k[3][d]++;
	}
	return;
}

int main() {
	double a,b;
	int hyou[4][2] = {0};

	while (cin >> a >> b) {
		check(a,hyou,0);
		check(b,hyou,1);
	}

	for (int i = 0; i < 4; i++) {
		cout << hyou[i][0] << " " << hyou[i][1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
using System;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            Console.WriteLine( (n == 3 || n==5 || n== 7 ) ? "YES":"NO");
                
            return;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    if(s.size() == 1) ans = stoi(s);
    else{
        int cnt = 0;
        for(int i = 1; i < s.size(); i++){
            if(s[i] == '9') cnt++;
            else break;
        }
        if(cnt == s.size() - 1){
            ans = (s[0] - '0') + 9 * (s.size() - 1);
        }else{
            ans = (s[0] - '0') - 1 +  9 * (s.size() - 1);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256