akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=998244353;
const ll maxn=1e4;
vector<vector<int> > adj(maxn);
vector<bool> used(maxn,false);
vector<int> d(maxn),p(maxn);
ll bin(ll a, ll b) {
	//a%=m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a; //mod
        a = a * a; //mod
        b >>= 1;
    }
    return res;
}

int gcd(int a, int b, int & x, int & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
ll fact(ll x)
{
  ll res=1;
  for(ll i=1;i<=x;i++)
    res=(res*i)%mod;

  return res;
}

ll lmod(string n,ll x)
{
	
	ll res=0;
	for(ll i=0;i<n.length();++i)
	{
		res=(res*10+(int)n[i]-'0')%x;
	}
	return res;
}
bool ispal(string s,int l,int r)
{
	string t=s;
	for(int i=l,j=r;i<=r;++i)
	{
		if(s[i]!=s[j])
			return false;
		else
			{
				--j;
			}
	}
	return true;
}
bool pl(string s)
{
	string t(s.rbegin(),s.rend());
	return t==s;
}
void bfs(int s)
{
	queue<int> q;
	used[s]=true;
	p[s]=-1;
	d[s]=0;
	q.push(s);
	while(!q.empty())
	{
		int v=q.front();
		q.pop();
		for(int u: adj[v])
		{
			if(!used[u])
			{
				used[u]=true;
				q.push(u);
				d[u]=d[v]+1;
				p[u]=v;
			}
			
		}
	}
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,x,y,i,j,k;
	cin>>n>>x>>y;
	for(i=1;i<n;i++)
	{
		adj[i].push_back(i+1);
		adj[i+1].push_back(i);
	}
	adj[x].push_back(y);
	adj[y].push_back(x);
	
	int freq[n+1];
	memset(freq,0,sizeof(freq));
	
	for(i=1;i<=n;i++)
	{
		bfs(i);
		for(j=i+1;j<=n;j++)
		{
			++freq[d[j]];
		}
		for(k=1;k<=n;++k)
		{
			d[k]=0;
			used[k]=false;
		}
	}
	/*for(i=1;i<=n;i++)
	{
		for(j=0;j<vd[i].size();++j)
		{
			cout<<vd[i][j]<<" ";
		}
		cout<<endl;
	}
	
	for(i=1;i<=n;++i);
	{
		bfs(i);
		for(j=i+1;j<=n;++j)
		{
			if(d[j]==i) ++freq[i];
		}	
		for(k=1;k<=n;++k)
		{
			d[k]=0;
			used[k]=false;
		}
	}*/
	for(i=1;i<n;i++)
	{
		cout<<freq[i]<<endl;
	}
	
}

Measured memory_bytes: 640
#include<iostream>
#include<set>
using namespace std;
 
 
 
int main(){
	int n, k, d, a;
	cin >> n >> k;
 
	set<int> bag;
	for(int i=1; i <= n; i++) bag.insert(i);
 
	while(k--){
		cin >> d;
		while(d--){
			cin >> a;
			if(bag.count(a)) bag.erase(a);
		}
	}
 
	cout << bag.size() << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

ll cost(char a){
  if(a-'a'==0) return 0;
  return 26 - (a - 'a');
}
int main(int argc, char const *argv[]) {
  string s;std::cin >> s;ll n = s.size();
  ll k;std::cin >> k;
  re(i, n){
    if(cost(s[i])<=k) k-=cost(s[i]), s[i] = 'a';
    if(i==n-1){
      ll t = s[i] - 'a';
      re(j, k) t++;
      s[i] = (t%26) +'a'; 
    }
  }
  std::cout << s << '\n';
  return 0;
}


Measured memory_bytes: 576
#include<stdio.h>
#define N 100

int main(){
  int n,a[N];
  int i,j,tmp,min;
  int count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  for(i=0;i<n;i++){
    min = i;
    for(j=i;j<n;j++){
      if(a[j]<a[min]){
       	min = j;
      }
    }
    if(a[i]==a[min]) continue;
    else{
    tmp=a[i];
    a[i]=a[min];
    a[min]=tmp;
    count++;
    }
  }
  printf("%d",a[0]);
  for(i=1;i<n;i++) printf(" %d",a[i]);
  
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))

using namespace std;

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    string str = "";
    for(int i = 0;i < n-k;i++){
        if(a[i] < a[i+k]){
            str += "Yes\n";
        } else {
            str += "No\n";
        }
    }

    cout << str << endl;
}

