akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
def inpl(): return list(map(int,input().split()))

class Counter:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

ui = defaultdict(Counter())
xylist = []

H, W, N = inpl()
for i in range(N):
    X, Y = inpl()
    n = ui[X]
    if n < len(xylist):
        xylist[n][1] = min(xylist[n][1],Y)
    else:
        xylist.append([X,Y])

xylist.sort(key=lambda x: x[0])
xylist.append([H+1,1])

Xprev = Yprev = 1
for X, Y in xylist:
    Ybound = Yprev + X - Xprev 
    if Y < Ybound:
        ans = X - 1
        break
    elif Y == Ybound:
        Xprev, Yprev = X, Ybound - 1
    else:
        Xprev, Yprev = X, Ybound

print(ans)

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

int main(void) {
	priority_queue<int> pq;
	string com;
	int k;
	cin >> com;
	while (com != "end") {
		if (com == "insert") {
			cin >> k;
			pq.push(k);
		} else if (com == "extract") {
			cout << pq.top() << endl;
			pq.pop();
		}
		cin >> com;
	}
}


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

int L[100001];
int R[100001];

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

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

	int n,t;
	vector <int> v;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

	sort(v.begin(),v.end());

	L[0] = 0;
	for(int i=0;i<n;i++)
	{
		L[i+1] = gcd(v[i],L[i]);
	}
	R[n] = 0;
	for(int i=n;i>=1;i--)
	{
		R[i-1] = gcd(R[i],v[i-1]);
	}

	int res = 0;

	for(int i=0;i<=n;i++)
	{
		res = max(res,gcd(L[i],R[i+1]));
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 1528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");

		double a = Double.parseDouble(str[0]);
		double b = Double.parseDouble(str[1]);
		double degree = Double.parseDouble(str[2]);

		double revrad = Math.PI * ( (180-degree)/180);

		double cx = b * Math.cos(revrad) + a;
		double cy = b * Math.sin(revrad);

		double sq = (a*cy) / 2;
		double len = Math.sqrt(cx*cx + cy*cy) + a + b;

		System.out.printf("%.5f %.5f %.5f\n",sq ,len ,cy);
	}
}

Measured memory_bytes: 24796
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	string s="CODEFESTIVAL2016";
	string t; cin>>t;
	int ans=0;
	rep(i,0,s.size())if(s[i]!=t[i])ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

vector<int> a[105];
int sum[105];
int n, d;

int maxSum(){
    int maxi = 0;
    int ret;
    rep(i,n){
        if(maxi < sum[i]){
            maxi = sum[i];
            ret = i;
        }
    }
    return ret;
}

bool C(){
    rep(i,n){
        if(not a[i].empty()) return false;
    }
    return true;
}

bool deleteMax(int p){
    int next_p = sum[p] - a[p].back();
    rep(i,n){
        if(i == p) continue;
        if(not (sum[i] - d <= next_p && sum[i] + d >= next_p)){
            return false;
        }
    }
    return true;
}

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

    while(cin >> n >> d,n){
        rep(i,105) a[i].clear();
        rep(i,105) sum[i] = 0;
        rep(i,n){
            int m;
            cin >> m;
            rep(j,m){
                int x;
                cin >> x;
                a[i].emplace_back(x);
                sum[i]+=x;
            }
        }

        bool f = true;
        while(f){
            int p = maxSum();
            f = false;
            int limit = sum[p] - d;
            rep(i,n){
                if(i == p || a[i].empty()) continue;
                while(sum[i] - a[i].back() >= limit){
                    f = true;
                    sum[i] -= a[i].back();
                    a[i].pop_back();
                    if(a[i].empty()) break;
                }
            }
            if(C()) break;
            //rep(i,n) show(sum[i])
            p = maxSum();
            while(not a[p].empty() && deleteMax(p)){
                f = true;
                sum[p] -= a[p].back();
                a[p].pop_back();
            }
            if(C()) break;
        }

        cout << (C() ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 3200
using System;
class Program
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    long A = long.Parse(input[0]);
    long B = long.Parse(input[1]);
    long C = long.Parse(input[2]);
    long D = long.Parse(input[3]);
    long CD = Lcm(C, D);
    
    long N = B - A + 1;
    long C_div = B/C - (A+C-1)/C + 1;
    long D_div = B/D - (A+D-1)/D + 1;
    long CD_div = B/CD - (A+CD-1)/CD + 1;
    
    Console.WriteLine(N - C_div - D_div + CD_div);
  }
	static long Gcd(long a, long b)
	{
 	   var v = new[] { a, b };
 	   while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
 	   return v[0];
	}
	
	static long Lcm(long a, long b)
	{
	    return a / Gcd(a, b) * b;
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    vector<pair<int,int> >P[n+5];
    vector<pair<int,int> >lst(m);
    for(int a=0;a<m;a++){
        int p,y;
        scanf("%d %d",&p,&y);
        P[p].push_back(make_pair(y,a));
    }
    for(int a=1;a<=n;a++) sort(P[a].begin(),P[a].end());
    for(int a=1;a<=n;a++){
        for(int b=0;b<P[a].size();b++){
            int idx=P[a][b].second;
            lst[idx]=make_pair(a,b+1);
        }
    }
    for(int a=0;a<m;a++){
        printf("%06d%06d\n",lst[a].first,lst[a].second);
    }
}


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

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(b==0)return a;
	return gcd(b,a%b);
}
long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}

