akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
int main() {
cout << fixed << setprecision(30);
  ll a,b;
  cin>>a>>b;
  putout(6-a-b);
  
}

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

namespace AtCoder.Abc
{
    // 問題:
    class A_158_Station_and_Bus
    {
        public static void Main(string[] args)
        {            
            // 文字列の入力
            string s = Console.ReadLine();

            if(s.Equals("AAA") || s.Equals("BBB"))
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

            Console.Out.Flush();
        }
    }
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, m;
  std::cin >> n >> m;
  n--, m--;
  print(n * m);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
string S;

signed main(){
	cin>>N>>S;
	int a=0,b=0,c=0;
	REP(i,N){
		if(S[i]=='R')a++;
		else if(S[i]=='G')b++;
		else c++;
	}
	int ans=a*b*c;
	for(int i=0;i<N;i++){
		for(int j=1;j<=N;j++){
			if(i+j+j>=N)continue;
			if(S[i]!=S[i+j]&&S[i+j]!=S[i+j+j]&&S[i]!=S[i+j+j]){
				ans--;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3620
n,K=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
dp=[float('inf') for i in range(n+1)]
dp[1]=0
for i in range(1,n):
    for k in range(1,min(K+1,n-i+1)):
        dp[i+k]=min(dp[i+k],dp[i]+abs(h[i+k]-h[i]))
print(dp[n])

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

//#define errOut(s) { std::cerr << "LINE:" << __LINE__ << " " << #s << " = " << s << std::endl; }
#define errOut(s)

std::array<uint32_t, 200000> as;
std::array<uint32_t, 200000> bs;
int n;

int main() {
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> as[i];
    }
    for (int i = 0; i < n; ++i) {
        std::cin >> bs[i] ;
    }

    if (n == 1) {
        std::cout << as[0] + bs[0] << std::endl;
        return 0;
    }
    errOut(n);

    std::sort(as.begin(), as.begin() + n);
    std::sort(bs.begin(), bs.begin() + n);
    const uint32_t aMax = as[n - 1];
    const uint32_t bMax = bs[n - 1];

    uint32_t msb = 1;
    for (;aMax >= msb || bMax >= msb; msb <<= 1)  {
    }
    uint32_t mask = msb - 1;
    msb >>= 1;
    if (msb == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }

    uint32_t ret = 0;
    for (; msb; msb >>= 1) {
        errOut(msb);
        errOut(mask);

        size_t j = static_cast<size_t>(n - 1);
        for (int i = 0; i < n; ++i) {
            j = std::lower_bound(bs.begin(), bs.begin() + std::min(j + 1, size_t(n)), mask - as[i] + 1) - bs.begin();
            ret ^= ((n - j) % 2) * (msb << 1);
            errOut(i);
            errOut(j);
            errOut(ret);
        }
        errOut(ret);

        if (n % 2) {
            size_t msbIdxA = std::lower_bound(as.begin(), as.begin() + n, msb) - as.begin();
            size_t msbIdxB = std::lower_bound(bs.begin(), bs.begin() + n, msb) - bs.begin();
            ret ^= ((msbIdxA * (n - msbIdxB) + (n - msbIdxA) * msbIdxB) % 2) * msb;
            errOut(((msbIdxA * (n - msbIdxB) + (n - msbIdxA) * msbIdxB) % 2) * msb);
            errOut(ret);
        }

        mask >>= 1;
        for (int i = 0; i < n; ++i) {
            as[i] &= mask;
            bs[i] &= mask;
        }
        std::sort(as.begin(), as.begin() + n);
        std::sort(bs.begin(), bs.begin() + n);
    }
    std::cout << ret << std::endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int n,l;
  cin>>n>>l;
  bool flag=1;
  vector<int> a(n);
  for(int i=1;i<=n;i++){
    a.at(i-1)=l+i-1;//cout<<a.at(i-1)<<" ";
    if(a.at(i-1)==0)flag=0;
  }
  //cout<<endl;
  if(l<0){sort(a.begin(),a.end());}
  else sort(a.rbegin(),a.rend());
  //r(i,n)cout<<a.at(i)<<" ";
  //cout<<endl;

  int sum=0;
  if(flag){
  r(i,n-1){
    sum+=a.at(i);
  }
}else {
  r(i,n){
    sum+=a.at(i);
  }
}
  cout<<sum<<endl;




  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

int n, x, ans;
int sum[100010];

int main()
{
    scanf("%d", &n);
    FOR(i, 1, n)
    {
        scanf("%d", &x);
        if (x > n) ++ans; else ++sum[x];
    }
    FOR(i, 1, n) if (sum[i] < i) ans += sum[i]; else ans += sum[i] - i;
    printf("%d\n", ans);
    return 0;
}


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

int main(){
while(1){
 int x,y,s;
 cin>>x>>y>>s;

 if(x==0&&y==0&&s==0)break;

 int tmax=-1;

 for(int a=1;a<=s-1;a++){
	int ax=a*(100+x)/100;
	int ay=a*(100+y)/100;

	for(int b=1;b<=s-1;b++){
		int bx=b*(100+x)/100;
		int by=b*(100+y)/100;

		if(ax+bx==s){
			tmax=max(tmax,ay+by);
		}else if(ax+bx>s){
			break;
		}
	}
 }
 cout<<tmax<<endl;
}
return 0;
}



Measured memory_bytes: 3004
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;


    int main(){
      string s;
      cin>>s;
      int cnt0 = 0;
      int cnt1 = 0;
      rep(i,s.size()){
        if(s[i] == '0')cnt0++;
        if(s[i] == '1')cnt1++;
      }
      int ans = min(cnt0,cnt1);
      cout<<ans*2<<endl;
    }
      


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, m, cnt, head[MAXN], pre[MAXN], deg[MAXN], f[MAXN];

struct Edge {int next, to;} edge[MAXN*2];
queue<int> q;

void addedge(int from, int to)
{
    edge[++cnt].next=head[from];
    edge[cnt].to=to;
    deg[to]++;
    head[from]=cnt;
}

int main()
{
    scanf("%d%d", &n, &m);
    for(rint i=1, x, y; i<=n-1+m; ++i)
    {
        scanf("%d%d", &x, &y);
        addedge(x, y);
    }
    for(rint i=1; i<=n; ++i)
        if(!deg[i]) q.push(i);
    while(!q.empty())
    {
        int x=q.front(); q.pop();
        for(rint i=head[x]; i; i=edge[i].next)
        {
            int to=edge[i].to;
            if(f[to]<f[x]+1)
            {
                f[to]=f[x]+1;
                pre[to]=x;
            }
            deg[to]--;
            if(!deg[to]) q.push(to);
        }
    }
    for(rint i=1; i<=n; ++i) printf("%d\n", pre[i]);
    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

#define WHITE 0
#define RED   1
#define BLUE  2
#define EMPTY 3
#define rotate_swap(x,a,b,c,d) swap(x.a,x.b);swap(x.b,x.c);swap(x.c,x.d);

class Dice{
public:
  char top,front,right;
};

class state{
public:
  int y,x;
  Dice d[3][3];
  state(){}
  state(int ty,int tx);
  bool operator<(const state & a)const;

};

state::state(int ty,int tx){
  y=ty;
  x=tx;
  rep(i,3){
    rep(j,3){
      d[i][j].top  =WHITE;
      d[i][j].right=BLUE;
      d[i][j].front=RED;
    }
  }
}

void rotate_r(Dice &x){
  swap(x.top,x.right);
}

void rotate_l(Dice &x){
  swap(x.top,x.right);
}

void rotate_f(Dice &x){
  swap(x.top,x.front);
}

void rotate_b(Dice &x){
  swap(x.top,x.front);
}


int require(state &a,int tar[3][3]){
  int ret=0;
  rep(i,3){
    rep(j,3){
      if (i == a.y && j == a.x){
	if (tar[i][j] != EMPTY)ret++;
      }else if (tar[i][j] != a.d[i][j].top)ret++;
    }
  }
  return max(0,ret-1);
}

bool isok(state  &a,int tar[3][3]){
  rep(i,3){
    rep(j,3){
      if (i == a.y && j == a.x){
	if (tar[i][j] != EMPTY)return false;
      }else if (tar[i][j] != a.d[i][j].top)return false;
    }
  }
  return true;
}

int dx[]={0,0,1,-1};//
int dy[]={1,-1,0,0};//
int opp[] ={1,0,3,2};
int ans;
void move(state &a,int tar[3][3],int cnt,int prev){
  int h = require(a,tar);
  if (isok(a,tar)){
    ans=min(ans,cnt);
    return;
  }
  if (cnt + h >= ans)return;


  rep(i,4){
    if (opp[i]==prev)continue;
    state next=a;
    next.x+=dx[i];
    next.y+=dy[i];
    if (next.x==-1||next.x==3||next.y==-1||next.y==3)continue;
    next.d[a.y][a.x]=next.d[next.y][next.x];
    if (i == 0)rotate_b(next.d[a.y][a.x]);
    if (i == 1)rotate_f(next.d[a.y][a.x]);
    if (i == 2)rotate_l(next.d[a.y][a.x]);
    if (i == 3)rotate_r(next.d[a.y][a.x]);
    move(next,tar,cnt+1,i);
  }
}

main(){
  int x,y;
  while(cin>>x>>y && x){
    x--;y--;
    int tar[3][3];
    state ini(y,x);
    
    rep(i,3){
      rep(j,3){
	char tmp;
	cin>>tmp;
	if (tmp == 'W'){
	  tar[i][j]=WHITE;
	}else if (tmp == 'E'){
	  tar[i][j]=EMPTY;
	}else if (tmp == 'B'){
	  tar[i][j]=BLUE;
	}else if (tmp == 'R'){
	  tar[i][j]=RED;
	}
      }
    }

    ans = 31;
    move(ini,tar,0,-1);
    if (ans == 31)cout << -1 << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,a,b;
 cin>>n>>a>>b;
 int x=0;
 for(int i=1;i<n+1;i++){
    int m=0;
    int j=i;
    while(j>0){
         m+=j%10;
         j/=10;
         if(m>b)break;
     }
     if(m>=a&&m<=b){
         x+=i;
     }
 }
 cout<<x<<endl;
}
      
//TLEになる

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

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0; i < n; i++)  cin >> h[i];
    vector<int> ans(n, 0);
    for(int i = n-2; i >= 0; i--){
        if(h[i] >= h[i+1])  ans[i] = ans[i+1]+1;
    }
    cout << *max_element(ans.begin(), ans.end()) << endl;
    return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n, k; cin >> n >> k;

	vector<LL> x(n);
	vector<LL> y(n);

	vector<LL> xb(n);
	vector<LL> yb(n);


	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];

		xb[i] = x[i];
		yb[i] = y[i];
	}

	sort(xb.begin(), xb.end());
	sort(yb.begin(), yb.end());

	LL ans = 9223372036854775807;

	for (int x1 = 0; x1 < n; x1++) {
		for (int x2 = x1+1; x2 < n; x2++) {

			for (int y1 = 0; y1 < n; y1++) {
				for (int y2 = y1+1; y2 < n; y2++) {

					LL xl = xb[x1];
					LL xr = xb[x2];

					LL ys = yb[y1];
					LL yu = yb[y2];

					LL cnt = 0;

					for (int i = 0; i < n; i++) {
						if (xl <= x[i] && x[i] <= xr) {
							if (yu >= y[i] && y[i] >= ys) {
								cnt++;
							}
						}
					}

					if (cnt >= k) {
						LL area = (LL)(xr - xl)*(LL)(yu - ys);

						ans = min(ans, area);
					}
				}

			}
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

template<typename T> struct BIT{
	vector<T> dat;
	ll sz;
	//all 1-indexed
	BIT(ll sz) : sz(sz){
		dat.assign(++sz, 0);
	}

	T sum(ll k){
		T ret = 0;
		for(++k; k > 0; k -= k & -k) ret += dat[k];
		return (ret);
	}

	void add(ll k, T x){
		for(++k; k < dat.size(); k += k & -k) dat[k] += x;
	}
	
	ll get(T k){
		if(k <= 0) return 0; 
		ll ret = 0;
		int n = 1; while(n < sz) n *= 2;
		for(int i=n/2; i>0; i/=2){
			if(ret+i < sz && dat[ret+i] < k){
				k -= dat[ret+i];
				ret += i;
			}
		}
		return ret;
	}
};

int main(){
	int n; cin >> n;
	vs s(n); rep(i,n) cin >> s[i];
	vector<pair<string,char>> t(n);
	int mx = 0;
	rep(i,n){
		chmax(mx, s[i].size());
		reverse(all(s[i]));
		t[i].second = s[i].back();
		s[i].pop_back();
		t[i].first = s[i];
	}
	mx += 10;
	sort(all(t));
	vector<vector<int>> ls(n,vector<int>(26,0));
	rep(i,n){
		for(auto j : t[i].first) ls[i][j-'a']++;
		ls[i][t[i].second-'a']++;
	}
	int pre = -1;
	vector<BIT<int>> cnt(26,BIT<int>(mx));
	ll ans = 0;
	rep(i,n){
		int l=i, r=n;
		while(r-l > 1){
			ll m = (l+r)/2;
			if(t[i].first < t[m].first.substr(0,t[i].first.size())) r = m;
			else l = m;
		}
		if(l > pre){
			for(int j=l; j>i; j--){
				rep(k,26) cnt[k].add(ls[j][k],1);
			}
		}else{
			rep(k,26) cnt[k].add(ls[i][k],-1);
			for(int j=pre; j>l; j--){
				rep(k,26) cnt[k].add(ls[j][k],-1);
			}
		}
		char c = t[i].second;
		ans += cnt[c-'a'].sum(mx-1) - cnt[c-'a'].sum(ls[i][c-'a']-1);
		pre = l;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 108896
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];
    
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    
    while(1) {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if(minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1 ) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY ) {
                if (d[v] >M[u][v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) sum += M[i][p[i]];
    }
    
    return sum;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }
    
    cout << prim() << endl;
    
    return 0;
}


Measured memory_bytes: 3136
import sys
        
def getpar(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[0] = -1
    par[p]  -1
    stack = [p]
    visited = set([p])
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            stack.append(vf)
    return par

def topological_sort_tree(E, r):
    Q = [r]
    L = []
    visited = set([r])
    while Q:
        vn = Q.pop()
        L.append(vn)
        for vf in E[vn]:
            if vf not in visited:
                visited.add(vf)
                Q.append(vf)
    return L

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p[1:], 1):
        res[v].append(i)
    return res


        

N, M = map(int, input().split())
Edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)

P = getpar(Edge, 0)
L = topological_sort_tree(Edge, 0)
C = getcld(P)

dp1 = [1]*N
for l in L[N-1:0:-1]:
    p = P[l]
    dp1[p] = (dp1[p]*(dp1[l]+1)) % M

dp2 = [1]*N
dp2[0] = dp1[0]
info = [0]*(N+1)

vidx = [0]*N
vmull = [None]*N
vmulr = [None]*N
for i in range(N):
    Ci = C[i]
    res = [1]
    for j, c in enumerate(Ci, 1):
        vidx[c] = j
        res.append(res[-1] * (1+dp1[c]) % M)
    vmulr[i] = res + [1]
    res = [1]
    for c in Ci[::-1]:
        res.append(res[-1] * (1+dp1[c]) % M)
    vmull[i] = [1] + res[::-1]
for l in L[1:]:
    p = P[l]
    pp = P[p]
    vi = vidx[l]
    res = vmulr[p][vi-1] * vmull[p][vi+1] % M
    res = res*(1+info[pp]) % M
    dp2[l] = dp1[l]*(res+1) % M
    info[p] = res % M

print(*dp2, sep = '\n')


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;


lli n;
lli f[100][5][2];
lli p[100][11];
lli cnt[100];
lli ans = -INT_MAX;

int main(){
  cin >> n;
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j < 5;j++){
      for(lli k = 0;k < 2;k++){
        cin >> f[i][j][k];
      }
    }
  }
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j <= 10;j++){
      cin >> p[i][j];
    }
  }
  for(lli i = 1;i < (1 << 10);i++){
    lli b = 1;
    for(lli j = 0;j < 5;j++){
      for(lli k = 0;k < 2;k++){
        if((i&b) != 0){
          for(lli l = 0;l < n;l++){
            cnt[l] += f[l][j][k];
          }
        }
        b <<= 1;
      }
    }
    lli mem = 0;
    for(lli j = 0;j < n;j++){
      mem += p[j][cnt[j]];
      cnt[j] = 0;
    }
    ans = max(ans,mem);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int a;
    string s;
    cin >> a >>s;
    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    return 0;
}
/*REの時vectorのoverflow確認*/

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n;
    int cnt=0;
    cin>>n;
    REP(i,n){
        int a;
        cin>>a;
        if(a%2)cnt++;
    }
    YES(!(cnt%2));
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ab_list = [list(map(int, input().split())) for _ in range(M)]

num_road = [0] * N

for a, b in ab_list:
  num_road[a-1] += 1
  num_road[b-1] += 1

for item in num_road:
  print(item)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
using namespace std;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    long long n, m, k, l;
    double d;
    cin >> n;
    cout << int(ceil(double(n) / 2));
    return 0;
}


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

typedef unsigned long long ull;
#define FOR(i, a, b) for (ull i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const ull mod = 1e9 + 7;

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

