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

using namespace std;

const int inf=100000000;

int k;

deque<int>q;
int dis[100005];

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

	cin>>k;

	for(int i=0;i<=k;i++)
	{
		dis[i]=inf;
	}

	q.push_back(1);
	dis[1]=1;
	while(!q.empty())
	{
		int x=q.front();q.pop_front();
		if(dis[x]<dis[(10*x)%k])//注意% 和 dis[x]较小 
		{
			dis[(10*x)%k]=dis[x];
			q.push_front((10*x)%k);
		}
		if(dis[x]+1<dis[(1+x)%k])//注意% 和 dis[x]较小 
		{
			dis[(1+x)%k]=dis[x]+1;
			q.push_back((1+x)%k);
		}
	}
	cout<<dis[k%k]<<'\n';//注意 
	
	return 0;
}

Measured memory_bytes: 896
using System;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		int counter = 0;
		if (s.Substring(0, 1) == "1") counter++;
		if (s.Substring(1, 1) == "1") counter++;
		if (s.Substring(2, 1) == "1") counter++;

		//出力
		Console.WriteLine(counter);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int main()
{
	int n;
	read(n);
	ll ans=1, ad=1;
	for(;n--;){
		int x; read(x); x%=2;
		ans *= 3;
		ad *= 1 + !x;
	}
	printf("%d\n", ans-ad);
	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 int long long

inline void chmax(int &a, int b) { a = max(a, b); }

signed main()
{
  int N, A, B;
  int X[100005];
  int sum = 0;
  cin >> N >> A >> B;

  cin >> X[0];
  for(int i = 1; i < N; i++) {
    cin >> X[i];
    if((X[i] - X[i - 1]) * A > B) {
      sum += B;
    } else {
      sum += (X[i] - X[i - 1]) * A;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
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; }

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

using pint = pair<int,int>;
using Edge = pair<long long,pint>;

// 入力
int N;
long long D;
vector<long long> A;

// 分割統治法
vector<Edge> edges;
void rec(int left, int right) {
    if (right - left <= 1) return;
    int mid = (left + right) / 2;
    
    long long leftmin = 1LL<<60;
    int leftminp = -1;
    for (int i = left; i < mid; ++i) if (chmin(leftmin, A[i]-D*i)) leftminp = i;
    long long rightmin = 1LL<<60;
    int rightminp = -1;
    for (int i = mid; i < right; ++i) if (chmin(rightmin, A[i]+D*i)) rightminp = i;
    
    for (int i = left; i < mid; ++i)
        edges.push_back(Edge(A[rightminp] + A[i] + D * (rightminp - i), pint(i, rightminp)));
    for (int i = mid; i < right; ++i)
        edges.push_back(Edge(A[leftminp] + A[i] + D * (i - leftminp), pint(leftminp, i)));
    
    rec(left, mid);
    rec(mid, right);
}

int main() {
    cin >> N >> D;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    // 分割統治法
    edges.clear();
    rec(0, N);
    
    // Kruskal
    UnionFind uf(N);
    sort(edges.begin(), edges.end());
    long long res = 0;
    for (auto e : edges) {
        long long w = e.first;
        int u = e.second.first, v = e.second.second;
        if (uf.issame(u, v)) continue;
        res += w;
        uf.merge(u, v);
    }
    cout << res << endl;
}












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

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) {cout << "Yes" << endl;}
	else {cout << "No" << endl;}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に

int main()
{
    int N, M;
    cin >> N >> M;
    VI s(M), c(M);
    rep(i,M){
        cin >> s.at(i) >> c.at(i);
    }
    int max=1;
    rep(i,N){
        max*=10;
    }
    int judge=0;
    rep(i,max+1){
        string a=to_string(i);
        if(N!=a.size()) continue;
        rep(j,M){
            if(s.at(j)==1 && c.at(j)==0 && a.size()!=1){
                cout << -1 << endl;
                return 0;
            }
            if(a.size()<s.at(j)){
                judge=1;   
            }    
            else if(ctoi(a.at(s.at(j)-1))!=c.at(j)){ 
               judge=1;
            }
        }
        if(judge==0){
            cout << i << endl;
            return 0;
        }
        judge=0;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s(m);
    vector<int> p(m);
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int a;
            cin >> a;
            --a;
            s[i].emplace_back(a);
        }
    }
    rep(i, m) cin >> p[i];

    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        bool ok = true;
        for (int i = 0; i < m; i++) {
            int sum = 0;
            for (auto a : s[i]) {
                if ((bit >> a) & 1) sum++;
            }
            if (sum % 2 != p[i]) {
                ok = false;
            }
        }
        if (ok) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
ls = [int(x) for x in input().split()]
dp = sum(ls[0:k])
for i in range(0,len(ls)-k):
    tmp = dp + ls[i+k] - ls[i]
    if tmp > dp:
        print("Yes")
    else:
        print("No")
    dp = tmp

Measured memory_bytes: 31668
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    
    int a,b,c,d,e,k;
    cin >>a>>b>>c>>d>>e>>k;
    if ((e-a) <= k ){
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
const int N = 155;
int n, k, mod;
inline void upd(int &x, const int &y) {
   (x += y) >= mod ? x -= mod : 0;
}
namespace part1 {

int f[N];
void main() {
   f[0] = 1; k >>= 1;
   for(int i = 1; i <= n; i ++) {
      f[i] = i <= k;
      for(int j = max(0, i - k - 1); j < i; j ++) { //choose [j + 2, i]
         upd(f[i], f[j]);
      }
   }
   printf("%d\n", (int) (1ll * f[n / 2] * f[n - n / 2] % mod));
}

}
namespace part2 {

int ans, f[N][N][N];
void main() {
   int c = (1 + k) / 2 - 1 + (n + 1) / 2;
   f[0][0][0] = 1;
   for(int i = 1; i <= c; i ++) {
      if(i <= (1 + k) / 2 - 1) {
         for(int j = 0; j <= i - 1; j ++) upd(f[i][0][0], f[i - 1][0][j]);
         for(int j = 1; j <= i; j ++) upd(f[i][0][j], f[i - 1][0][j - 1]);
      } else if(i <= n / 2) {
         for(int x = 0; x <= k + 1; x ++) // 0 0
            for(int y = 0; y <= i - 1; y ++)
               upd(f[i][0][0], f[i - 1][x][y]);
         for(int x = 0; x <= k + 1; x ++) if(x != 1) // 1 0
            for(int z = 0; z <= i - 1; z ++)
               upd(f[i][x][0], f[i - 1][!x ? 0 : x - 1][z]);
         for(int y = 1; y <= i; y ++)
            for(int z = 0; z <= k + 1; z ++)
               upd(f[i][0][y], f[i - 1][z][y - 1]);
         for(int x = 2; x <= k + 1; x ++) {
            for(int y = 1; y <= i && 1 + y <= x; y ++) {
               if(1 + y == x) {
                  for(int z = 0; z < x; z ++) {
                     upd(f[i][x][y], f[i - 1][z][y - 1]);
                  }
               } else {
                  f[i][x][y] = f[i - 1][x - 1][y - 1];
               }
            }
         }
      } else {
         for(int x = 0; x <= k + 1; x ++) {
            if(x == 0) {
               for(int y = 0; y <= k + 1; y ++)
                  for(int z = 0; z <= i - 1; z ++)
                     upd(f[i][0][0], f[i - 1][y][z]);
               for(int z = 0; z <= i - 1; z ++)
                  upd(f[i][0][0], f[i - 1][0][z]);
            } else if(x != 1) {
               for(int z = 0; z <= i - 1; z ++)
                  upd(f[i][x][0], f[i - 1][x - 1][z]);
            }
         }
      }
   }
   for(int y = 0; y <= k + 1; y ++)
      for(int z = 0; z <= n / 2; z ++)
         upd(ans, f[c][y][z]);
   printf("%d\n", ans);
}

}
int main() {
   scanf("%d%d%d", &n, &k, &mod);
   if(k % 2 == 0) part1::main();
   else part2::main();
   return 0;
}

Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define pi 3.141592653897932384626
//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
using namespace std;
#define abs(x) (((x)<0)?(-(x)):(x))
stack<long>q;
pair<long,long>a[100005];
int main()
{
    long n,s;
    cin>>n>>s;
    for(long i=0,x;i<n;++i){scanf("%ld%ld",&a[i].first,&a[i].second);}
    a[n]=pair<long,long>(s,0);
    ++n;
    sort(a,a+n);
    if(s==a[0].first||s==a[n-1].first){
        printf("%ld\n",a[n-1].first-a[0].first);
        return 0;
    }
    else{
        for(long i=0,j=n-1,x=a[0].second,y=a[n-1].second;;){
            //cout<<i<<' '<<j<<endl;
            if(s==a[i].first){
                while(s!=a[j].first){
                    q.push(j);
                    --j;
                }
                break;
            }
            else if(s==a[j].first){
                while(s!=a[i].first){
                    q.push(i);
                    ++i;
                }
                break;
            }
            else if(x<y){
                y=x+y;
                q.push(i);
                ++i;
                x=a[i].second;
            }
            else{
                x=x+y;
                q.push(j);
                --j;
                y=a[j].second;
            }
        }
    }
    long long sum=0;
    long long x=s;
    while(q.size()){
        //cout<<x<<' ';
        sum+=abs(x-a[q.top()].first);
        x=a[q.top()].first;
        q.pop();
    }//cout<<endl;
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  string t;
  cin >> t;
  int n = t.size();
  REP(i, n) {
    if (t[i] == '?') {
      if (i == 0) t[i] = 'D';
      else {
        if (t[i - 1] == 'P') t[i] = 'D';
        else if (t[i + 1] == '?') {
          t[i] = 'P';
          t[i + 1] = 'D';
        } else if (t[i + 1] == 'D') {
          t[i] = 'P';
        } else {
          t[i] = 'D';
        }
      }
    }
  }
  cout << t << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3740
//エイシング2020_A
#include <stdio.h>

int main(){
	int l,r,d;
	int cnt=0;
	scanf("%d %d %d",&l,&r,&d);
	
	for(int i=l;i<=r;i++){
		if(i % d == 0)	cnt=cnt+1;
	}
	
	printf("%d",cnt);
	
	return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

// x : 開始の数(初項)
// d : 足す数(公差)
// n : x から何個後まで見るか(第 n 項)
// 例) x = 3, d = 1, n = 4 の場合 3+4+5+6=18
ll AriProSum(ll x, ll d, ll n) {
    return n * (2 * x + (n - 1) * d) / 2;
}

ll N;

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

    cin >> N;

    ll ans = AriProSum(1, 1, N - 1);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner scan;
	String s1;
	int count;

	public static void main(String args[]){
		new Main().compute();
	}
	void compute() {
		scan=new Scanner(System.in);

		s1=scan.next();
		String[] s2=s1.split("");
		
		for(int i=0;i<3;i++) {
			if(s2[i].equals("o")) {
				count++;
			}
		}
		System.out.println(700+100*count);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    int n;
    scanf("%d", &n);
    int fg = 0;
    int x;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &x);
        if (x % 2 == 0)
        {
            if (x % 3 != 0 && x % 5 != 0)
            {
                fg = 1;
            }
        }
    }
    if (fg)
        printf("DENIED\n");
    else
        printf("APPROVED\n");
    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 vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
const long long inf=1ll<<61;

signed main(){
    int a,b,c,k;cin>>a>>b>>c>>k;
    int cnt=0;
    while(a>=b){
        b*=2;cnt++;
    }
    while(b>=c){
        c*=2;cnt++;
    }
    if(cnt<=k)puts("Yes");
    else puts("No");
}

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

namespace LinearSearch
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var S = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var q = int.Parse(Console.ReadLine());
            var T = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ans = 0;
            var idx = 0;

            foreach(int num in S)
            {
                idx = Array.IndexOf(T, num);
                if (idx >= 0)
                {
                    ans++;
                    T[idx] = -1;
                }                
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 18208
#include<stdio.h>
int main()
{
  int x,y,z;

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

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

  if(x>y){
    z=x;
    x=y;
    y=z;

  }
  
  printf("%d %d\n",x,y);

  }
  
  return 0;

}

Measured memory_bytes: 600
a = input().rstrip().split(" ")

N, D = map(int,a)       #N 点の数　　D　原点からの距離（以下）

cnt = 0

for i in range(N):
    b = input().rstrip().split(" ")
    x, y = map(int,b)
    
    if x ** 2 + y ** 2 <= D ** 2:
        cnt += 1

print(cnt)

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
const double PI = acos(-1);
int n;
vector<P> t;

double Arg(P a,P b){
  return arg( b*conj(a) );
}

bool check(){
  for(int i=0;i+1<n;i++){
    double maxm=-10;
    double mini=10;
    for(int j=i+2;j<n;j++){
      P base=t[i+1]-t[i];
      P target=t[j]-t[i+1];
      maxm=max(maxm,Arg(base,target));
      mini=min(mini,Arg(base,target));
    }
    if( maxm-mini > PI )return true;
  }
  return false;
}

int main(){
  cin>>n;
  t.resize(n);
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    t[i]=P(x,y);
  }
  if( check() ){
    cout<<"Impossible"<<endl;
    return 0;
  }
  reverse(t.begin(),t.end());
  if( check() ){
    cout<<"Impossible"<<endl;
    return 0;
  }
  cout<<"Possible"<<endl;
  return 0;
}



Measured memory_bytes: 3416
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;



      cin>>n>>m;

      if(n==m)cout<<"Yes"<<endl;

      else cout<<"No"<<endl;











}



Measured memory_bytes: 3608
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        String N = scan.next();

        if(N.equals("Sunny"))
            System.out.println("Cloudy");
        else if(N.equals("Cloudy"))
            System.out.println("Rainy");
        else
            System.out.println("Sunny");
    }
}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using pii = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<pii> ab(N), cd(N);
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        ab[i] = pii(a, b);
    }
    REP(i, N) {
        int c, d;
        cin >> c >> d;
        cd[i] = pii(c, d);
    }
    sort(all(ab));
    int result = 0;
    vector<bool> used_cd(N, false);
    RREP(i, N) {
        int k = N;
        int d_min = 2 * N;
        REP(j, N) {
            if (!used_cd[j] && ab[i].first < cd[j].first && ab[i].second < cd[j].second && d_min > cd[j].second) {
                k = j;
                d_min = cd[j].second;
            }
        }
        if (k != N) {
            used_cd[k] = true;
            ++result;
        }
    }
    cout << result << endl;
    return 0;
}

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