int main() {
	long long a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld",lcm(a,b));
}


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

#define ll long long
#define mod 1000000007

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

    string s,t;
    cin >> s >> t;
    int n = s.size();
    int cnt = 0;

    for (int i=0;i<n;i++) {
        if (s[i] != t[i])
            cnt++;
    }
    cout << cnt << "\n";

    
}


Measured memory_bytes: 3708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exawizards
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int countR = 0, countB = 0;
            for(int i = 0; i < N; i++)
            {
                if (s[i] == 'R') countR++;
                else countB++;
            }
            string r = countR > countB ? "Yes" : "No";
            Console.WriteLine(r);
        }

    }
}


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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var A = sc.ArrayInt(N + 1);
        var B = sc.ArrayInt(N);
        long ans = 0;
        for (int i = 0; i < N; i++) {
            var zan = 0;
            if (A[i] - B[i] < 0) {
                zan = B[i] - A[i];
                ans += A[i];
                A[i] = 0;
            } else {
                ans += B[i];
                A[i] -= B[i];
                continue;
            }

            if (A[i + 1] - zan < 0) {
                ans += A[i + 1];
                A[i + 1] = 0;
            } else {
                ans += zan;
                A[i + 1] -= zan;
            }
        }
        WriteLine(ans);
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 31716
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  int w;
  cin >> s >> w;
  for(int i=0; i<s.size(); i+=w){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
ll x,k,d;cin>>x>>k>>d;
x = abs(x);
ll a = x/d;
if(a > k){
    cout<< x - k*d<<endl;
}else
{
    if((k-a)%2 == 0){
        cout<<x%d<<endl;
    }else
    {
        ll b = x%d;
        cout<<abs(b-d)<<endl;
            }
    
}

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vec;
typedef std::vector<ld> vecld;
typedef std::vector< std::vector<ll> > vecvec;
typedef std::pair<ll, ll> pr;
typedef std::vector< pr > vpr;

#define tin ll t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define sz(a) (ll)((a).size())
#define pb push_back
#define trvect(c,i) for(vector<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trset(c,i) for(set<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trmap(c,i) for(map<ll,ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define present(c,x) ((c).find(x) != (c).end())
#define ff first
#define ss second
#define mp make_pair
#define sq(a) (a)*(a)
#define cube(a) (a)*(a)*(a)
#define cnti(x) (__builtin_popcount(x)) //number of set bits in x
#define mod 1000000007
#define N 100005

ll qpow (ll n, ll m) {
	ll ret = 1;
	while (m) {
		if (m & 1) ret = ret * n % mod;
		n = n * n % mod;
		m >>= 1;
	}
	return ret;
}
ll inv (ll a) {
	return qpow(a, mod - 2);
}

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



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

    ll arr[m],ass=0;
    rep(i,0,m) cin>>arr[i],ass+=arr[i];

    if(ass>n)
    	cout<<-1<<"\n";
    else
    	cout<<n-ass<<"\n";
}