	ull N,M,A,B;	cin>>N>>M;
	int H[N+1];
	bool st[N+1];
	FOR(i,1,N+1) {
      cin>>H[i];
      st[i]=0;
    }
	while(M--){
		cin>>A>>B;
		if(H[A]>H[B])	st[B]=1;
		if(H[B]>H[A])	st[A]=1;
		else if(H[A]==H[B]){
			st[A]=1;
			st[B]=1;
		}
    }
	int count=0;
	FOR(i,1,N+1)	if(st[i]==0)	count++;
	cout<<count<<endl;
    return 0;
}




Measured memory_bytes: 4088
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define MAX_N 1000

using namespace std;

int main() {

  int n;
  bool f[55][35];

  vector<int> vec;

  while(1){
    for(int i=0; i<55; i++){
      for(int j=0; j<35; j++){
        f[i][j] = false;
      }
    }

    cin>>n;
    if(n == 0) break;

    for(int i=0; i<n; i++){
      int t;
      cin>>t;
      if(t == 0) break;
      for(int j=0; j<t; j++){
        int tt;
        cin>>tt;
        f[i][tt] = true;
      }
    }

    set<int> s[55];
    for(int i=0; i<50; i++){
      s[i].insert(i);
    }
    int ans = 1;

    for(int day = 1; day <= 30; day++){
      set<int> v;
      for(int mem = 0; mem < n; mem++){
        if(f[mem][day]){
          set<int>::iterator it = s[mem].begin();
          while(it != s[mem].end()){
            v.insert((*it));
            it++;
          }
        }
      }

      for(int mem = 0; mem < n; mem++){
        if(f[mem][day]){
          s[mem] = v;
        }
      }
      bool flag = false;
      for(int mem = 0; mem < n; mem++){
        if(s[mem].size() == n) flag = true;
      }
      if(flag) break;
      ans++;
    }

    if(ans == 31) vec.push_back(-1);//cout<<-1<<endl;
    else vec.push_back(ans);//cout<<ans<<endl;

  }

  for(int l=0; l<vec.size(); l++) cout<<vec[l]<<endl;

  return 0;
}

