akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int, int>;

int main() {
    int H, W, M;
    cin >> H >> W >> M;
    map<pair<int, int>, int> mp;
    vector<int> tate(W), yoko(H);
    rep(i, M) {
        int h, w;
        cin >> h >> w;
        h--, w--;
        mp[{h, w}]++;
        tate[w]++;
        yoko[h]++;
    }
    vector<P> X, Y;
    rep(i, H) X.emplace_back(yoko[i], i);
    rep(i, W) Y.emplace_back(tate[i], i);
    sort(X.rbegin(), X.rend());
    sort(Y.rbegin(), Y.rend());

    int ans = 0;

    rep(i, H) rep(j, (int)min(10, (int)Y.size())) {
        auto[cnt, h] = X[i];
        auto[cnt2, w] = Y[j];
        int tmp = cnt + cnt2;
        if(mp.find({h, w}) != mp.end()) tmp--;
        ans = max(ans, tmp);
    }

    rep(i, (int)min(10, (int)X.size())) rep(j, W) {
        auto[cnt, h] = X[i];
        auto[cnt2, w] = Y[j];
        int tmp = cnt + cnt2;
        if(mp.find({h, w}) != mp.end()) tmp--;
        ans = max(ans, tmp);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 32680
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


int main(){
	double mindiff=1e10;
	int t,d;
	int ta,tb,da,db;
	cin>>t>>d>>ta>>tb>>da>>db;

	for(int va=0;va<=d;va+=da){
		for(int vb=0;va+vb<=d;vb+=db){
			double tmp=(double)(ta*va+tb*vb)/(va+vb);
			if(fabs(tmp-t)<mindiff){
				mindiff=fabs(tmp-t);
			}
		}
	}
	printf("%.4f\n",mindiff);
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const ll mod=1000000007;
/*ll fast_mul(ll x,ll y)
{
	ll temp=x*y-(ll)((long double)x*y/mod+1.0e-8)*mod;
	return temp<0?temp+mod:temp;
}*/
ll fast_mul(ll x,ll y)
{
	ll temp=(x*y-(ll)((long double)x*y/mod)*mod+mod)%mod;
	return temp;
}
int main()
{
	ll n,k,s,i,j,x,y,p=0,q=0,a[2005];
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
				p++;
			}
		}
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[j]>a[i]){
				q++;
			}
		}
	}
	if(k%2==0){
		x=k/2;
		y=k-1;
	}
	else{
		x=k;
		y=(k-1)/2;
	}
	s=(p*k)%mod+(fast_mul(x,y)*q)%mod;
	cout<<s%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
divide = ['dream','dreamer','erase','eraser']
dp = [0] * 100010
dp[0] = 1
for i in range(len(s)):
    # print(i)
    # print(dp)
    if dp[i] == False:
        continue
    for str in divide:
        # print(s[i:i+len(str)])
        if s[i:i+len(str)] == str:
            dp[i + len(str)] = 1

print("YES") if dp[len(s)] else print("NO")