Measured memory_bytes: 3672
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n + 1);
    ll s = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s += a[i];
    }

    vector<ll> diff(n + 1, 0);
    ll d;
    for (int i = 2; i <= n; i++) {
        if (i == n) {
            d = (a[n] - a[n - 1]) * 2 + diff[n - 1];
        } else {
            diff[i + 1] = (a[i] - a[i - 1]) * 2 + diff[i - 1];
        }
    }
    for (int i = 2; i <= n - 1; i += 2) {
        diff[i] -= d;
    }
    ll tmpS = 0;
    for (auto& di : diff) {
        tmpS += di;
    }
    ll add = (s - tmpS) / n;
    for (int i = 1; i <= n; i++) {
        cout << diff[i] + add << " ";
    }
    return 0;
}


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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

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

    int i, j;
    int ans = 0;
    int yakusu = 0;
    for(i=1; i<=n; i=i+2){
        yakusu=0;
        for(j=1; j<=i; j++){
            if(i%j==0){
                yakusu++;
            }
        }
        if(yakusu==8){
            ans++;
            //cout<<i;
        }
    }

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

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

using namespace std;

const uint64_t MOD = 1e+9 + 7;

int main()
{
  string S;
  cin >> S;
  
  vector< array<uint64_t, 13> > dp(S.size() + 1);
  dp[0][0] = 1;
  
  for (uint64_t i = 0; i < S.size(); ++i) {
    if (S[i] == '?') {
      for (uint64_t d = 0; d < 10; ++d) {
        for (uint64_t j = 0; j < 13; ++j) {
          dp[i + 1][(d + j * 10) % 13] += dp[i][j];
          dp[i + 1][(d + j * 10) % 13] %= MOD;
        }
      }
    } else {
      uint64_t d = S[i] - '0';
      for (uint64_t j = 0; j < 13; ++j) {
        dp[i + 1][(d + j * 10) % 13] += dp[i][j];
        dp[i + 1][(d + j * 10) % 13] %= MOD;
      }
    }
  }
  
  cout << dp[S.size()][5] << endl;
  
  return 0;
}

Measured memory_bytes: 10752
import Control.Applicative
import Text.Printf
main = do xys <- map read . words <$> getLine
          printf "%.5g\n" $ solve xys

solve :: [Double] -> Double
solve (x1:y1:x2:y2:_) = sqrt $ (x1-x2) ** 2 + (y1-y2) ** 2

Measured memory_bytes: 4124
using System;
using System.Linq;

namespace Ex160424_1{
    public class Program{
        public static void Main(string[] args){
            var seq = Enumerable.Range(1, 30).ToList();
            for(var i = 0; i < 28; i++) seq.Remove(int.Parse(Console.ReadLine()));
            Console.WriteLine(seq.Min());
            Console.WriteLine(seq.Max());
        }
    }
}

