akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

vector<ll>v;
ll c[5000],p[5000];

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin >> x;
		v.pb(x);
		c[x]++,p[x]++;
	}

	for(i=1;i<=4000;i++)
		c[i]+=c[i-1];


	ll ans=0;

	for(i=1;i<=1000;i++)
	{
		if(p[i]>1)
		{
			x = (p[i]*(p[i]-1))/2;
			y = c[2*i-1]-p[i];
			ans += x*y;
		}
		if(p[i]>2)
		{
			y = (p[i]*(p[i]-1)*(p[i]-2))/6;
			ans += y;
		}
	}

	for(i=1;i<=1000;i++)
	{
		for(j=i+1;j<=1000;j++)
			ans+=(c[i+j-1]-c[j])*p[i]*p[j];
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
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: 3096
#include <iostream>
#include <set>
using namespace std;

int main()
{
	int N;
	string S;
	cin >> N >> S;

	int resmax = 0;
	for(int s=1; s<N; s++){
		int n;
		set<char> f;
		for(n=0; n<s; n++){
			f.insert(S[n]);
		}
		set<char> l;
		for(;n<N;n++){
			l.insert(S[n]);
		}
		int res = 0;
		for(auto it = f.begin(); it != f.end(); it++){
			if(l.find(*it) != l.end()){
				res++;
			}
		}
		if(resmax < res){
			resmax = res;
		}
	}
	cout << resmax;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int p[100005];
vector <int> a,b;
vector <int> g[100005];
bool tk[100005];
void dfs(int i)
{
	if(tk[i])
	    return;
	tk[i]=true;
	a.push_back(i);
	b.push_back(p[i]);
	for(int j=0;j<g[i].size();j++)
	    dfs(g[i][j]);
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	    cin>>p[i];
	for(int i=1;i<=m;i++)
	{
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	int res=0;
	for(int i=1;i<=n;i++)
	{
		dfs(i);
		sort(a.begin(),a.end());
		sort(b.begin(),b.end());
		int l=0,r=0;
		while(l<a.size()&&r<b.size())
		{
			if(a[l]<b[r])
			    l++;
			else
			if(a[l]>b[r])
			    r++;
			else
			{
				l++;
				r++;
				res++;
			}			
		}
		a.clear();
		b.clear();
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 9132
#include <bits/stdc++.h>
struct fastio { fastio() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } _fastio_;
template<class T> bool chmin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool chmax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

#include <vector>

template<typename T>
struct edge {
    int to; T cost;
    edge (int to, T cost = 1) : to(to), cost(cost) { }
    bool operator< (const edge &r) const { return (cost < r.cost); }
};

template<typename T>
using graph = std::vector<std::vector<edge<T>>>;

#include <vector>
#include <queue>
#include <utility>

template <typename T>
std::vector<T> dijkstra(const graph<T> &g, int s){
	using node = std::pair<T, int>;
	std::vector<T> ret(g.size(), T(-1));
	std::priority_queue<node, std::vector<node>, std::greater<node>> que;
	que.emplace(ret[s], s); ret[s] = 0;
	while (not que.empty()) {
		auto [c, v] = que.top(); que.pop();
		if (ret[v] < c) continue;
		for (const auto &e : g[v]) {
			if (ret[e.to] > ret[v] + e.cost or ret[e.to] == -1) {
				ret[e.to] = ret[v] + e.cost;
				que.emplace(ret[e.to], e.to);
			}
		}
	}
	return ret;
}

const std::pair<int, int> delta[4] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };

int main() {
	int h, w, cx, cy, dx, dy;
	std::cin >> h >> w >> cx >> cy >> dx >> dy;
	cx--; cy--; dx--; dy--;
	std::vector<std::string> s(h);
	for (auto &e : s) std::cin >> e;
	
	graph<int> g(h * w);
	auto idx = [&](int i, int j) {
		return (i * w + j);
	};
	
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
		for (auto [x, y] : delta) {
			int nx = i + x, ny = j + y;
			if (nx < 0 or h <= nx or ny < 0 or w <= ny) continue;
			if (s[nx][ny] == '#') continue;
			g[idx(i, j)].emplace_back(idx(nx, ny), 0);
		}
		for (int x = -2; x <= 2; x++) for (int y = -2; y <= 2; y++) {
			int nx = i + x, ny = j + y;
			if (nx < 0 or h <= nx or ny < 0 or w <= ny) continue;
			if (s[nx][ny] == '#') continue;
			g[idx(i, j)].emplace_back(idx(nx, ny), 1);
		}
	}
	
	std::vector<int> dist = dijkstra(g, idx(cx, cy));
	std::cout << dist[idx(dx, dy)] << '\n';
	return 0;
}

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

std::string c;

int main()
{
	std::cin >> c;

	bool fl = c == "a" || c == "i" || c == "u" || c == "e" || c == "o";

	std::cout << (fl ? "vowel" : "consonant") << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll a,c;
    cin >> a >> c;
    cout << (c>=2*a?(a+(c-2*a)/4):min(a,c/2)) <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n = in();
  map<string,int> mp;
  rep(i,n) {
    string s = in<string>();
    mp[s]++;
  }
  int maxv = 0;
  for (const auto& x : mp) {
    int v = x.se;
    if (v > maxv) maxv = v;
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->se == maxv) cout << it->fi << '\n';
  }
  return 0;
}

Measured memory_bytes: 25216
def main():
    N = int(input())
    a = [0 for i in range(N)]
    for i in range(N):
        a[i] = int(input())
    now = 1
    for i in range(N):
        if a[now - 1] == 2:
            break
        elif i == N - 1:
            i = -2
        else:
            now = a[now - 1]
        #print('{}: {}'.format(i, now))
    print(i + 1)
main()


Measured memory_bytes: 46240
#include <iostream>

int main()
{
    int n;

    std::cin >> n;

    int *a = new int[n];

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

    for (int i = n - 1; i >= 0; i--)
    {
        std::cout << a[i];

        if (i > 0) std::cout << " ";
        else       std::cout << std::endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n, p;
	cin >> n >> p;
	vector<ll>a(n);
	bool oflag = false;
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 2 == 1)oflag = true;
	}
	if (oflag == true) cout << fixed << setprecision(0) << pow(2, n - 1) << endl;
	else cout << fixed << setprecision(0) << (p == 0 ? pow(2, n) : 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

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

    ld ans;
    if(a*a*b <= x*2){
        ld y = (2*x/(a*a))-b;
        ans = atan2(a, b-y);
    }
    else{
        ld y = (2*x/(a*b));
        ans = atan2(y, b);
    }
    ld degrees = ans * (180.0/3.141592653589793238463);
    cout << fixed << setprecision(10) << fixed << 90 - degrees << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
    char x;
    cin>>x;
    if(x=='A')
    {
        cout<<"T"<<endl;
    }
    else if(x=='T')
    {
        cout<<"A"<<endl;
    }
    else if(x=='C')
    {
        cout<<"G"<<endl;
    }
    else
    {
        cout<<"C"<<endl;
    }
    return 0;
}


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

int main()
{
   int n,a[105];cin>>n;
   int cnt=0,flag=0;
   for(int i=0;i<n;i++) {cin>>a[i];
   if(a[i]%2==0){cnt++;
   if(a[i]%3==0 || a[i]%5==0) flag++;}}
   if(cnt==flag) puts("APPROVED");
   else puts("DENIED");
}


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

int main() {
  int n, i;
  cin >> n;
  
  vector<int> d(n);
  for(i = 0; i < n; i++) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  
  cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	//DP
	int DP(int xy[][],int DP[][]){
		for(int i = 1;i < 1001;i++){
			for(int j = 1;j < 1001;j++){
				if(xy[i][j] == 1){
					if(DP[i][j-1] < DP[i-1][j]){
						DP[i][j] = DP[i][j-1] + 1;
					}
					else{
						DP[i][j] = DP[i-1][j] + 1;
					}
				}else{
					if(DP[i][j-1] < DP[i-1][j]){
						DP[i][j] = DP[i-1][j];
					}
					else{
						DP[i][j] = DP[i][j-1];
					}
				}
			}
		}
		return DP[1000][1000];
	}
	//最短距離
	void doIt() { 
		while(true){
			int n = sc.nextInt();
			if(n == 0)break;
			int xy[][] = new int[1001][1001];
			int DP[][] = new int[1001][1001];
			for(int i = 0;i < n;i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				xy[a][b] = 1;
			}
			int m = sc.nextInt();
			for(int i = 0;i < m;i++){
				int a = sc.nextInt();
				int b = sc.nextInt();
				xy[a][b] = 1;
			}
			System.out.println(DP(xy,DP));
		}
     }
    public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

Measured memory_bytes: 70052
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

///////////////////////////////////////////////////////////////////////////////////////

ll dp[MAX_10p5][11];

int main() {
	while (1) {
		string s;
		cin >> s;
		if (s == "0") break;
		repi(i, 0, MAX_10p5) {
			repi(j, 0, 11) {
				dp[i][j] = 0;
			}
		}
		repi(i, 0, s.length()) {
			if (i == 0) dp[i][(ll)(s[i] - '0')]++;
			else {
				repi(j, 0, 11) {
					ll idx = (j * 10 + (ll)(s[i] - '0')) % 11;
					dp[i][idx] += dp[i - 1][j];
					if (j == 0 && idx != 0) dp[i][idx]++;
				}
			}
		}
		ll ans = 0;
		repi(i, 0, s.length()) {
			ans += dp[i][0];
		}
		wrln(ans);
	}
	return 0;
}



Measured memory_bytes: 11932
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int E[MAX_N], W[MAX_N];
string S;

void solve() {
	cin >> N;
	cin >> S;
	rep(i, 0, N) {
		if(S[i] == 'W') W[i]++;
		else E[i]++;
	}
	rep(i, 0, N) W[i + 1] += W[i];
	rer(i, N, 0) E[i] += E[i + 1];

	int res = inf;
	rep(i, 0, N) {
		int v = (i == 0 ? 0 : W[i - 1]);
		int w = (i == N - 1 ? 0 : E[i + 1]);
		MIN(res, v + w);
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 3092
def dfs(v)
  return true if v == $goal
  $used[v] = true
  $g[v].each do |u, c|
    if !$used[u] && c > 0
      if dfs(u)
        $g[v][u] -= 1
        $g[u][v] += 1
        return true
      end
    end
  end
  false
end

def max_flow(size)
  flow = 0
  loop do
    $used =  [false] * size
    if dfs($start)
      flow += 1
    else
      return flow
    end
  end
end

v, e = gets.split.map(&:to_i)
$g = (v + 1).times.map { {} }
r = e.times.map{ [] }
e.times do |i|
  s, t = gets.split.map(&:to_i)
  r[i] = [s, t]
  $g[s][t] = $g[t][s] = 1
end
$start, $goal = gets.split.map(&:to_i)

p max_flow(v)

ret = r.map.with_index{ |(s, t), i| i if $g[t][s] == 0 }.compact
p ret.size
ret.each{ |i| p i + 1 }

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define vp vector <pi>
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1n(x,n) for(int x = 1; x <= n ;++ x)
#define forn1(x,n) for(int x = 1; x < n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

int main(){
	IOS
	int n;
	cin>>n;
	bool flag = true;
	string s;
	cin>>s;
	if(n%2)
	{
		cout<<"No"; return 0;
	}
	int mid = n/2;
	int start = (n%2==0)?mid:mid+1;
	for(int i=0;i<mid;i++)
		if(s[i]!=s[start+i])
			{
				flag = false;
				break;
			} 
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;	
}

Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	S := readLine()
	fmt.Printf("%s\n", ABC136D(S))
}

// ABC136D ...
func ABC136D(S string) (resstr string) {
		res := make([]int, len(S))

	succ := 1
	for i := 1; i < len(S); i++ {
		if succ != 0 && S[i] == 'L' {
			if succ%2 == 0 {
				res[i-1] += succ / 2
				res[i] += succ / 2
			} else {
				res[i-1] += succ/2 + 1
				res[i] += succ / 2
			}
			succ = 0
		} else if S[i] == 'R' {
			succ++
		}
	}

	succ = 1
	for i := len(S) - 2; i >= 0; i-- {
		if succ != 0 && S[i] == 'R' {
			if succ%2 == 0 {
				res[i] += succ / 2
				res[i+1] += succ / 2
			} else {
				res[i] += succ / 2
				res[i+1] += succ/2 + 1
			}
			succ = 0
		} else if S[i] == 'L' {
			succ++
		}
	}

	for i := 0; i < len(res)-1; i++ {
		resstr += strconv.Itoa(res[i]) + " "
	}
	resstr += strconv.Itoa(res[len(res)-1])

	return
}


Measured memory_bytes: 6560
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>
using namespace std;

int main() {
	int A,B,C,D,sum=0,i,j,k;
	char a,b,c,d;
	cin>>a>>b>>c>>d;
	A=a-'0';
	B=b-'0';
	C=c-'0';
	D=d-'0';
	for(i=0;i<2;i++)
	{
	for(j=0;j<2;j++)
		{
	for(k=0;k<2;k++)
			{
		sum+=A;
		if(i==0)sum+=B;
		else sum-=B;
		if(j==0)sum+=C;
		else sum-=C;
		if(k==0)sum+=D;
		else sum-=D;
		if(sum==7)break;
		sum=0;
			}
		if(sum==7)break;
		}
		if(sum==7)break;
	}
	cout<<A<<((i)?"-":"+")<<B<<((j)?"-":"+")<<C<<((k)?"-":"+")<<D<<"=7";
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
int h,w;
cin>>h>>w;
char a[h+2][w+2];
rep(i,w+2){
    a[0][i] = '#';
    a[h+1][i] = '#';
}
rep(i,h+2){
    a[i][0] = '#';
    a[i][w+1] = '#';
}
for(int i = 1; i < h+1 ; i++){
    for(int j = 1; j < w+1; j++){
        cin>>a[i][j];
    }
}

rep(i,h+2){
    rep(j,w+2){
        cout<<a[i][j];
    }
    cout<<endl;
}
   return 0;
}


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

int main()
{
	int n, di1[101], di2[101];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> di1[i] >> di2[i];
	}
	for (int i = 0; i < n - 2; i++) {
		if (di1[i] == di2[i] && di1[i + 1] == di2[i + 1] && di1[i + 2] == di2[i + 2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3632
//666yuchen
#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a,b,c,x,gs;
int main()
{
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
      for(int k=0;k<=c;k++)
        if(i*500+j*100+k*50==x)gs++;
  cout<<gs;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int m1, d1, m2, d2;
int main() {
  cin >> m1 >> d1 >> m2 >> d2;

  cout << (m1 == m2 ? '0' : '1') << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
s = input()
s += '#'
lis = []
cnt = 0
for i in range(n):
    cnt += 1
    if s[i] != s[i+1]:
        lis.append(cnt)
        cnt = 0
#print(lis)
val = 0
ans = 0
for i in range(len(lis)):
    if i < 2*k+1:
        val += lis[i]
    else:
        ans += lis[i] - 1
ans += val - 1
print(ans)


Measured memory_bytes: 45296
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();

      int[] data = new int[n];
      int sum = 0;
      int max = 0;
      for (int i = 0;i<n ;i++ ) {
        data[i] = sc.nextInt();
        max = Math.max(max,data[i]);
        sum += data[i];
      }
      if(sum-max>max){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
      
}
}


Measured memory_bytes: 22740
#include<iostream>
#include<sstream>
#include<map>
#include<vector>
#include<set>
using namespace std;

int main()
{
  int cnt=0;
  map<int,int> data[2];
  vector<int> numlist;
  string str;
  for(;getline(cin,str);)
    {
      if(str=="")
	{
	  cnt++;
	  continue;
	}
      istringstream ss(str);
      int num,day;
      char buf;
      ss>>num>>buf>>day;
      data[cnt][num]++;
      numlist.push_back(num);
    }
  set<int> s(numlist.begin(),numlist.end());

  for(set<int>::iterator it=s.begin();it!=s.end();it++)
    {
      if(data[0].count(*it)!=0 &&data[1].count(*it)!=0 )
	cout<<(*it)<<" "<<(data[0][*it]+data[1][*it])<<endl;
    }

}

Measured memory_bytes: 1248
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector<double> vd;
typedef std::vector<std::string> vs;
typedef std::vector<pii> vpii;
typedef std::vector<vi> vvi;
typedef std::vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { rep(i,v.size()) is >> v[i]; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

typedef std::vector<Edge> Edges;
typedef std::vector<Weight> Array;
typedef std::vector<Array> Matrix;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int &size = 0) : g(size) {}
  int size() const { return g.size(); }
  const Edges &operator[](const int &i) const { return g[i]; }
  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }
  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }
};

template<int inf = std::numeric_limits<Weight>::max() / 8> std::pair<std::vector<Weight>, std::vector<int>> dijkstra(const Graph &g, const int &src) {
  using state = std::pair<Weight, int>;
  std::priority_queue<state, std::vector<state>, std::greater<state>> q;
  std::vector<Weight> dist(g.size(), inf);
  std::vector<int> via(g.size());
  dist[src] = 0;
  q.emplace(0, src);
  while (q.size()) {
    Weight d;
    int v;
    std::tie(d, v) = q.top();
    q.pop();
    if (dist[v] < d) continue;
    for (auto &e : g[v]) {
      if (cmin(dist[e.dst], dist[v] + e.weight)) {
        via[e.dst] = v;
        q.emplace(dist[e.dst], e.dst);
      }
    }
  }
  return {dist, via};
}

main {
  int n;
  cin >> n;
  Graph g(n);
  while (n--) {
    int r, k;
    cin >> r >> k;
    --r;
    while (k--) {
      int t;
      cin >> t;
      --t;
      g.addArc(r, t);
    }
  }
  n = g.size();
  Matrix dist(n, Array(n));
  rep(i, n) {
    vector<Weight> d = dijkstra<INF>(g, i).first;
    rep(j, n) dist[i][j] = d[j];
  }
  int p;
  cin >> p;
  while (p--) {
    int s, d, v;
    cin >> s >> d >> v;
    --s, --d;
    if (dist[s][d] + 1 > v) {
      cout << "NA" << endl;
      continue;
    }
    cout << dist[s][d] + 1 << endl;
  }
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int N;
  cin>>N;
  vector<ll> A,B,C;
  A=B=C=vector<ll>(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)cin>>B[i];
  for(int i=0;i<N;i++)cin>>C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  ll ans=0;
  for(int i=0;i<N;i++){
    ll C_num=N-(upper_bound(C.begin(),C.end(),B[i])-C.begin());
    ll A_num=lower_bound(A.begin(),A.end(),B[i])-A.begin();
    ans+=A_num*C_num;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2688
#include <stdio.h>

int main(int argc, const char * argv[]) {
   
    
    char S[13];
    int i;
    gets(S);
    
    for (i=0; i<12; i++) {
        printf("%c",S[i]);
        if (i==3) {
            printf(" ");
        }
            
            }
    
    
    printf("\n");
    
    return 0;
}


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

int main(){
    
    while(1){
        string s;
        cin >> s;
        
        if(s == "-"){
            break;
        }
        
        int m;
        cin >> m;
        
        for(int i = 0; i < m; i++){
            int h;
            cin >> h;
            s = s.substr(h) + s.substr(0, h);
        }
        cout << s << endl;
    }
  return 0;
}


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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    boost;
    time_t tic, toc;

    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, h, w, u, v, x, y;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s, t, tmp;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;
        cout << n + n*n + n*n*n << nl;
        
    } 
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
#define print(x) cout<<'>'<<#x<<':'<<x<<endl;
#define F first
#define S second
const int mod=1000000007;

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    if ((a+b)>=c)cout<<"Yes";
    else cout<<"No";

}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
import itertools

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

N = NLinput[0]
L = NLinput[1]

S_list = []
for i in range(N):
    temp = input()
    S_list.append(temp)

S_list = sorted(S_list)
str_temp = ''
for i in S_list:
    str_temp += i
print(str_temp)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll ans = 1;
    for(ll i = 1; i<=n; i++) ans = (ans*i)%MODV;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;
lli ExGCD(lli a, lli b, lli &x, lli &y){
	lli d=a;
	x=1; y=0;
	if(b!=0){ d=ExGCD(b, a%b, y, x); y-=a/b*x; }
	return d;
}
lli fact[1000001];
lli inv[1000001];
void maketable(){
	fact[0] = 1;
	for(int i=0; i<1000000; i++){
		fact[i+1] = fact[i]*(i+1) %mod;
	}
	lli y;
	for(int i=0; i<1000000; i++){
		ExGCD(fact[i], mod, inv[i], y);
		while(inv[i]<0) inv[i]+=mod;
	}
}
lli nPr(lli n, lli r){
	return fact[n] *inv[n-r] %mod;
}

int main(){
	maketable();
	int n,m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	for(int i=0; i<m; i++){
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	if((int)a.size()!=n || (int)b.size()!=m){
		cout << 0 << endl;
		return 0;
	}

	lli ans = 1;
	int ridx=0, cidx=0;
	int used=0;
	while(ridx<n && cidx<m){
		if(ridx!=n && cidx!=m && a[ridx]==b[cidx]){
			//同時
			int num = n-ridx +m-cidx -1;
			if(used+num <= a[ridx]){
				ans *= nPr(a[ridx]-used-1, num-1);
				ans %= mod;
				used += num;
				ridx++;
				cidx++;
			}else{
				ans = 0;
				break;
			}
		}else if(cidx==m || (ridx!=n && a[ridx] < b[cidx])){
			//行を取る
			int num = m-cidx;
			if(used+num <= a[ridx]){
				ans *= nPr(a[ridx]-used-1, num-1) *num %mod;
				ans %= mod;
				used += num;
				ridx++;
			}else{
				ans = 0;
				break;
			}
		}else{
			//列を取る
			int num = n-ridx;
			if(used+num <= b[cidx]){
				ans *= nPr(b[cidx]-used-1, num-1) *num %mod;
				ans %= mod;
				used += num;
				cidx++;
			}else{
				ans = 0;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15872
from collections import defaultdict
from heapq import heappush, heappop, heapify
def main():
    N = int(input())
    SC = []
    SCrev = []
    for _ in range(N):
        s, c = input().split()
        c = int(c)
        SC.append((s, c))
        SCrev.append((s[::-1], c))
    dist = defaultdict(lambda: 10**18)
    q = [(c, s, "") for s, c in SC] + [(c, "", s) for s, c in SCrev]
    for c, l, r in q:
        dist[(l, r)] = min(dist[(l, r)], c)
    heapify(q)
    while q:
        dist_v, vl, vr = heappop(q)
        if (vl == vr == "") or (len(vl) and vl == vl[::-1]) or (len(vr) and vr == vr[::-1]):
            print(dist_v)
            exit()
        if dist[(vl, vr)] != dist_v:
            continue
        if len(vl) < len(vr):
            for s, c in SC:
                if len(s) <= len(vr):
                    if vr.startswith(s):
                        vr_ = vr[len(s):]
                        dist_u = dist_v + c
                        if dist_u < dist[("", vr_)]:
                            dist[("", vr_)] = dist_u
                            heappush(q, (dist_v+c, "", vr_))
                else:
                    if s.startswith(vr):
                        vl_ = s[len(vr):]
                        dist_u = dist_v + c
                        if dist_u < dist[(vl_, "")]:
                            dist[(vl_, "")] = dist_u
                            heappush(q, (dist_v+c, vl_, ""))
        else:
            for s, c in SCrev:
                if len(s) <= len(vl):
                    if vl.startswith(s):
                        vl_ = vl[len(s):]
                        dist_u = dist_v + c
                        if dist_u < dist[(vl_, "")]:
                            dist[(vl_, "")] = dist_u
                            heappush(q, (dist_v+c, vl_, ""))
                else:
                    if s.startswith(vl):
                        vr_ = s[len(vl):]
                        dist_u = dist_v + c
                        if dist_u < dist[("", vr_)]:
                            dist[("", vr_)] = dist_u
                            heappush(q, (dist_v+c, "", vr_))
    print(-1)

main()


Measured memory_bytes: 9496
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<ll,ll>      mll;


int main()
{
 //O_O ;
   ll t,p=0;
   cin>>t;
   mll mp;
for(ll i=0;i<t;i++){
    ll n;
    cin>>n;
    mp[n]++;
    if(mp[n]==2)
    {
        p=1;
        break;
    }


}
  if(p)
    cout<<"NO"<<nn;
else
    cout<<"YES"<<nn;

    return 0;
}


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

using namespace std;

int main()
{
    int a, b, c, n;
    int ans = 0;

    cin >> a >> b >> c >> n;

    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            if ((n - (i*a + j*b)) >= 0 && (n - (i*a + j*b)) % c == 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long N,K,Q;
  cin >> N >> K >> Q;
  int A[Q],B[N+1];
  for(int i=0; i<Q; i++) cin >> A[i];
  for(int i=0; i<N+1; i++) B[i] = 0;
  for(int i=0; i<Q; i++) B[A[i]]++;
  for(int i=1; i<N+1; i++) {
    if(K-(Q-B[i])>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
int A,B,C,D,S=0;
cin>>A>>B>>C>>D;
if(A>B)
S=S+B;
else
S=S+A;
if(C>D)
S=S+D;
else
S=S+C;
cout<<S;
return 0;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}
int n,y;
bool flag = false;
int a_a=0,a_b=0,a_c=0;
void dfs(int i, int sum, int a, int b, int c, int k){
  if(i==n){
    if(y==sum){
      flag = true;
      a_a = a;
      a_b = b;
      a_c = c;
    }
    return;
  }
  if(k==0) dfs(i+1,sum+10000,a+1,b,c,0);
  if(k<=1) dfs(i+1,sum+5000,a,b+1,c,1);
  if(k<=2) dfs(i+1,sum+1000,a,b,c+1,2);
}

int main(){
  scanf("%d %d",&n,&y);
  dfs(0,0,0,0,0,0);
  if(flag){
    printf("%d %d %d\n",a_a,a_b,a_c);
  }else{
    printf("-1 -1 -1\n");
  }
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    private static long MOD = 1000000007;
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();
        long total = 0;

        for (long i = K; i <= N+1; i++) {
            long min = sum(i-1);
            long max = sum(N) - sum(N-i);
            long diff = (max - min) + 1;
            total = (total + diff);
        }
        System.out.println(total % MOD);
    }

    private static long sum(long i) {
        return i*(i+1)/2;
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n+10);
  int m = 0;
  rep(i,n){
    cin >> a[i];
    m += a[i];
  }
  m /= n;
  int ans = 1000000;
  for(int i = -100;i < 101;++i){
    int count = 0;
    rep(j,n){
      count += (a[j]-i)*(a[j]-i);
    }
    ans = min(ans,count);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;



int main() {
	string s;
	cin >> s;
	ll res = 0, ans = 0;
	REP(i, s.size()) {
		if (s[i] == 'B')res++;
		else ans += res;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean[] AC = new boolean[100005];
        int[] WA = new int[100005];
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int ac=0;
        int wa=0;
        
        for(int i=0;i<M;i++) {
            int p = sc.nextInt();
            String S = sc.next();
            if(S.equals("AC")) {
            	AC[p]=true;	
            } else {
            	if(AC[p]==false) {
            		WA[p]++;
            	}
            }            
        }
        
        for(int i=0;i<100005;i++) {
        	if(AC[i]==true) {
        		ac++;
        		wa=wa+WA[i];
        	}
        }
        
        System.out.println(ac + " " + wa);
    }

}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

int n;
vec<int> v;

bool bin(int key) {
   int left = 0, right = n - 1;
   while (left <= right) {
      int mid = (left+right)/2;
      if (key > v[mid]) {
         left = mid + 1;
      } else if (key < v[mid]) {
         right = mid - 1;
      } else {
         return true;
      }
   }
   return false;
}

int main() {
   cin >> n;
   rep (i, 0, n) {
      int x;
      cin >> x;
      v.push_back(x);
   }
   sort(all(v));

   int q;
   cin >> q;
   int cnt = 0;
   rep (i, 0, q) {
      int x;
      cin >> x;
      if (bin(x)) cnt++;
   }
   cout << cnt << endl;

   return 0;
}


Measured memory_bytes: 3412
row,column = gets.chomp.split(" ").map(&:to_i)
res = 0
odd_row = 0
even_row = 0

if row <= 1
  odd_row = 1
elsif row % 2 == 0
  odd_row = row / 2
  even_row = row / 2
elsif row % 2 == 1
  odd_row = row / 2 + 1
  even_row = row / 2
end

if row == 1 or column == 1
  res = 1
else
  if column > 2 and column.odd?
    res += (column / 2 + 1) * odd_row
  elsif column > 2 and column.even?
    res += (column / 2) * odd_row
  elsif column <= 2
    res += 1 * odd_row
  end

  if column >= 2 and column.even?
    res += (column / 2) * even_row
  elsif column >= 2 and column.odd?
    res += (column / 2) * even_row
  elsif column == 1
    res += 0
  end
end

puts res

Measured memory_bytes: 1788
local X = io.read()

local function main(str)
	local cloneStr = string.sub(str, 1, string.len(str) / 2)
	local s1 = string.gsub(cloneStr, "S", "")
	if string.len(s1) == 0 then
		print(0)
		return
	end

	str = string.gsub(str, "ST", "")

	local s = string.find(str, "ST")
	if s then
		return main(str)
	end
	print(string.len(str))
end

main(X)

Measured memory_bytes: 1964
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let vec: Vec<i32> = read_line();
    let hs: Vec<i32> = read_line();

    let mut dp: Vec<i32> = Vec::new();
    dp.push(0);
    dp.push((hs[1] - hs[0]).abs());
    for _ in 2..hs.len() { dp.push(0); }
    for i in 2..hs.len() {
        dp[i] = cmp::min(
                    dp[i - 2] + (hs[i] - hs[i - 2]).abs(),
                    dp[i - 1] + (hs[i] - hs[i - 1]).abs(),
                );
    }
    println!("{}", dp.last().unwrap());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x,y;
  cin>>x>>y;
  int l=x.length(),m=y.length(),j;
  for(j=0;j<m;j++) cout<<x.at(j)<<y.at(j);
  if(l>m) cout<<x.at(m);
  cout<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl "\n"
#define mem(a, i) memset(a, i, sizeof(a))
int main()
{
    FASTIO
    long double n, m;
    cin >> n >> m;
    cout << (ll)((n * m)+0.001) << endl;

    return 0;
}


Measured memory_bytes: 3728
n,l = map(int,input().split())
a =[]
for i in range(n):
    s = i + l 
    a.append(s)
if min(a)<0 and max(a)<=0:
    print(sum(a)-max(a))
elif min(a)>=0 and max(a) >0:
    print(sum(a)-min(a))
else:
    print(sum(a))

Measured memory_bytes: 3064