Measured memory_bytes: 3268
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
/*
(char)'1' - (int)48 = (int)1; 



*/


int main()
{
	int n;
	cin >> n;
	string ans[10] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv","wxyz"};
	while (n--)
	{
		string a;
		cin >> a;
		int now = -1;
		for (int i = 0; i < a.size(); i++)
		{
			int k = a[i] - 48;
			if (k == 0)
			{
				if (now != -1)
				{
					cout << ans[(int)(a[i-1]-49)][(now) % (int)ans[a[i-1]-49].size()];
					now = -1;
				}
			}
			else
			{
				now++;
			}


		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------


int main(void){
    int n;
    cin >> n;

    vector<ll> a(n);
    for(ll i = 0; i < n; i++) cin >> a[i];

    vector<ll> l(n);
    l[0] = a[0];
    for(ll i = 1; i < n; i++){
        l[i] = l[i - 1] + a[i];
    }

    vector<ll> r(n);
    r[n - 1] = a[n - 1];
    for(ll i = n - 1; i >= 0; i--){
        r[i] = r[i + 1] + a[i];
    }

    reverse(r.begin(), r.end());

    ll ans = INF;
    for(ll i = 0; i < n - 1; i++){
        ans = min(ans, abs(l[i] - r[n - 2 - i]));
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
//#include<stdio.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
#define endl '\n'
#define pb push_back
#define pf pop.front()
using namespace std;
ll MOD=1000000000000007;

vector <long int>g[200001];
bool vis[200001];
l cnt;
l maxn;


void dfs(int v)
{
	vis[v]=true;
	for(long int child : g[v])
	{
		if(!vis[child])
		{
			cnt++;
			dfs(child);
		}
	}
}
int main()
{
FAST
l n,e,i;
cin>>n>>e;
int a,b;

for(i=0;i<e;i++)
{
	cin>>a>>b;
	g[a].pb(b);
	g[b].pb(a);
}

for(i=1;i<=n;i++)
{
	if(!vis[i])
	{
	cnt=1;
	dfs(i);
	maxn=max(maxn,cnt);
	}
}

cout<<maxn<<endl;
}








Measured memory_bytes: 21012
#include"iostream"
#include"vector"
#include"string"
#include"map"
#include"set"
using namespace std;
typedef long long ll;
int gcd(int a, int b)
{
	// Everything divides 0  
	if (a == 0)
		return b;
	if (b == 0)
		return a;

	// base case 
	if (a == b)
		return a;

	// a is greater 
	if (a > b)
		return gcd(a - b, b);
	return gcd(a, b - a);
}
int main(){
	
	ll a, b;
	cin >> a >> b;
	ll x = (a*b)/gcd(a,b);
	cout << x << endl;
	return 0;
}

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

int main(){
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    unsigned long ans{0};
    for(unsigned long i{1}; i <= K; ++i){
        auto t = K / i;
        auto r{1UL}, n{N}, a{t}, v{i};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        for(unsigned long j{2}, k{i}; j * j <= k || ((k > 1 && ((v /= k) *= (k - 1))), 0); ++j)if(k % j == 0){
            (v /= j) *= (j - 1);
            while(k % j == 0)k /= j;
        }
        ans += r * v;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
vi a, b, c;
int memo[101010][3];

int rec(int p, int mae) {
    if (p == n) return 0;
    if (memo[p][mae] == -1) {
        if (mae == 0) {
            memo[p][mae] = max(rec(p + 1, 1) + b[p], rec(p + 1, 2) + c[p]);
        } else if(mae == 1) {
            memo[p][mae] = max(rec(p + 1, 2) + c[p], rec(p + 1, 0) + a[p]);
        } else {
            memo[p][mae] = max(rec(p + 1, 0) + a[p], rec(p + 1, 1) + b[p]);
        }
    }
    // cout << p << " " << mae << ": " << memo[p][mae] << endl;
    return memo[p][mae];
}

int main() {
    cin >> n;
    a.resize(n); b.resize(n); c.resize(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    rep(i, n) rep(j, 3) memo[i][j] = -1;

    int ans = 0;
    rep(i, 3) {
        ans = max(ans, rec(0, i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 7296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	static int gen = 0;

	static class Vertex {
		List<Vertex> adj = new ArrayList<>();
		long stones;
		int id = gen++;

		public Vertex(long stones) {
			this.stones = stones;
		}

		long dfs(Vertex parent) {
			if (adj.size() == 1)
				return stones;
			long sum = 0;
			long max = 0;
			for (Vertex v : adj) {
				if (v == parent)
					continue;
				long got = v.dfs(this);
				sum += got;
				max = Math.max(max, got);
			}
			long nextPathNum = 2 * stones - sum;
			max = Math.max(max, nextPathNum);
			if (nextPathNum < 0) {
				return -1;
			}
			if (2 * max > 2 * stones) {
				return -1;
			}
			return nextPathNum;
		}
	}

	static int N;
	static int[] a, b;
	static Vertex[] vs;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		vs = new Vertex[N];
		for (int i = 0; i < N; ++i)
			vs[i] = new Vertex(sc.nextInt());
		a = new int[N - 1];
		b = new int[N - 1];
		for (int i = 0; i < N - 1; ++i) {
			Vertex a = vs[sc.nextInt() - 1];
			Vertex b = vs[sc.nextInt() - 1];
			a.adj.add(b);
			b.adj.add(a);
		}

		if (N == 2) {
			if (vs[0].stones == vs[1].stones) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
			return;
		}

		Vertex root = null;
		for (Vertex v : vs) {
			if (v.adj.size() > 1) {
				root = v;
				break;
			}
		}

		long pathNum = root.dfs(null);
		if (pathNum == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            int k = n - i * r - j * g;
            if (k < 0) {
                continue;
            }
            if (k % b == 0) {
                ans++;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	double mina = a / 0.08;
	double maxa = (a + 1) / 0.08;
	double minb = b / 0.10;
	double maxb = (b + 1) / 0.10;

	if (mina >= maxb || maxa <= minb) {
		cout << -1 << endl;
		return 0;
	}

	int i = floor(min(mina, minb));

	while (true) {
		if (i > maxa || i > maxb) {
			cout << -1 << endl;
			return 0;
		}

		if (mina <= i && i < maxa && minb <= i && i < maxb) {
			cout << i << endl;
			return 0;
		}

		i++;
	}
}


Measured memory_bytes: 256
result = []

gets.to_i.times do
  n = gets.to_i
  
  field = Array.new(n) {" " * n}
  x, y = 0, n - 1
  
  go = ->(dx, dy, l) {
    l.times do
      field[y][x] = "#"
      x += dx
      y += dy
    end
  }
  square = ->(l) {
    case l
    when 1
      field[y][x] = "#"
    when 2
      go.(0, -1, 1)
      go.(1,  0, 1)
      field[y][x] = "#"
    when 3
      go.(0, -1, 2)
      go.(1,  0, 2)
      go.(0,  1, 2)
      field[y][x] = "#"
    when 4
      go.(0, -1, 3)
      go.(1,  0, 3)
      go.(0,  1, 3)
      go.(-1, 0, 2)
    else
      go.(0, -1, l - 1)
      go.(1,  0, l - 1)
      go.(0,  1, l - 1)
      go.(-1, 0, l - 3)
      go.(0, -1, 2)
      square.(l - 4)
    end
  }
  
  square.(n)
  result << field.map {|l| l + "\n"}.join
end
puts result.join("\n")



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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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 int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vi h(n);
  rep(i,n) cin>>h[i];
  
  int dp[n];
  fill(dp, dp+n, INF);
  dp[0]=0;
  for(int i=1; i<n; i++){
    if(i>1) dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    else dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
package main

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

func main() {
	k := getInt()
	s := getInt()

	ans := 0
	for i := 0; i <= k; i++ {
		for j := 0; j <= k; j++ {
			tmp := s - i - j
			if tmp >= 0 && tmp <= k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;

const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;

#define endl '\n'
#define elif else if
#define def  inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def run()
#define all(v) begin(v), end(v)

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for(ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for(ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) inc(i, 0, n-1)
#define each(i, n) for(auto &&i : (n))

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)
run{fasten,fout(10);}

// Math
func gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
func lcm(ll a, ll b) {return a * b / gcd(a, b);}

signed main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

// for compilation: g++ -O2 -o _ _.cpp -std=c++17
// 

Measured memory_bytes: 256
fn main() {
  use std::io::Read;
  let mut input = String::new();
  std::io::stdin().read_to_string(&mut input).unwrap();
  let mut tok = input.split_whitespace();
  let n : usize = tok.next().unwrap().parse().unwrap();
  println!("{}", n / 500 * 1000 + (n - n / 500 * 500) / 5 * 5);
}


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

const int N = 105;
char s[N][N];
bool row[N], col[N];

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%s", s[i]);
    }
    for (int i = 0; i < n; ++i) {
        bool allw = true;
        for (int j = 0; j < m; ++j) if (s[i][j] == '#') allw = false;
        if (allw) row[i] = true;
    }

    for (int j = 0; j < m; ++j) {
        bool allw = true;
        for (int i = 0; i < n; ++i) if (s[i][j] == '#') allw = false;
        if (allw) col[j] = true;
    }

    for (int i = 0; i < n; ++i) {
        if (row[i]) continue;
        for (int j = 0; j < m; ++j) {
            if (col[j]) continue;
            printf("%c", s[i][j]);
        }
        puts("");
    }
}

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

int main(){
    int c;
    string str;
    
    getline(cin,str);
    c = str.size();
    for(int i = 0 ; i < c ; i++)
      {
        if(str[i] == 'a' && str[i+1] == 'p' && str[i+2] == 'p' 
	   && str[i+3] == 'l' && str[i+4] == 'e')
	  {
	    str[i]='p';
	    str[i+1]='e';
	    str[i+2]='a';
	    str[i+3]='c';
	    str[i+4]='h';
	  }
        else if(str[i] == 'p' && str[i+1] == 'e' && str[i+2] == 'a'
		&& str[i+3] == 'c' && str[i+4] == 'h')
	  {
            str[i]='a';
	    str[i+1]='p';
	    str[i+2]='p';
	    str[i+3]='l';
	    str[i+4]='e';
	  }
      }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define lli long long int
#define inf 2147483647
#define infll LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n, a, b;
    cin >> n >> a >> b;

    lli ans = a * (n / (a+b));
    n %= (a+b);
    ans += min(n, a);

    cout << ans << endl;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll X;
    cin >> X;
    vector<ll> V;
    for (ll i = 0; i <= 100000; ++i) {
        V.pb(i * (i + 1) / 2);
    }
    auto it = lower_bound(all(V), X);
    cout << it - V.begin() << endl;
}



Measured memory_bytes: 1400