Measured memory_bytes: 4524
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> color;
bool dfs(vector<vector<int>> &graph, int v, int cur = 0){
  color[v] = cur;
  for(int next_v : graph[v]){
    if(color[next_v] != -1){
      if(color[next_v] == cur) return false;
      continue;
    }
    if(!dfs(graph, next_v, 1-cur)) return false;
  }
  return true;
}

vector<int> bfs(int s, int N, vector<vector<int>> &graph){
  vector<int> dist(N, INF);
  dist[s] = 0;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(auto v : graph[p]){
      if(dist[v] != INF) continue;
      dist[v] = dist[p]+1;
      q.push(v);
    }
  }
  return dist;
}

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

  vector<vector<int>> graph(N);
  REP(i, N){
    string s;
    cin >> s;
    REP(j, N){
      if(s[j] == '1') graph[i].emplace_back(j);
    }
  }

  color.resize(N, -1);
  if(!dfs(graph, 0)){
    cout << -1 << "\n";
    return 0;
  }

  int ans = 0;
  REP(i, N){
    auto dist = bfs(i, N, graph);
    REP(j, N) chmax(ans, dist[j]+1);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 110;
int n, m;
int a[maxn];
int main()
{
    //freopen("/Users/zhangkanqi/Desktop/11.txt","r",stdin);
    scanf("%d %d", &n, &m);
    int sum = 0;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]), sum += a[i];
    int x = sum%(4*m)==0?sum/(4*m):sum/(4*m)+1;
    int num = 0;
    for(int i = 1; i <= n; i++) if(a[i]>=x) num++;
    if(num>=m) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