int getMin(int arr[]) {
	int m = 100;
	for (int i = 0; i < 3; i++) {
		m = min(m, arr[i]);
	}
	return m;
}

int main(int argc, char const* argv[]) {
	int c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &c[i][j]);
		}
	}
	int a[3], b[3];
	a[0] = getMin(c[0]);
	for (int i = 0; i <= a[0]; i++) {
		for (int j = 0; j < 3; j++) {
			b[j] = c[0][j] - i;
		}
		// cout << a[0] << " " << b[0] << " " << b[1] << " " << b[2] << "\n";
		if (c[1][0] - b[0] >= 0 && c[1][0] - b[0] == c[1][1] - b[1] && c[1][1] - b[1] == c[1][2] - b[2]
				&& c[2][0] - b[0] >= 0 && c[2][0] - b[0] == c[2][1] - b[1] && c[2][1] - b[1] == c[2][2] - b[2]) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");

	return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    cout << (n+1)/2 << '\n';
    return 0;
}

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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

template<unsigned mod=998244353>struct mint {
   unsigned val;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=ll(val)*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=ll(val)*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
template<unsigned mod=998244353>struct factorial {
   using Mint=mint<mod>;
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};
using Mint=mint<>;

typedef pair<ll,ll> P;
vector<int> g[201000];

int main(){
   int n; scanf("%d",&n);
   vector<P> rs; rs.push_back({-inf,inf});
   rep(i,0,n){
      int x,d; scanf("%d%d",&x,&d);
      rs.push_back({x,x+d});
   }n++;
   sort(ALL(rs)); stack<int> st;
   rep(i,0,n){
      while(!st.empty()&&rs[st.top()].second<=rs[i].first)st.pop();
      if(!st.empty())g[st.top()].push_back(i);
      while(!st.empty()&&rs[st.top()].second<rs[i].second)st.pop();
      st.push(i);
   }
   vector<Mint> dp(n,1);
   rrep(i,n-1,-1){for(int nxt:g[i])dp[i]*=dp[nxt];dp[i]+=1;}
   dp[0]-=1; printf("%d\n",dp[0].val);
   return 0;
}

Measured memory_bytes: 15852
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
    map<char,bool> data;
    string str;
    cin >> str;
    for(int i=0;i<str.length();i++){
        data[str[i]]=true;
    }
    bool res=false;
    for(char i='a';i<='z';i++){
        if(data[i]==false){
            cout << i << endl;
            res=true;
            break;
        }
    }
    if(res==false){
        cout << "None" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
using System;
class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            int count = 0;
            for (int i = 0; i < 2; i++)
            {
                if (a <= b)
                {
                    count += b;
                    b--;
                }
                else
                {
                    count += a;
                    a--;
                }
                
            }
            Console.WriteLine(count);
        }
    }

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