Measured memory_bytes: 9840
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, n, u, w, deg[100001] = {};
	list *adj[100001] = {}, e[200001];
	scanf("%d", &n);
	for (i = 0; i < n - 1; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
		deg[u]++;
		deg[w]++;
	}
	
	int flag[100001] = {}, par[100001], q[100001], head, tail;
	list *p;
	flag[1] = 1;
	q[0] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (flag[w] == 0) {
				flag[w] = 1;
				q[tail++] = w;
			}
		}
	}
	
	int s = q[head-1], t;
	flag[s] = 0;
	par[s] = s;
	q[0] = s;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (flag[w] != 0) {
				flag[w] = 0;
				par[w] = u;
				q[tail++] = w;
			}
		}
	}
	for (t = q[head-1], u = t, flag[s] = 1; u != s; u = par[u]) flag[u] = 1;
	for (i = 1; i <= n; i++) if (flag[i] == 0 && deg[i] != 1) break;
	if (i <= n) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	int j, k, ans[2][100001];
	for (u = par[t], i = 2, k = 2, ans[0][1] = 1, ans[0][n] = n; u != s; u = par[u]) {
		ans[0][i + deg[u] - 2] = k++;
		for (j = 3; j <= deg[u]; j++) ans[0][i++] = k++;
		i++;
	}
	for (i = 1; i <= n; i++) flag[i] = 0;
	s = t;
	flag[s] = 1;
	par[s] = s;
	q[0] = s;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			w = p->v;
			if (flag[w] == 0) {
				flag[w] = 1;
				par[w] = u;
				q[tail++] = w;
			}
		}
	}
	for (t = q[head-1], u = par[t], i = 2, k = 2, ans[1][1] = 1, ans[1][n] = n; u != s; u = par[u]) {
		ans[1][i + deg[u] - 2] = k++;
		for (j = 3; j <= deg[u]; j++) ans[1][i++] = k++;
		i++;
	}
	
	for (i = 1; i <= n; i++) if (ans[0][i] != ans[1][i]) break;
	k = (i > n || ans[0][i] < ans[1][i])? 0: 1;
	for (i = 1; i < n; i++) printf("%d ", ans[k][i]);
	printf("%d\n", ans[k][n]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7956
//  __/\\\\____________/\\\\______/\\\\\\\\\______/\\\________/\\\___/\\\\\\\\/\\____/\\\\\\\\\\_|
//   _\/\\\\\\________/\\\\\\____/\\\\\\\\\\\\\___\/\\\________/\\\__\/\\\____\/\\\__\////\\\///__|
//    _\/\\\//\\\____/\\\//\\\___/\\\/////////\\\__\/\\\________/\\\__\/\\\____\/\\\\____\/\\\_____|
//     _\/\\\\///\\\/\\\/_\/\\\__\/\\\_______\/\\\__\/\\\\\\\\\\\\\\\__\/\\\____\/\\\\____\/\\\_____|
//      _\/\\\__\///\\\/___\/\\\__\/\\\\\\\\\\\\\\\__\/\\\/////////\\\__\/\\\____\/\\\\____\/\\\_____|
//       _\/\\\____\///_____\/\\\__\/\\\/////////\\\__\/\\\_______\/\\\__\/\\\____\/\\\_____\/\\\_____|
//        _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\___/\\\\______\/\\\_____|
//         _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\\\\/\\_____/\\\\\\\\\\__|
//          _\///______________\///___\///________\///___\///________\///___\/////////_____\//////////___|
#include<bits/stdc++.h>
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< long long > vl;
#define hurry ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define setp setprecision
#define popp pop_back()
#define pb push_back
#define mp make_pair
#define beg begin()
#define end end()
#define sc second
#define sz size()
#define fr first
#define endl '\n'
//=======================================================================================================================
//GLOBAL
int a[1002][1003];
ll dp[1002][1003];
const int mod=1e9+7;
//=======================================================================================================================
//FUNCTIONS
//=======================================================================================================================
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        str s;
        cin>>s;
        for(int j=0;j<m;j++)
        {
            if(s[j]=='#')
                a[i][j+1]=1;
        }
    }
    if(a[1][1]==1)
    {
        cout<<0;
        return 0;
    }
    else
        dp[1][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(!a[i][j])
            {
                if(i==1 and j!=1)
                    dp[i][j]=dp[i][j-1]%mod;
                if(j==1 and i!=1)
                    dp[i][j]=dp[i-1][j]%mod;
                if(i!=1 and j!=1)
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[n][m]%mod;
}
//========================================================================================================================


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define all(arr) arr.begin(), arr.end() 
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, k, q;
unordered_map<ll, ll>vis;

int main(){
	IOS
	cin >> n >> k >> q;
	for(int i=1;i<=n;i++){
		vis[i]=k-q;
	}
	while(q--){
		ll a;
		cin >> a;
		vis[a]++;
	}
	for(int i=1;i<=n;i++){
		if(vis[i]<=0){
			cout << "No" << '\n';
		}
		else{
			cout << "Yes" << '\n';
		}
	}
}


Measured memory_bytes: 7328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] item = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            item[i] = sc.nextInt();
        }

        for (int j : item) {
            sum += j;
        }

        double wakeru = sum / (4.0 * M);
        int count = 0;


        for (int a = 0; a < N; a++) {
            if (wakeru <= item[a]) {
                count += 1;
            }
        }
        if (count >= M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, m, t, dp[(1 << 21)], mod = 1e9 + 7;
bool com[21][21], inc[(1 << 21)][21];
vector< ll > adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first

// void match(ll mask, ll cur){
// 	cout << mask << " " << cur << "**&&**";
// 	if( cur == n )
// 		return;
// 	ll options = (1 << n) - 1 - mask;
// 	for(int i = 0 ; i < n ; i++){
// 		ll nxtMask = mask | (1 << i);
// 		if( (options & (1 << i)) > 0 and com[i][cur] ){
// 			dp[nxtMask] += dp[mask];
// 			dp[nxtMask] %= mod;
// 			match(nxtMask, cur + 1);
// 		}
// 	}
// }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 0 ; i < n ; i++)
    	for(int j = 0 ; j < n ; j++)
    		cin >> com[i][j];
    dp[0] = 1;
	queue< pair< ll, ll> > q;
	q.push(make_pair(0, 0));
	while( !q.empty() ){
		ll mask = q.front().ff;
		ll cur = q.front().ss;
		q.pop();
		// cout << mask << " " << cur << "**&&**";
		ll options = (1 << n) - 1 - mask;
		for(int i = 0 ; i < n ; i++){
			ll nxtMask = mask | (1 << i);
			if( (options & (1 << i)) > 0 and com[i][cur] ){
				dp[nxtMask] += dp[mask];
				dp[nxtMask] %= mod;
				if( cur < n - 1 and !inc[nxtMask][cur + 1] ){
					inc[nxtMask][cur + 1] = true;
					q.push(make_pair(nxtMask, cur + 1));
				}
			}
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	return(0);
}

Measured memory_bytes: 71408
N, Y = map(int, input().split())

found = False
for i in range(N+1):
    for j in range(N+1-i):
        k = N - (i + j)
        otoshidama = 10000*i + 5000*j + 1000*k
        if otoshidama == Y:
            print(i, j, k)
            found = True
            break
    if found: break

if not found: print(-1, -1, -1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n;i++)
int main(){
    string s; cin>>s;
    char now;
    int ans=0;
    rep(i,s.size()){
        if(!i){if(s[i]=='A')ans++;now=s[0];continue;}
        else if(now==s[i]){ans++; now=s[i];continue;}
        if(now>s[i])ans++;
        now=s[i];
    }
    cout<<ans<<endl;
}

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

int main()
{
	int n;
	int year;
	while (cin >> n)
	{
		if (n == 0) break;

		int a[30];

		a[0] = 1;
		a[1] = 2;
		a[2] = 4;

		for (int i = 3; i < n; i++)
		{
			a[i] = a[i - 1] + a[i - 2] + a[i - 3];
		}

		year = a[n - 1] / 3650;
		if (a[n - 1] % 3650 > 0)
		{
			year += 1;
		}

		cout << year << endl;

	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include<iomanip>



#define ll long long
using namespace std;


ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;

    return n * factorial(n - 1);
}


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

    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];

    int dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        dp[i] = 10e4 + 1;
        if (i >= 2)
            dp[i] = min(abs(arr[i] - arr[i - 2]) + dp[i - 2], abs(arr[i] - arr[i - 1]) + dp[i-1]);

        else
            dp[i] = abs(arr[i] - arr[i-1]) + dp[i - 1];
    }


    cout << dp[n - 1];

    return 0;
}


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