Measured memory_bytes: 3956
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        d: usize,
    }
    let man = 2 * d + 1;
    let mut ans = 0;
    let mut tmp = 0;
    while tmp < n {
        ans += 1;
        tmp += man;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	private class DisjointSet {
		
		int[] p, rank;
		
		public DisjointSet(int size) {
			p = new int[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = x;
			rank[x] = 0;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}

//		private int findSet(int x) {
//			while (x != p[x]) {
//				x = p[x];
//			}
//			return p[x];
//		}
		
		private int findSet(int x) {
			if (x != p[x]) {
				p[x] = findSet(p[x]);
			}
			return p[x];
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] > rank[y]) {
				p[y] = x;
			} else {
				p[x] = y;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x= Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


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

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> ans;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (i + j != n + (n % 2 == 0)) {
        ans.emplace_back(i, j);
      }
    }
  }
  cout << ans.size() << "\n";
  for (auto p : ans) {
    cout << p.first << " " << p.second << "\n";
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    int sum=0;
    for (int i=1; i<=b-a; i++) {
        sum += i;
    }
    cout<<sum-b<<endl;
    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int H, W, D, Q;
    int dist[99000];
    map<int, pair<int, int>> mp;
    cin >> H >> W >> D;
    rep(y, H){
        rep(x, W){
            int A;
            cin >> A;
            mp[A] = make_pair(x+1, y+1);
        }
    }

    FOR(i, D+1, H*W+1){
        dist[i] = dist[i-D] + abs(mp[i].first - mp[i-D].first) + abs(mp[i].second - mp[i-D].second);
    }

    cin >> Q;
    while(Q--){
        int L, R;
        cin >> L >> R;
        cout << dist[R] - dist[L] << "\n";
    }

    return 0;
}

Measured memory_bytes: 7168
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

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

const int MX=1003;
char s[MX],t[MX];

int main()
{
    scanf("%s %s",s,t);
    int n=strlen(s),m=strlen(t);
    int ans=m;
    for(int i=0;i+m<=n;i++){
        int c=0;
        for(int j=i;j<i+m;j++){
            if(s[j]!=t[j-i]) c++;
        }
        ans=min(ans,c);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3820
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/28/2019 8:00:12 PM
*************************************************************************/
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//ifstream cin("C:\\Users\\LENOVO\\Desktop\\in.txt");
	//ofstream cout("C:\\Users\\LENOVO\\Desktop\\out.txt");
	ll n,a,b;cin>>n>>a>>b;
	ll t=b-a;
	if(t&1LL) cout<<t/2+min(a-1,n-b)+1<<endl;
	else cout<<t/2<<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)

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  x -= (y + 2 * z);
  cout << 1 + (x / (y + z)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define double long double
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<double, double>;

double dist(ii a, ii b){
	return sqrt(pow(a.ff-b.ff, 2)+pow(a.ss-b.ss, 2));
}
int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<ii> vs(n);
	for(auto &x:vs)
		cin >> x.ff >> x.ss;
	double ans = 0.0;
	double tam = 0;
	sort(all(vs));
	do{
		tam+=1;
		for(int i=1; i<n; ++i)
			ans += dist(vs[i], vs[i-1]);
	}while(next_permutation(all(vs)));
	cout << fixed << setprecision(10) << ans/tam << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	ll x,y;
	cin >> x >> y;
	ll z=4*x;
	ll raj=z-y;
	
	
	if(y%2!=0)
	{
		cout << "No";
		return 0;	
	}
	
	ll a=2*x;
	ll b=4*x;
	
	if(y>=a && y<=b)
	{
		cout << "Yes";
	}
	else
	cout << "No";
		
	
}


Measured memory_bytes: 3616
main(){float a,b,c,d,e,f,x;for(;~scanf("%f%f%f%f%f%f",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(c-b*x)/a,x/=a*e-b*d))x=a*f-d*c;exit(0);}

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

typedef long long LL;  //Attention!!
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;

int main()
{
ios_base::sync_with_stdio(0); cout.precision(15);cout.setf(ios::fixed);
int n,l,i;

cin>>n>>l;

vector <string> v(n);

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

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

for(i=0;i<n;i++)
	cout<<v[i];
cout<<endl;

}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
const int N = 4005;
const int inf = 0x3f3f3f3f;
typedef long long ll;
vector<int>VR,VG,VB;
char a[N];
/*void find(int x)
{
    if(f[x]==x)
        return x;
    else
       {
           f[x]=find(f[x]);
            return f[x];
       }
}
void merge(int i,int j)
{
    fa[find(i)]=find(j);
}*/
ll sum=0;
int main()
{
    int n;
    scanf("%d",&n);
    char s[4005];
    scanf("%s",s+1);

    //printf("%s",s);
    ll R=0,G=0,B=0;
    for(int i=1; i<=n; i++)
    {
        if(s[i]=='R')
            R++;
        if(s[i]=='G')
            G++;
        if(s[i]=='B')
            B++;
    }
    sum=R*G*B;
    ll x=0;
    //printf("%lld\n",sum);
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            if(2*j-i<=n)
            {
                if(s[i]!=s[j]&&s[i]!=s[2*j-i]&&s[j]!=s[2*j-i])
                    x++;
            }
        }
    }
    printf("%lld\n",sum-x);
    return 0;
}


Measured memory_bytes: 3832
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;