int main(){

	vector<vector<int>> m(3, vector<int>(3));
	vector<vector<bool>> marca(3,vector<bool>(3,0));

	for (int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			scanf("%d", &m[i][j]);

	int n, ans = 0;
	scanf("%d", &n);

	while(n--){
		
		int b;
		scanf("%d", &b);

		for (int i=0;i<3;i++)
			for (int j=0; j<3; j++)
				if (m[i][j]==b)	marca[i][j]=1;
	}

	for (int i=0;i<3;i++){
	
			if (marca[i][0]+marca[i][1]+marca[i][2] == 3 | 
				marca[0][i]+marca[1][i]+marca[2][i] == 3 |
				marca[0][0]+marca[1][1]+marca[2][2] == 3 |
				marca[0][2]+marca[1][1]+marca[2][0] == 3){

					ans = 1;
					break;
			}
	}
	
	printf((ans) ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const int mod=1000000007;    
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

    
int main(){
  int n;cin>>n;
  int a[n],sum=0;
  rep(i,n){
    cin>>a[i];
    sum=(sum+a[i])%2;
    }
  if(sum)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
  }


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int y = tx - sx, t = ty - sy;
    for(int i=0; i<t; i++){
        cout << "U";
    }
    for(int i=0; i<y; i++){
        cout << "R";
    }
    for(int i=0; i<t; i++){
        cout << "D";
    }
    for(int i=0; i<y; i++){
        cout << "L";
    }
    cout << "L";
    for(int i=0; i<t+1; i++){
        cout << "U";
    }
    for(int i=0; i<y+1; i++){
        cout << "R";
    }
    cout << "DR";
    for(int i=0; i<t+1; i++){
        cout << "D";
    }
    for(int i=0; i<y+1; i++){
        cout << "L";
    }
    cout << "U" << endl;
    return 0;
}

Measured memory_bytes: 3508
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long ;

string s;
int c;

int main(){

	cin >> s;
	for (int i = 0; i < 4; i++){
		if (s[i] == '+') c++;
		else c--;

	}
	cout << c << endl;

	return 0;
}



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

int main() {
	int a1,  a2, a3;
	cin >> a1 >> a2 >> a3;
	
	if (a1+a2+a3 <= 21){
		cout << "win" << endl;
	}
	else {
		cout << "bust" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)//fdavdsv

        {
            for(int j=1;j<=w;++j)
            {//fdavdsv

                if(j!=w) printf("%d ",G[i][j]);//fdavdsv

                else printf("%d\n",G[i][j]);
            }//fdavdsv
        }
    }
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;

namespace AtCoder169
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputList = input.Replace(".", "").Split(" ");
            long.TryParse(inputList[0], out var a);
            long.TryParse(inputList[1], out var b);


            var abi = new BigInteger(a * b);
            var rc = $"{abi}";

            if (rc.Length < 3)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(rc.Substring(0, rc.Length - 2));
            }

        }
    }
}