int main() {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (d >= abs(a - c) || (d >= abs(a - b) && d >= abs(b - c))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c;cin >> a >> b >> c;
    long long z = c - a - b;
    if(z < 0)
    {
        cout << "No" << endl;
        return 0;
    }
    long long x = 4*a*b;
    z = z*z;
    if(z > x)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const double INF=1e9;
const double PI=acos(-1);

int n;
double r,theta;
int x[20],y[20];

// from,now,carrots
double dp[20][20][10001];

double d[20][20];
bool moveable[20][20][20];

inline double dist(int a, int b)
{
    return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
}

inline bool check(int a, int b, int c)
{
    double abx=x[b]-x[a], aby=y[b]-y[a];
    double bcx=x[c]-x[b], bcy=y[c]-y[b];

    double AB=sqrt(abx*abx+aby*aby);
    double BC=sqrt(bcx*bcx+bcy*bcy);
    double dot=abx*bcx+aby*bcy;

    double alpha=acos(dot/AB/BC)*180.0/PI;
    return alpha<=theta;
}

int main()
{
    scanf(" %d %lf %lf", &n, &r, &theta);
    rep(i,n) scanf(" %d %d", &x[i], &y[i]);

    rep(i,20)rep(j,20)rep(k,10001) dp[i][j][k]=INF;
    rep(i,n)rep(j,n) d[i][j]=dist(i,j);
    rep(i,n)rep(j,n)rep(k,n)
    {
        if(i==j || i==k || j==k) continue;
        moveable[i][j][k]=check(i,j,k);
    }

    int ans=0;
    for(int i=1; i<n; ++i)
    {
        if(d[0][i]<r)
        {
            dp[0][i][1]=d[0][i];
            ans=1;
        }
    }

    for(int i=1; i<10000; ++i)
    {
        bool update=false;
        rep(from,n)rep(now,n)
        {
            if(from==now) continue;
            if(dp[from][now][i]>r) continue;
            rep(to,n)
            {
                if(to==from || to==now) continue;
                if(moveable[from][now][to])
                {
                    double add=d[now][to];
                    double tmp=dp[from][now][i]+add;
                    if(tmp<=r && dp[now][to][i+1]>tmp)
                    {
                        dp[now][to][i+1]=tmp;
                        update=true;
                    }
                }
            }
        }
        if(update) ans=i+1;
        else break;
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 34808
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n, ans = 0;
	string s;
	cin >> n >> s;
	rep(i, 0, 1000) {
		int a = i / 100, b = i / 10 % 10, c = i % 10, k1, k2, k3;
		for (k1 = 0; k1 < n; k1++) { if (s[k1] == a + '0')break; }
		for (k2 = k1 + 1; k2 < n; k2++) { if (s[k2] == b + '0')break; }
		for (k3 = k2 + 1; k3 < n; k3++) { if (s[k3] == c + '0') { ans++; break; } }
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3768
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define infinity (1<<30)
const int maxx=2000100;
int A[maxx];
int n;

void max_heap(int i){
	int left=2*i,right=2*i+1,x;
	if(left<=n && A[left]>A[i]) x=left;
	else x=i;
	if(right<=n && A[right]>A[x] ) x=right;
	if(x!=i){
		swap(A[x],A[i]);
		max_heap(x);
	}
	return ;
}

int extract(){
	int x;
	x=A[1];
	A[1]=A[n];
	n--;
	max_heap(1);
	return x;
}

int main (){
	string s;
	int a;
	n=0;
	while(cin>>s){
		if(s[0]=='i'){
			cin>>A[++n];
			int i=n;
			while(i>1 && A[i]>A[i/2]){
				swap(A[i],A[i/2]);
				i=i/2;
			}
		}
		else if(s[1]=='x'){
			cout<<extract()<<endl;
		}
		else return 0;
	}
	return 0;
}


Measured memory_bytes: 6964
#include<bits/stdc++.h>
#define k 1000000007
typedef long long ll;
using namespace std;

ll mod(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1)
		ans=ans*x%k;
		x=x*x%k;
		y>>=1;
	}
	return ans;
}
int main()
{   ll n,a,b;
	cin>>n>>a>>b;
	ll ans=mod(2,n);
	ans--;
	a=max(n-a,a);
	b=max(n-b,b);
	ll x=1,y=1;
	for(ll i=a+1;i<=n;i++)
	x=x*i%k;
	//cout<<x<<endl;
	for(ll i=1;i<=n-a;i++)
	y=y*i%k;
	ans=(ans+k-x*mod(y,k-2)%k)%k;
	//cout<<ans<<endl;
	x=1;
	y=1;
	for(ll i=b+1;i<=n;i++)
	x=x*i%k;
	for(ll i=1;i<=n-b;i++)
	y=y*i%k;
	ans=(ans+k-x*mod(y,k-2)%k)%k;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
from sys import stdin


def distance(y, z):
    distance2 = 0
    for i in range(len(y)):
        distance2 += (y[i] - z[i])**2
    return distance2**0.5


n, d = (int(x) for x in stdin.readline().rstrip().split())
points = [[int(x) for x in stdin.readline().rstrip().split()]
          for _ in range(n)]

count = 0
for i in range(n):
    for j in range(i+1, n):
        a = distance(points[i], points[j])
        if a == int(a):
            count += 1

print(count)

Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <iterator>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
//#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

// 0-indexed, [0, n-1]
template<class T>
class BIT {
	vector<T> bit;
	int n;

public:
	BIT(int size) :
		bit(vector<int>(size, 0)), n(size) {}

	T sum(int i) {
		++i;
		if (i > n) {
			//cout << "illegal label in sum" << endl;
			return 0;
		}
		T s = 0;
		while (i > 0) {
			s += bit[i - 1];
			i -= i & -i;
		}
		return s;
	}

	void add(int i, T x) {
		++i;
		if (i > n) {
			//cout << "illegal label in add" << endl;
			return;
		}
		while (i <= n) {
			bit[i - 1] += x;
			i += i & -i;
		}
	}
};

const ll MOD = 998244353;
const int MN = 200010;
int num[MN][4];
ll p2[MN];

int main() {
	int N; cin >> N;
	vector<pii> vec(N);
	vi xs, ys;

	rep(i, N) {
		int x, y; cin >> x >> y;
		vec[i] = mp(x, y);
		xs.pb(x); ys.pb(y);
	}

	sort(ALL(xs)); sort(ALL(ys));
	rep(i, N) {
		int x = vec[i].fi, y = vec[i].se;
		x = lower_bound(ALL(xs), x) - xs.begin() + 1;
		y = lower_bound(ALL(ys), y) - ys.begin() + 1;
		vec[i] = mp(x, y);
		//cout << vec[i] << endl;
	}

	sort(ALL(vec));

	BIT<int> Tinc(MN);
	BIT<int> Tdec(MN);

	rep(i, N) {
		int a = Tinc.sum(vec[i].se - 1);
		int b = i - Tinc.sum(vec[i].se);
		int c = Tdec.sum(vec[N - 1 - i].se - 1);
		int d = i - Tdec.sum(vec[N - 1 - i].se);

		num[i][0] = a;
		num[i][1] = b;
		num[N - 1 - i][2] = c;
		num[N - 1 - i][3] = d;

		Tinc.add(vec[i].se, 1);
		Tdec.add(vec[N - 1 - i].se, 1);
	}

	ll ans = 0;

	p2[0] = 1;
	for (int i = 1; i < MN; ++i) {
		p2[i] = p2[i - 1] * 2 % MOD;
	}

	rep(i, N) {
		ll a = (p2[num[i][0]] + p2[num[i][3]] - 1) % MOD;
		ll b = (p2[num[i][1]] + p2[num[i][2]] - 1) % MOD;

		ll v = (p2[N] - a * b) % MOD;
		if (v < 0) v += MOD;
		ans = (ans + v) % MOD;
	}

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

Measured memory_bytes: 9836
import math

A, B = map(int, input().split())

for n in range(0, 10):
  for m in range(0, 10):
    x = math.floor((A + n/10) / 0.08 + 0.5)
    y = math.floor((B + m/10) / 0.1 + 0.5)
    if x == y:
      if math.floor(x * 0.08) == A and math.floor(y * 0.1):
        print(x)
        exit()
print("-1")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll N, X;
	cin >> N >> X;
	vec L(N);
	readv(L);

	ll ans=1;
	ll xnow=0;
	REP(i,N){
		xnow += L[i];
		if(xnow<=X) ans++;
		else break;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  if ((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3])) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
#define def 0
template<class V, int NV> struct SegTree { //[l,r)
    V comp(V& l, V& r) { return max(l, r); };

    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x, int y, int l = 0, int r = NV, int k = 1) {
        if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
        auto a = get(x, y, l, (l + r) / 2, k * 2); 
        auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
        return comp(a, b);
    }
    void update(int i, V v) {
        i += NV; val[i] = v;
        while (i>1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
    }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    V operator[](int x) { return get(x, x + 1); }
};

/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/











int N, H[201010], A[201010];
SegTree<ll, 1 << 18> dp;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> H[i];
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N) {
        ll opt = dp.get(0, H[i]) + A[i];
        dp.update(H[i], max(dp[H[i]], opt));
    }

    cout << dp.get(0, 1<<18) << endl;
}


Measured memory_bytes: 5888
class UF():
  def __init__(self, N):
    self.parents = [-1] * N

  def find(self, n):
    if self.parents[n] < 0:
      return n
    else:
      self.parents[n] = self.find(self.parents[n])
      return self.parents[n]

  def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def same(self, u,v):
    return self.find(u) == self.find(v)

N,M = map(int,input().split())
uf = UF(N+1)
ans = 0
edges = []
for _ in range(M):
  u,v = map(int,input().split())
  edges.append((u,v))

res = 0
for i in range(M):
  uf = UF(N+1)
  for j,edge in enumerate(edges):
    if i==j: continue
    uf.union(edge[0],edge[1])

  u,v = edges[i]
  if not uf.same(u,v):
    res += 1

print(res)

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

signed main() {
    int alpha[26] = {};
    
    string s;
    cin >> s;
    for ( int i = 0; i < 4; i++ ) {
        alpha[ s[i] - 'A' ] ++;
    }
    sort(alpha, alpha + 26, greater<int>());
    
    if ( alpha[0] == 2 && alpha[1] == 2 ) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return (0);
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
  int n;
  double t, a;
  cin >> n >> t >> a;

  vector<pair<double, int>> v(n);
  for (int i=0; i<n; i++) {
    double h;
    cin >> h;

    v[i]=make_pair(abs(a-(t-h*0.006)), i+1);
  }

  sort(v.begin(), v.end());

  cout << v[0].second << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

string str;

int main(){
	while(cin>>str){
		for(int i=0;i<str.size();i++){
			if(str[i]=='@'){
				i++;
				for(int j=0;j<str[i]-'0';j++) cout<<str[i+1];
				i++;
				continue;
			}
			cout<<str[i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int arr[100005];

int main()
{
    string s;
    cin >> s;

    sort(s.begin(), s.end());

    if(s[0] != s[2] and s[0] == s[1] and s[2] == s[3]) puts("Yes");
    else puts("No");

    return 0;
}


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

using namespace std;

size_t f(size_t h) {
    if (h > 1)
        return 1 + 2 * f(h / 2);
    return 1;
}

int main() {
    size_t h;
    cin >> h;
    cout << f(h) << endl;
    return 0;
}



Measured memory_bytes: 256
//ROADTOBLUE
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>




#define int long long
// #define uint unsigned int
// #define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define sz(x) (int)x.size()
#define pii pair < int, int >
using namespace std;


const int MAXN = 1e17;
const int SIZE =  2e5 + 100;  //are u sure?
const int MOD = 998244353;
int dp[110][110], wall[110][110], h, w;
char c;

void solve() {
	cin >> h >> w;
	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) {
			cin >> c;
			wall[i][j] = (c == '.') ? 0 : 1;
		}
	}

	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) {
			if(i + j == 2) {
				dp[i][j] = wall[i][j];
			} else {
				dp[i][j] = MAXN;
				if(i - 1 > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (wall[i][j] && !wall[i - 1][j]));
				if(j - 1 > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (wall[i][j] && !wall[i][j - 1]));
			}
		}
	}
	cout << dp[h][w] << endl;
}

signed main(){
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0LL;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define all(c) (c).begin(), (c).end()
int32_t main()
{
 
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin >> t;
    // while(t--){
	int l,r,d;
	cin >> l >> r >> d;
	int ri = r/d;
	int li = (l-1)/d;
	cout << ri-li << endl;   


   // }


return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	int res[4] = {};
	for (int i = 0; i < s.size(); i++)
	{
		if(s[i] == 'N') res[0] = 1;
		else if(s[i] == 'W') res[1] = 1;
		else if(s[i] == 'S') res[2] = 1;
		else res[3] = 1;
	}

	if((res[0] + res[2]) % 2 == 0 &&  (res[1] + res[3]) % 2 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3608
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n,k;
	cin>>n>>k;
	int a[n+1];
	fo1(i,n){
		cin>>a[i];
	}
	int dp[n+1];
	for(int i=1;i<=n;i++){
		dp[i]=INT_MAX;
	}
	dp[1]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k and i+j<=n;j++){
			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
		}
	}
	cout<<dp[n];
}
int32_t main()
{
	
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n,t;
    cin >> n >> t;
    t = t/2;
    vector<int>a(n);
    vector<int>b(n);
    rep(i,n){
        cin >> a[i];
        b[n-i-1] = a[i];
    }
    rep(i,n){
        if(i==0){
            continue;
        }
        b[i] = max(b[i],b[i-1]);
    }
    /*rep(i,n){
        cout << b[i] << endl;
    }*/
    reverse(b.begin(),b.end());
    int ans = 0;
    int sa = -1;
    rep(i,n){
        if(sa < b[i]-a[i]){
            ans=1;
            sa = b[i]-a[i];
        }
        else if(sa == b[i] -a[i]){
            ans++;
            //cout << ans << " " << i << endl;
        }
        
        
    }
    //cout <<"sa" <<  sa << endl;
    cout << ans << endl;
    
    return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> cards;
  rep(i,n) {
    int a;
    cin >> a;
    cards.push_back({a,1});
  }
  rep(i,m) {
    int b, c;
    cin >> b >> c;
    cards.push_back({c,b});
  }
  sort(cards.begin(), cards.end(), greater<P>());
  ll res = 0;
  int cnt = 0;
  int idx = 0;
  while (cnt < n) {
    if (cards[idx].second + cnt <= n) {
      res += cards[idx].first * cards[idx].second;
      cnt += cards[idx].second;
    } else {
      res += cards[idx].first * (n - cnt);
      cnt = n;
    }
    idx++;
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 6384
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
mod = 10**9 + 7
ans = 1
cnt = [0] * N
for a in A:
    if a > 0:
        ans *= (cnt[a - 1] - cnt[a])
    cnt[a] += 1
    ans %= mod
for i in range(cnt[0]):
    ans *= 3 - i
print(ans % mod)

Measured memory_bytes: 14396