int main() {
  string i;
  
  cin >> i;
  
  if (i[1] == i[2] && (i[0] ==i[1] || i[1] == i[3])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define ceil(a, b) a / b + !!(a % b)
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    int n, m;
    while (cin >> n && n) {
        cin >> m;
        
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        vector<int> w(2 * m);
        rep(i, m) cin >> w[i];
        rep3(i, m, 2 * m) w[i] = -w[i - m];
        
        set<int> s;
        rep(i, (1 << (2 * m))) {
            int sum = 0;
            int flg = 0;
            rep(j, 2 * m) {
                if (i & (1 << j)) {
                    if (j >= m && i & (1 << (j - m))) {
                        flg = 1;
                        break;
                    }
                    sum += w[j];
                }
            }
            if (flg) continue;
            // if (sum > 0) s.insert(sum);
            sum = abs(sum); s.insert(sum);
        }
        
        // for (auto e : s) cout << e << " "; cout << endl << endl;
        
        set<int> s2;
        int flg = 0;
        
        rep(i, n) {
            if (s.find(a[i]) != s.end()) continue;
            flg++;
            
            if (flg == 1) {
                for (auto e : s) {
                    s2.insert(e + a[i]);
                    s2.insert(abs(e - a[i]));
                }
            } else {
                set<int> s3;
                for (auto e : s) {
                    if (s2.find(e + a[i]) != s2.end()) {
                        s3.insert(e + a[i]);
                    }
                    
                    if (s2.find(abs(e - a[i])) != s2.end()) {
                        s3.insert(abs(e - a[i]));
                    }
                    
                }
                s2 = s3;
            }
            
            // cout << flg << "    "; for (auto e : s2) cout << e << " "; cout << endl;
        }
        
        if (flg == 0) cout << 0 << '\n';
        else if (sz(s2) == 0) {
            cout << -1 << '\n';
        } else {
            int ans = inf;
            for (auto e : s2) chmin(ans, abs(e));
            cout << ans << '\n';
        }
    }
}






Measured memory_bytes: 7656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
	int N, K;
	cin >> N;
	cin >> K;
	int h[N] = {};
	
	REP(i,N) cin >> h[i];
	
	ll DP[N];
    REP(i, N) DP[i] = INF;
    DP[0] = 0;
	
	REPS(i, N-1) {
		REPS(j, K){
			if (i-j>=0) chmin(DP[i],DP[i-j]+abs(h[i] - h[i-j]));
		}
	}
	cout << DP[N-1];

    return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N;
  cin >> N;
  VLL X(N),Y(N);
  REP(i,N){
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }
  
  SORT(Y);
  
  LL a=Y.at(N/2-1), b=Y.at(N/2);
  
  REP(i,N){
    if(X.at(i) <= a) cout << b << endl;
    else cout << a << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>

using namespace std;

bool check(const string& s)
{
    string t = "CF";
    int i = 0;
    for (const auto c: s) {
        if (c == t[i]) {
            if (i == 1) return true;
            ++i;
        }
    }
    return false;
}

int main()
{
    string s;
    cin >> s;
    cout << (check(s) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var r, g, b, n int
	fmt.Scan(&r, &g, &b, &n)
	count := 0
	for i := 0; i <= n; i++ {
		for j := 0; j <= n; j++ {
			x := n - (i * r + j * g)
			if x < 0 {
				break
			}
			if x % b == 0 {
				count++
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>

using namespace std;


int main()
{
	int K, S;
	cin >> K >> S;
	int count = 0;
	for (int X = 0; X <= K; X++) {
		for (int Y = 0; Y <= K; Y++) {
			int Z = S - X - Y;
			if (Z >= 0 && Z <= K) count++;
		}
	}
	cout << count << endl;
	return 0;

}


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

int main() {
    int n, cnt = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        cnt += 1-a%2;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3096
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) { std::cout << x << '\n'; }
template <typename T>
void print(std::vector<T>& v, string c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  vector<char> v;
  REP(i, s.size()) {
    if (s[i] == 'B' && !v.empty()) {
      v.pop_back();
    } else if (s[i] != 'B') {
      v.pb(s[i]);
    }
  }
  print(v, "");

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int A[N];
    rep(i,N) cin >> A[i];
    if(A[0]!=0) {
        cout << -1 << endl;
        return 0;
    }
    bool can=true;
    int ans=0;
    rep(i,N-1){
        if(A[i+1]-A[i]>=2){
            can=false; break;
        }
        if(A[i+1]-A[i]==1) ans++;
        else ans+=A[i+1];
    }
    if(can) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


bool judge(int a, int b, int c) {
    if ((a > b && b > c) || (a < b && b < c)) return true;
    return false;
}

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

    int K, X;
    cin >> K >> X;

    REPinit(i, X - K + 1, X + K - 1) {
        cout << i << " ";
    }
    cout << (X + K - 1) << endl;


    return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <vector>
using namespace std;

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

const int MAX_N = 2e5 + 10, MOD = 1e9 + 7;
int n;
pii p[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i].second >> p[i].first;
	sort(p, p + n);

	ll T = 0;
	for (int i = 0; i < n; i++) {
		T += p[i].second;
		if (p[i].first < T) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	return 0;
}

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

int fact(int a,int b){
    int i,ii,kazu,kazuzu,ireka;
  	i = ii = kazu = kazuzu = ireka = 0;
    if(a < b){
        ireka = a;
        a = b;
        b = ireka;
    }
    if(a > b){
        while(i == 0){
            kazu = a / b;
            if(b * kazu == a){
                i = 1;
            }else{
                kazuzu = a;
                a = b;
                b = kazuzu - kazu * b;
            }
        }
        return(b);
    }else if(a == b){
        return(a);
    }
}
int main(){
    long long int a,b,c,d;
    b = c = d = 0;
    cin >> a;
    for(int i = 1;i <= a;i++){
        for(int ii = 1;ii <= a;ii++){
            for(int iii = 1;iii <= a;iii++){
                b = fact(i,ii);
                c = fact(b,iii);
                d = d + c;
            }
        }
    }
    cout << d << endl;

    
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

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

  string s;
  cin >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] == s[i]) {
      cout << "Bad\n";
      return 0;
    }
  }
  cout << "Good\n";
  return 0;
}


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

int main(){
 int hills[10];
 for(int i  =0;i<10;i++){
 cin >> hills[i];
 }
 sort(hills,hills+10);
 cout << hills[9] << endl << hills[8] << endl << hills[7] << endl;
 return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    long N = sc.nextLong();
    long[] arr = new long[5];
    arr[0] = sc.nextLong();
    arr[1] = sc.nextLong();
    arr[2] = sc.nextLong();
    arr[3] = sc.nextLong();
    arr[4] = sc.nextLong();

    sc.close();

    Arrays.sort(arr);

    double ans = (double)N / arr[0];

    System.out.println((long) Math.ceil(ans)+4);
    
  }

}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long N, A, B;
string s;
int a[100001];
int main() {
	cin >> N >> A >> B >> s;
	int cnt_b = 0;
	int rank = 0;
	for(int i=0; i<N; ++i){
		if (s[i] == 'a') {
			if (rank < A + B) {
				cout << "Yes" << endl;
				rank++;
			}else if (rank >= A + B) cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			cnt_b++;
			if (rank < A + B && cnt_b <= B) {
				cout << "Yes" << endl;
				rank++;
			}
			else {
				cout << "No" << endl;
			}
			
		}
		else if (s[i] == 'c') {
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <regex>
using namespace std;

template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

string s;
smatch sm;
regex pattern("YAKI.*");

int main() {

    cin >> s;
    if (regex_match(s, sm, pattern)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        UnionFindTree uf = new UnionFindTree(n);
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            uf.union(a, b);
        }

        int ans = 1;
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        for (int i = 0; i < n; i++) {
            Integer root = new Integer(uf.getRoot(i));
            Integer count = map.get(root);
            if (count != null) {
                int c = count.intValue() + 1;
                ans = Math.max(ans, c);
                map.put(root, new Integer(c));
            } else {
                map.put(root, new Integer(1));
            }
        }
        System.out.println(ans);
    }
}

class UnionFindTree {

    private int[] parent; //インデックスにとノードを対応させ、そのルートノードのインデックスを格納
    private int[] rank; //parentと同様に、木の高さを格納

    public UnionFindTree(int size) {
        this.parent = new int[size];
        this.rank = new int[size];
        for (int i = 0; i < size; i++) {
            init(i);
        }
    }

    public void init(int i) {
        parent[i] = i;
        rank[i] = 0; //集合の高さ
    }

    public void union(int x, int y) {
        int xRoot = getRoot(x);
        int yRoot = getRoot(y);

        // xが属する木の方が大きい場合
        if (rank[xRoot] > rank[yRoot]) {
            parent[yRoot] = xRoot; //yの親をxに更新
        } else if(rank[xRoot] < rank[yRoot]) {
            parent[xRoot] = yRoot;
        } else if (xRoot != yRoot){
            parent[yRoot] = xRoot;
            rank[xRoot]++; //同じ高さの木がルートの子として着くから大きさ++;
        }
    }

    // 引数の属する木のルートのidを返す
    public int getRoot(int i) {
        if (i != parent[i]) {
            parent[i] = getRoot(parent[i]);
        }
        return parent[i];
    }

    // 同じ木に属しているか
    public boolean isSame(int x, int y) {
        return getRoot(x) == getRoot(y);
    }

}


Measured memory_bytes: 67420
n = int(input())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

ans = 0

for i in range(4**len(str(n))):
    cnt = Base_10_to_n(i, 4)

    if cnt.count("0") != 0 or (cnt.count("1") == 0 or cnt.count("2") == 0 or cnt.count("3") == 0):
        continue

    temp = []
    for j in range(len(cnt)):
        if cnt[j] == "1":
            temp.append("3")
        elif cnt[j] == "2":
            temp.append("5")
        elif cnt[j] == "3":
            temp.append("7")
    num = int("".join(temp))

    if num <= n:
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;

vector<pair<int, int>> a;

void input() {
  cin >> n;

  a.resize(n);
  for (auto&& [f, s] : a)
    cin >> f >> s;
}

void solve() {
  sort(a.begin(), a.end(), [](auto f, auto s) {
    if (f.second != s.second)
      return f.second < s.second;

    return f.first < s.first;
  });

  string ans = "Yes";

  int cur = 0;
  
  for (auto&& [f, s] : a) {
    cur += f;

    if (cur > s) {
      ans = "No";

      break;
    }
  }

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

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
int n,be[100002],ans=1;
vector<int> son[100002],inc,src;
int dfs(int k)
{
	if(k==n)
	{
		inc.erase(inc.end()-1);
		return 1;
	}
	for(int i=0;i<son[k].size();i++)
	{
		if(be[son[k][i]]==0)
		{
			be[son[k][i]]=1;
			inc.push_back(son[k][i]);
			if(dfs(son[k][i])==1)return 1;
			be[son[k][i]]=0;
			inc.erase(inc.end()-1);
		}
	}
	return 0;
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		son[a].push_back(b);
		son[b].push_back(a);
	}
	be[1]=1;
	src.push_back(1);
	dfs(1);
	//for(int i=0;i<inc.size();i++)cout<<inc[i]<<" ";
	//cout<<endl;
	int dvd=(inc.size()+inc.size()%2)/2;
	for(int i=0;i<inc.size();i++)
	{
		if(i<dvd)
		{
			ans++;
			src.push_back(inc[i]);
		}
		else be[inc[i]]=2;
	}
	while(src.size())
	{
		for(int i=0;i<son[src[0]].size();i++)
		{
			if(be[son[src[0]][i]]==0)
			{
				ans++;
				be[son[src[0]][i]]=1;
				src.push_back(son[src[0]][i]);
			}
		}
		src.erase(src.begin());
	}
	if(ans>=n/2+1)cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 10104
p = list(map(int, input().split()))
N = 4 * int(input())

p[1] = min(p[1], p[0] * 2)
p[2] = min(p[2], p[1] * 2, p[0] * 4)
p[3] = min(p[3], p[2] * 2, p[1] * 4, p[0] * 8)

k = 8
ret = 0
for m in p[::-1]:
    ret += N // k * m
    N %= k
    k //= 2

print(ret)


Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func canNotWaitForHoliday(s string) int {
	switch s {
	case "SUN":
		return 7
	case "MON":
		return 6
	case "TUE":
		return 5
	case "WED":
		return 4
	case "THU":
		return 3
	case "FRI":
		return 2
	case "SAT":
		return 1
	}
	return 0
}

func main() {
	var s string
	fmt.Scan(&s)
	fmt.Println(canNotWaitForHoliday(s))
}


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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

string n;

int main()
{
    cin>>n;

    if(n[0]=='7' or n[1]=='7' or n[2]=='7'){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;

}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int ans[N];char s[N];
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
		if(s[i]=='R'&&s[i+1]=='L')
		{
			int sum=0;
			for(int j=i;j>=0;j--)
				if(s[j]=='R')sum++;else break;
			ans[i+1]+=sum/2;
			ans[i]+=sum-sum/2;
			sum=0;
			for(int j=i+1;j<n;j++)
				if(s[j]=='L')sum++;else break;
			ans[i]+=sum/2;
			ans[i+1]+=sum-sum/2;
		}
	for(int i=0;i<n;i++)
		printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,a[1000001];
int main()
{
	read(n);bool ff=false;
	for(res i=1;i<=n;++i) scanf("%1d",&a[i]),--a[i],ff|=a[i]==1;
	if(!ff) {
		int tot=0;
		for(res i=1;i<=n;++i) if(((n-1)|(i-1))==n-1) tot+=a[i]/2;
		print(tot%2*2,'\n');return 0;
	}
	int tot=0;
	for(res i=1;i<=n;++i) if(((n-1)|(i-1))==n-1) tot+=a[i];
	print(tot%2,'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 4096
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = getLine >> breads >>= print . solve

solve :: [Int] -> Int 
solve xs = last ys - head ys
    where
        ys = sort xs

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

Measured memory_bytes: 508
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()
// --> 
// @@ !! LIM  -- end mark --

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> X(N), Y(N), P(N);
  for (ll i = 0; i < N; i++) {
    ll x, y, p; cin >> x >> y >> p;
    X.at(i) = x;
    Y.at(i) = y;
    P.at(i) = p;
  }

  ll pssize = 1LL << N;
  vector distX(pssize, vector(N, 0LL));
  vector distY(pssize, vector(N, 0LL));
  for (ll t = 0; t < pssize; t++) {
    for (ll i = 0; i < N; i++) {
      ll vminx = abs(X.at(i));
      ll vminy = abs(Y.at(i));
      for (ll j = 0; j < N; j++) {
	if (t & (1LL << j)) {
	  vminx = min(vminx, abs(X.at(i) - X.at(j)));
	  vminy = min(vminy, abs(Y.at(i) - Y.at(j)));
	}
      }
      distX.at(t).at(i) = vminx;
      distY.at(t).at(i) = vminy;
    }
  }

  vector<ll> ans(N+1, LLONG_MAX);
  for (ll tt = 0; tt < pssize; tt++) {
    ll k = __builtin_popcountll(tt);
    for (ll tx = tt; true; tx = (tx - 1) & tt) {
      ll ty = tt ^ tx;
      ll sum = 0;
      for (ll i = 0; i < N; i++) {
	sum += min(distX[tx][i], distY[ty][i]) * P[i];
      }
      ans.at(k) = min(ans.at(k), sum);
      if (tx == 0) break;
    }
  }

  for (ll i = 0; i <= N; i++) cout << ans.at(i) << "\n";

  return 0;
}



Measured memory_bytes: 12964
<?php  
$stdins = array();
    while(true)
    {
        $stdin = trim(fgets(STDIN));
        if ($stdin === ''|| $stdin ==0)
        {
            //var_dump($stdins);
            //return;
break;
        }  
        $stdins[] = $stdin;
    }
  $num = count($stdins);
  foreach($stdins as $key => $val ){
  echo "Case " . ($key+1) . ": ".$val ;  
  if($num != ($key+1)){
  echo PHP_EOL;
}
}
?>

Measured memory_bytes: 16712
l,r=map(int,input().split())
m=200000

if r*(r-1)<2019:
    print(l*(l+1))
elif r-l>=673:
    print(0)
else:
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            if (i*j)%2019<m:
                m=(i*j)%2019
    print(m)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  int res = 0;
  for (int i = 0; N > i; i++){
    int a;
    cin >> a;
    while(a % 2 == 0){
      res++;
      a = a/2;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
	ll a, b, k;
	cin >> a >> b >> k;
	if(a>=k){
		prt2(a-k, b);
	} else {
		prt2(0, max(0ll, b-(k-a)));
	}
}


Measured memory_bytes: 3620
//あり本 p135

#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main(){
    string s;
    cin >> s;
    bool flag[3];
    REP(i, 3){
        REP(j, 3){
            if(s[j] == 'a'){
                flag[0] = true;
            }else if(s[j] == 'b'){
                flag[1] = true;
            }else if(s[j] == 'c'){
                flag[2] = true;
            }
        }
    }
    bool f = true;
    REP(i, 3){
        if(!flag[i])f = false;
    }
    if(f){
        print("Yes")
    }else{
        print("No");
    }
    return 0;

}

Measured memory_bytes: 256
n = input()
n = int(n)
l = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]
for i in range(n):
  b,f,r,v = input().split()
  b = int(b)
  f = int(f)
  r = int(r)
  v = int(v)
  l[b-1][f-1][r-1]+=v
for i in range(4):
  for j in range(3):
    for k in range(10):
      print("",l[i][j][k],end="")
    print()
  if i == 3:
    break
  print("####################")
  


Measured memory_bytes: 5632
N = int(input())
H = []
for _ in range(N):
    H.append(tuple(map(int, input().split())))

table = [[0] * 3 for _ in range(N)]
st = set(range(3))
for n in range(N):
    table[n] = [H[n][i] + max(table[n - 1][j] for j in (st - {i})) for i in st]

print(max(table[N - 1]))


Measured memory_bytes: 41760
#include <stdio.h>
#include <stdlib.h>
#define MAXN 100
#define MAX_INT 100001

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

int main()
{
  int n, b[MAXN], mps = 0;
 scanf("%d", &n);
  for(int i = 1; i<n; i++)
    scanf("%d", &b[i]);
  b[n] = MAX_INT;
  mps += b[1];
  for(int i = 2; i<=n; i++)
  {
    mps+=min(b[i-1], b[i]);
  }
  printf("%d", mps);
}


Measured memory_bytes: 128
#include <stdio.h>
 
int main() {
 
  int n,m,i,j;
  int a,b;
  int A[100][100] = {{0}};
  int B[100] = {0};
  int c[100] = {0};
 
  scanf("%d %d " ,&n,&m);
 
  for(j=0; j<n; j++) {
  for(i=0; i < m; i++) {
    scanf("%d",&a);
    A[j][i] = a;
  }
}
 
  for(j=0; j<m; j++) {
    scanf("%d",&b);
    B[j] = b;
  }
 
  for(j=0;j<n ; j++){ 
  for(i = 0; i<m; i++){
     c[j] = c[j] + A[j][i]*B[i];
    }
  }
 
  for(i=0;i<n;i++) {
    printf("%d\n",c[i]);
  }
  return 0;
}


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

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

const int N = 1e6;

int ans[N];
int c[N];
vector<pair<int, int> > qs[N];
int lst[N];

int fenw[N];

void add(int pos, int x)
{
    while (pos < N)
    {
        fenw[pos] += x;
        pos = pos | (pos + 1);
    }
}

int get(int x)
{
    int res = 0;
    while (x >= 0)
    {
        res += fenw[x];
        x = (x & (x + 1)) - 1;
    }
    return res;
}

int get(int l, int r)
{
    if (l == 0) return get(r);
    return get(r) - get(l - 1);
}

signed main()
{
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) cin >> c[i];
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        l--, r--;
        qs[r].push_back({l, i});
    }
    for (int i = 0; i < N; i++) lst[i] = -1;
    for (int i = 0; i < n; i++)
    {
        if (lst[c[i]] != -1)
            add(lst[c[i]], -1);
        add(i, 1);
        lst[c[i]] = i;
        for (int j = 0; j < qs[i].size(); j++)
        {
            ans[qs[i][j].second] = get(qs[i][j].first, i);
        }
    }
    forn(i, q) cout << ans[i] << "\n";
}


Measured memory_bytes: 46868
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int l = sc.nextInt();
    int r = sc.nextInt();
    long ans = 2020;

    r = Math.min(r, l+2019*2);

    for(long i=l; i<=r; ++i) {
      for(long j=i+1; j<=r; ++j) {
        ans = Math.min(ans, i*j%2019);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23892
a = [int(input()) for i in range(5)]
max = 0
for i in range(5):
    if a[i]%10!=0 and a[max]%10>a[i]%10:
        max = i
ans = 0
for i in range(5):
    if max==i:
        ans += a[i]
    else:
        ans += -(-a[i]//10)*10
print(ans)

Measured memory_bytes: 3060
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#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++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;
const int MAX = 10000;

/** Problem0216 : Cutting Down Water Bills **/
int main()
{
	int w;
	
	while (cin>>w, w>=0) {
		int sum=1150;
		if (w>10) {
			w-=10;
		} else {
			w=0;
		}
		
		if (w>0) {
			if (10<w) {
				w-=10;
				sum+=1250;
			} else {
				sum+=w*125;
				w=0;
			}
		}
		
		if (w>0) {
			if (10<w) {
				w-=10;
				sum+=1400;
			} else {
				sum+=w*140;
				w=0;
			}
		}
		
		if (w>0)
			sum+=w*160;
			
		cout << 4280 - sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
while True:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    
    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<ll,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
ll a[maxn],b[maxn];
priority_queue<pii,vector<pii>,less<pii> > que;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&b[i]);
		if(b[i]>a[i])
			que.push(make_pair(b[i],i));
		else if(b[i]<a[i])
		{
			printf("-1\n");
			return 0;
		}
	}
	ll cnt=0;
	int x,y,pre,aft;
	ll sum,nval,k,bnda,bndq;
	while(!que.empty())
	{
		pii cur=que.top();
		que.pop();
		x=cur.second;
		bnda=a[x];
		pre=(x-1+n)%n;
		aft=(x+1)%n;
		if(b[x]-b[pre]<b[aft])
		{
			printf("-1\n");
			return 0;
		}
		sum=b[pre]+b[aft];
		bndq=max(b[pre],b[aft]);
		if(bndq>b[x])
		{
			printf("-1\n");
			return 0;
		}
		if(bnda>=bndq)
		{
			if((b[x]-bnda)%sum!=0)
			{
				printf("-1\n");
				return 0;
			}
			else
			{
				cnt+=(b[x]-bnda)/sum;
				b[x]=a[x];
			}
		}
		else
		{
			k=(b[x]-bndq)/sum+1;
			nval=b[x]-sum*k;
			if(nval<a[x])
			{
				printf("-1\n");
				return 0;
			}
			cnt+=k;
			b[x]=nval;
			if(b[x]!=a[x])que.push(make_pair(b[x],x));
		}
		/*	if((b[x]-bnda)%sum!=0)
			{
				printf("-1\n");
				return 0;
			}
			else
			{
				cnt+=(b[x]-bnda)/sum;
				b[x]=a[x];
			}
		if(!que.empty())
		{
			bndq=que.top().first;
			x=cur.second;
			bnda=a[x];
		//	cout<<x<<" "<<b[x]<<" "<<bndq<<" "<<bnda<<endl;
			if(bnda>=bndq)
			{
				pre=(x-1+n)%n;
				aft=(x+1)%n;
				if(b[x]-b[pre]<b[aft])
				{
					printf("-1\n");
					return 0;
				}
				sum=b[pre]+b[aft];
				if((b[x]-bnda)%sum!=0)
				{
					printf("-1\n");
					return 0;
				}
				else
				{
					cnt+=(b[x]-bnda)/sum;
					b[x]=a[x];
				}
			}
			else
			{
				pre=(x-1+n)%n;
				aft=(x+1)%n;
				if(b[x]-b[pre]<b[aft])
				{
					printf("-1\n");
					return 0;
				}
				sum=b[pre]+b[aft];
				k=(b[x]-bndq)/sum+1;
				nval=b[x]-sum*k;
				if(nval<a[x])
				{
					printf("-1\n");
					return 0;
				}
				cnt+=k;
				b[x]=nval;
				if(b[x]!=a[x])que.push(make_pair(b[x],x));
			}
		}
		else
		{
			x=cur.second;
			bnda=a[x];
			pre=(x-1+n)%n;
			aft=(x+1)%n;
			if(b[x]-b[pre]<b[aft])
			{
				printf("-1\n");
				return 0;
			}
			sum=b[pre]+b[aft];
			if((b[x]-bnda)%sum!=0)
			{
				printf("-1\n");
				return 0;
			}
			else
			{
				cnt+=(b[x]-bnda)/sum;
				b[x]=a[x];
			}
		}*/
	}
	printf("%lld\n",cnt);
	return 0;
}

Measured memory_bytes: 8944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

  sort(a.begin(), a.end());
  bool flag = true;
  int ans = 1;
  if (a[0] == 0)
  {
    if ((n < 1 && a[1] == 0) || n % 2 == 0)
      flag = false;
    int t = 2;
    for (int i = 1; i < n; i += 2)
    {
      if (a[i] != t || a[i] != a[i + 1])
        flag = false;
      if (!flag)
        break;
      t += 2;
      ans = (ans * 2) % MOD;
    }
  }
  else
  {
    if (n % 2 == 1)
      flag = false;
    int t = 1;
    for (int i = 0; i < n; i += 2)
    {
      if (a[i] != t || a[i] != a[i + 1])
        flag = false;
      if (!flag)
        break;
      t += 2;
      ans = (ans * 2) % MOD;
    }
  }
  if (flag)
    cout << ans << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())

tasks = []
for i in range(n):
    tasks.append([0, 0])

A = 0
P = 0

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)

    if tasks[p-1][0] == 0:
        if s == "AC":
            A += 1
            tasks[p-1][0] = 1
            P += tasks[p-1][1]
        else:
            tasks[p-1][1] += 1
    else:
        continue

print(A, P)

Measured memory_bytes: 13172
import numpy as np
import bisect
import heapq

n,m=map(int,input().split())
a=np.array([int(i) for i in input().split()])
a=a*(-1)
a.sort()
a=list(a)

for i in range(m):
    check=-(-heapq.heappop(a)//2)
    heapq.heappush(a,check)
print(sum(a)*(-1))

Measured memory_bytes: 23108
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 1e+9

struct edge {
    int to;
    double cost;
};

// <最短距離, 頂点の番号>
using P = pair<double, int>;

int V;
const int ci = 2e5+ 5;
vector<edge> G[ci];
double d[ci];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) { //cout << "On" << endl;
        P p = que.top();
        que.pop();
        int v = p.second; //cout << "v=" << v << endl;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e = G[v][i]; //cout << "koo" << endl;
            if (d[e.to] > d[v] + e.cost) { //cout << e.cost << endl;
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
    int n; cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n % 2 != 0){
        cout << b[n / 2] - a[n / 2] + 1 << endl;
    }else{
        /*long double p = (b[n / 2] + b[n / 2 - 1]) / 2;
        long double q = (a[n / 2] + a[n / 2 - 1]) / 2;
        long double r = (p - q) / 0.5;
        cout << r + 1 << endl;*/
        cout << b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1 << endl;
    }

}

Measured memory_bytes: 11124