int main(){
    int a, b, c, x, ans=0;
    cin >> a >> b >> c >> x;
    for(int i = 0;i <= a;i++){
        for(int j = 0;j <= b;j++){
            for(int k = 0;k <= c;k++){
                if(500*i + 100*j + 50*k == x) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

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

	ll t=1;
	//cin >> t;

	for(ll i=1;i<=t;i++){
		ll x,k,d;
		cin >> x >> k >> d;

		long double temp=(x*1.0/(2*d));
		temp=temp+(k*1.0/2);

		//cout << temp << endl;

		ll j1=floor(temp);
		ll j2=ceil(temp);

		//cout << j1 << " " << j2 << endl;

		if(j2>=1 && j2<=k){

			ll m1=x+(d*(k-2*j1));
			ll m2=x+(d*(k-2*j2));
			m1=abs(m1);
			m2=abs(m2);

			cout << min(m1,m2) << "\n";

		}
		else{
			ll m1=x-(d*k);
			ll m2=x+(d*k);
			m1=abs(m1);
			m2=abs(m2);
			cout << min(m1,m2) << "\n";
		}
	}
}


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

int main() {
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    sort(all(h));
    double ans = h[0];
    for(int i =1;i<N;i++){
      ans = (ans +h[i])/2.0;
    }
 
    cout<<setprecision(10)<<ans<<endl;
    return 0;    
}

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

int ord (const void * x, const void * y){
	const int a = *(int *)x, b = *(int *)y;
	
	if (a > b)
		return -1;
	if (a < b)
		return 1;
	
	return 0;
}


int main(){

	int n, k;
	
	scanf("%d%d", &n, &k);
	
	int num[n];
	
	for (int i = 0; i < n; ++i){
		scanf("%d", &num[i]);
	}
	
	qsort(num,n,sizeof(num[0]), ord);
	
	int soma = 0;
	
	for (int p = 0; p < k; p++){
		soma += num[p];
	}
	
	printf("%d\n", soma);

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// A -> 0
// C -> 1
// G -> 2
// T -> 3
// prohibited: ?AGC, ?GAC, ?ACG, A?GC, AG?C
// prohibited: ?021, ?201, ?012, 0?21, 02?1

// dp[i][j][k][l] .. the count in position i with suffix j,k,l.
// dp[i+1][j][k][l] = sum dp[i][x][j][k] where (S[x,j,k,l] is not in [?AGC, ?GAC, ?ACG, A?GC, AG?C])
ll dp[105][4][4][4];

int main(int argc, char** argv) {
  int N;
  cin >> N;
  rep(j, 4) {
    rep(k, 4) {
      rep(l, 4) {
        if ((j == 0) && (k == 2) && (l == 1)) { continue; }
        if ((j == 2) && (k == 0) && (l == 1)) { continue; }
        if ((j == 0) && (k == 1) && (l == 2)) { continue; }
        dp[2][j][k][l] = 1;
      }
    }
  }

  for (int i = 2; i < N-1; ++i) {
    rep(j, 4) rep(k, 4) rep(l, 4) {
      rep(x, 4) {
        if ((j == 0) && (k == 2) && (l == 1)) { continue; }
        if ((j == 2) && (k == 0) && (l == 1)) { continue; }
        if ((j == 0) && (k == 1) && (l == 2)) { continue; }
        if ((x == 0) && (k == 2) && (l == 1)) { continue; }
        if ((x == 0) && (j == 2) && (l == 1)) { continue; }
        dp[i+1][j][k][l] += dp[i][x][j][k];
        dp[i+1][j][k][l] %= MOD;
      }
    }
  }

  ll ans = 0;
  rep(j, 4) {
    rep(k, 4) {
      rep(l, 4) {
        ans += dp[N-1][j][k][l];
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}


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

int main() {
  string s;
  int n;
  cin >> s >> n;
  for(int i = 0; i < n; i++) {
    string order;
    cin >> order;
    int a, b;
    cin >> a >> b;
    if(order == "print") {
      string sub = s.substr(a, b - a + 1);
      cout << sub << "\n";
    }else if(order == "reverse") {
      string sub = s.substr(a, b - a + 1);
      reverse(sub.begin(), sub.end());
      s.replace(a, b - a + 1, sub);
    }else {//order == "replace"
      string sp;
      cin >> sp;
      s.replace(a, b - a + 1, sp);
    }
  }
}


Measured memory_bytes: 3208
import numpy as np


def solve():
    sheet = np.zeros(9)
    bingo_inds = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 4, 6], [0, 3, 6], [1, 4, 7], [2, 5, 8]]
    for bi in b:
        if bi in hm:
            sheet[hm[bi]] = 1
    for bi in bingo_inds:
        if sum(np.take(sheet, bi)) == 3:
            print("Yes")
            exit()
    print("No")


r1 = [int(s) for s in input().split(" ")]
r1.extend([int(s) for s in input().split(" ")])
r1.extend([int(s) for s in input().split(" ")])
hm = {v: i for i, v in enumerate(r1)}
n = int(input())
b = [int(input()) for i in range(n)]
solve()


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	int64 res = (N-1)*N/2;
	cout << res << endl;
}


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

int n,d,x,a;

int main(){
	scanf("%d%d%d",&n,&d,&x);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		x+=(int)ceil((double)d/(double)a);
	}
	printf("%d\n",x);
	return 0;
}

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

signed main() {
	string str;
	cin >> str;
	bool flag = 1, C = 0;
	for (int i = 0; i < (int)str.size(); ++i) {
		if (i == 0 && str[i] != 'A') {
			flag = 0;
		} else if (i > 0) {
			if (str[i] >= 'A' && str[i] <= 'Z') {
				if (C) {
					//cout << 1 << endl;
					flag = 0;
				}
				else if (i > 1 && i < (int)str.size()-1 && str[i] == 'C') {
					//cout << i << "  " << 1 << " " << str.size()-1 << " " << str[i] << endl;
					//cout << 3 << endl;
					C = 1;
				}
				else {
					//cout << str[i] << " " << 2 << endl;
					flag = 0;
				}
			}
		}
	}
	if (flag && C)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main() {
	FASTIO;
	int n;
	cin >> n;
	map<string, int> m;
	rep(i, n) {
	    string s;
	    cin >> s;
	    m[s] += 1;
	}
	vector<pair<string, int>> v;
	v.eb(pair("a", 0));
	for(auto &a : m) {
	    if(a.second == v[0].second) {
	        v.eb(a);
	    } else if(a.second > v[0].second) {
	        v.clear();
	        v.eb(a);
	    }
	}
	for(auto &a : v) {
	    cout << a.first << endl;
	}
}

Measured memory_bytes: 29320
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    {
        string s;
        string en = "";
        string bg = "";

        cin >> s;
        in(q);
        ll val = 0;
        fw(i, 0, q)
        {
            in(n);
            if (n == 1)
            {
                if (val)
                    val = 0;
                else
                {
                    val = 1;
                }
            }
            if (n == 2)
            {
                in(f);
                string y;
                cin >> y;

                if (val)
                {
                    if (f == 1)
                    {
                        en = en + y;
                    }
                    else
                    {
                        bg = y + bg;
                    }
                }
                else
                {
                    if (f == 1)
                    {
                        bg = y + bg;
                    }
                    else
                    {
                        en += y;
                    }
                }
            }
        }
        if (val)
        {
            s = bg + s + en;
            reverse(s.begin(), s.end());
            cout << s << endl;
        }
        else
        {
            // reverse(bg.begin(), bg.end());
            // reverse(s.begin(), s.end());
            cout << bg << s << en << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4300
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,sum=0;
  cin>>a>>b;
  sum=a+b;
  if(sum == 3)
    cout<<'3';
  else if(sum == 4)
    cout<<"2";
  else if(sum == 5)
    cout<<"1";
  return 0;
}

Measured memory_bytes: 256
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Thursday August 13, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof arr)
#define ll    int64_t

const int oo  = (int)(1e9);
const ll lloo  = (ll)(1e18);

const int N = 1e5 + 10;

class Task {
public:
    
    int n, k;
    vector<int> A;

    ll dp[N];

    ll go(int index) {
        if(index > n) return 0LL;
        if(index == n) {
            return 0LL;
        }

        ll &ans = dp[index];
        if(ans != -1) return ans;

        ll x = oo;
        
        for(int i = 1; i <= k; ++i){            
            if(index+i <= n) {
                x = min(x, abs(A[index]-A[index+i]) + go(index + i));
            }
        }
        if(x == oo) {
            x = 0;
        }
        ans = x;
        return ans;
    }


    ll solveOne(istream &in, ostream &out) {
        in >> n >> k;
        A.resize(n+1);
        for(int i = 1; i <= n; ++i){
            in >> A[i];
        }
        memset(dp, -1, sizeof dp);
        ll ans = go(1);
        return ans;  
    }
    
    void solve(istream &in, ostream &out) {
        int t=1;
        while(t--) {
            out << solveOne(in, out) << endl;
        }
    }
};

auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}



Measured memory_bytes: 12168
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;
long long  a[N],b[N];
int main()
{
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
	int k;
	cin>>k;
	int a=7%k;
	for(int i=1;i<=1e6;i++)
	{
		if(a==0)
		{
			cout<<i;
			return 0;
		}
		a=(long long )(a*10+7)%k;



	}
	cout<<"-1"<<endl;
}


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

int main()
{
     long long n,m,a[200005],b[200005],i,j,k,dp[2002][2002]={0},mod=1e9+7;
     cin>>n>>m;
     for(i=0;i<n;i++)   cin>>a[i];
     for(i=0;i<m;i++)   cin>>b[i];
     
     for(i=0;i<n;i++){
         for(j=0;j<m;j++){
            
                dp[i][j]=(mod+dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
            if(a[i]==b[j])
                dp[i][j]+=(1+dp[i-1][j-1])%mod;
            //cout<<dp[i][j]<<' ';
        }
    }
    cout<<(dp[n-1][m-1]+1)%mod;
}   


Measured memory_bytes: 34688
H, W = map(int, input().split())
 
Ss = [[-1 if c == "#" else 0 for c in input()] for _ in range(H)]
 
def plus(i, j):
  if 0 <= i < H and 0 <= j < W:
    if Ss[i][j] >= 0:
      Ss[i][j] += 1
 
for i in range(H):
  for j in range(W):
    if Ss[i][j] != -1:
      continue
    for x, y in ((x,y) for x in range(-1, 2) for y in range(-1, 2)):
      if x != 0 or y != 0:
        plus(i+x, j+y)
 
for i in range(H):
  for j in range(W):
    print("#" if Ss[i][j] == -1 else Ss[i][j], end="")
  print()

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    int ans = 1;
    while((ans << 1) <= N) ans <<= 1;
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		int[][] letters = new int[number][26];
		int[] minletters = new int[26];
		for (int i = 0; i < number; i++) {
			String line = sc.next();
			for (int j = 0; j < line.length(); j++) {
				letters[i][(int)line.charAt(j)-97]++;
			}
		}
		for (int column = 0; column < 26; column++) {
			int smallest = 0;
			for (int row = 0; row < number; row++) {
				if (row == 0) {
					smallest = letters[row][column];
				}
				if (letters[row][column] < smallest) {
					smallest = letters[row][column];
				}
			}
			minletters[column] = smallest;
		}
		for (int index = 0; index < 26; index++) {
			for (int times = 0; times < minletters[index]; times++) {
				System.out.print((char)(index+97));
			}
		}
	}
}


Measured memory_bytes: 20948
n=int(input())
s=[]
h=[]
c=[]
d=[]

for i in range(n):
    a,b=map(str,input().split())
    if a=="S":
        s.append(int(b))
    if a=="H":
        h.append(int(b))
    if a=="C":
        c.append(int(b))
    if a=="D":
        d.append(int(b))
for i in range(1,14):
    if i in s:
        pass
    else:
        print("S",i)
for i in range(1,14):
    if i in h:
        pass
    else:
        print("H",i)
for i in range(1,14):
    if i in c:
        pass
    else:
        print("C",i)
for i in range(1,14):
    if i in d:
        pass
    else:
        print("D",i)



Measured memory_bytes: 5604
#include<cstdio>
#include<iostream>
using namespace std;
int x,y,z,num,ans;
int main() {
	scanf("%d%d%d%d",&x,&y,&z,&num);
	for(int i=0; i<=x; i++) {
		if(i*500>num) break;
		for(int j=0; j<=y; j++) {
			if(i*500+j*100>num) break;
			for(int g=0; g<=z; g++) {
				if(i*500+j*100+50*g>num) break;
				if(i*500+j*100+50*g==num) ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}/*
洛殿佑我AC此题！！*/

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)
MOD = 10**9 + 7

lcm = A.inject(1){|a, e| a = a.lcm(e)}
puts A.inject(0){|a, e| a = (a + lcm / e) } % MOD


Measured memory_bytes: 75900
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <cstring>
#include <string>
#include <limits.h>
#include <algorithm>

using namespace std;

typedef long long int LLN;

int main(){
    int N, D, X;
    while(scanf("%d%d%d", &N, &D, &X) != -1){
        --D;
        int total_cho = X;
        for(int i = 0; i < N; ++i){
            int A = 0;
            scanf("%d", &A);
            total_cho += (D / A) + 1;
        }

        printf("%d\n", total_cho);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;

    ll t = 1900 * m + (n - m) * 100;
    ll ip = 1;
    rep(i, m) ip *= 2;
    put(t * ip);

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define STIZE(x) fprintf(stderr, "STIZE%d\n", x);
#define PRINT(x) fprintf(stderr, "%s = %d\n", #x, x);
#define NL(x) printf("%c", " \n"[(x)]);
#define lld long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(a) begin(a),end(a)
#define sz(a) int((a).size())
#define LINF 1000000000000000
#define INF 1000000000
#define EPS 1e-9
using namespace std;


int main() {
    string x; cin >> x;
    for(int i = 0; i < sz(x); i++) {
        if(x[i] == '9') return printf("Yes"), 0;
    }
    printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long w,h,n,x[200],y[200],a[200],t,b,r,l,ans,height,side;
  cin >> w >> h >> n;
  for(int i=0;i < n;i++){
    cin >> x[i] >> y[i] >> a[i];
  }
  l=0;
  b=0;
  r=w;
  t=h;
  for(int i=0;i<n;i++){
    switch(a[i]){
      case 1:
        if(l < x[i]) l = x[i];
        break;
      case 2:
        if(r > x[i]) r = x[i];
        break;
      case 3:
        if(b < y[i]) b  = y[i];
        break;
      case 4:
        if(t > y[i]) t = y[i];
        break;
    }
  }
  side = r - l;
  height = t -b;
  if(side <= 0 || height <= 0)ans = 0;
  else ans = side * height;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//#define TEST

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string s;
    static List<int> dx; // x軸方向の移動距離
    static List<int> dy; // y軸方向の移動距離
    static int x;
    static int y;

    static void Main()
    {
        s = Console.ReadLine();
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        x = input[0];
        y = input[1];
        dx = new List<int>();
        dy = new List<int>();

        int c = 0;
        bool f = false; // trueならx軸方向、falseならy軸方向
        int st = 0;
        while (st < s.Length && s[st] != 'T')
            st++;
        dx.Add(st);
        for (int i = st + 1; i < s.Length; i++)
        {
            if (s[i] == 'F')
            {
                c++;
                continue;
            }
            if (f && c > 0)
                dx.Add(c);
            else if (!f && c > 0)
                dy.Add(c);
            c = 0;
            f = !f;
        }
        if (f)
            dx.Add(c);
        else
            dy.Add(c);

#if TEST
        foreach (var i in dx)
            Console.Write("{0} ", i);
        Console.WriteLine();
        foreach (var i in dy)
            Console.Write("{0} ", i);
        Console.WriteLine();
#endif

        /* dpx[x,i] : dxをi+1番目まで見て、x-8000に到達可能か */
        bool[,] dpx = new bool[16001, dx.Count];
        dpx[dx[0] + 8000, 0] = true;
        for (int i = 1; i < dx.Count; i++)
        {
            int xl = dx[i];
            for (int j = 0; j <= 16000; j++)
            {
                if (j - xl >= 0)
                {
                    dpx[j, i] = dpx[j - xl, i - 1];
                }
                if (j + xl <= 16000)
                {
                    dpx[j, i] = dpx[j, i] || dpx[j + xl, i - 1];
                }
            }
        }
        bool xf = dpx[x + 8000, dx.Count - 1];

#if TEST
        Console.WriteLine(xf);
#endif

        /* dpy[y,i] : dyをi番目まで見て、y-8000に到達可能か */
        bool[,] dpy = new bool[16001, dy.Count + 1];
        dpy[8000, 0] = true;
        for (int i = 0; i < dy.Count; i++)
        {
            int yl = dy[i];
            for (int j = 0; j <= 16000; j++)
            {
                if (j - yl >= 0)
                {
                    dpy[j, i + 1] = dpy[j - yl, i];
                }
                if (j + yl <= 16000)
                {
                    dpy[j, i + 1] = dpy[j, i + 1] || dpy[j + yl, i];
                }
            }
        }
        bool yf = dpy[y + 8000, dy.Count];
#if TEST
        Console.WriteLine(yf);
#endif

        Console.WriteLine((xf && yf) ? "Yes" : "No");
    }
}

Measured memory_bytes: 75736
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster
    
    int x;
    
    cin>>x;
    
    if(x>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;




    return 0;
}


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

int main(){
    int n;
    cin>>n;
    map<string,int>mp;
    rep(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans=0;
    for(auto& p:mp){
        int s=p.second;
        ans+=(ll)s*(s-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11136
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

template<typename T> inline T absdiff(T a, T b) { return (a - b) * (static_cast<T>(a > b) * 2 - 1); }

signed main()
{
    int x, n;
    cin >> x >> n;
    V<bool> v(102, true);
    REP(i, n) {
        int p;
        cin >> p;
        v[p] = false;
    }

    int d = INF, ans = 0, i=0;
    while(i < 102) {
        if (v[i]) {
            if (absdiff(x, i) < d) {
                d = absdiff(x, i);
                ans = i;
            }
        }
        i++;
    }

    col(ans);
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int n, k;
string s;
vector<int> order;
vector<int> tmp;
vector<int> sa;

bool compare_sa(const int &i, const int &j)
{
  if(order[i] != order[j]) return order[i] < order[j];
  else
  {
    int ri = i + k <= n ? order[i+k] : -1;
    int rj = j + k <= n ? order[j+k] : -1;
    return ri < rj;
  }
}

void construct_sa()
{
  for(int i = 0; i <= n; i++)
  {
    sa[i] = i;
    order[i] = i < n ? s[i] : -1;
  }
  for(k = 1; k <= n; k*=2)
  {
    sort(sa.begin(),sa.end(),compare_sa);
    tmp[sa[0]] = 0;
    for(int i = 1; i <= n; i++)
      tmp[sa[i]] = tmp[sa[i-1]] + (compare_sa(sa[i-1],sa[i])?1:0);
    for(int i = 0; i <= n; i++)
      order[i] = tmp[i];
  }
}

void init()
{
  n = s.size();
  order.resize(n+1);
  tmp.resize(n+1);
  sa.resize(n+1);
  construct_sa();
}

bool contain(string t)
{
  int l=0, r=n;
  while(r-l>1)
  {
    int m = (l+r)/2;
    if(s.compare(sa[m],t.size(),t)<0) l = m;
    else r = m;
  }
  return s.compare(sa[r],t.size(),t) == 0;
}

int main(){

	cin >> s;
	string t;
	int q ; cin >> q;
	init();
	construct_sa ();
	for (int i = 0; i < q; ++i)
	 {
	 	cin >> t;
	 	cout << contain(t) << endl;
	 } 
	 return 0;
}

Measured memory_bytes: 15832
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

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

class Work {
    public:
        int a; // days
        int b; // values

        bool operator < (const Work &other) const {
            return b < other.b;
        }
};

typedef priority_queue<Work> PriorityQueue;

const int MAX_N = 100000;
const int MAX_M = 100000;

int solve(const int N, const int M, const vector<Work> &works) {
    PriorityQueue queue;
    int acc = 0;
    int i = 0;
    for (int m = 1; m <= M; m++) {
        while (i < N && works[i].a <= m) {
            queue.push(works[i]);
            i++;
        }
        if (!queue.empty()) {
            Work w = queue.top();
            acc += w.b;
            queue.pop();
        }
    }
    return acc;
}

int main(void) {
    int N, M;
    cin >> N >> M;

    vector<Work> works;
    for (int i = 0; i < N; i++) {
        Work w;
        cin >> w.a >> w.b;
        works.push_back(w);
    }
    sort(works.begin(), works.end(), [](const Work &x, const Work &y) {
            return x.a < y.a;
            });

    cout << solve(N, M, works) << endl;

    return 0;
}


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

#define llint long long int
#define pb push_back

using namespace std;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  int a[] = {3, 5, 7, 9, 11, 13 };
  vector<int> v;
  for(int i = 0; i < 6; i++)
    for(int j = i+1; j < 6; j++)
      for(int k = j+1; k < 6; k++)
        v.pb(a[i]*a[j]*a[k]);
  sort(v.begin(), v.end());
  int i = 0;
  while(v[i] <= n)
    i++;
  cout << i;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
 
  int a,b,c,tmp;
 
  scanf("%d%d",&a,&b);
 
 if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
 

  c=a%b;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
 

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

Measured memory_bytes: 592
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define met(a,b); memset(a,b,sizeof(a));
typedef long long ll;
using namespace std;
double pai=3.141592653589793;
 
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
 
// inline long long read() {
//     long long tmp=0, fh=1; char c=getchar();
//     while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
//     while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
//     return tmp*fh;
// }
int main(){
    ll h,n;
    cin>>h>>n;
    for(int i=0;i<n;i++)
    {
        ll t;
        cin>>t;
        h-=t;
        if(h<=0){
            cout<<"Yes";
            exit(0);
        }
    }
    cout<<"No";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        var lists = new List<Vec>();
        for(int i=0; i<n; i++){
            string[] str = Console.ReadLine().Split(' ');
            lists.Add(new Vec(str[0], str[1]));
        }
        foreach(var vec in lists.OrderBy(v => v.X).ThenBy(v => v.Y)){
            vec.PrintVector();
        }
    }
}
class Vec{
    public int X{ set; get; }
    public int Y{ set; get; }
    public Vec(int tx, int ty){
        X = tx;
        Y = ty;
    }
    public Vec(string sx, string sy){
        X = int.Parse(sx);
        Y = int.Parse(sy);
    }
    public void PrintVector(){
        Console.WriteLine("{0} {1}",X,Y);
    }
}



Measured memory_bytes: 30428
#include <iostream>
#include <cstdio>
using namespace std;
long long n, s, mx, a[200005];
int main() {
	long long i;
	scanf("%lld", &n);
	for(i=1; i<=n; i++) scanf("%lld", a+i);
	for(i=n; i; i--) {
		mx = max(mx-1, a[i]);
		if(a[i]<mx) mx=i=1;
		else if(a[i] == a[i-1]+1) s++;
		else s += a[i];
	}
	printf("%lld", mx>0 ? -1 : s);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

int main(){
    int n;
    int m;
    while(cin >> n, n){
        cin >> m;
        int mat[n][n];
        for(int k(0); k < n; ++k)
            for(int l(0); l < n; ++l)
                mat[k][l] = 1 << 30;
        for(int i(0); i < n; ++ i) mat[i][i]=0;
        for(int i(0);i < m;++i){
            int a, b, d;
            char g;
            cin >> a;
            cin >> g;
            cin>> b;
            cin >> g;
            cin>> d;

            d = d / 100 - 1;
            mat[a][b] = mat[b][a] = d;
            // map[a].push_back(make_pair(b, d/100 -1));
            // map[b].push_back(make_pair(a, d/100 -1));
        }
        // for(int k(0); k < n; ++k){
        //     for(int l(0); l < n; ++l){
        //      cout << mat[k][l] << " ";
        //     }
        //     cout << endl;
        // }
        vector<int> vs, nvs;
        for(int i(1); i < n; ++ i) nvs.push_back(i);
        // vector<pair<int,int>> es;
        int sum=0;
        vs.push_back(0);
        while(vs.size() < n){
            pair<int,int> tmp = {0,0};
            int d = 1 << 30;
            for(int i: vs){
                for(int j: nvs){
                    if(mat[i][j] < d){
                        d = mat[i][j];
                        tmp = make_pair(i,j);
                    }
                }
            }
            vs.push_back(tmp.second);
//          std::remove(nvs.begin(), nvs.end(), tmp.second);
            nvs.erase(std::remove(nvs.begin(), nvs.end(), tmp.second), nvs.end());
            sum += d;
        }
        cout << sum << endl;
    }

}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100 + 5;
ll A, B, K;
int main(){
	cin >> A >> B;
	ll x = A + B;
	if (x % 2 != 0) cout << "IMPOSSIBLE" << endl;
	else cout << x/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,C,K;
  cin >> N >> C >> K;
  
  vector<int> T(N);
  for (int i=0; i<N; i++) cin >> T.at(i);

  sort(T.begin(),T.end());
  int res = 0;
  for (int i=0; i<N;) {
    int a = T.at(i) + K;
    int j = 1;
    for (; j < C && i+j < N; j++) {
      if ( a < T.at(i+j) ) break;
      if ( j >= C ) j++;
    }
    res++;
    i += j;
  }
  
  cout << res << endl;
}

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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (1LL << 60);

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("template.1", "r", stdin);

  int N;
  cin >> N;
  vector<vector<int>> h(3, vector<int>(N, 0));
  for (int i = 0; i < N; i++) {
    cin >> h[0][i] >> h[1][i] >> h[2][i];
  }
  vector<vector<ll>> dp(3, vector<ll>(N + 1, INF));
  for (int k = 0; k < 3; k++)
    dp[k][0] = h[k][0];
  for (int i = 1; i < N; i++) {
    for (int k = 0; k < 3; k++) {
      ll m = 0;
      if (k != 0)
        m = max(m, dp[0][i - 1] + h[k][i]);
      if (k != 1)
        m = max(m, dp[1][i - 1] + h[k][i]);
      if (k != 2)
        m = max(m, dp[2][i - 1] + h[k][i]);
      dp[k][i] = m;
    }
    dumpv(dp[0]);
    dumpv(dp[1]);
    dumpv(dp[2]);
  }
  ll ans = dp[0][N - 1];
  ans = max(ans, dp[1][N - 1]);
  ans = max(ans, dp[2][N - 1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4600