akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(int argc, char** argv){
    int r, D;
    int x[11];
    cin >> r >> D >> x[0];
    for (int i=1; i<=10; i++){
        x[i] = x[i-1]*r - D;
        cout << x[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
ll mod = 1e9+7;

int main() 
{ 
	char n;
	cin>>n;
	int x = (int)n;
	if(x>=97)
		cout<<"a";
	else
		cout<<"A";

    return 0; 
} 

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


int main() {
int d,t,s;
cin >> d >> t >> s;
double ans = (double)d/s;
if(t>=ans){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}

}


Measured memory_bytes: 3604
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#include <string>
#include <sstream>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef long long ll;
ul gcd(ul a, ul b){return b? gcd(b, a%b):a;}
using namespace std;

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

    int F[N][10];
    int P[N][11];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++){
            cin >> P[i][j];
        }
    }

    int ans = INT_MIN;
    for(int b = 1; b < 1024; b++){
        int tmp = 0;
        for(int i =0; i < N; i++){
            int open = 0;
            for(int j = 0; j < 10; j++){
                if ((b>>j & 1) && F[i][j] ==1){
                    open++;
                }
            }
            tmp += P[i][open];

        }
        if (tmp > ans){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}
    


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int w[10],k[10],tmp,i,j;
for(i=0;i<10;i++){
cin>>w[i];
}
for(i=0;i<10;i++){
cin>>k[i];
}
for(i=0;i<9;i++){
for(j=9;j>i;j--){
if(w[j]>=w[j-1]){
tmp=w[j];
w[j]=w[j-1];
w[j-1]=tmp;
}
if(k[j]>=k[j-1]){
tmp=k[j];
k[j]=k[j-1];
k[j-1]=tmp;
}
}
}
cout<<w[0]+w[1]+w[2]<<" "<<k[0]+k[1]+k[2]<<endl;
return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll N, K;
ll A[201010];

int main() {
  //
  cin >> N >> K;
  repe(i, 1, N) { cin >> A[i]; }

  for (ll i = K + 1; i <= N; ++i) {
    if (A[i] > A[i - K]) {
      cout << "Yes"
           << "\n";
    } else {
      cout << "No"
           << "\n";
    }
  }
}


Measured memory_bytes: 5204
#include <cassert>
#include <cmath>
#include <cstdio>

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

  for (int i = 0; i < n; ++i) {
    float x1, y1, x2, y2, x3, y3;
    scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);

    // x^2 + y^2 + lx + my + n = 0

    float A[3][3] = { {x1, y1, 1}, {x2, y2, 1}, {x3, y3, 1} };
    // detA = a00a11a22 + a10a21a02 + a20a01a12 - a00a21a12 - a20a11a02 - a10a01a22
    float detA =
        A[0][0] * A[1][1] * A[2][2]
      + A[1][0] * A[2][1] * A[0][2]
      + A[2][0] * A[0][1] * A[1][2]
      - A[0][0] * A[2][1] * A[1][2]
      - A[2][0] * A[1][1] * A[0][2]
      - A[1][0] * A[0][1] * A[2][2];

    assert(detA != 0);
    float invA[3][3] = {
        { (A[1][1] * A[2][2] - A[1][2] * A[2][1]) / detA,
          (A[0][2] * A[2][1] - A[0][1] * A[2][2]) / detA,
          (A[0][1] * A[1][2] - A[0][2] * A[1][1]) / detA },
        { (A[1][2] * A[2][0] - A[1][0] * A[2][2]) / detA,
          (A[0][0] * A[2][2] - A[0][2] * A[2][0]) / detA,
          (A[0][2] * A[1][0] - A[0][0] * A[1][2]) / detA },
        { (A[1][0] * A[2][1] - A[1][1] * A[2][0]) / detA,
          (A[0][1] * A[2][0] - A[0][0] * A[2][1]) / detA,
          (A[0][0] * A[1][1] - A[0][1] * A[1][0]) / detA }
    }; 

    float b[3] = {-(x1 * x1 + y1 * y1), -(x2 * x2 + y2 * y2), -(x3 * x3 + y3 * y3)};
    
    float l = invA[0][0] * b[0] + invA[0][1] * b[1] + invA[0][2] * b[2];
    float m = invA[1][0] * b[0] + invA[1][1] * b[1] + invA[1][2] * b[2];
    float n = invA[2][0] * b[0] + invA[2][1] * b[1] + invA[2][2] * b[2];
      
    // (x + l/2)^2 - l^2/4 + (y + m/2)^2 - m^2/4 + n = 0;
    // (x, y) = (-l/2, -m/2)
    // r = sqrt(l^2/4 + m^2/4 - n)
    float px = -l / 2;
    float py = -m / 2;
    float r = std::sqrt(l * l / 4.0 + m * m / 4.0 - n);
    
    printf("%.3f %.3f %.3f\n", px, py, r);
  }
}