Measured memory_bytes: 27760
N=int(input())
D,X=map(int,input().split())
L=[]
count=0
for i in range (N):
	L.append(int(input()))
for i in range (N):
	j=1
	while(1):
		count+=1
		if L[i]*j+1>D:
			break
		j+=1
print(count+X)

Measured memory_bytes: 3064
void main()
{
    string s = readln.chomp;

    writeln(s.countUntil("YAKI") == 0 ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<cstdio>
int sosu[10001];
int main(){
  int N;
  sosu[0]=1;
  sosu[1]=1;
  for(int i=2;i<=10000;i++){
    if(sosu[i]) continue;
    for(int j=i+i;j<=10000;j+=i){
      sosu[j]=1;
    }
  }
  while(scanf("%d",&N),N){
    for(int i=N;i>1;i--){
      //      printf("%d %d\n",sosu[i],sosu[i-2]);
      if(!sosu[i] && !sosu[i-2]){
	printf("%d %d\n",i-2,i);
	break;
      }
    }
  }
}

Measured memory_bytes: 1064
import sys
from collections import Counter
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
A_counters = Counter(A)
A.sort()
A_set = set(A)
ans = 0
for a in A:
    if a in A_set:
        if A_counters[a] == 1:
            ans += 1
        for i in range(1, A[-1] // a + 1):
            if a * i in A_set:
                A_set.remove(a * i)
print(ans)

Measured memory_bytes: 44876
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())

X, Y = map(int, input().split())
MOD = pow(10, 9) + 7

def comb_mod(n, r, mod):
  num = 1
  den = 1
  for i in range(r):
    num = (num * (n - i)) % mod
    den = (den * (i + 1)) % mod
  den_r = pow(den, mod - 2, mod)
  return (num * den_r) % mod


n = (2*Y - X) // 3
m = (2*X - Y) // 3

if (n == (2*Y - X) / 3 and m == (2*X - Y) / 3 
    and n >= 0 and m >= 0):  
  a = n + m
  b = min(n, m)
  print(comb_mod(a, b, MOD))
else :
  print (0)
  


Measured memory_bytes: 3568
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
var lines = input.split('\n');

var score = [];
var line;
while (line = lines.shift()) {
    var arr = line.split(',').map(function(n){return +n;});

    if (arr[0] + arr[1] == 0)
        break;

    score.push({id: arr[0], score: arr[1]});
}

var rank = score.map(function(o) {
    return o.score;
})
.filter(function(v,i,a) {
    return a.indexOf(v) == i;
})
.sort(function(a, b) {
    return b - a;
});

while (line = lines.shift()) {
    var id = +line;
    var team = score.filter(function(o){return o.id == id;})[0];
    var r = rank.indexOf(team.score) + 1;
    console.log(r);
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

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

int main(){
  int n,d;
  cin >> n >> d;
  int ans = (n+2*d)/(2*d+1);
  cout << ans << endl;
}


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


int main() {
	int k;
	long long c[13][10] = {};
	cin >> k;
	rep(i, 10) c[0][i] = 1;
	for(int i = 0;; i++) {
		for(int j = 1; j < 10; j++) {
			if (k > c[i][j]) {
				k -= c[i][j];
			} else  {
				long long r = j;
				i--;
				for(; i >= 0; i--) {
					if (j > 0 && c[i][j-1] >= k) {
						j = j - 1;
						r = r * 10 + j;
						continue;
					}
					if (j > 0) k -= c[i][j-1];
					if (c[i][j] >= k) {
						r = r * 10 + j;
						continue;
					}
					k -= c[i][j];
					j = j + 1;
					r = r * 10 + j;
				}
				cout << r << endl;
				return 0;
			}
		}
		for(int j = 0; j < 10; j++) {
			if (j > 0) {
				c[i+1][j] += c[i][j-1];
			}
			if (j < 9) {
				c[i+1][j] += c[i][j+1];
			}
			c[i+1][j] += c[i][j];
		}
	}
}

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

int main()
{
    int x, y;
    long long a, b;
    double k;
    cin >> a >> b;
    if(a != b)
    {
        k = (a+b)*0.5;
        if(k == int (k))
        {
            x = abs (a-k);
            y = abs (b-k);
            if (x == y)
            {
                cout << fixed << setprecision(0) << k << endl;
            }
            else
            {
                cout << "IMPOSSIBLE" << endl;
            }
        }
        else
        {
            cout << "IMPOSSIBLE" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi;
typedef vector<double> vd;
 
double mypow(double b ,int e){
      if(e == 0) return 1;
      if(e%2==0)
            return mypow( b*b, e/2 );
      else
            return mypow( b*b, e/2 ) * b;
}
 
int main(){
 
 
      int N,M,L; cin >> N >> M >> L ;
      if(N==1){
            cout << 1.0 << endl;
            return 0;
      }
      vector<vd> prob(N,vd(M+1,0.0));
      vector<vd> dist(N,vd(M+1,0.0));
 
      vd p(N),t(N),v(N);
      for(int i=0; i<N; i++) cin >> p[i] >> t[i] >> v[i];
 
      // PRE PROCESS
      for(int i=0; i<N; i++){
            dist[i][0] = (double)L / v[i];
            for(int j=1; j<=M; j++){
                  dist[i][j] = dist[i][j-1] + t[i];
            }
      }
      for(int i=0; i<N; i++)
            prob[i][0] = mypow((100-p[i])/100,M);
      for(int i=0; i<N; i++){
            for(int j=1; j<=M; j++){
                  if(p[i] != 100)
                        prob[i][j] = (prob[i][j-1] * (p[i]/100)) / ((100-p[i])/100);
                  else
                        prob[i][j] = 1.0;
            }
      }
      double comb = 1;
      for(int j=1; j<=M; j++){
            comb = comb * (M - j + 1) / j; 
            for(int i=0; i<N; i++){
                  prob[i][j] *= comb;
            }
      }
       
      vector<vd> sum = prob;
      for(int i=0; i<N; i++){
            for(int j=M-1; j>=0; j--){
                  sum[i][j] += sum[i][j+1];
                  if(sum[i][j] > 1) sum[i][j] = 1;
            }
      }
 
      vector<vd> ans = prob;
      for(int i=0; i<N; i++){
            for(int j=0; j<=M; j++){
                  for(int k=0; k<N; k++){
                        if(i==k) continue;
                        int id = upper_bound(dist[k].begin(),dist[k].end(), dist[i][j]) - dist[k].begin();
                        if(id > M) ans[i][j] = 0.0;
                        else       ans[i][j] *= sum[k][id];
 
                  }
            }
      }
 
      for(int i=0; i<N; i++){
            double tmp = 0.0;
            if(p[i] == 100) tmp = ans[i][M];
            else
                  for(int j=0; j<=M; j++)
                        tmp += ans[i][j];
            if(tmp > 1) tmp = 0;
            printf("%.10f\n",tmp);
      }
                         
}

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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int output = 0;
  for (int i = 1; i <= n; ++i) {
    output += i;
  }
  std::cout << output << std::endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] tmp = scanner.nextLine().split(" ");
		int n        = Integer.parseInt(tmp[0]);
		int q        = Integer.parseInt(tmp[1]);
		char[] s     = scanner.nextLine().toCharArray();
		int[]  sum   = new int[n];


		for(int i = 1; i < n; i++) {

			if(s[i - 1] == 'A' && s[i] =='C') {

				sum[i]++;
			}

			sum[i] += sum[i - 1];
		}

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

			int a = scanner.nextInt() - 1;
			int b = scanner.nextInt() - 1;

			System.out.println(sum[b] - sum[a]);
		}

	}

}


Measured memory_bytes: 62856
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&!(1<<i);}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const int inf = 0xFFFFFFFFFFFFFFFL; //very large number
// priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int rangesum(int lo, int hi, vi& pre) {
	if(lo==0)
		return pre[hi]%MOD;
	return (pre[hi]-pre[lo-1]+MOD)%MOD;
}
int32_t main(void)
{
	IOS;
	int n, m; cin>>n>>m;
	vector<vi> adjlist(m+1);
	for(int i = 0; i < n; i++) {
		int a,b; cin>>a>>b;
		if(a > m)
			continue;
		adjlist[a].pb(b);
	}
	priority_queue<int> pq;
	int sum=0;
	for(int i = 1; i <= m; i++) {
		for(int j = 0; j < adjlist[i].size(); j++) {
			pq.push(adjlist[i][j]);
		}
		if(!pq.empty()) {
			sum += pq.top();
			pq.pop();
		}
	}
	cout<<sum<<endl;
	time();
	return 0;
}

