akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  vector<int> C(N);
  for(int i=0;i<N;i++){
    cin>>C.at(i);
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    if(V.at(i)>=C.at(i)){
      ans+=V.at(i)-C.at(i);
    }
  }
  cout<<ans<<endl;
  return 0;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int n,k;
    cin>>n>>k;
    cout<<(n-k+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 2e5+9, INF = 0x3f3f3f3f;
int dt[105], v[105], w[105];

int main( void ) {
    ios::sync_with_stdio( false );
    int n, num;
    cin >> n;
    for( int i = 0; i < n; ++i ) cin >> dt[i];
    for( int i = 1; i <= n; ++i ) {
        cin >> num;
        v[i] = num;
    }
    for( int i = 1; i <= n - 1; ++i ) {
        cin >> num;
        w[i] = num;
    }
    int ans = v[dt[0]];
    for( int i = 1; i < n; ++i ) {
        if( dt[i] - dt[i - 1] == 1 ) ans += v[dt[i]] + w[dt[i - 1]];
        else ans += v[dt[i]];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
r = 0;
for a in range(0, A + 1):
    for b in range(0, B + 1):
        for c in range(0, C + 1):
            if (500 * a + 100 * b + 50 * c == X):
                r += 1
print(r)


Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/format.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  const string pat = (boost::format("^\\d{%d}-\\d{%d}$") % A % B).str();
  regex re(pat);
  cout << (regex_match(S, re) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<ll>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi a(n);
    vi sum(n+1);
    rep(i, n) {
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }

    sort(sum.begin(), sum.end());
    ll ans = 0LL;
    map<ll, int> mp;
    rep(i, n+1) {
        mp[sum[i]]++;
    }

    for(pair<ll, int> x:mp) {
        if(x.second&1) {
            ans += (x.second-1)/2LL*x.second;
        } else {
            ans += x.second/2LL*(x.second-1);
        }
        
    }

    cout << ans << endl; 
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> kane(N+1);
    for(int i = 0; i < N+1; i++){
        kane[i] = i;
    }
    for(int i = 9 ; i < N+1; i = i*9){
        for (int j = 0; j < N + 1; j++){
            if (j+i < N+1){
                kane[j+i] = min(kane[j+i],kane[j]+1);
            }
        }
    }
    for(int i = 6; i < N+1; i = i*6){
        for (int j = 0; j < N+1; j++){
            if(j+i < N+1){
                kane[j+i] = min(kane[j+i],kane[j]+1);
            }
        }
    }
    cout << kane[N] << endl;
}

Measured memory_bytes: 3776
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
int A,B,Q;
vector<ll> As,Bs,Qs;
ll INF=(ll)1000*1000*1000*1000;
int main() {
  cout << fixed << setprecision(15);
  cin >> A >> B >> Q;
  As.resize(A);Bs.resize(B);Qs.resize(Q);
  REP(i,A)
    As[i]=getll();
  REP(i,B)
    Bs[i]=getll();
  REP(i,Q) {
    ll x=getll();
    auto ita=lower_bound(ALL(As),x);
    auto itb=lower_bound(ALL(Bs),x);
    // only go left
    ll ans=INF;
    vector<ll> alis,blis;
    if (ita!=As.end()) {
      alis.pb(*ita);
    }
    if (itb!=Bs.end()) {
      blis.pb(*itb);
    }
    if (ita!=As.begin()) {
      ita--;
      alis.pb(*ita);
    }
    if (itb!=Bs.begin()) {
      itb--;
      blis.pb(*itb);
    }
    for(ll a:alis)
      for(ll b:blis) {
        ans = min(ans,abs(a-x)+abs(b-a));
        ans = min(ans,abs(b-x)+abs(b-a));
      }
    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int a[]={-1,0,2,0,1,0,1,0,0,1,0,1,0};
    int x,y;
	cin >> x>> y;
    string ans;
    if(a[x]==a[y])ans="Yes";
    else ans = "No";
      cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define INF 1 << 30
#define MAX_N 100

using namespace std;

int cost[MAX_N][MAX_N];
int mincost[MAX_N];
bool used[MAX_N];
int n;

int prim(){
  rep(i, n){
    mincost[i] = INF;
    used[i] = false;
  }

  mincost[0] = 0;
  int res = 0;

  while(true){
    int v = -1;
    rep(u, n)
      if(!used[u] && (v == -1 || mincost[u] < mincost[v])) v = u;

    if(v == -1) break;
    used[v] = true;
    res += mincost[v];

    rep(u, n)
      mincost[u] = min(mincost[u], cost[v][u]);
  }
  return res;
}

int main(){
  int m;
  while(scanf("%d%d", &n, &m) && n+m){
    rep(i, n) rep(j, n) cost[i][j] = INF;
    rep(i, m){
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      cost[a][b] = cost[b][a] = c;
    }
    
    printf("%d\n", prim());
  }
  return 0;
}

Measured memory_bytes: 1228
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,l,r) for(int i=(l);i<(r);i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 

int main(){
    ll x=0,y=0,z=0,n,m=0,k,ans=0,h,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9+1;
    string s,t,u;
    char c;
    bool ok=true;
    cin >> c;
    //VL a();
    cout << (char)(c+1) << endl;
    return 0;
}


 

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(int argc, char** argv) {
	int h, n;
  cin >> h >> n;
  int a[n];
  int total = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    total += a[i];
  }
  
  if (total >= h) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 888
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const int N=300005;
const int MOD=998244353;
int n,A[N],a[N];
bool vis[N];
int L[N],R[N];
int s[N];//已经确定的位置 
int tim;
int ans=1;
struct qq
{
	int len,id;
}h[N];int cnt=0;
int pos;
bool cmp (qq x,qq y)	{return x.id<y.id;}
int mul (int x,int y)	{return (LL)x*y%MOD;}
void solve ()
{
	for (int u=1;u<=n;u++)
		if (s[u]!=0)
		{
			pos=u;
			break;
		}
//	printf("ans:%d\n",ans);
/*	printf("%d\n",pos);
	for (int u=1;u<=n;u++) printf("%d ",s[u]);
	printf("\n");*/
	int now=pos,lst=s[now],o=0;
	do
	{
		now++;
		if (now>n) now=1;
		if (s[now]!=0)
		{
			//printf("OZY:%d %d\n",lst,s[now]);
			if (o!=0)
			{
				cnt++;
				h[cnt].len=o;
				h[cnt].id=max(lst,s[now]);
			}	
			lst=s[now];
			o=0;
		}
		else o++;
	}while (now!=pos);
	sort(h+1,h+1+cnt,cmp);
	//for (int u=1;u<=cnt;u++) printf("%d %d\n",h[u].id,h[u].len);
	int lalal=0;
	now=0;
	for (int u=1;u<=n;u++)//这个数需要被插入 
		if (vis[u]==false)
		{
			while (now<=cnt&&h[now+1].id<u)
			{
				now++;
				lalal=lalal+h[now].len;
			}
			//printf("%d %d %d %d\n",u,lalal,now,h[now+1].id);
			if (lalal==0)
			{
				printf("0\n");
				return ;
			}
			ans=mul(ans,lalal);
			lalal--;
		}
	printf("%d\n",ans);
}
int main()
{
	memset(s,0,sizeof(s));
	memset(vis,false,sizeof(vis));
	scanf("%d",&n);
	pos=-1;
	for (int u=0;u<n;u++) 	
	{
		scanf("%d",&A[u]);
		if (pos==-1&&A[u]==1) pos=u;
	}
	if (pos==-1)	{printf("0\n");return 0;}
	if (pos==0)
	{
		for (int u=n-1;u>=0;u--)
			if (A[u]==1)	pos=u;
			else break;
	}
	//printf("%d\n",pos);
	for (int u=1;u<=n;u++) a[u]=A[(pos+u-1)%n];
	/*for (int u=1;u<=n;u++) printf("%d ",a[u]);
	printf("\n");*/
	for (int u=1;u<=n;u++)
	{
		tim=tim+(a[u]==1);
		if (a[u]!=a[u-1])
		{
			if (vis[a[u]]==true)	{printf("0\n");return 0;}
			vis[a[u]]=true;
		}
	}
	//printf("%d\n",tim);
	for (int u=1;u<=n;u++)	
		if (a[u]==a[u-1]) L[u]=L[u-1];
		else L[u]=u;
	for (int u=n;u>=1;u--)
		if (a[u]==a[u+1]) R[u]=R[u+1];
		else R[u]=u;
	//for (int u=1;u<=n;u++) printf("%d %d\n",L[u],R[u]);
	for (int u=1;u<=n;u++)
		if (u==L[u])
		{
			if (R[u]-L[u]+1>tim)
			{
				printf("0\n");
				return 0;
			}
			int pos=-1,pos1=-1;
			int l,r;
			l=L[u]-1;if (l<=0) l+=n; 
			r=R[u]+1;if (r>n) r-=n;
			if (a[l]>a[u])	pos=L[u]+tim-1;
			if (pos>n) pos=pos-n;
			if (a[r]>a[u])  pos1=R[u];
		/*	printf("%d %d\n",L[u],tim);*/
			//printf("YES:%d %d %d %d %d\n",u,l,r,pos,pos1);
			if (pos!=-1&&pos1!=-1&&pos!=pos1)	{printf("0\n");return 0;}
			if (pos!=-1)
			{
				//printf("YES\n");
				if (s[pos]!=0) {printf("0\n");return 0;}
				s[pos]=a[u];
			}
			else if (pos1!=-1)
			{
				if (s[pos1]!=0)	{printf("0\n");return 0;}
				s[pos1]=a[u];
			}
			if (pos==-1&&pos1==-1)
			{
				if (tim<(R[u]-L[u]+1)) {printf("0\n");return 0;}
				//printf("YES:%d\n",a[u]);
				if (L[u]==1&&R[u]==n)	ans=mul(ans,n);
				else 
				{
					int t=tim-(R[u]-L[u]+1)+1;
					//printf("%d %d %d\n",u,t);
					ans=mul(ans,t);
				}
				//printf("%d\n",R[u]);
				s[R[u]]=a[u];
			}
		}
	/*printf("%d\n",ans);
	for (int u=1;u<=n;u++) printf("%d ",s[u]);
	printf("\n");*/
	solve();
	return 0;
}

Measured memory_bytes: 7936
/*Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout << #x << " " << x <<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef priority_queue<int, vector<int>, function<bool(int, int)>> pq_func;
/*---------------------------------------------------------------------------------------------------------------------------*/
int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a != 0 && c != 0)
	{
		c -= b;
		if (c <= 0)
		{
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0)
		{
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3660
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

A = IL()
BC = [IL() for i in range(M)]
A.sort()
BC.sort(key=itemgetter(1),reverse=True)

tmp = bisect.bisect_left(A,BC[0][1])
cnt = 0
j = 0
for b,c in BC:
    for i in range(b):
        if c > A[j]:
            A[j] = c
            j += 1
            cnt += 1
            if cnt == tmp:
                break
        else:
            break
    else:
        continue
    break

print(sum(A))

Measured memory_bytes: 41868
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int X, N;
	cin >> X >> N;
	map<int, int> mp;
	rep(i,N){
		int a;
		cin >> a;
		mp[a]++;
	}
	for(int i=0;i<1000;i++){
		if(!mp[X-i]){
			cout << X-i << endl;
			return 0;
		}
		else if(!mp[X+i]){
			cout << X+i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(){
  char s[3];
  scanf("%s",&s);
  
  char t[3];
  scanf("%s",&t);
  int cnt=0;
  if(s[0]==t[0])++cnt;
  if(s[1]==t[1])++cnt;
  if(s[2]==t[2])++cnt;
  printf("%d\n",cnt);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll b[n],c[n];
    memset(b,0,sizeof(b));
    memset(c,0,sizeof(c));
    b[0]=a[0];
    c[n-1]=a[n-1];
    for(int i=1;i<n;i++)
    {
        b[i]=a[i]+b[i-1];

    }
    for(int i=n-2;i>=0;i--)
    {
        c[i]=a[i]+c[i+1];
    }
    /*for(auto t:b)cerr<<t<<" ";
        cerr<<endl;
    for(auto t:c)cerr<<t<<" ";
        cerr<<endl;*/
    ll ans=INT_MAX;
    for(int i=0;i<n-1;i++)
    {
        ll temp=abs(b[i]-c[i+1]);
        ans=min(ans,temp);
    }
    cout<<ans<<endl;

}
return 0;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int l;
		for(l=1; l<N; l++){
			N -= l;
		}
		if(N != l){
			System.out.println("No");
			System.out.flush();
			return;
		}
		System.out.println("Yes");
		System.out.println(l+1);
		int[][] answer = new int[l+1][l];
		int Index = 1;
		for(int i=0; i<=l; i++){
		StringBuilder string = new StringBuilder();
			string.append(l);
			int j=0;
			for(; j<i; j++){
				string.append(" ");
				string.append(answer[j][i-1]);
			}
			for(; j<l; j++){
				string.append(" ");
				string.append(answer[i][j]=Index++);
			}
			System.out.println(string.toString());
		}
		System.out.flush();
		return;
	}
}


Measured memory_bytes: 36076
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
int main()
{
	int n, m;
 
	cin >> n >> m;
 
	cout << m * 2 - n << endl;
 
	return 0;
}

Measured memory_bytes: 256
// Solution for 0539: Pizza
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
int d1, n, m, order, sum, ans, mid;
int n2[MAX_N];
void search(int first, int last){
	if (first == last)
		return;
	if ((first + last) % 2)
		mid = (first + last) / 2 + 1;
	else
		mid = (first + last) / 2;
	if (n2[mid] == order)
		return;
	if (n2[mid] < order){
		if (last - mid == 1){
			if (abs(n2[last] - order) < abs(n2[mid] - order))
				mid++;
			return;
		}
		search(mid, last);
	}
	else{
		if (mid - first == 1){
			if (abs(n2[first] - order) < abs(n2[mid] - order))
				mid--;
			return;
		}
		search(first, mid);
	}
}
int main(){
	while (cin >> d1){
		if (!d1)
			return 0;
		ans = 0;	
		cin >> n >> m;
		n2[0] = 0;
		for (int i = 1; i < n; i++){
			cin >> n2[i];
		}
		sort(n2, n2 + n);
		for (int i = 0; i < m; i++){
			cin >> order;
			if (order > n2[1] && order < n2[n - 1]){
				search(1, n - 1);
				ans += abs(n2[mid] - order);
			}
			else{
				if (order <= n2[1]){
					sum = min(order, n2[1] - order);
				}
				if (order >= n2[n - 1]){
					sum = min(d1 - order, order - n2[n - 1]);
				}
				ans += sum;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1568
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        double r = sc.nextDouble();
 
        System.out.printf("%.10f %.10f\n",r*r*Math.PI,(2*r)*Math.PI);
    }
}


Measured memory_bytes: 28380
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
const ll MOD = 1e9+7;
const int MAX = 100005;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int n; cin >> n;
    vector<int> a(n+1);
    int key, l, r;
    vector<bool> flag(n+1, false);
    rep(i,n+1){
        cin >> a[i];
        if(flag[a[i]]) key = a[i];
        flag[a[i]] = true;
    }
    bool seen = false;
    rep(i,n+1){
        if(a[i] == key){
            if(seen){
                r = n-i;
                break;
            }
            else{
                seen = true;
                l = i;
            }
        }
    }

    COMinit();
    FOR(i, 1, n+2) cout << (COM(n+1, i) - COM(l+r, i-1) + MOD) % MOD << endl;
}

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

int main() {
  int a, b, cnt = 0;
  cin >> a >> b;
  
  while (a <= b) {
    if (to_string(a).at(0) == to_string(a).at(4)) {
      if (to_string(a).at(1) == to_string(a).at(3))
        cnt++;
    }
    a++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
import math
S = list(input())
K = int(input())
s = S * 2
c1 = 0
c2 = 0
for i in range(len(s)-1):
    if s[i+1] == s[i]:
        if i < len(S)-1:
            c1 += 1
        c2 += 1
        s[i+1] = 0
c = S[0]
for s in S:
    if s != c:
        print(c1+(c2-c1)*(K-1))
        exit()
print(math.floor(len(S)*K/2))


Measured memory_bytes: 61796
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();
		
		BigDecimal culc = a.multiply(b);
		long ans = culc.longValue();
		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 37448
#include <cstdio>

int main()
{
  int h, w;
  scanf("%d %d", &h, &w);
  char s[101];
  for (int i = 0; i < w + 2; ++i)
  {
    printf("#");
  }
  for (int i = 0; i < h; ++i)
  {
    scanf("%s", s);
    printf("\n#%s#", s);
  }
  printf("\n");
  for (int i = 0; i < w + 2; ++i)
  {
    printf("#");
  }
  printf("\n");
  return 0;
}

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


int main(){
    string S;
    cin >> S;
    int64_t ans=0;
    for(int bit = 0; bit < (1<< (int)S.size()-1); bit++){
        int64_t num = S[0]-'0';
        for(int i = 0; i < S.size()-1; i++){
            if(bit&(1<<i)){
                ans+=num;
                num=0;
            }
            num=num*10+S[i+1]-'0';
        }
        ans+=num;
    }
    cout << ans << endl;
}
    
    


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=3e5+5;
struct node{
	int l,r;
	bool operator < (const node &b)const{
		return r-l<b.r-b.l;
	}
}a[N];
int n,m,bit[N];
void modify(int x,int v){
	while(x<=m)
		bit[x]+=v,x+=x&-x;
}
int query(int x){
	int res=0;
	while(x)
		res+=bit[x],x^=x&-x;
	return res;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+n+1);
	for(int i=1,j=1;i<=m;++i){
		while(j<=n&&a[j].r-a[j].l<i)
			modify(a[j].l,1),modify(a[j].r+1,-1),++j;
		int res=n+1-j;
		for(int k=i;k<=m;k+=i)
			res+=query(k);
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int main(){
	
	int N, M;
	
	cin >> N >> M;
	
	int A[200];
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	for(int i = 1; i <= M; i++){
		for(int j = 0; j < N - 1; j++){
			if(A[j] % i > A[j + 1] % i){
				swap(A[j], A[j + 1]);
			}
		}
	}
	
	for(int i = 0; i < N; i++){
		cout << A[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
  
function main(){
  var read = 0;
  var resultCase = 1;
  while(true){
    var maxWeight = +input[read++];
    if(!maxWeight){
      break;
    }
      
    var treasures = +input[read++];
    var dp = new Int16Array(maxWeight + 1);
    for(var i = treasures; i--;){
      var c = input[read++].split(",");
      var tv = +c[0];
      var tw = +c[1];
  
      for(var w = maxWeight; w - tw >= 0; w--){
        dp[w] = max(dp[w-tw] + tv, dp[w]);
      }
    }
  
    var resultWeight = 1001;
    var resultCost = 0;
    for(var i = 0; i <= maxWeight; i++){
      var dpi = dp[i];
      if(dpi > resultCost){
        resultCost = dpi;
        resultWeight = i;
      }
    }
      
    console.log("Case " + resultCase++ + ":\n" + resultCost + "\n" + resultWeight);
  }
}
 
 
function max(a, b) {
  var t = a - b;
  return a - (t & (t >> 31));
}

Measured memory_bytes: 8696
//Matrix Chain Multiplication
#include <iostream>
#include <climits>

using namespace std;

int matrixChainMultiplication(int p[], int n) {
    int m[n + 1][n + 1];
    for(int i = 0; i < n + 1; i++) m[i][i] = 0;
    for(int l = 2; l < n + 1; l++) {
        for(int i = 1; i < n - l + 2; i++) {
            int j = i + l - 1;
            m[i][j] = INT_MAX;
            for(int k = i + 1; k < j + 1; k++) {
                m[i][j] = min(m[i][j], m[i][k - 1] + m[k][j] + p[i - 1] * p[k - 1] * p[j]);
            }
        }
    }
    return m[1][n];
}

int main() {
    int n, r, c;
    cin >> n;
    int p[n + 1];
    for(int i = 0; i < n; i++) {
        cin >> r >>  c;
        if(i == 0) p[0] = r;
        p[i + 1] = c;
    }

    cout << matrixChainMultiplication(p, n) << endl;
}


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

int main(){
  int n,t,a;
  cin >> n >> t >> a;
  double h;
  double mini = 10e4;
  int num;
  for(int i = 1; i <= n; i++){
    cin >> h;
    h = t - h*0.006;
    if(mini > abs(double(a-h))){
      mini = abs(a-h);
      num = i;
    }
  }
  cout << num << endl;
}



Measured memory_bytes: 256
# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b

n = int(input())
i = 1
ans = []
while i * (i + 1) // 2 <= n:
    ans.append(i)
    i += 1
else:
    ans.append(i)
s = i * (i + 1) // 2
diff = s - n

if diff > 0:
    ans.remove(diff)
print(*ans, sep='\n')

Measured memory_bytes: 72060
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

// int MOD = 998244353;
int MOD = 1000000007;

#define N 100010
int par[N];
int rnk[N];
int weight[N];

void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        weight[i] = 1;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]){
        weight[find(y)] += weight[find(x)];
        par[x] = y;
    }
    else{
        weight[find(x)] += weight[find(y)];
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}

//----------------------------------------------------------------
signed main(){

	string s;
	cin >> s;
	rep(i,s.size()){
		if(i%2 == 0 && s[i] == 'L'){
			cout << "No" << endl;
			return 0;
		}
		if(i%2 == 1 && s[i] == 'R'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	

	return 0;
}

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

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://abc141.contest.atcoder.jp/tasks/abc141_b

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

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

    vector<int> a;
    int n;
    cin >> n;
    a.resize(n);

    int ans = 0;
    int pos = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        ans += abs(a[i] - pos);
        pos = a[i];
    }
    ans += abs(pos);

    int pre = 0;
    int end = 0;
    for (int i = 0; i < n; i++)
    {
        if (i != n - 1)
        {
            cout << ans - abs(a[i + 1] - a[i]) - abs(a[i] - pre) + abs(a[i + 1] - pre) << "\n";
        }
        else
        {
            cout << ans - abs(end - a[i]) - abs(a[i] - pre) + abs(end - pre) << "\n";
        }
        pre = a[i];
    }

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int n,a[N];
int main(){
	cin >> n;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	sort(a+1,a+n+1);
	if (a[n]-a[1]>1)
		return puts("No"),0;
	if (a[1]==a[n])
		return puts(a[1]==n-1||(a[1]<n&&n%a[1]==0)?"Yes":"No"),0;
	int t=0;
	for (int i=1;i<=n;i++)
		if (a[i]==a[n])
			t++;
	if (n-t+1<=a[n]&&a[n]<=n-t+t/2)
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int n;
double ans, a;

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a,
        ans += 1.0/a;
    printf("%.9lf\n", 1.0/ans);
}

Measured memory_bytes: 256
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
  k = input().upper()
  if k == 'AC':
    ac +=1
  elif k == 'WA':
    wa +=1
  elif k == 'TLE':
    tle +=1
  elif k == 'RE':
    re +=1
    
print('{} x {}'.format('AC',ac))
print('{} x {}'.format('WA',wa))
print('{} x {}'.format('TLE',tle))
print('{} x {}'.format('RE',re))

Measured memory_bytes: 74700
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N;
  std::cin >> N;
  std::vector<std::vector<std::pair<int, int>>> adj(N + 1);
  for (int i = 1; i <= N - 1; ++i) {
    int u, v, w;
    std::cin >> u >> v >> w;
    adj[u].push_back(std::make_pair(v, w));
    adj[v].push_back(std::make_pair(u, w));
  }

  // Main
  std::vector<int> res(N + 1, -1);
  std::vector<bool> visited(N + 1, false);
  std::queue<int> que;
  res[1] = 0;
  visited[1] = true;
  que.push(1);
  while (not que.empty()) {
    int u = que.front();
    que.pop();
    for (int k = 0; k < adj[u].size(); ++k) {
      int v, w;
      std::tie(v, w) = adj[u][k];
      if (visited[v])
        continue;
      if (w % 2 == 0) {
        res[v] = res[u];
      } else {
        res[v] = 1 - res[u];
      }
      visited[v] = true;
      que.push(v);
    }
  }

  // Output
  for (int i = 1; i <= N; ++i) {
    int r = res[i];
    if (r == -1)
      r = 0;
    std::cout << r << std::endl;
  }

  return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <climits>

using namespace std;
#define ll long long
#define ve vector
#define umap unordered_map

ll calc(ll a, ll x) {
    if(a<0) return 0;
    return (a/x+1);
}

int main() {
    ll a, b, x;
    cin>>a>>b>>x;
    cout<< calc(b, x) - calc(a-1, x);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
N = int(input())
L = [0] * (N + 1)
L[0] = 2
if N == 1:
    print(1)
else:
    L[1] = 1
    for i in range(2, N + 1):
        L[i] = L[i - 1] + L[i - 2]
    print(L[N])


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  map<char, vector<int>> mp;
  map<char, set<int>> mp2;

  for (int i = 0; i < int(s.size()); i++) {
    mp2[s[i]].insert(i);
  }
  for(auto a : mp2){
    mp[a.first] = vector<int> (ALL(a.second));
  }

  if(mp[t[0]].size() == 0){
    cout << -1 << endl;
    return 0;
  }

  int before = *min_element(ALL(mp[t[0]]));
  ll res = 0;

  for (int i = 1; i < int(t.size()) - 1; i++) {
    if(mp[t[i]].size() == 0){
      cout << -1 << endl;
      return 0;
    }

    int index = upper_bound(ALL(mp[t[i]]), before) - mp[t[i]].begin();
    // cout << index << endl;
    if(index >= mp[t[i]].size()){
      before = mp[t[i]][0];
      res++;
    }
    else before = mp[t[i]][index];
  }

  res = res * int(s.size()) + before + 1;


  int n = int(t.size());
  if(mp[t[n-1]].size() == 0){
    cout << -1 << endl;
    return 0;
  }

  int m = int(s.size());
  if(n > 1){
    while(true){
      before++;
      res++;
      if(s[before % m] == t[n-1]){
        break;
      }
    }

  }

  cout << res << endl;
}


Measured memory_bytes: 10192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{
	public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] x = convertStringToInt(br.readLine().split(" "));
        int[] y = convertStringToInt(br.readLine().split(" "));

        calcMD(x,y,1);
        calcMD(x,y,2);
        calcMD(x,y,3);
        calcMD(x,y,0);

        br.close();
    }

	private static int[] convertStringToInt(String[] str){
		int[] list = new int[str.length];
		for(int i=0; i<str.length;i++){
			list[i] = Integer.parseInt(str[i]);
		}
		return list;
	}


    private static void calcMD(int[] x, int[] y,int p){
    	double D=0;
    	if(p == 0){
    		for(int i=0;i<x.length;i++){
    			double d = Math.abs(x[i]-y[i]);
    			if(D<=d){
    				D=d;
    			}
    		}
    	}else{
    		double d=0;
    		for(int i=0;i<x.length;i++){
    			d += Math.pow(Math.abs(x[i] - y[i]), p);
    		}
			D  =Math.pow(d, (double)1/p);
    	}
    	System.out.println(D);
    }
}

Measured memory_bytes: 24520
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextFloat() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func main() {
	N := nextFloat()
	fmt.Println(int(math.Ceil(N / 2)))
}


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

int main() {
    int N; cin >> N;
    bool exist_odd = false;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a & 1) exist_odd = true;
    }
    if (exist_odd) puts("first");
    else puts("second");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int a,b;cin>>a>>b;
	set<int> s;s.insert({a,b});
	for(int i=1;i<=3;i++){
		if(!s.count(i)){
			cout<<i;
			return 0;
		}
	}
}


Measured memory_bytes: 256
def cross_section_diagram():
	down = []
	edge = []
	pool = []

	for i, c in enumerate(input()):
		if c == '\\':
			down.append(i)
		elif c == '/' and down:
			left = down.pop()
			area = i - left

			while edge:
				if edge[-1] < left:
					break
				edge.pop()
				area += pool.pop()

			edge.append(left)
			pool.append(area)

	print(sum(pool))
	print(len(pool), *pool)

if __name__ == '__main__':
	cross_section_diagram()

Measured memory_bytes: 8188
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll mod = (1000000007LL);

inline ll poww(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if(b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
inline pii operator+(pii A, pii B){
	return pii(A.f + B.f, A.s + B.s);
}
inline pii operator-(pii A, pii B){
	return pii(A.f - B.f, A.s - B.s);
}
inline ll mult(ll a, ll b){
	return (a * b) % mod;
}

ll gcd (ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

/*
	>Colocar (>DEFINE INT LONG LONG<) no inicio do template
	>mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
	>NAO ESQUECER DEFINE INT LONG LONG
	> N = 1 ? 
*/

///CUIDADO COM MAXN
#define N 1000050

int n, m, q, k, d, a,ans;
int bit[N];
pii TT, w[N];

string s;
void upd(int l, int r, int v){
    for(int i = l; i < N; i += (i&-i)) bit[i] += v;
    r++;
    for(int i = r; i < N; i += (i&-i)) bit[i] -= v;
}
int query(int x){
    int sum=0;
    for(int i = x; i > 0; i -=(i&-i)) sum += bit[i];
    return sum;
}
vector<int> x;
int get(int p){
    return upper_bound(all(x), p)-x.begin();
}
int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>d>>a;
    for(int i = 1; i<= n; i++) cin>>w[i].f>>w[i].s, x.pb(w[i].f), x.pb(w[i].f + 2*d);
    sort(all(x));
    x.erase(unique(all(x)), x.end());
    sort(w+1, w+n+1);
    for(int i = 1; i <= n; i++){
        int R = w[i].f + 2*d, x = w[i].f;
        R = get(R), x = get(x);
        w[i].s -= query(x);
        if(w[i].s <= 0) continue;
        int qtd = (w[i].s % a ==  0? w[i].s/a : w[i].s/a + 1);
        ans += qtd;
        upd(x, R, qtd * a);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 14444
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
            break
        if x[j] == y[z[i][j]]:
            order[j] = 1
            if x[j] == x[-j-1]:
                order[j] = 2
    else:
        if 2 in order or z[i][3] == sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Measured memory_bytes: 7692
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
using namespace std;
typedef long long LL;
typedef double db;
//char buf[1<<24],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
	if (x< 0) putchar('-'),x=-x;
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
char s[N];
int main ()
{
	// freopen (".in","r",stdin);
	// freopen (".out","w",stdout);
	scanf ("%s",s+1);
	if (s[1]=='S') puts("Cloudy");
	else if (s[1]=='C') puts("Rainy");
	else puts("Sunny");

	return 0;
}


Measured memory_bytes: 128
import Data.List
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
main=getLine*>B.getLine>>=print.sum.map (\a->(a*a-a)`div`2).M.elems.foldl (\m a->M.insertWith(+)a 1 m) M.empty.scanl' (+) 0.unfoldr (B.readInt.B.dropWhile(==' '))

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

using namespace std;


int main() {
  #ifdef LOCAL
  freopen("sol.in", "r", stdin);
  freopen("sol.out", "w+", stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> abc(n, vector<int>(3));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> abc[i][j];
    }
  }
  vector<vector<int>> dp(n + 1, vector<int>(3));
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (j == k) {
          continue;
        }
        dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i - 1][j]);
      }
    }
  }
  int ans = 0;
  for (int j = 0; j < 3; j++) {
    ans = max(ans, dp[n][j]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, K;
  cin >> N >> K;
  
  int snake[N];
  
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    snake[i] = a;
  }
  sort(snake, snake + N);
  reverse(snake, snake + N);
  
  int ans;
  for(int i = 0; i < K; i++){
    ans += snake[i];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  float a[n];
  int i;
  float revSum;
  
  i = 0;
  revSum = 0;
  while (i < n)
  {
    scanf("%f",&a[i]);
    revSum += 1 / a[i];
    i++;
  }
  printf("%f",1 / revSum);
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll a, b, n;
	cin >> a >> b >> n;

	ll x;
	if (b - 1 <= n) {
		x = b - 1;
	}
	else {
		x = n;
	}
	
	ll first = floor(a * x / b);
	ll second = floor(x / b);

	out(first - second);

	return 0;
}

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

int main() {
	string s;
  	cin>>s;
  	int zero=0,one=0;
  	for(int i=0;i<s.size();i++){
    	if(s[i]=='0'){
        	zero++;
        }else{
        	one++;
        }
    }
  	cout<<min(zero,one)*2<<endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

using ll = long long;

int main()
{
  ll n, k;
  cin >> n >> k;

  ll sum = 0;
  for (ll b = k + 1; b <= n; b++)
  {
	sum += (n / b) * (b - k) + max<ll>(0ll, n % b - k + 1);
  }
  if (k == 0)
  {
	sum -= n;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int D = sc.nextInt();

		sc.close();

		out.print("Christmas");
		for (int i = 0; i <= 24 - D; i++) {
			out.print(" Eve");
		}
		out.println();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 19668
#include <strings.h>
#include <stdio.h>

int min;

int calc(int a, int b, int c) {
    int ma = (a / 5) * 5 * 380 * 0.8 + (a % 5) * 380;
    int mb = (b / 4) * 4 * 550 * 0.85 + (b % 4) * 550;
    int mc = (c / 3) * 3 * 850 * 0.88 + (c % 3) * 850;
    return ma + mb + mc;
}

void shopping(int amount) {
    int a, b, total;
    for (a = 0;  a <= amount / 200; a++) {
        for (b = 0;  b <= (amount - a*200) / 300; b++) {
            int remain = amount - a*200 - b*300;
            if (remain % 500 == 0) {
                total = calc(a, b, remain /500);
                if (min > total)
                    min = total;
            }
        }
    }
}

int main(void) {
    int amount;

    while (scanf("%d", &amount), amount) {
        min = 200000000;
        shopping(amount);
        printf("%d\n", min);
    }

    return 0;
}

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

// シカのAtCoDeerくんは二つの正整数a,bを見つけました。aとbの積が偶数か奇数か判定してください。

int a, b; // a, b は整数型であると宣言

// main関数（プログラム実行時に実際に実行される関数）
int main() {
    // scanf("変換指定子", &変数名)
    scanf("%d%d", &a, &b);
    // printf("%d\n%d\n", a, b);

    if ((a * b) % 2) {
        // 余りはあるとき、Trueになり、奇数となる
        printf("Odd");
    } else {
        // 余りが0のとき、Falseになり、偶数となる
        printf("Even");
    }

    return 0;
}




Measured memory_bytes: 256