Measured memory_bytes: 1088
// 20151005
// ??????????????\????????¶?????????




#include<stdio.h>




int main() {
  double a, b, c; // ??? 1 ????????°
  double d, e, f; // ??? 2 ????????°




  /* ??\??? */
  while ((scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f)) != EOF) {
    /** ??¶?´??????? **/
    if (a < -1000 && a > 1000) break;
    if (b < -1000 && b > 1000) break;
    if (c < -1000 && c > 1000) break;
    if (d < -1000 && d > 1000) break;
    if (e < -1000 && e > 1000) break;
    if (f < -1000 && f > 1000) break;
    /*** ??????????????? ***/
    /**** (1, 1) ??? 1 ??? ****/
    b = b / a;
    c = c / a;
    a = a / a; // ????????????
    /* printf("--------------------------\n"); */
    /* printf("%f %f %f\n", a, b, c); */
    /* printf("%f %f %f\n", d, e, f); */
    /***** (2, 1) ??? 0 ???*****/
    e = e - b * d;
    f = f - c * d;
    d = d - a * d; // ????????????
    /* printf("--------------------------\n"); */
    /* printf("%f %f %f\n", a, b, c); */
    /* printf("%f %f %f\n", d, e, f); */




    /**** (2, 2) ??? 1 ??? ****/
    d = d / e;
    f = f / e;
    e = e / e; // ????????????
    /* printf("--------------------------\n"); */
    /* printf("%f %f %f\n", a, b, c); */
    /* printf("%f %f %f\n", d, e, f); */
    /***** (1, 2) ??? 0 ???*****/
    a = a - d * b;
    c = c - f * b;
    b = b - e * b; // ????????????
    /* printf("--------------------------\n"); */
    /* printf("%f %f %f\n", a, b, c); */
    /* printf("%f %f %f\n", d, e, f); */




    /****** ??¨??? *******/
    printf("%0.3lf %0.3lf\n", c, f);
  }
			



  /* ?????? */
  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <math.h>

using namespace std;

int main()/////1974
{
	int N[4];
	for (int a = 0; a < 4; a++) {
		cin >> N[a];
	}
	sort(N, N+4);
	if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9)cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    if (s[s.size()-1] == 's') cout << s + "es" << endl;
    else cout << s + "s" << endl;
    return 0;
}

Measured memory_bytes: 3620
n = int(input())
x = input()

original_pop_count = x.count('1')
one_pop_count = original_pop_count - 1 # 0になりうる
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_pop_count != 0:
        one_mod = (one_mod * 2 + int(b)) % one_pop_count
    zero_mod = (zero_mod * 2 + int(b)) % zero_pop_count