Measured memory_bytes: 5632
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstring>
#define R register
#define EN std::puts("")
#define LL long long
inline LL read(){
	LL x=0,y=1;
	char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=0;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return y?x:-x;
}
//a:abs大的负数->abs小的负数->小正数->大正数
//b:大正数->小正数->abs小的负数->abs大的负数 
int n,fir;//a[fir]是a数组中第一个非负数
LL k;
LL a[200006],b[200006];
inline int finda(int i,LL ans){
	R int l=1,r=n,mid,ret=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(a[mid]*a[i]<ans) ret=mid,l=mid+1;
		else r=mid-1;
	}
	return ret>=i?(ret-1):ret;//如果ret>=i，说明其中有一对是两个a[i]相乘得到，此时要减1
}
inline int findb(int i,LL ans){
	R int l=1,r=n,mid,ret=0;
	while(l<=r){
		mid=(l+r)>>1;
		if(b[mid]*a[i]<ans) ret=mid,l=mid+1;
		else r=mid-1;
	}
	return (ret+i>n)?(ret-1):ret;//同理，但b是倒序
}
inline int check(LL ans){
	LL nowk=0;
	for(R int i=1;i<fir;i++)//负数 
		nowk+=findb(i,ans);
	for(R int i=fir;i<=n;i++)//正数
		nowk+=finda(i,ans);
	nowk/=2;//去重
	return nowk>=k;
}
inline int cmp(int x,int y){
	return x<y;
}
int main(){
	n=read();k=read();
	for(R int i=1;i<=n;i++) a[i]=read(); 
	std::sort(a+1,a+1+n,cmp);
	fir=n+1;
	for(R int i=1;i<=n;i++)
		if(a[i]>=0){fir=i;break;}
	for(R int i=1;i<=n;i++) b[n-i+1]=a[i];//存入b数组，对负数二分时使用
	R LL l=-1e18,r=1e18,mid,ans;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	std::printf("%lld",ans-1);
	return 0;
}

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

