akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> closest(n + 1, 0);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;

        chmax(closest[b], a);
    }

    int ans = 0;
    int cut = 1;
    rep(i, n + 1)
    {
        if (closest[i] >= cut)
        {
            cut = i;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
const int N = 2000 + 10;
const ll inf = 1e18 + 10, mod = 1e9 + 7;
int x;
int main()
{
    ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("lca_rmq.in", "r", stdin);
    //freopen("lca_rmq.out", "w", stdout);
    for(int i = 1; i <= 5; i++)
    {
        cin >> x;
        if(x == 0)cout << i;
    }
}

















Measured memory_bytes: 3576
package main

import "fmt"

func main() {
	var str string

	fmt.Scan(&str)
	m := map[int32]int{}

	for _, s := range(str) {
		m[s] += 1
	}

	c := 0
	for _, v := range m {
		c += 1
		if c > 2 || v != 2 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


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

int main() {
    int n,m,x;
    cin>>n>>m>>x;
    int l=0,r=0;
    for (int i=0;i<m;i++) {
        int a;
        cin>>a;
        if (a<x)
            l++;
        else
            r++;
    }
    cout<<min(l,r)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll ans = 0;
    ll k, x;

    cin >> k >> x;

    for (int i = 0; i < 2 * k - 1; i++) {
        cout << x - k + i + 1 << " ";
    }
    cout << endl;

    
}

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

using namespace std;

int main()
{
    string a="Sunny";
    string b="Cloudy";
    string c="Rainy";
    string s;
    cin >>s ;
    if(s[0]=='S'){
        cout <<b<< endl;
    }
    else if(s[0]=='C'){
        cout << c << endl;
    }
    else cout << a << endl;
    return 0;
}


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

int main(){

  int n;
  string sa,sd;
  int fa,fd;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> sa >> sd;
    fa = 0;
    fd = 0;
    for(int j=0;j<sa.length();j++){
      if(sa[j] == 'm')
	{
	  if( 2 <= sa[j-1]-'0' && sa[j-1]-'0' <= 9)
	    {
	      fa += 1000*(sa[j-1]-'0');
		continue;
	    }
	  fa += 1000;
	} 
      if(sa[j] == 'c')
	{
	  if( 2 <= sa[j-1]-'0' && sa[j-1]-'0' <= 9)
	    {
	      fa += 100*(sa[j-1]-'0');
		continue;
	    }
	  fa += 100;
	} 
      if(sa[j] == 'x')
	{
	  if( 2 <= sa[j-1]-'0' && sa[j-1]-'0' <= 9)
	    {
	      fa += 10*(sa[j-1]-'0');
		continue;
	    }
	  fa += 10;
	} 
      if(sa[j] == 'i')
	{
	  if( 2 <= sa[j-1]-'0' && sa[j-1]-'0' <= 9)
	    {
	      fa += 1*(sa[j-1]-'0');
		continue;
	    }
	  fa += 1;
	} 
     
    }




 for(int j=0;j<sd.length();j++){
      if(sd[j] == 'm')
	{
	  if( 2 <= sd[j-1]-'0' && sd[j-1]-'0' <= 9)
	    {
	      fd += 1000*(sd[j-1]-'0');
		continue;
	    }
	  fd += 1000;
	} 
      if(sd[j] == 'c')
	{
	  if( 2 <= sd[j-1]-'0' && sd[j-1]-'0' <= 9)
	    {
	      fd += 100*(sd[j-1]-'0');
		continue;
	    }
	  fd += 100;
	} 
      if(sd[j] == 'x')
	{
	  if( 2 <= sd[j-1]-'0' && sd[j-1]-'0' <= 9)
	    {
	      fd += 10*(sd[j-1]-'0');
		continue;
	    }
	  fd += 10;
	} 
      if(sd[j] == 'i')
	{
	  if( 2 <= sd[j-1]-'0' && sd[j-1]-'0' <= 9)
	    {
	      fd += 1*(sd[j-1]-'0');
		continue;
	    }
	  fd += 1;
	} 
     
    }
 // cout << fa << " "  <<fd <<endl;    

 int ff = fa+fd;    
 char ch[20000];
 sprintf(ch,"%d",ff);
 string s;
 string ans;
 s.append(ch);
 for(int i=0;i<s.length();i++){
   if(s[i]-'0' == 0){
continue;
   }
   else if(2 <= s[i]-'0' && s[i]-'0' <= 9){
     cout << s[i];
   }
   if(s.length() == 4){
     if(i == 0)cout << 'm';
     else if(i == 1)cout << 'c';
     else if(i == 2)cout << 'x';
     else if(i == 3)cout <<'i';
   }
   else if(s.length() == 3){
     if(i == 0)cout << 'c';
     else if(i == 1)cout << 'x';
     else if(i == 2)cout <<'i';
   }
 else if(s.length() == 2){
     if(i == 0)cout << 'x';
     else if(i == 1)cout <<'i';
   }
 else if(s.length() == 1){
    cout <<'i';
   }
   



 }cout << endl;







    
  }
  





}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void) {
	int a[5], i, ans = 0;
	for (i = 0; i < 3; i++) {
		cin >> a[i];
		ans = ans + a[i];
	}
	if (ans >= 22) {
		cout << "bust" << endl;
	}
	else
		cout << "win" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PII pair<int,int>
using namespace std;
const int P=998244353;
const int N=2.1e6+5;
const int Gi=332748118;

struct Pint{
	int x;
	inline Pint(){x=0;}
	inline Pint(int b){x=(b%P+P)%P;}
	inline void operator=(int b){x=(b%P+P)%P;}
    inline bool operator==(const Pint &b) const {return x==b.x;}
    inline bool operator!=(const Pint &b) const {return x!=b.x;}
    inline Pint operator+(const Pint &b)const {return x+b.x>=P?x+b.x-P:x+b.x;}
	inline Pint operator-(const Pint &b)const {return x-b.x<0?x-b.x+P:x-b.x;}
	inline Pint operator*(const Pint &b)const {return 1LL*x*b.x%P;}
	inline void operator+=(const Pint &b){x=x+b.x>=P?x+b.x-P:x+b.x;}
	inline void operator-=(const Pint &b){x=x-b.x<0?x-b.x+P:x-b.x;}
	inline void operator*=(const Pint &b){x=1LL*x*b.x%P;}
	inline void read(){
		char c;int a, b;
	    for(c=getchar(),a=0,b=1;c<48||57<c;c=getchar()){
	        if(c==EOF){x=0;return;}
	        if(c=='-')b=-1;
	    }
	    for(;48<=c&&c<=57;c=getchar())a=((a+(a<<2))<<1)+(c^'0');
	    *this=a*b;
	}
};
Pint a[N],b[N],o[N],fac[N],inv[N],ans;
int lim,l,n,m,r[N],h[N],p[N];
inline Pint ksm(Pint x,int y=P-2){
	Pint ans=1;
	for(;y;y>>=1,x*=x)
		if(y&1)ans*=x;
	return ans;
}
inline void init(int len){
    lim=1,l=-1;
    while(lim<=len)lim<<=1,++l;
    for(int i=1;i<lim;i++)r[i]=(r[i>>1]>>1)|((i&1)<<l);
}
inline void NTT(Pint *A,int ty){
    for(int i=0;i<lim;i++)
        if(i<r[i])swap(A[i],A[r[i]]);
    for(int p=1;p<lim;p<<=1){
        int D=p<<1;
		Pint wn=ksm(ty==1?3:Gi,(P-1)/D);
        o[0]=1;
        for(int i=1;i<p;i++)o[i]=o[i-1]*wn;
        for(int i=0;i<lim;i+=D){
            for(int j=0;j<p;j++){
                Pint x=A[i+j],y=A[i+j+p]*o[j];
                A[i+j]=x+y,A[i+j+p]=x-y;
            }
        }
    }
    if(ty==-1){
    	Pint INV__=ksm(lim);
        for(int i=0;i<lim;i++)
            A[i]*=INV__;
    }
}
Pint C(int x,int y){
	return fac[y]*inv[x]*inv[y-x];
}
Pint A(int x,int y){
	return fac[y]*inv[y-x];
}
vector<Pint>f[N];
priority_queue<PII,vector<PII>,greater<PII> >Q;

int main(){
	scanf("%d",&n),n*=2;
    for(int i=1;i<=n;i++)scanf("%d",&h[i]);
    sort(h+1,h+1+n);
    for(int i=1;i<=n;i++){
    	if(h[i]!=h[i-1])p[++m]=1;
    	else p[m]++;
	}
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i;
	inv[n]=ksm(fac[n]);
	for(int i=n-1;~i;i--)inv[i]=inv[i+1]*(i+1);
	for(int i=1;i<=m;i++){
    	for(int j=0;j<=(p[i]>>1);j++){
    		f[i].push_back(A(j,p[i])*C(j,p[i]-j)*ksm(ksm(2,j)));
		}
		Q.push(PII(f[i].size(),i));
	}
	while(Q.size()>1){
		int u=Q.top().second;
		Q.pop();
		int v=Q.top().second;
		Q.pop(); 
		int su=f[u].size(),sv=f[v].size();
		init(su+sv-2);
		for(int i=0;i<=lim;++i) a[i]=0,b[i]=0;
		for(int i=0;i<su;++i) a[i]=f[u][i];
		for(int i=0;i<sv;++i) b[i]=f[v][i];
		NTT(a,1),NTT(b,1);
		for(int i=0;i<lim;i++) a[i]=a[i]*b[i];
		NTT(a,-1);
		++m;
		if(!Q.size()){
			for(int i=0;i<=su+sv-2;++i)
				ans+=ksm(-1,i)*a[i]*A((n-2*i)>>1,n-2*i)*ksm(ksm(2,(n-2*i)>>1));
			break;
		}
		for(int i=0;i<=su+sv-2;++i) f[m].push_back(a[i]);
		Q.push(PII(f[m].size(),m));
	}
	printf("%d\n",ans.x);
} 

Measured memory_bytes: 101500
#include<bits/stdc++.h>
    #define bye ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    using namespace std;
    int main()
    {
        bye;
        int n,r;
        cin>>n;
        while(n>0)
        {
            r=n%10;
            if(r==7)
            {
                cout<<"Yes";
                return 0;
            }
            n/=10;
        }
        cout<<"No";
        return 0;
    }

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

#define ll long long

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int x;
	
	cin >> x;
	
	if(x >= 30 )
		cout << "Yes\n";
	else
		cout <<"No\n";
	
		

	
	return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll a,b; cin >> a >> b;
    if(a*b <= 0){ //0を跨がる時
        cout << "Zero" << endl;
    }
    else{
        if(a>0 && b > 0){
            cout << "Positive" << endl;
        }
        else{
            if((b-a) % 2 == 0)cout << "Negative" << endl;
            else cout << "Positive" << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int D = 365;
V p(D);
V l(D, 0);
VV up(D, V(26));
void calc(ll& now, int x, int d) { // 今のスコア、どれを選んだか、何日目か(0-indexed)
	l[x] = d + 1;
	now += up[d][x];
	rep(j, 26) {
		now -= p[j] * ((d + 1) - l[j]);
	}
}
ll test(ll now, int x, int d) { // その選択をしてみる
	ll tmp = now;
	tmp += up[d][x];
	rep(j, 26) {
		tmp -= p[j] * ((d + 1) - l[j]);
	}
	return tmp - now;
}
int main() { // とりあえずgreedyにやる
	int d;
	cin >> d;
	ll now = 0;
	queue<int> que;
	rep(i, 26) cin >> p[i];
	rep(i, d) rep(j, 26) cin >> up[i][j];
	rep(i, d) {
		ll diff = UNDER;
		int select = -1;
		rep(j, 26) {
			if (chmax(diff, test(now, j, i))) select = j;
		}
		que.push(select + 1);
		calc(now, select, i);
	}
	while (!que.empty()) {
		cout << que.front() << endl;
		que.pop();
	}
	return 0;
}

Measured memory_bytes: 3708
N, M = list(map(int, input().split()))
X_list = sorted(list(map(int, input().split())))
offset_list =[]
for x in range(len(X_list)):
    if x==0:
        continue
    offset = abs(X_list[x] - X_list[x-1])
    offset_list.append(offset)
offset_list.sort(reverse=True)
del offset_list[:N-1]
move_count = 0
for o in offset_list:
    move_count += o
print(move_count)

Measured memory_bytes: 13968
#include <stdio.h>
int main(void){
    int a[5]={0};
    int i,j,tmp;
    
    for(i=0;i<5;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=4;i>0;i--){
        for(j=0;j<i;j++){
            if(a[j]<a[j+1]){
                tmp=a[j];
                a[j]=a[j+1];
                a[j+1]=tmp;
            }
        }
    }
    
    for(i=0;i<5;i++){
        printf("%d",a[i]);
        if(i<4)printf(" ");
    }
    puts("");
    
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

inline bool isPrime(int x) {
  bool ans = true;
  if (x <= 1) ans = false;
  for (int i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      ans = false;
      break;
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 11; i <= 55555; i += 30) {
    if (isPrime(i)) {
      cout << i;
      if (--n == 0) {
        break;
      }
      cout << " ";
    }
  }
  cout << '\n';
}


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

int main(){
  string S;
  cin >> S;
  string s="aaa";
  
  s.at(0)=S.at(0);
  s.at(1)=S.at(1);
  s.at(2)=S.at(2);
  
  cout << s << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9 + 7;
const int INT_MOD=1e9+7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;

signed main(){
    int n;cin>>n;
    int a[3003];
    ll dp[3003][3003]={};
    rep(i,n) cin>>a[i];
    RREP(i,n-1){
        for(int j=i;j<n;j++){
            if((n-i-j-1)%2==0){
                dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
            }else{
                dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define all(cont) cont.begin(), cont.end()
#define pb push_back
#define fi first
#define se second
#define DEBUG(x) cerr << (#x) << ": " << (x) << '\n'

using namespace std;

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

template<class T> bool uin(T &a, T b) {return (a < b ? false : (a = b, true));}
template<class T> bool uax(T &a, T b) {return (a > b ? false : (a = b, true));}

//ifstream f(".in");
//ofstream g(".out");

const int NMAX = 1005;
const int MOD = 1e9 + 7;

char a[NMAX][NMAX];

void add(int &a, int b) {
  a += b;
  if (a >= MOD) a-= MOD;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen(".in", "r", stdin);
#endif

  int n, m;
  cin >> n >> m;
  cin.get();
  for (int i = 1; i <= n; ++i) {
    cin.getline(a[i] + 1, NMAX);
  }

  vector<vector<int>> dp(n + 2, vector<int>(m + 2, 0));

  dp[1][1] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == '.') {
        if (i + 1 <= n && a[i + 1][j] == '.') {
          add(dp[i + 1][j], dp[i][j]);
        }
        if (j + 1 <= m && a[i][j + 1] == '.') {
          add(dp[i][j + 1], dp[i][j]);
        }
      }
    }
  }

  cout << dp[n][m] << '\n';

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
int main()
{
         string a;
         cin>>a;
         int c=0,i;
         for(i=0;i<a.size();i++)
        {
           if(a[i]=='7') c++;
        }
 
         if(c>0) cout<<"Yes"<<endl;
         else cout<<"No"<<endl;
}

Measured memory_bytes: 3584
import sys
sys.setrecursionlimit(10**7)

N = int(input())
color = [-1] * N
G = [[] for _ in range(N)]
W = [[] for _ in range(N)]
for i in range(N-1):
  u, v, w = map(int, input().split())
  G[u-1].append(v-1)
  G[v-1].append(u-1)
  W[u-1].append(w)
  W[v-1].append(w)

def dfs(v, cur):
  color[v] = cur
  for next_v, w in zip(G[v], W[v]):
    if color[next_v] != -1:
      continue
    if w % 2 == 0:
      dfs(next_v, cur)
    else:
      dfs(next_v, 1 - cur)
      
for i in range(N):
  if color[i] != -1:
    continue
  dfs(i, 0)
for i in range(N):
  print(color[i])

Measured memory_bytes: 90840
N = int(input())
A = list(map(int,input().split()))
#t:  1, 2, 3,..., N
#A: A1,A2,A3,...,AN
#|t-s| = At+As となるt,sのペアの数は、
# t-s  = At+As かつ t>s となるt,sのペアの数と等しく、
# t-At =  s+As かつ t>s となるt,sのペアの数と等しい
ms = [0]*N
ps = [0]*N
for i in range(N):
    ms[i],ps[i] = (i+1)-A[i],(i+1)+A[i]

msc,psc = {},{}
mi,pi = 0,0
out = 0
while mi<N:
    msc[ms[mi]] = msc.get(ms[mi],0)+1
    out += psc.get(ms[mi],0)
    psc[ps[mi]] = psc.get(ps[pi],0)+1
    mi+=1
    pi+=1
print(out)

Measured memory_bytes: 132960
#include<stdio.h>
#include<stdlib.h>
int m[40][40],d[40][40][40][40],e[40][40][40][40],h,w,n;
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int f(int a,int b,int c,int d){return m[a][b]+m[c][d]-m[c][b]-m[a][d];}
int main(){
	int i,j,k,l,a;
	while(scanf("%d %d %d",&h,&w,&n),h){
		for(i=0;i<40*40;i++){
			for(j=0;j<40*40;j++)d[i/40][i%40][j/40][j%40]=-1e9;
			for(j=0;j<40*40;j++)e[i/40][i%40][j/40][j%40]=0;
			m[i/40][i%40]=0;
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				scanf(" %d",&a);
				m[i+1][j+1]=m[i+1][j]+m[i][j+1]-m[i][j]+a;//printf("%d ",m[i+1][j+1]);
			}//printf("\n");
		}
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				for(k=0;k+i<=h;k++){
					for(l=0;l+j<=w;l++){//printf("%d,",f(k,l,k+i,l+j));
						if(m[h][w]-f(k,l,k+i,l+j)<=n){
							if(d[k][l][k+i][l+j]<2){
								d[k][l][k+i][l+j]=1;
								e[k][l][k+i][l+j]=MAX(e[k][l][k+i][l+j],m[h][w]-f(k,l,k+i,l+j));
							}
						}
						for(a=k+1;a<k+i;a++){
							if( d[k][l][k+i][l+j]<    d[k][l][a][l+j]+d[a][l][k+i][l+j]){
								d[k][l][k+i][l+j]=    d[k][l][a][l+j]+d[a][l][k+i][l+j];
								e[k][l][k+i][l+j]=MAX(e[k][l][a][l+j],e[a][l][k+i][l+j]);
							}
							if( d[k][l][k+i][l+j]==                         d[k][l][a][l+j]+d[a][l][k+i][l+j]){
								e[k][l][k+i][l+j]=MIN(e[k][l][k+i][l+j],MAX(e[k][l][a][l+j],e[a][l][k+i][l+j]));
							}
						}
						for(a=l+1;a<l+j;a++){
							if( d[k][l][k+i][l+j]<d[k][l][k+i][a]+d[k][a][k+i][l+j]){
								d[k][l][k+i][l+j]=d[k][l][k+i][a]+d[k][a][k+i][l+j];
								e[k][l][k+i][l+j]=MAX(e[k][l][k+i][a],e[k][a][k+i][l+j]);
							}
							if( d[k][l][k+i][l+j]==d[k][l][k+i][a]+d[k][a][k+i][l+j]){
								e[k][l][k+i][l+j]=MIN(e[k][l][k+i][l+j],MAX(e[k][l][k+i][a],e[k][a][k+i][l+j]));
							}
						}//printf("%d %d:",d[k][l][k+i][l+j],e[k][l][k+i][l+j]);
					}//printf("\n");
				}//printf("\n");
			}
		}
		printf("%d %d\n",d[0][0][h][w],n-e[0][0][h][w]);
	}
	return 0;
}


Measured memory_bytes: 21700
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int a[N] = {0};
  
  int joshi;
  for (int i = 0; i< N-1; i++) {
    cin >> joshi;
    a[joshi -1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 4376
#include <iostream>
#include<string>
#include <sstream>
using namespace std;
int main() {
    int a,b ;
    cin>>a>>b;
 ostringstream convert;
string str1="";
string str2="";
if (a>=1 && a<=9 && b>=1 &&b<=9){

          convert<<a;
      string concatonateA=    convert.str();

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

            str1=str1+concatonateA;
          }
           ostringstream convert;
           convert<<b;
      string concatonateB=    convert.str();
 for(int i=0 ;i<a;i++){

            str2=str2+concatonateB;
          }
        }
        if (str1.size()>=str2.size())
 cout<<str1;
 else cout<<str2;
}


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

int vis[101];

int main(){
	int N, K;
	cin >> N >> K;
	
	for(int i=1; i<=K; i++){
		int d1, v;
		cin >> d1;                   //1
		for(int j=1; j<=d1; j++){    //3
			cin >> v;
			vis[v] = 1;
		}
	}
	
	int ans = 0;
	for(int i=1; i<=N; i++){
		if(vis[i]==0) ans++;
	}
	
	cout << ans;
	return 0;
}
 

Measured memory_bytes: 3628
N, X, Y = map(int, input().split())
from itertools import combinations

ans = {i+1:0 for i in range(N)}
for a, b in combinations(range(1, N+1), 2):
    t = b - a
    if a <= X:
        t = min(t, X - a + 1 + abs(Y - b))
    elif a <= Y:
        t = min(t, abs(a - X) + 1 + abs(Y - b))
    ans[t] += 1

for i in range(1, N):
    print(ans[i])

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

typedef long long ll;
using namespace std;

int N;
ll c[9][9];
ll INF = 1LL<<61;
typedef pair<ll, vector<int> > P;
int main() {
	cin >> N;
	vector<int> s;
	for (int i = 1; i <= N; i++) {
		s.push_back(i);
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			cin >> c[i][j];
		}
	}

	map<vector<int>, ll> d;

	priority_queue<P, vector<P>, greater<P> > q;
	d[s] = 0;
	q.push(P(0, s));
	while (!q.empty()) {
		P p = q.top();
		q.pop();
		vector<int> v = p.second;
		if (d[v] < p.first)
			continue;
		for (int i = 1; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				vector<int> nv = v;
				swap(nv[i - 1], nv[j - 1]);
				if (!d.count(nv)) {
					d[nv] = INF;
				}
				if (d[nv] > d[v] + c[i][j]) {
					d[nv] = d[v] + c[i][j];
					q.push(P(d[nv], nv));
				}
			}
		}
	}

	map<vector<int>, ll>::iterator it = d.begin();
	ll ans = 0;
	while (it != d.end()) {
		ans = max(ans, (*it).second);
		it++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10788
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int D,N;
  cin >> D >> N;

  long long num;
  num = pow(100,D);
  if(N == 100){
    cout << num*N+num << endl;
  }else{
    cout << num*N << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n,A,a[51];
ll ans,f[2][51][2510];
int main(){
	scanf("%d%d",&n,&A);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	f[0][0][0]=1;
	for(int i=1;i<=n;++i){
		memcpy(f[i&1],f[(i&1)^1],sizeof(f[i&1]));
		for(int j=1;j<=i;++j){
			for(int k=a[i];k<=2500;++k){
				f[i&1][j][k]+=f[(i&1)^1][j-1][k-a[i]];
			}
		}
	}
	for(int i=1;i<=n;++i) ans+=f[n&1][i][i*A];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007


int main() {
  double A;
  cin >> A;
  A/=3;
  printf("%.20lf\n", A*A*A);

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int C = in.nextInt();
		int K = in.nextInt();
		int[] T = new int[N];
		for (int i = 0; i < N; i++) {
			T[i] = in.nextInt();
		}
		Arrays.sort(T);
		long max = T[0] + K;
		int ans = 0;
		int count = 0;
		int index = 0;
		while (index < N) {
			count++;
			if (T[index] > max) {
				ans++;
				count = 0;
				max = T[index] + K;
			} else if (count == C) {
				ans++;
				count = 0;
				if (index + 1 < N) {
					max = T[index + 1] + K;
				}
				index++;
			} else if (index == N - 1) {
				ans++;
				index++;
			} else {
				index++;
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 49280
// input! macro from
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
use std::mem;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


fn gcd(mut x: u32, mut y: u32) -> u32 {
    if x < y {
        mem::swap(&mut x, &mut y);
    }

    if y == 0 {
        return x;
    }

    gcd(y, x % y)
}


fn main () {
    input!{
        n: usize,
        xs: [u32; n],
    }

    let x0 = xs.iter().next().unwrap();
    let ans = xs.iter().fold(*x0, |acc, x| gcd(acc, *x));
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int a = sc.nextInt();
		int i=1;
		int tmp=h;
		while(true) {
			tmp = tmp-a;
			if(tmp <= 0) break;
			i++;
		}
		System.out.println(i);
		sc.close();

	}

}

Measured memory_bytes: 23892
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();//トッピングの種類数
		int base = sc.nextInt();//生地の値段
		int topping = sc.nextInt();//トッピングの値段
		int basec = sc.nextInt();//生地のカロリー
		int tp[] = new int[x];//トッピングのカロリーの配列
		int i;
		double bc = basec/base;//1ドルあたりの生地のカロリー
		double max = bc;//ベストピザ
		double sum = 0;//合計
		double bunshi = basec;
		double bunbo = base;
		for(i = 0; i < x; i++){
			tp[i] = sc.nextInt();//トッピングのカロリー
		}
		Arrays.sort(tp);//昇順に並び替え
		for(i = x-1; 0 <= i; i--){
			bunshi = bunshi + tp[i];
			bunbo = bunbo + topping;
			sum = bunshi/bunbo;
			if(max <= sum){
				max = sum;
			}
		}
		System.out.println((int)max);
	}

}

Measured memory_bytes: 18148
#include<iostream>
#include<string>
using namespace std;
string in;
int pos;
int p,q,r;

int formula(){
  if(isdigit(in[pos])){
    return in[pos++]-'0';
  }

  switch(in[pos]){
  case 'P':++pos; return p;
  case 'Q':++pos; return q;
  case 'R':++pos; return r;
  }

  if(in[pos]=='-'){
    ++pos;
    return 2-formula();
  }
  ++pos;
  int a=formula();
  char cc=in[pos++];
  int b=formula();
  pos++;
  if(cc=='+'){
    if(a==2 || b==2)return 2;
    if(!a && !b)return 0;
    return 1;
  }
  if(!a || !b)return 0;
  if(a==2 && b==2)return 2;
  return 1;
}


main(){
  while(cin>>in){
    if(in==".")break;
    int ans=0;
    for(p=0;p<3;p++)for(q=0;q<3;q++)for(r=0;r<3;r++){
      pos=0;
      if(formula()==2)++ans;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1188
# vim: fileencoding=utf-8


def main():
    s = input()
    t = input()
    lt = len(t)
    ans = lt
    for i in range(0, len(s) - lt + 1):
        sub = s[i : i + lt]
        c = 0
        for j in range(0, lt):
            if sub[j] != t[j]:
                c += 1
        if ans > c:
            ans = c
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> a(M);
    rep(i,M) cin >> a[i];
    int now = 0;
    vector<int> dp(N+1,0);
    dp[0] = 1;
    for(int i = 1;i<=N;i++){
        if(now < M && a[now] == i){
            ++now;
            continue;
        }
        if(i==1) dp[i] = dp[i-1];
        else {
            dp[i] = dp[i-1] + dp[i-2];
            dp[i]%=(int)(1e9+7);
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 2005
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) printf("Case %lld:\n",i)
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,ll>mpp;
map<pair<ll,ll>,bool>mb;
ll itr,n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,ok=0;
bool flag=0;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>adj[MAX+19];
bool visited[MAX+19];
ll start_time[MAX+10],finish_time[MAX+10],deep[MAX+10],parent[MAX+12];
ll dp[MAX];
void calc()
{
    memset(dp,0,sizeof dp);
    dp[0]=1;
    FOR1(i,MAX)
    {
        dp[i]=(dp[i-1]*i)%mod;
    }
}
ll mulmod(ll a , ll b , ll mo)
{
    ll q = ((long double) a * (long double) b / (long double) mo);
    ll res = a * b - mo * q;
    return ((res % mo) + mo) % mo;
}
ll bigmod (ll a, ll b, ll c)
{
    ll res = 1;
    a=a%c;
    while (b > 0)
    {
        if (b % 2 == 1)
        {
            res=mulmod(res,a,c);
        }
        a=mulmod(a,a,c);
        b=b/2;
    }
    return res;
}
ll m_inv(ll a, ll p)
{
    return bigmod (a,p-2,p);
}
int main()
{
    fast;
    calc();
    cin>>n>>k;
    ll blue=k;
    ll red=n-k;
    blue-=1;
    FOR1(i,k)
    {
        ll ok=1;
        ll ok1=1;
        ll denom=i-1;
        ll x=(dp[blue])%mod;
        ll y=(dp[denom]*dp[blue-denom])%mod;
        ll de=m_inv(y,mod)%mod;
        ll rem=(dp[red+1])%mod;
        if(red+1>=i){
        ll rem1=(dp[red+1-i]*dp[i])%mod;
        ll de1=(m_inv(rem1,mod))%mod;
        ok=(rem*de1)%mod;
        }
        else{
           ok=0;
        }
        ok1=(x*de)%mod;
        ///cout<<"b in r: "<<ok<<endl;
        ///cout<<"way: "<<ok1<<endl;
        cout<<(ok*ok1)%mod<<endl;
    }
    return 0;
}
 /*1 10 9 9
 6 9 9 9
 6 9 9 9
 8 9 9 9
 1 2 5 10 3 4 6 7 8 9
10 4 9 10 3 4 9 7 9 9*/


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

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt {
	fint64 x;
	ModInt():x(0){}
	ModInt(fint64 x):
		x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
		{}
	// 負号
	ModInt operator -() const{
		return ModInt(-x);
	}
	// 加算
	ModInt &operator +=(const ModInt &rhs){
		x+=rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator +(const ModInt &rhs) const{
		return ModInt(*this)+=rhs;
	}
	// 減算
	ModInt &operator -=(const ModInt &rhs){
		x+=MOD-rhs.x;
		if(x>=MOD) x-=MOD;
		return (*this);
	}
	ModInt operator -(const ModInt &rhs) const{
		return ModInt(*this)-=rhs;
	}
	// 乗算
	ModInt &operator *=(const ModInt &rhs){
		x*=rhs.x;
		if(x>=MOD) x%=MOD;
		return (*this);
	}
	ModInt operator *(const ModInt &rhs) const{
		return ModInt(*this)*=rhs;
	}
	// 除算
	ModInt &operator /=(const ModInt &rhs){
		(*this)*=rhs.inverse();
		return (*this);
	}
	ModInt operator /(const ModInt &rhs) const{
		return ModInt(*this)/=rhs;
	}
	// 等号
	bool operator ==(const ModInt &rhs){
		return x==rhs.x;
	}
	bool operator !=(const ModInt &rhs){
		return x!=rhs.x;
	}
	// 累乗
	ModInt pow(fint64 n) const{
		fint64 tmp=x;
		fint64 ret=1;
		while(n>0){
			if(n&1) ret=ret*tmp%MOD;
			tmp=tmp*tmp%MOD;
			n>>=1ll;
		}
		return ModInt(ret);
	}
	// 逆元
	ModInt inverse() const{
		fint64 a=x,b=MOD,s=1,t=0;
		while(b>0){
			fint64 u=a/b;
			a-=u*b;
			s-=u*t;
			swap(a,b);
			swap(s,t);
		}
		return ModInt(s);
	}
	// 入出力
	friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
		fint64 x; lhs>>x;
		rhs=ModInt<MOD>(x);
		return lhs;
	}
	friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
		return lhs<<rhs.x;
	}
};


vector<int> edge[200010];
int parent[200010];
int child[200010];

int dfs(int from, int par) {
	int ret = 0;
	for(int to : edge[from]) {
		if(to == par) continue;
		parent[to] = from;
		ret += dfs(to, from);
	}
	return child[from] = ret + 1;
}

const int MOD = 1e9 + 7;
using mint = ModInt<MOD>;
int main() {
	int n; cin >> n;
	for(int i = 0; i < n - 1; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	parent[0] = -1;
	dfs(0, -1);
	mint ans = 0;
	for(int i = 0; i < n; ++i) {
		mint x = 1;
		mint y = 1;
		for(int j : edge[i]) {
			mint p = 2;
			if(parent[j] == i) {
				p = (mint)1 / p.pow(child[j]);
			} else {
				p = (mint)1 / p.pow(n - child[i]);
			}
			x *= p;
			y += (mint)1 / p - 1;
		}
		ans += ((mint)1 - x * y) / 2;
		// cerr << ((mint)1 - x * y) / 2 << '\n';
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int r;
    cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}


Measured memory_bytes: 256
#coding: utf-8
A, B = map(int, input().split())

if A == 1 and B == 1:
    A = 14
    B = 14
elif A == 1:
    A = 14
elif B == 1:
    B = 14

if A > B:
    print("Alice")
elif A < B:
    print("Bob")
else:
    print("Draw")

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef tuple<string, int, int> T;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> dq(n);
    rep(i, n) {
        cin >> dq[i];
    }
    ll ans = 0;
    for (ll l = 0; l <= k; l++) {
        for (ll r = 0; r <= k - l; r++) {
            if (l + r > n) break;
            ll d = k - l - r;
            ll now = 0;
            vector<ll> s;
            for (ll i = 0; i < l; i++) {
                now += dq[i];
                s.push_back(dq[i]);
            }
            for (ll i = n - r; i < n; i++) {
                now += dq[i];
                s.push_back(dq[i]);
            }
            sort(s.begin(), s.end());
            for (ll i = 0; i < d; i++) {
                if (i >= s.size()) break;
                if (s[i] >= 0) break;
                now -= s[i];
            }
            ans = max(ans, now);
        }
    }

    cout << ans << endl;
}



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


int main()
{
	int N, R;
	cin >> N >> R;
	if (N >= 10) cout << R << endl;
	else {
		cout << R + 100 * (10 - N) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
"""

重要度はlかuしかとらないと考えてよい
高橋君のほうが青木君より低い点数を取ると決めた科目に対してはl、それ以外はuと定める
それぞれのテストの点数の差をdとして、Σ[a>=b](d*u) - Σ[a<b](d*l) >= 0 を満たす
最小のΣaを求める
→各iについて、biまではli個ずつ減らすことができ、それより多く減らす場合はXを超えない範囲で
 ui個ずつ減らすことができる
→heapqでできそう
 単純なheapqだと、例えば一つのテストの中でlとuの値の差がとても大きい時に
 正しい答えが出せない
→二分探索

"""
import sys
input = sys.stdin.readline

n, x = map(int, input().split())
BLU = [list(map(int, input().split())) for _ in range(n)]
SBLU = sorted([(b*l+(x-b)*u, b, l, u) for b, l, u in BLU], reverse=True)
S, B, L, U = zip(*SBLU)
M = sum([b*l for b, l, u in BLU])

def select(q, r):
  f = sum(S[:q+1])
  for i in range(n):
    temp = f - S[min(i, q)]
    temp += L[i]*min(B[i], r) + U[i]*max(r-B[i], 0)
    if temp>=M:
      return True
  return False


ng = -1
ok = sum(B)
while ok-ng > 1:
  mid = (ok+ng)//2
  q, r = divmod(mid, x)
  if select(q, r):
    ok = mid
  else:
    ng = mid
print(ok)

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

long long n,ans,i,x;

int main(){
	
	cin>>n;
	if(n%2==1){
		cout<<"0"<<endl;
		return 0;
	}
	else{
		for(i=10;i<=n;i*=5){
			ans+=(n/i);
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int n, k, ans; cin >> n >> k;
    vector<int> l;
    ans = 0;
    for (int i = 0; i < n; i++)
    {
        int ln;
        cin >> ln;
        l.push_back(ln);
    }
    sort(l.begin(), l.end(), greater<int>());
    for (int j = 0; j < k; j++)
    {
        ans += l.at(j);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from bisect import bisect_right

read = sys.stdin.read

N, D, A, *XH = map(int, read().split())
X = XH[::2]
H = XH[1::2]
D *= 2
X, H = zip(*sorted(zip(X, H)))

damage = [0] * (N + 1)
answer = H[0] // A + min(1, H[0] % A)
damage[0] += A * answer
damage[bisect_right(X, X[0] + D)] -= A * answer

for i in range(1, N):
    damage[i] += damage[i - 1]
    h = H[i]
    x = X[i]
    if damage[i] >= h:
        continue
    else:
        h -= damage[i]

    cnt = h // A + min(1, h % A)
    answer += cnt
    damage[i] += A * cnt
    damage[bisect_right(X, x + D)] -= A * cnt

print(answer)


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

int main() { /* ここに書く */
  
  int N,ans;
  ans = 0;
  
  for(int i = 1; i<6; i++){
    
    cin >> N;
    
    if(N == 0){
      ans = i;
      break;
    }
    
  }
    
  cout << ans << endl;
}

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

int main()
{
  int N, D;
  cin >> N >> D;
  int X[N][D];
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < D; j++)
    {
      cin >> X[i][j];
    }
  }

  int ans = 0;
  double norm2;
  double norm;
  double eps = 1E-7;
  for (int i = 0; i < N - 1; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      norm2 = 0;
      for (int d = 0; d < D; d++)
      {
        norm2 += pow(X[i][d] - X[j][d], 2);
      };
      if (ceil(sqrt(norm2)) == floor(sqrt(norm2)))
        ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    for i in 0..n {
        a[i] -= i as i64 + 1;
    }
    a.sort();
    let val = |x: i64| {
        let mut res = 0;
        for i in 0..n {
            res += (a[i] - x).abs();
        }
        res
    };

    println!(
        "{}",
        if n > 1 {
            min(val(a[n / 2]), val(a[n / 2 + 1]))
        } else {
            0
        }
    );
}


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

int main(){
    int n;
    cin >> n;
    unordered_set<string> s;
    for(int i = 0; i < n; i++){
        string item;
        cin >> item;
        if(s.find(item) == s.end()){
            s.insert(item);
        }
    }
    
    cout << s.size();
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(4);
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++){
    cin >> X[i] >> Y[i];
  }
  if (N % 2 == 1){
    cout << "NA" << endl;
  } else {
    int Px = 0, Py = 0;
    for (int i = 0; i < N; i++){
      Px += X[i];
      Py += Y[i];
    }
    set<pair<int, int>> st;
    for (int i = 0; i < N; i++){
      st.insert(make_pair(X[i] * N, Y[i] * N));
    }
    bool ok = true;
    for (auto P : st){
      int x = P.first;
      int y = P.second;
      if (!st.count(make_pair(Px * 2 - x, Py * 2 - y))){
        ok = false;
      }
    }
    if (!ok){
      cout << "NA" << endl;
    } else {
      cout << (double) Px / N << ' ' << (double) Py / N << endl;
    }
  }
}


Measured memory_bytes: 3300
package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)


func bordersInt(in_map [][]int, invalid int) [][]int{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]int, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]int, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func bordersString(in_map [][]string, invalid string) [][]string{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]string, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]string, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	buf := make([]byte, 1004)
	sc.Buffer(buf, 1000000009)
	var (
		N, min, check int
		rlist []int
	)
	fmt.Scan(&N)
	rlist = scanIntSplit(N)
	for check != N {
		min, check = 1000000009, 0
		for i:=0; i<N; i++ {
			if rlist[i] < min { 
				min = rlist[i]
			}
		}
		for i:=0; i<N; i++ {
			if rlist[i]%min == 0 {
				rlist[i] = min
				check++
			} else {
				rlist[i] = rlist[i]%min
			}
		}
	}
	fmt.Println(min)
}

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

using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<ll>L(n+1);
    L[0] = 2;
    L[1] = 1;
    for(int i = 2; i <= n; i++){
        L[i] = L[i-1] + L[i-2];
    }

    cout << L[n] << endl;

}

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

#define debug(x) cerr << #x << " = " << x << endl

const int N_MAX = 200003;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  if ((a[0] & 1) == 0 || (a[1] & 1) == 0 || (a[2] & 1) == 0) {
    cout << 0 << endl;
    return 0;
  }
  else {
    sort(a, a + 3);
    cout << 1ll * a[0] * a[1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll x,y;cin>>x>>y;
  ll ans=0;
  while(x<=y){
    ans++;
    x*=2;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	char ch;
	cin >> ch;
	if ('A' <= ch && ch <= 'Z')
		cout << "A";
	else
		cout << "a";
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;


int main(void) {
    string src;
    cin >> src;

    bool invalid = false;
    int result = 0;
    int count = 0;
    for(const auto& c: src) {
        switch(c) {
            case 'A':
            case 'C':
            case 'G':
            case 'T':
                invalid = false;
                count++;
                break;
            default:
                if (!invalid) {
                    if(result < count) {
                        result = count;
                        count = 0;
                    }
                }
                invalid = true;
                break;
        }
    }
    if (!invalid) {
        if(result < count) {
            result = count;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
cities = []
m.times do
  cities << gets.chomp.split(" ").map(&:to_i)
end
cities.each_with_index do |city, index|
  city.unshift(index)
end

cities.sort! {|a, b| (a[1] <=> b[1]).nonzero? || (a[2] <=> b[2])}

previous = 0
count = 0

cities.each_with_index do |city, index|
  if city[1] != previous
    count = 1
  elsif city[1] == previous
    count += 1
  end
  city << "%#06d" % city[1] + "%#06d" % count
  previous = city[1]
end

cities.sort! {|a, b| a[0] <=> b[0]}

cities.each do |city|
  puts city[3]
end

Measured memory_bytes: 33256