# f の前計算
f = [0] * 220000
pop_count = [0] * 220000
for i in range(1, 220000):
    pop_count[i] = pop_count[i // 2] + i % 2
    f[i] = f[i % pop_count[i]] + 1

# pow2 の前計算
one_pow2 = [1] * 220000
zero_pow2 = [1] * 220000
for i in range(1, 220000):
    if one_pop_count != 0:
        one_pow2[i] = one_pow2[i - 1] * 2 % one_pop_count
    zero_pow2[i] = zero_pow2[i - 1] * 2 % zero_pop_count

for i in range(n-1, -1, -1):
    if x[n-i-1] == '1':
        if one_pop_count != 0:
            nxt = one_mod
        # nxt -= pow(2, i, one_pop_count)
            nxt -= one_pow2[i]
            nxt %= one_pop_count
            print(f[nxt] + 1)
        else:
            print(0)
    elif x[n-i-1] == '0':
        nxt = zero_mod
        # nxt += pow(2, i, zero_pop_count)
        nxt += zero_pow2[i]
        nxt %= zero_pop_count
        print(f[nxt] + 1)

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

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

    int N;
    cin >> N;
    string S;
    cin >> S;

    string s1 = S.substr(0, N);
    string s2 = S.substr(N, N);
    reverse(s2.begin(), s2.end());
    map<pair<string, string>, ll> mp;

    for (int tmp = 0; tmp < (1 << N); ++tmp) {
        bitset<20> BIT(tmp);
        string a = "";
        string b = "";
        for (int i = 0; i < N; ++i) {
            if (BIT.test(i)) {
                a += s1.at(i);
            } else {
                b += s1.at(i);
            }
        }
        mp[make_pair(a, b)]++;
    }

    ll ans = 0;
    for (int tmp = 0; tmp < (1 << N); ++tmp) {
        bitset<20> BIT(tmp);
        string a = "";
        string b = "";
        for (int i = 0; i < N; ++i) {
            if (BIT.test(i)) {
                a += s2.at(i);
            } else {
                b += s2.at(i);
            }
        }
        ans += mp[make_pair(a, b)];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 91904
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

int main() {
   int N;
   std::cin >> N;
   std::map<std::string, int> map;   
   bool flg = true;
   std::string tmp;
   char last;
   for (int i = 0; i < N; i++) {
      std::cin >> tmp;
      if (map[tmp] == 1) flg = false;
      else map[tmp] = 1;
      if (i == 0);
      else if (last != tmp[0]) flg = false;
      last = tmp[tmp.size()-1];
   }
   if (flg == false) std::cout << "No" << std::endl;
   else std::cout << "Yes" << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std ;

int main()
{
char ch[3][3];
for(int i=0;i<3;i++)
{
    for(int t=0;t<3;t++)
    {
        cin>>ch[i][t];
    }
}
cout<<ch[0][0]<<ch[1][1]<<ch[2][2];
    return 0;
}


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

int main()
{
    int n, l[100000], r[100000], i;
    scanf("%d", &n);
    for (i=0; i<n; i++)
    {
        scanf("%d%d", &l[i], &r[i]);
    }
    int sum = 0;
    for (i=0; i<n; i++)
    {
        sum += r[i] - l[i] + 1;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	ll n;
	cin >> n ;
	double M = sqrt(n);
	int m = M + 1;
	for (int i = m; i >= 0; i--) {
		if (n%i == 0) {
			n /= i;
			int ans = 1;
			while (n / 10) {
				n /= 10;
				ans++;
			}
			cout << ans << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF = 100000000;
int main() {
    int n ;
    cin >> n;
    int a[210];
    for (int i = 0; i< n; i++) cin >> a[i];

    int res = INF;

    for (int i = 0; i<n; i++) {
        int count = 0;

        while (a[i] % 2 == 0){
            a[i] /= 2;
            ++count;
        }

        if (res > count) res = count;
    }

    cout << res << endl;
}

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

#define endl '\n'

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

    string s; cin >> s;
    int ans = 0;
    for (int i=0; i<s.size()/2; i++){
        ans += (s[i] != s[s.size() - i - 1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){
    ll i;
    vector<int> ans;
    cin>>i;
    if(i==0||i==1){
        cout<<i<<endl;
        return 0;
    }
    ll j=1;
    while(i!=0){
        ll i0=i;
        if(i0%(-2*j)==0){
            ans.push_back(0);
        }else{
            ans.push_back(1);
            i -= j;
        }
        j *=(-2);
    }
    for(auto ite=ans.end()-1;ite>=ans.begin();ite--){
        cout<<*ite;
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
import re
h,w = map(int, input().split())
m=[]
d = [[0]*w for _ in range(h)]
u = [[0]*w for _ in range(h)]
for _ in range(h):
  t=[]
  for i in re.split("(#)", input()):
    if not i == "#":
      t.extend([len(i)]*len(i))
    else:
      t.append(0)
  m.append(t)

for i in range(w):
  for j in range(h):
    if m[j][i] == 0:
      d[j][i] = 0
    else:
      if j != 0:
        d[j][i] = d[j-1][i] + 1
      else:
        d[j][i] = 1

    if m[h-1-j][i] == 0:
      u[h-1-j][i] = 0
    else:
      if h-1-j == h-1:
        u[h-1-j][i] = 1
      else:
        u[h-1-j][i] = u[h-j][i] + 1
ans=0
for i in range(w):
  for j in range(h):
    ans = max(ans, u[j][i]+d[j][i]+m[j][i])
print(ans - 2)

Measured memory_bytes: 221588
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {

  long n,m;
  scanf("%ld %ld", &n, &m);
  if (labs(n-m) > 1) {
    printf("0\n");
    return 0;
  }
  long mod = pow(10,9)+7;
  long answer = 1;
  if (labs(n-m) == 0) {
    answer *= 2;
  }
  for (long i = 1; i <= n; i++) {
    answer *= i;
    answer %= mod;
  }
  for (long i = 1; i <= m; i++) {
    answer *= i;
    answer %= mod;
  }
  printf("%ld\n", answer);

  return 0;
}

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

#define int long long
const int N = 25 ;
bool gp[N][N] ;

int dx[4] = {1,-1,0,0} ;
int dy[4] = {0,0,1,-1} ;
struct pt{
	int x ,y , d ;
	pt(int a , int b , int c){
		x = a , y = b , d = c ;
	}
} ;

int solve(int x , int y , int n , int m){
	int ans = 0 ;
	queue<pt> q ;
	q.push(pt(x,y,0)) ;
	map<pair<int,int>,int> visited ;
	visited[{x,y}] = 1;
	while(q.size()){
		x = q.front().x ;
		y = q.front().y ;
		int d = q.front().d ;
		ans = max(ans,d) ;
		q.pop() ;
		for(int i = 0 ; i < 4 ; i++){
			int x1 = x + dx[i] , y1 = y + dy[i] ;
			if(x1 < 0 || x1 >= n || y1 < 0 || y1 >= m) continue ;
			if(gp[x1][y1] && !visited.count({x1,y1})){
				q.push(pt(x1,y1,d+1)) ;
				visited[{x1,y1}] = 1 ;
			}
		}
	}
	return ans ;
} 

int32_t main(){
	int n , m ;
	cin >> n >> m ;
	string s[n] ;
	for(int i = 0 ; i < n ; i++) cin >> s[i] ;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < m ; j++){
			gp[i][j] = (s[i][j] == '.') ;
		}
	}
	int mx = 0 ;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < m ; j++){
			if(!gp[i][j]) continue ;
			mx = max(mx,solve(i,j,n,m)) ;
		}
	}
	cout << mx ;
				
	return 0 ;
}



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

int main() {
  double n,a;
  int s,max;
  max=0;
  cin>>n;
  for(double i=2;i<10;i++){
  a=pow(n,1/i);
  s=(10000*a+0.9)/10000;
  s=pow(s,i);
  if(s>max) max=s;  
  }
  cout<<max<<endl;  
}

  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
const int N = 130200;
struct SA{
	int buc[N],sa[N],rk[N],tt[N],h[N],v[19][N],Log[N];
	int init(char *a, int n){
		rep(i,1,n){Log[i]=Log[i-1];if(i==(1<<Log[i]+1))Log[i]++;}
		memset(buc,0,4*256);
		rep(i,1,n)buc[a[i]]++;
		rep(i,1,256)buc[i]+=buc[i-1];
		rep(i,1,n)sa[buc[a[i]]--]=i;
		rep(i,1,n)rk[sa[i]]=rk[sa[i-1]]+(a[sa[i]]!=a[sa[i-1]]);
		for(int j=1;j<n;j<<=1){
			int p=0;rep(i,n-j+1,n)tt[++p]=i;
			rep(i,1,n)if(sa[i]-j>=1)tt[++p]=sa[i]-j;
			memset(buc,0,4*(n+2));
			rep(i,1,n)buc[rk[i]]++;
			rep(i,1,n)buc[i]+=buc[i-1];
			per(i,n,1)sa[buc[rk[tt[i]]]--]=tt[i];
			rep(i,1,n)tt[sa[i]]=tt[sa[i-1]]+(rk[sa[i]]!=rk[sa[i-1]]||(sa[i]+j<=n?rk[sa[i]+j]:-1)!=(sa[i-1]+j<=n?rk[sa[i-1]+j]:-1));
			memcpy(rk,tt,4*(n+2));
		}
	//	rep(i,1,n)cerr<<sa[i]<<' ';cerr<<endl;
		rep(i,1,n)if(sa[i]<=n/2)return sa[i];
	//	assert(0);
	}
}sa;
int n,k;char s[N],t[N];
int main(){
	read(n);read(k);scanf("%s",s+1);
	int mn=1e9;rep(i,1,n)umin(mn,(int)s[i]);
	if(k>=20){rep(i,1,n)s[i]=mn,printf("%c",s[i]);return 0;}
	rep(tt,1,k){
		if(tt>1){rep(i,1,n)t[i]=s[n-i+1],t[n+i]=s[i];}
		else{rep(i,1,n)t[i]=s[i],t[n+i]=s[n-i+1];}
		int p=sa.init(t,n*2);
	//	cerr<<p<<endl;
		rep(i,1,n)s[i]=t[p+i-1];
	}
	rep(i,1,n)printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;
// Union Find begin

class UnionFind {
 private:
  vector<ll> _par;
  vector<ll> _rank;
 public:
  explicit UnionFind(ll n);
  ll find(ll x);
  void unite(ll x, ll y);
  bool isSame(ll x, ll y);
};

UnionFind::UnionFind(ll n) {
  for (ll i = 0; i < n; ++i) {
    _par.push_back(i);
    _rank.push_back(0);
  }
}

ll UnionFind::find(ll x) {
  if (_par.at(static_cast<unsigned long>(x)) == x) return x;
  else return _par.at(static_cast<unsigned long>(x)) = find(_par.at(static_cast<unsigned long>(x)));
}

void UnionFind::unite(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (_rank.at(static_cast<unsigned long>(x)) < _rank.at(static_cast<unsigned long>(y)))
    _par.at(static_cast<unsigned long>(x)) = y;
  else {
    _par.at(static_cast<unsigned long>(y)) = x;
    if (_rank.at(static_cast<unsigned long>(x)) == _rank.at(static_cast<unsigned long>(y)))
      ++_rank.at(static_cast<unsigned long>(x));
  }

}

bool UnionFind::isSame(ll x, ll y) {
  return find(x) == find(y);
}

// Union Find end

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n, a, b;
  ccin >> n >> a >> b;
  vector<pair<ll, ll>> mp;
  rep(i, n) {
    ll x;
    ccin >> x;
    mp.emplace_back(x, i);
  }
  UnionFind unf(n);
  ll ans = 0, cnt = 0;
  rep(i, n - 1) {
    if ((mp[i + 1].first - mp[i].first) * a < b) {
      unf.unite(i, i + 1);
      ans += (mp[i + 1].first - mp[i].first) * a;
    } else {
      ans += b;
    }
  }

  ccout << ans << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define YOKO 1
#define TATE 2

using namespace std;

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

const ll MOD = (ll)1e9 + 7LL;

char domino[2][52];

int main()
{
	memset(domino, 0, sizeof(domino));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	rep (i, 2) rep (j, N){
		cin >> domino[i][j];
	} // end rep

	vector<int> d; d.clear();
	int i = 0;
	while(i < N){
		if (domino[0][i] == domino[1][i]){
			d.push_back(TATE);
			++i;
		}else
		if ((i + 1 < N) && (domino[0][i] == domino[0][i+1]) && (domino[1][i] == domino[1][i+1])){
			d.push_back(YOKO);
			i += 2;
		} // end if
	} // end rep

	ll res = 1LL;
	if (d[0] == YOKO){
		res = (res * 6LL) % MOD;
	}else
	if (d[0] == TATE){
		res = (res * 3LL) % MOD;
	} // end if
/*
	rep (i, (int)d.size()){
		cerr << (d[i] == YOKO ? 'Y' : (d[i] == TATE ? 'T' : '?'));
	} // end rep
	cerr << endl;
*/
	for (int i = 1; i < (int)d.size(); ++i){
		if (d[i-1] == YOKO){
			if (d[i] == YOKO){
				res = (res * 3LL) % MOD;
			}else
			if (d[i] == TATE){
				res = (res * 1LL) % MOD;
			} // end if
		}else
		if (d[i-1] == TATE){
			if (d[i] == YOKO){
				res = (res * 2LL) % MOD;
			}else
			if (d[i] == TATE){
				res = (res * 2LL) % MOD;
			} // end if
		} // end if
	} // end for

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long H, long long A){
	cout << (H+A-1)/A << endl;

}

int main(){
    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,A;
	cin>>N;
	A=((N%10)+(N/10)%10+(N/100)%10+(N/1000)%10+(N/10000)%10+(N/100000)%10+(N/1000000)%10+(N/10000000)%10+(N/100000000)%10+(N/1000000000)%10);
	if(N%A==0){
		cout<<"Yes"<<endl;	
	}
	else{
		cout<<"No"<<endl;
	}

}

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

int main(){
    int i,n,count=1;
    cin >> n;
    vector<int> a(n);
    bool big=true,small=true;
    for(i=0;i<n;i++){
        cin >> a.at(i);
        if(i==0)continue;
        else{
            if(a.at(i-1)==a.at(i))continue;
            else if(a.at(i-1)<a.at(i)){
                if(big){
                    big=true;
                    small=false;
                }
                else{
                    big=true;
                    small=true;
                    count++;
                }
            }
            else if(a.at(i-1)>a.at(i)){
                if(small){
                    big=false;
                    small=true;
                }
                else{
                    big=true;
                    small=true;
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll INF = 1e6;

void solve()
{
    ll n, m;
    cin>>n>>m;
    if(m==1 || n==m)
        cout<<0;
    else
    {
        if(n>m)
        cout<<(n/m+1)*m-n;
        else
        {
            if(2*n<=m)
                cout<<n;
            else
                cout<<m-n;
        }
    }
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s;
    s+=s[0];
    //cout<<s<<"\n";
    string anst;
    for(int i=0;i<4;i++){
        string ans;
        if(i==0)
        ans="WW";
        else if(i==1)
        ans="WS";
        else if(i==2)
        ans="SS";
        else 
        ans="SW";
        bool c=false;
        for(int j=1;j<=n;j++){
            //cout<<ans[ans.size()-1]<<" "<<ans[ans.size()-2]<<" "<<s[i]<<"\n";
            if(s[j]=='o'){
                if(ans[ans.size()-1]=='W'){
                    if(ans[ans.size()-2]=='W'){

                        ans+='S';
                    }
                    else{
                        ans+='W';
                    }
                }
                else{
                    if(ans[ans.size()-2]=='W'){
                        ans+='W';
                    }
                    else{
                        ans+='S';
                    }
                }
            }
            else{
                if(ans[ans.size()-1]=='W'){
                    if(ans[ans.size()-2]=='W'){
                        ans+='W';
                    }
                    else{
                        ans+='S';
                    }
                }
                else{
                    if(ans[ans.size()-2]=='W'){
                        ans+='S';
                    }
                    else{
                        ans+='W';
                    }
                }
            }
            //cout<<ans<<"\n";
        }
        if(ans[0]==ans[ans.size()-2]&&ans[1]==ans[ans.size()-1]) {
            //cout<<ans<<"\n";
            anst=ans;
            break;
        }
        if(i==3) return cout<<-1<<"\n",0; 
    }
    for(int i=0;i<anst.size()-2;i++){
        cout<<anst[i];
    }
    cout<<"\n";
}


Measured memory_bytes: 744
n, k = [int(x) for x in input().split()]

arr = [int(x) for x in input().split()]

# dp[i] -> number of ways to distribute i candies to n childers
MOD = 10**9 + 7
dp = [0]*(k+1)

dp[0] = 1
pref = [0] + [1]*(k+1)
for i in range(n):
    for left in range(k,0,-1):
        dp[left] += pref[left] - pref[left - min(arr[i],left)]
        dp[left] %= MOD
        # for give in range(1,min(arr[i],left)+1):
        #     dp[left] += dp[left-give]
    pref = [0]
    for e in dp:
        pref.append(pref[-1] + e)

print(dp[k]%MOD)


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

using namespace std;

int main(int argc, char *argv[])
{
    
    
    
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);

    int m, f, r;
    
    while (cin >> m >> f >> r, m + 1 || f + 1 || r+1) {
        if (m == -1 || f == -1) {
            cout << "F" << endl;
        }
        else if (m+f>=80){
            cout << "A" << endl;
        }
        else if (m+f>=65){
            cout << "B" << endl;
        }
        else if (m+f>=50){
            cout << "C" << endl;
        }
        else if (m+f>=30){
            if (r>=50) {
                cout << "C" << endl;
            }
            else {
                cout << "D" << endl;
            }
        }
        else {
            cout << "F" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>
#include <math.h>

int main(void) {
    unsigned long long h;
    unsigned long long i;

    scanf("%llu", &h);

    for (i = 1; h > 1; h /= 2)
        i *= 2;

    printf("%llu\n", i * 2 - 1);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    
    string s;
    cin >> s;
    
    if(s[0] == '9' || s[1] == '9'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int a;
	cin >> a;

	if (a % 100 <= 12 && a % 100 >= 1) {
		if (a / 100 <= 12 && a / 100 >= 1)
			cout << "AMBIGUOUS" << endl;
		else
			cout << "YYMM" << endl;
	}
	else if (a / 100 <= 12 && a / 100 >= 1)
		cout << "MMYY" << endl;
	else
		cout << "NA" << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    e = [[] for _ in range(n)]
    for _ in range(m):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)

    s, t = ns()
    s, t = s - 1, t - 1

    visited = [[True] * 3 for _ in range(n)]

    que = collections.deque()
    que.append([0, s])
    visited[s][0] = False
    cnt = 0
    ans = -1
    flg = True

    while que and flg:
        cnt += 1
        for _ in range(len(que)):
            i, q = que.popleft()
            for ei in e[q]:
                tmp = (i + 1) % 3
                if tmp == 0 and ei == t:
                    ans = cnt // 3
                    flg = False
                    break
                elif visited[ei][tmp]:
                    visited[ei][tmp] = False
                    que.append([tmp, ei])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 34920
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    const ll mod=1e9+7;
    int n,m;
    cin>>n>>m;
    vector<ll>dp(n+1,1);
    rep(i,m){
        int a; cin>>a;
        dp[a]=0;
    }
    for(int i=2; i<=n; ++i){
        if(dp[i]!=0)dp[i]=(dp[i-1]+dp[i-2])%mod;
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		char ans[] = {'A', 'G', 'T', 'C'};
		int a = -1;
		StringBuffer ans2 = new StringBuffer();
		String ans3 = "";
		for(int i = 0; i < s.length(); ++i) {
			a = -1;
			for(int j = 0; j < ans.length; ++j) {
				if(s.charAt(i) == ans[j]) {
					ans2.append(s.charAt(i));
					a = 0;
				}
			}
			if(a == -1) {
				if(ans3.length() < ans2.length()) {
					ans3 = ans2.substring(0).toString();
				}
				ans2.delete(0,  ans2.length());
			}
		}
		if(ans3.length() < ans2.length())
			ans3 = ans2.substring(0).toString();
		System.out.println(ans3.length());
	}

}


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

using namespace std;

int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    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 += 1;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
x_list = list(map(int, input().split()))

x_list.sort()
ans = 0

margin = [0] * (M - 1)
f = x_list[0]
for i in range(1, M):
    margin[i - 1] = x_list[i] - f
    f = x_list[i]
margin = sorted(enumerate(margin), key=lambda x: (-x[1], x[0]))
cnt = [0]
for i, v in margin:
    if len(cnt) == N:
        break
    cnt.append(i + 1)

if len(cnt) == 1:
    p = -1
    for i, x in enumerate(x_list):
        if i == 0:
            p = x_list[0]
        else:
            ans += x_list[i] - p
            p = x_list[i]
    print(ans)
    exit()
start = 0
prev = x_list[0]
cnt.append(M)
cnt.sort()
for i, c in enumerate(cnt[1:]):
    for j in range(start, c):
        ans += x_list[j] - prev
        prev = x_list[j]
    if c != M:
        start = c
        prev = x_list[c]
print(ans)


Measured memory_bytes: 26400
package main

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

func main() {
	x, y, z, k := readInt(), readInt(), readInt(), readInt()
	a := make([]int, x)
	for i := range a {
		a[i] = readInt()
	}
	b := make([]int, y)
	for i := range b {
		b[i] = readInt()
	}
	c := make([]int, z)
	for i := range c {
		c[i] = readInt()
	}

	ab := make([]int, 0)
	for i := range a {
		for j := range b {
			ab = append(ab, a[i]+b[j])
		}
	}

	sort.Sort(sort.Reverse(sort.IntSlice(ab)))
	sort.Sort(sort.Reverse(sort.IntSlice(c)))

	kk := min(len(ab), k)
	abc := make([]int, kk*z)
	for i := 0; i < kk; i++ {
		for j := range c {
			abc[j+i*z] = ab[i] + c[j]
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(abc)))

	for i := 0; i < k; i++ {
		fmt.Println(abc[i])
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

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

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

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

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

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 61464
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let c = char();
    println!("{}", match c {
        'a' => "vowel",
        'e' => "vowel",
        'i' => "vowel",
        'o' => "vowel",
        'u' => "vowel",
        _ => "consonant"
    })
}


Measured memory_bytes: 4352
/*input
5 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e15;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}

// default code end
const ll maxn=105;
const ll maxlg=__lg(maxn)+2;
vector<pii> v;
int main(){
	int n,k;
    cin>>n>>k;
    int x=((n-1)*(n-2))/2;
    if(x<k){
        cout<<-1;
        return 0;
    }
    REP(i,n-1) v.pb({i,n-1});
    while(x>k){
        REP(i,n){
            for(int j=i+1;j<n-1;j++){
                v.pb({i,j});
                x--;
                if(x==k) break;
            }
            if(x==k) break;
        }
    }
    cout<<sz(v)<<'\n';
    REP(i,sz(v)) cout<<v[i].f+1<<' '<<v[i].s+1<<'\n';
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;


ll A[1005],B[1005],C[1005],AB[3005];

int main(){
    ll X,Y,Z,K; cin >> X >> Y >> Z >> K;
    for(int i=0;i<X;i++) cin >> A[i];
    for(int i=0;i<Y;i++) cin >> B[i];
    for(int i=0;i<Z;i++) cin >> C[i];

    vector<ll> v;
    for(int i=0;i<X;i++){
        for(int j=0;j<Y;j++){
            v.push_back(A[i]+B[j]);
        }
    }
    sort(v.rbegin(),v.rend());
    for(int i=0;i<min(X*Y,K);i++) AB[i] = v[i];

    vector<ll> ans;
    for(int i=0;i<min(X*Y,K);i++){
        for(int j=0;j<Z;j++){
            ans.push_back(AB[i]+C[j]); 
        }
    }
    sort(ans.rbegin(),ans.rend());

    for(int i=0;i<K;i++) cout << ans[i] << "\n";

    return 0;
}

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

int day[1001][11][21];

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

	memset(day, -1, sizeof day);

	int x = 0;
	for(int y = 1; y < 1000; y++) {
		for(int m = 1; m <= 10; m++) {
			int dmax = 19;
			if(y % 3 == 0) dmax = 20;
			else if(m % 2 == 1) dmax = 20;
			for(int d = 1; d <= dmax; d++) {
				day[y][m][d] = x++;
			}
		}
	}

	int n;
	cin >> n;
	while(n--) {
		int y, m, d;
		cin >> y >> m >> d;
		cout << x - day[y][m][d] << endl;
	}
}

Measured memory_bytes: 4044
n,m = list(map(int,input().split()))
l = []
for i in range(n): l.append(list(map(int,input().split())))
l.sort(key = lambda x:x[0])

res = 0
while m > 0:
  if l[0][1] == 0:
    l.pop(0)
  else:
    res += l[0][0]
    l[0][1] -= 1
    m -= 1
print(res)

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

using namespace std;

int main() {
  int n;
  cin>>n;
  int w;
  cin>>w;
  vector<int> a(n),b(n);
  for (int i=0;i<n;i++) {
    cin>>a[i];
    cin>>b[i];
  }
  vector<long int> dp(100001,1e10);
  dp[0]=0;
  for (int i=0;i<n;i++) {
    for (int j=100000;j>=b[i];j--) dp[j] = min(dp[j],dp[j-b[i]]+a[i]); 
  }
  int soln=0;
  for (int i=1;i<=100000;i++) {
    if (dp[i]<=w*1l) soln = i;
  }
  cout<<soln;
  return 0;
}
  

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;

ll my_pow(ll a, ll b) {
	if(b == 0) return 1;
	return a*my_pow(a,b-1) % MOD;
}

int main(){
	int n;
	cin >> n;
	vector<ll> d(n);
	for(int i=0;i<n;i++) cin >> d[i];
	if(d[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	sort(d.begin(), d.end());
	if(d[1] != 1) {
		cout << 0 << endl;
		return 0;
	}
	vector<pair<ll,ll>> c;
	ll cnt = 1;
	for(int i=1;i<n;i++) {
		if(d[i-1]==d[i]) {
			cnt++;
		}else{
			c.push_back({cnt, d[i-1]});
			cnt = 1;
		}
	}
	c.push_back({cnt,d[n-1]});
	ll ans = 1;
	for(int i=1;i<c.size();i++) {
		//cout << c[i].first << " " << c[i].second << endl;
		if(i != c[i].second) {
			cout << 0 << endl;
			return 0;
		}
		ans *= my_pow(c[i-1].first,c[i].first);
		ans %= MOD;
	}
	cout << ans << endl;
}

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


typedef long long ll;

const int maxn=2e5+10;

int main()
{
	string s;
	cin>>s;
	int cnt=0,ans=0;
	
	for( int i=0;i<3;i++ )
	{
		if( s[i]=='R' ) cnt++;
		else
		{
			ans=max(ans,cnt);
			cnt=0;
		}
	}
	ans=max(ans,cnt);
	cout<<ans<<endl;
} 

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

namespace abc_090a
{
    class Program
    {
        static void Main(string[] args)
        {
            string output = "";
            for (int i = 0; i < 3; i++)
            {
                string raw = Console.ReadLine();
                output += raw[i];
            }
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 13140
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static void main(String[] args) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int ans=0;
		ans+=a+b+c;
		
		if(ans>=22) {
			p("bust");
		}else {
			p("win");
		}
		
	}
	
	
	
	
}


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

int main(){ 
    int n;
    cin >> n;
    char s[10000];
    cin >> s;
    //for(int i=0;i<27;i++) cin >> s[i];
    int l=strlen(s);
    for(int i=0;i<l;i++){
        int index = s[i]-'A';
        index=(index+n)%26;
        //cout << index-'A';
        putchar(index+'A');
    }
    putchar('\n');
    //cout << endl;
    
    return 0;
} 


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

# flip odd or even
# check concatinated mass
# if that odd, it will back. if even, be opposite.
# ans=0
# for i in range(n):
#     for j in range(m):
#         c=0
#         for h in range(-1,2):
#             for w in range(-1,2):
#                 if 0<i+h<n-1 and 0<j+w<m-1:
#                     c+=1
#         if c%2==1:
#             ans+=1
# print(ans, flush=True)
# TLE


ans=0
if n==1 and m==1:
    print(1, flush=True)
elif n==1 or m==1:
    print(max(n-2, m-2), flush=True)
else:
    print((n-2)*(m-2))


Measured memory_bytes: 9024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
# include <climits>
#define ll long long int
#define rep(i,rept) for (ll i = 0; i < rept; i++)
#define yes(b) std::cout<< (b ? "Yes" : "No")
#define YES(b) std::cout<< (b ? "YES" : "NO")
using namespace std;
/*int ketawa(ll num) {
	int dig, sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}
*/
ll func(ll a, ll b, ll c, ll d,int n) {
	return ((c / (d - b) + n)*(d - b)) + (a % (d - b));
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s="aoieu";
	char c;
	cin >> c;
	cout << (s.find(c) == string::npos ? "consonant" : "vowel");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < 100; ++i) {
        if(1+(a-1)*i >= b){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;
    vint p(m);
    vstr s(m);
    rep(i, m) {
        cin >> p[i] >> s[i];
        p[i]--;
    }

    vbool f(n, false);
    vint pn(n, 0);
    int pn_ans = 0;
    rep(i, m) {
        if (s[i] == "AC" && f[p[i]] == false) {
            pn_ans += pn[p[i]];
            f[p[i]] = true;
        }
        if (s[i] == "WA" && f[p[i]] == false) {
            pn[p[i]]++;
        }
    }
    int ac = 0;
    rep(i, n) if (f[i]) ac++;

    cout << ac << " " << pn_ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	int n;
	cin>>n;
	long long int a[n];
	long long int x;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
		
	}
	x=a[0];
	for(int i=1;i<n;i++)
		x=x^a[i];
	for(int i=0;i<n;i++){
		cout<<(x^a[i])<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 5084