int main () {
  ll N;
  cin >> N;

  cout << (N % 2 ?  N*2 : N) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define INF 10000

struct edge {int to, cap, rev;};

vector<edge> G[202];
bool used[202];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge{to, cap, (int)G[to].size()}));
    G[to].push_back((edge{from, 0, (int)G[from].size()-1}));
}

int dfs(int v, int t, int f, vector<edge> G[]){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap), G);
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int main(){
    int N;
    int a[101], b[101], c[101], d[101];
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> a[i] >> b[i];
        add_edge(0, i, 1);
    }
    for(int i = 1; i <= N; i++){
        cin >> c[i] >> d[i];
        add_edge(N+i, 2*N+1, 1);
    }
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            if(a[i] < c[j] && b[i] < d[j]){
                add_edge(i, N+j, 1);
            }
        }
    }
    int flow = 0;
    while(true){
        memset(used, 0, sizeof(used));
        int f = dfs(0, 2*N+1, INF, G);
        if(f == 0){
            cout << flow << endl;
            break;
        }
        flow += f;
    }
}

Measured memory_bytes: 384
#include<stdio.h>

int A[2000001],B[2000001],C[100001];

int main(){
  int n,i,j,k = 0;

  
  scanf("%d", &n);
  for( i = 1; i <= n; i++ ) {
    scanf("%d", &A[i]);
    if(A[i]>k){
      k=A[i];
    }
  }
  
  for(i=0;i<=k;i++){
    C[i]=0;
  }
  
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
  
  return 0;
}

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

ll x = 1e9 + 7; 
const int INF = 1001001001;


int main() {
  int n;
  cin >> n;
  vector<ll> d(n+1);
  vector<ll> a(n+1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    d[a[i]]++;
  }
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += d[i]*(d[i]-1)/2;
  }
  for (int i = 1; i <= n; i++) {
    ll ans = sum;
    ans -= d[a[i]]*(d[a[i]]-1)/2;
    ans += (d[a[i]]-1)*(d[a[i]]-2)/2;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 6404
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}
int main() {
    int n,div=2,k;

    int ans;
    int max,min;
    int a[1000000]={};

    cin >> n>>k ;
    for(int i=0;i<n;i++) {
        cin >> a[i];
    }
    qsort(a,n,sizeof(int),int_sort);
    //for(int i=0;i<n;i++)
        //cout<<a[i]<<endl;

    ans=a[0]-a[k-1];
    for(int i=1;i<=n-k;i++){
        //cout<<a[i]-a[i+k-1]<<endl;
        if(ans>=a[i]-a[i+k-1])
            ans=a[i]-a[i+k-1];
    }
    cout<<ans;
    return 0;
}




Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
void err() {
  cout << "NO" << endl;
  exit(0);
}
inline bool chmin (int& a, int b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
inline bool chmax (int& a, int b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  vector<int> w(2), s(2);
  int n;
  cin >> w[0] >> w[1] >> n >> s[0] >> s[1];
  s[0]--, s[1]--;
  vector<vector<int>> dir(2, vector<int>(n, 0)), eir(2, vector<int>(n, 0));
  for (int p = 0; p < 2; p++) {
    for (int i = 0; i < n; i++) {
      char c;
      cin >> c;
      if (c == 'U') dir[0][i]--;
      if (c == 'D') dir[0][i]++;
      if (c == 'L') dir[1][i]--;
      if (c == 'R') dir[1][i]++;
    }
    swap(dir, eir);
  }

  for (int q = 0; q < 2; q++) {
    int l(0), r(w[q]);
    for (int i = n - 1; i >= 0; i--) {
      if (eir[q][i] == -1) r++, chmin(r, w[q]);
      if (eir[q][i] == +1) l--, chmax(l, 0);
      if (dir[q][i] == -1) l++;
      if (dir[q][i] == +1) r--;
      if (r - l < 1) err();
    }
    if (s[q] < l || r <= s[q]) err();
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 4208