akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号
  vector<int> siz;  //葉の値を持つ

  UnionFind(int n)
      : par(n),
        siz(n, 1)  //初期化
  {
    for (int i = 0; i < n; i++) par[i] = i;
  }

  int root(int x)  //データxが属する木の根を再帰で得る
  {
    if (par[x] == x)
      return x;
    else
      return par[x] = root(par[x]);
  }

  int size(int x) { return siz[root(x)]; }

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

  bool unite(int x, int y)  // xとyの木を併合
  {
    if ((x = root(x)) == (y = root(y)))  // xとyの根が同じ時はそのまま
      return false;
    if (siz[y] > siz[x]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;  // yの根にxをつける
    return true;
  }
};

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  UnionFind uf(n + 1);
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    uf.unite(a, b);
  }
  int ans = 0;
  rep(i, 0, n) { chmax(ans, uf.size(i)); }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 6328
using System;
using System.Linq;

namespace test
{
    class Program {
        public static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            int a, b;
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            var target = Console.ReadLine();
            int count = target.Count(x => x == '-');
            if (count != 1) {
                Console.WriteLine("No");
            }
            else {
                int hifun = target.IndexOf('-');
                if (hifun == a && target.Length == a + b + 1) {
                    Console.WriteLine("Yes");
                }
                else {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 11220
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init,ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T> &v) {
	T ans = -INF;
	rep(i,0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C& c, std::ostream& os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}

bool kansu(pll a, pll b) {
	return a.first < b.first;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

ll n,d;
string k;
ll dp[10003][103][2];

ll modpow(ll n, ll a, ll m) {
	if (a == 0)return 1;
	if (a % 2 == 0) {
		ll b = modpow(n, a / 2, m);
		return (b * b) % m;
	}
	else if (a % 2 == 1) return (n * modpow(n, a - 1, m)) % m;
}

int main() {
	string s;
	cin >> s;
	ll n = 2019;
	vl dp(200000 + 5),dpa(2019);
	for (ll i = s.size(); i > 0; i--) {
		ll n = modpow(10, s.size() - i, 2019);
		dp[i - 1] = dp[i] + (ll((s[i - 1]) - ll('0')) * n) % 2019;
		dp[i - 1] %= 2019;
	}
	rep(i, 0, s.size() + 1) {
		ll v = dp[i];
		dpa[v] += 1;
	}
	ll ans = 0;
	rep(i, 0, 2019) {
		ans += dpa[i] * (dpa[i] - 1) / 2;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 5144
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	bool ans[Nmax];
	ans[0]=true;
	if(s[0]=='o') ans[1]=true;
	else ans[1]=false;
	FOR(i,1,N){
		if(s[i]=='o'){
			if(ans[i]) ans[i+1]=ans[i-1];
			else ans[i+1]=!ans[i-1];
		}else{
			if(ans[i]) ans[i+1]=!ans[i-1];
			else ans[i+1]=ans[i-1];
		}
	}
	if(ans[N-1] && (ans[0]==ans[N])){
		REP(i,N){
			if(ans[i]) cout<<"S";
			else cout<<"W";
		}
		return 0;
	}
	
	ans[0]=true;
	if(s[0]=='o') ans[1]=false;
	else ans[1]=true;
	FOR(i,1,N){
		if(s[i]=='o'){
			if(ans[i]) ans[i+1]=ans[i-1];
			else ans[i+1]=!ans[i-1];
		}else{
			if(ans[i]) ans[i+1]=!ans[i-1];
			else ans[i+1]=ans[i-1];
		}
	}
	if(!ans[N-1] && (ans[0]==ans[N])){
		REP(i,N){
			if(ans[i]) cout<<"S";
			else cout<<"W";
		}
		return 0;
	}
	
	ans[0]=false;
	if(s[0]=='o') ans[1]=false;
	else ans[1]=true;
	FOR(i,1,N){
		if(s[i]=='o'){
			if(ans[i]) ans[i+1]=ans[i-1];
			else ans[i+1]=!ans[i-1];
		}else{
			if(ans[i]) ans[i+1]=!ans[i-1];
			else ans[i+1]=ans[i-1];
		}
	}
	if(ans[N-1] && (ans[0]==ans[N])){
		REP(i,N){
			if(ans[i]) cout<<"S";
			else cout<<"W";
		}
		return 0;
	}
	ans[0]=false;
	if(s[0]=='o') ans[1]=true;
	else ans[1]=false;
	FOR(i,1,N){
		if(s[i]=='o'){
			if(ans[i]) ans[i+1]=ans[i-1];
			else ans[i+1]=!ans[i-1];
		}else{
			if(ans[i]) ans[i+1]=!ans[i-1];
			else ans[i+1]=ans[i-1];
		}
	}
	if(!ans[N-1] && (ans[0]==ans[N])){
		REP(i,N){
			if(ans[i]) cout<<"S";
			else cout<<"W";
		}
		return 0;
	}
	
	cout<<-1<<endl;
	return 0;
}

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

int main() {
	string s,t;
	int cnt=0;
	cin>>s>>t;
	for(int i=0;i<3;i++){
		if(s.at(i)==t.at(i)){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 85
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int main()
{
    int k,i,j;
    scanf("%d",&k);
    char s[3]={'A','C','L'};
    for(i=0;i<k;i++)
    {
        for(j=0;j<3;j++)
        {
            printf("%c",s[j]);
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define lpx(i,x,n) for(int i=x; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<char, int> pci;
typedef vector<pii> vp;
typedef vector<pci> vpc;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 500000;
int mx = -1e9 , mn = 1e9 ;
ll arr[N],arr2[N] ;

int dcmp(double x, double y)
{
    return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}



int main()
{
    int n; cin>> n;
    lp(i,n+1)
        cin >> arr[i] ;
    lp(i,n)
        cin >> arr2[i];
    ll a = 0;
    lp(i,n){
        int x = min(arr[i],arr2[i]);
        //cout << i << ' ' << arr[i] << ' '<<arr2[i]<<endl;
        a += x;
        arr[i] -= x;
        arr2[i] -= x;
        if(arr2[i]){
            //cout <<arr2[i] << ' ' << i << endl;
            int y = min(arr[i+1],arr2[i]);
            a += y;
            arr[i+1] -= y;
            arr2[i] -= y;
        }
        //cout <<  a << endl;
    }
    cout << a << endl;



    return 0;
}
























Measured memory_bytes: 5120
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D;
  cin >> N;
  H = min(H, 2 * Q);
  S = min(S, 2 * H);
  D = min(D, 2 * S);
  ll ans = (N % 2) * S + (N / 2) * D;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m;
bool ok;

void dfs(vector<vector<int>> g, vector<int> &color, int v, int c) {
    color[v] = c;
    for(int nv: g[v]) {
        if(color[nv] == c) {
            ok = 0;
            return;
        } else if(color[nv] == -1) {
            dfs(g, color, nv, 1 - c);
        }
    }
}

void solve() {
	while(cin >> n >> m) {
        if(n == 0 && m == 0) break;
        vector<vector<int>> g(n, vector<int>());
        rep(i, m) {
            int u, v; cin >> u >> v;
            --u, --v;
            g[u].push_back(v);
            g[v].push_back(u);
        }
        vector<int> color(n, -1);
        ok = 1;
        dfs(g, color, 0, 0);
        if(!ok) {
            cout << 0 << endl;
        } else {
            int cnt = 0;
            rep(i, n) {
                if(color[i] == 0) ++ cnt;
            }
            //debug(cnt);
            set<int> ans;
            if(cnt % 2 == 0) {
                ans.insert(cnt / 2);
            }
            if((n - cnt) % 2 == 0) {
                ans.insert((n - cnt)/ 2);
            }
            cout << (int)ans.size() << endl;
            for(auto p: ans) {
                cout << p << endl;
            }
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


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

int main()
{
    int n;
    cin>>n;
    if(n%2==0){ 
        n=n-2;
        cout<<n/2;
    } 
    else { 
        n--;
        cout<<n/2;
    } 

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Console.WriteLine(vals.Count(x => x >= nk[1]));
    }
}

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

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for(int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  cin >> M;
  vector<string> t(M);
  for(int j = 0; j < M; j++) {
    cin >> t.at(j);
  }
  
  int p = 0, q = 0;
  //点数評価開始
  for(int k = 0; k < N; k++) {
    //加点評価
    for(int l = 0; l < N; l++) {
      if(s.at(k) == s.at(l)) {
        p += 1;
      }
      
    }
    //減点評価
    for(int m = 0; m < M; m++) {
      if(s.at(k) == t.at(m)) {
        p -= 1;
      }
      
    }
    //大小評価
    if(p > q) {
      q = p;
    }
    //初期化
    p =0;
  }
  
  cout << q << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  while(true){
    char ch;
    scanf("%c", &ch);
    if (isalpha(ch)){
      if(islower(ch)) printf("%c", toupper(ch));
      else if(isupper(ch)) printf("%c", tolower(ch));
    }
    else printf("%c", ch);
    if(ch=='\n') break;
  }
  return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	map<int, map<int, char>> mx, my, ms, md;
	IN(int, n);
	inc(i, n) {
		IN(int, x, y);
		IN(string, s);
		char c = s[0];
		mx[x][y] = c;
		my[y][x] = c;
		ms[x + y][x - y] = c;
		md[x - y][x + y] = c;
	}
	
	const int INF = 1e7;
	int ans = INF;
	auto f = [&](auto const & mm, char a, char b) {
		for(auto const & [v_, m]: mm) {
			int p = -2 * INF;
			for(auto const [x, c]: m) {
				if(c == a) { p = x; }
				if(c == b) { setmin(ans, x - p); }
			}
		}
	};
	f(mx, 'U', 'D');
	f(my, 'R', 'L');
	f(ms, 'R', 'U');
	f(ms, 'D', 'L');
	f(md, 'U', 'L');
	f(md, 'R', 'D');
	OUT(ans == INF ? "SAFE" : to_string(ans * 5));
}


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

//Compiler version g++ 6.3.0

int main()
{
    string s;
    
    cin >> s;
    
    s[0]='2';
    s[1]='0';
    s[2]='1';
    s[3]='8';
    
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 3572
S = input()
N = len(S)

def judge(S:str) -> tuple:
    
    left = 0
    right = 2
    
    ## XXがあるか判定
    for i in range(N-1):
        if S[left] == S[right-1]:
            return (left+1, right)

            
        left += 1
        right += 1
        
    ## XYXがあるか判定
    left = 0
    right = 3
    for i in range(N-2):
        if S[left] == S[right-1]:
            return (left+1,right)
        
        left += 1
        right += 1
        
        
    return (-1,-1)


print(*judge(S))

Measured memory_bytes: 3188
N,P = map(int, input().split())
A = list(map(int, input().split()))

n = 0
for a in A:
    if a % 2 == 0: n += 1
if N == n:
    if P == 0:
        ans = 2 ** N #選ぶか選ばないか => 2通り
    else: ans = 0
else: ans = 2 ** (N-1)
print(ans)

Measured memory_bytes: 3060
ball_n = int(input())
robbotb_x_position = int(input())
ball_x_positions= map(int, input().split())


result = 0
for ball_x_position in ball_x_positions:
    b_distance = abs(ball_x_position - robbotb_x_position)
    a_distance = ball_x_position
    if b_distance > a_distance:
        result += a_distance * 2
    else:
        result += b_distance * 2

print(result)

Measured memory_bytes: 2940
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(vector<int>& A) {
        int n = A.size();

        multiset<int> M;

        for (auto x : A) {
            if (M.empty()) {
                M.insert(x);
            } else {
                auto it = M.lower_bound(x);
                if (it == M.begin()) {
                    M.insert(x);
                } else {
                    --it;
                    M.erase(it);
                    M.insert(x);
                }
            }
        }

        return M.size();
    }
};

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

    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    Solution sol;
    cout << sol.solve(A) << "\n";

    return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {

    	Scanner sc=new Scanner(System.in);

    	int a=sc.nextInt();
    	int b=sc.nextInt();

    	if(a>b) {
    		System.out.println(a-1);
    	}else {
    		System.out.println(a);
    	}
    }


}







Measured memory_bytes: 21716
n = int(input())
# １フロア１０部屋、３階建ての公舎４棟
n_room = 10
n_floor = 3
n_building = 4
room_info = [[[0 for _ in range(n_room)] for _ in range(n_floor)] for _ in range(n_building)]

for _ in range(n):
    # b棟f階のr番目の部屋にv人が追加で入居
    b, f, r, v = map(int, input().split(" "))
    room_info[b - 1][f - 1][r - 1] += v
    
checker = 0
for building_info in room_info:
    if checker != 0:
        print("#" * 20)
    for floor_info in building_info:
        for room_info in floor_info:
            print(f" {room_info}", end="")
        print()
    checker += 1


Measured memory_bytes: 5636
#include <iostream>

using namespace std;

int main(void){
    int a=0;
    int b=0;
    int c=0;
    int sum=0;

    cin >> a >> b >>c;

    sum=a+b;

    if(sum>=c)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		int l = a.length();
		boolean cf = false;
 
		for(int i = 0; i < l; i++){
			char c = a.charAt(i);
			if(c=='C')
				cf = true;
			if(cf && c=='F'){
				sb.append("Yes");
				System.out.println(sb);
				return;
			}
		}
 
		sb.append("No");
		System.out.println(sb);
	}
}

Measured memory_bytes: 8148
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int N,K;
        string str[11];
        string lis[10021];
        cin>>N>>K;
        if(N==0&&K==0)break;
        for(int i=0;i<N;i++)cin>>str[i];
        int ii=0;
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                for(int k=0;k<N;k++){
                    for(int l=0;l<N;l++){
                        if(i!=j&&j!=k&&k!=l&&i!=k&&j!=l&&i!=l){
                            if(K==2)lis[ii]=str[i]+str[j];
                            if(K==3)lis[ii]=str[i]+str[j]+str[k];
                            if(K==4)lis[ii]=str[i]+str[j]+str[k]+str[l];
                            ii++;
                        }
                    }
                }
            }
        }
        sort(lis,lis+10012);
        int ans=-1;
        for(int i=0;i<10015;i++)if(lis[i]!=lis[i+1])ans++;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1528
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int N, M;

bool solve() {
    map<int,int> ma;
    for (int i = 0; i < N; ++i) {
        int d; cin >> d; ma[d]++;
    }
    cin >> M;
    bool ok = true;
    for (int i = 0; i < M; ++i) {
        int e; cin >> e;
        ma[e]--;
        if (ma[e] < 0) ok = false;
    }
    return ok;
}

int main() {
    while (cin >> N) {
        if (solve()) puts("YES");
        else puts("NO");
    }
}

Measured memory_bytes: 9600
#include<cassert>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
LL L;
LL X[300011];
LL T[300011];

void MAIN() {
    scanf("%d%lld", &N, &L);
    for (int i=1; i<=N; i++) scanf("%lld", X+i);
    for (int i=1; i<=N; i++) scanf("%lld", T+i);
    X[N+1] = L;

    int left_cnt = 0, middle_cnt = 0, right_cnt = 0;
    LL ans = 0;
    VI le, bo;
    for (int i=N; i>=1; i--) {
	LL k = T[i] / (2*L);
	LL r = T[i] % (2*L);
	ans += k;

	bool a = (r <= 2*X[i]);
	bool b = (r <= 2*(L-X[i]));
//	eprintf("%d %d, r=%lld\n", b, a, r);
	if (r == 0) {
	    // nothing
	} else if (a && b) {
	    bo.push_back(i);
	} else if (a) {
	    assert(le.empty());
	    if (!bo.empty()) {
		ans++;
		bo.pop_back();
	    } else {
		right_cnt++;
	    }
	} else if (b) {
	    le.push_back(i);
	} else {
	    ans++;
	}
    }

    int last = -1;
    {
	reverse(bo.begin(), bo.end());
	reverse(le.begin(), le.end());
	int boi = 0, lei = 0;
	VI bo2, le2;
	while (boi < (int)bo.size() || lei < (int)le.size()) {
	    if (lei == (int)le.size() || (boi < (int)bo.size() && bo[boi] < le[lei])) {
		bo2.push_back(bo[boi]);
		boi++;
	    } else {
		if (le[lei] == N && bo2.size() % 2 == 0) {
		    ans += bo2.size()/2;
		    bo2.clear();
		    le2.push_back(le[lei]);
		} else if (!bo2.empty()) {
		    ans++;
		    bo2.pop_back();
		} else {
		    le2.push_back(le[lei]);
		}
		lei++;
	    }
	}
//	while (boi < (int)bo.size()) bo2.push_back(bo[boi++]);
//	while (lei < (int)le.size()) le2.push_back(le[lei++]);

	ans += bo2.size()/2;
	if (bo2.size() % 2) amax(last, bo2.back());
	if (!le2.empty()) amax(last, le2.back());
	middle_cnt = bo2.size()%2;
	left_cnt = le2.size();
    }

//    eprintf("%d %d %d\n", left_cnt, middle_cnt, right_cnt);

    if (last == N) {
	assert(right_cnt == 0);
	ans += left_cnt + middle_cnt;
    } else {
	ans += left_cnt + middle_cnt + right_cnt + 1;
    }
    printf("%lld\n", ans * 2 * L);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 9200
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    As = list(map(int, readline().split()))
    if len(As) == len(set(As)):
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()


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

void dfs(int v, vector<long long> & dist, const vector<vector<pair<int, long long>>> &Es){
    for (auto &edge : Es[v]){
        int u = edge.first;
        long long c = edge.second;
        if (dist[u] != -1) continue;
        dist[u] = dist[v] + c;
        dfs(u, dist, Es);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<pair<int, long long>>> Es(N + 1, vector<pair<int, long long>>());
    for (int i = 1; i != N; ++i){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        Es[a].emplace_back(make_pair(b, c));
        Es[b].emplace_back(make_pair(a, c));
    }
    int Q, K;
    cin >> Q >> K;
    vector<long long> dist(N + 1, -1);
    dist[K] = 0;
    dfs(K, dist, Es);
    for (int q = 0; q != Q; ++q){
        int x, y;
        cin >> x >> y;
        cout << dist[x] + dist[y] << '\n';
    }
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long a, b;
  cin >> a;
  for(int i = 0; i < N - 1; i++) {
    cin >> b;
    a *= b / __gcd(a,b);
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,t,c,p;
	cin >> n >> t;
	pair<int,int> pp[n];
	REP(i,n){
		cin >> c >> p;
		pp[i]=make_pair(c,p);
		if(pp[i].second>t) pp[i].first=1001;
	}
	SORT(pp,n);
	if(pp[0].first==1001) cout << "TLE" << endl;
	else cout << pp[0].first << endl;
	
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    if(N%2 != 0){
        cout << "No" << endl;
        return 0;
    }

    string T = S.substr(0, N/2), U = S.substr(N/2, N/2);
    if(T == U)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

void warshall(vector<vector<int> > &adj){
	int n=adj.size();
	for(int k=0; k<n; k++){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
			}
		}
	}
}

int main(){
	int n;
	cin >> n;
	vector<vector<int> > a(n, vector<int>(n)), tmp;
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin >> a[i][j];
		}
	}
	tmp = a;
	warshall(tmp);
	if(tmp != a){
		cout << -1 << endl;
		return 0;
	}
	
	long long int ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			int shortest = inf+1;
			for(int k=0; k<n; k++){
				if(k==i || k==j) continue;
				shortest = min(shortest, a[i][k]+a[k][j]);
			}
			if(shortest < a[i][j]){
				ans = -1;
				i = n;
				break;
			}else if(shortest > a[i][j]){
				ans += a[i][j];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
static const long long INF = 100000000;
int main(){
    long long h;
    int n;
    cin >> h >> n;
    long long sum = 0;
    rep(i,n){
        int j;
        cin >> j;
        sum += j;
    }
    if (h <= sum){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

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

int main()
{
    int m,a,b,d;
    while(~scanf("%d",&a))
    {
        if(a<3)
            printf("0\n");
        else
        {
           printf("%d\n",a/3);
        }
    }
    return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = int(1e9) + 7;

int N, M;
string A[55], B[55];

bool match(int sy, int sx) {
  for (int i = 0; i < M; ++i) {
    if (i + sy >= N) return false;
    for (int j = 0; j < M; ++j) {
      if (j + sx >= N) return false;
      else if (A[sy+i][sx+j] != B[i][j]) return false;
    }
  }
  return true;
}

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> N >> M;

  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];

  for (int sy = 0; sy < N; ++sy) {
    for (int sx = 0; sx < N; ++sx) {
      if (match(sy, sx)) {
        cout << "Yes" << "\n";
        return 0;
      }
    }
  }

  cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 256
#pragma warning(disable: 4996)
#include<stdio.h>

int sec, h, m, s, hp, mp;

int main() {
	scanf("%d", &sec);
		h = sec / 3600;
		hp = sec % 3600;
		m = hp / 60;
		mp = hp % 60;
		s = mp;
	
		printf("%d:%d:%d\n", h, m, s);

		return 0;
	
}


Measured memory_bytes: 2148
/**
 🍪 the_hyp0cr1t3
 🍪 31.08.2020 10:14:30
**/
#ifdef W
#include "k_II.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define aylmao cin.tie(nullptr)->sync_with_stdio(false);
#endif
#define endl '\n'
#define pb emplace_back
// #define int long long
#define sz(x) (int)((x).size())
#define all(x) x.begin(), x.end()
#define Luv(...) [&](auto&& u, auto&& v) { return __VA_ARGS__; }
auto chmax = [](auto& A, auto&& B) { return B > A? A = B, true : false; };
auto chmin = [](auto& A, auto&& B) { return B < A? A = B, true : false; };

using ll = long long;
using pii = pair<int, int>;
const ll DESPACITO = 2e18;
const int INF = 2e9, MOD = 1e9+7;

const int N = 2e5+5;
int a[N];

int32_t main() {
    aylmao
    int i, n, cur = 1; ll ans = 0;
    cin >> n;
    for(i = 0; i < n; i++) 
        cin >> a[i];
    deque<ll> v;
    for(i = 0; i < n; i++) {
        v.push_back(a[i]);
        while(sz(v) > 2) {
            ll x = v[sz(v)-3];
            ll y = v[sz(v)-2];
            ll z = v[sz(v)-1];
            if(x > y or y < z) break;
            v.pop_back(); v.pop_back(); v.pop_back();
            v.push_back(x+z-y);
        }
    }
    while(!v.empty()) {
        ans += max(v.front(), v.back()) * cur;
        if(v.front() > v.back()) v.pop_front();
        else v.pop_back();
        cur = -cur;
    }
    cout << ans;
    return 0;
}

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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
long long d[1000][1000];
int main(int argc, char** argv) {
	int n;
	cin>>n;
	long long a[n];
	for(int i = 0; i < n; i++)
		cin>>a[i];
	long long pref[n];
	pref[0]=a[0];
	for(int i = 1; i < n; i++){
		pref[i]=pref[i-1]+a[i];
	}
	for(int len = 1; len <= n; len++){
		for(int l = 0; l < n; l++){
			int r = l + len - 1;
			if(r == n)
				break;
			if(len == 1)
				d[l][l] = 0;
			else{
				d[l][r] = 2e18;
				for(int mid = l; mid < r; mid++){
					long long calc;
					if(l == 0){
						calc = d[l][mid] + d[mid + 1][r] + pref[r];
					}
					else{
						calc = d[l][mid] + d[mid + 1][r] + (pref[r] - pref[l - 1]);
					}
					d[l][r] = min(d[l][r] , calc);
				}
			}
		}
	}
	cout<<d[0][n-1];
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ss, ts, es;
    int a, b, c;
    while(cin >> a >> b >> c, a){
        a--; b--;
        ss.emplace_back(a);
        ts.emplace_back(b);
        es.emplace_back(c);
    }
    int l;
    cin >> l;
    for (int i = 0; i < l; ++i) {
        vector<int> v(m), ans(n);
        for (auto &&j : v) scanf("%d", &j);
        for (int j = 0; j < ss.size(); ++j) {
            ans[ss[j]] += v[ts[j]]*es[j];
        }
        for (int j = 0; j < n; ++j) {
            printf("%d", ans[j]);
            putchar(j == n-1 ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 3792
from collections import deque

def bfs(n,e,fordfs):
    W = [-1]*n
    W[e] = 0
    que = deque()
    que.append(e)
    len = [0]*n
    while que:
        now = que.popleft()
        nowv = W[now]
        nowlen = len[now]
        for ne in fordfs[now]:
            if nowv == W[ne]:
                return -1
#                print(-1)
#                exit()
            elif W[ne] == -1:
                W[ne] = (nowv+1) % 2
                len[ne] = nowlen+1
                que.append(ne)
    return max(len)

N = int(input())
data = [list(map(int, list(input()))) for i in range(N)]
v = [[] for i in range(N)]
maxlen = [0]*N

for i in range(N):
    for j in range(N):
        if data[i][j] == 1:
            v[i].append(j)
for i in range(N):
    maxlen[i] = bfs(N,i,v)


ans = max(maxlen)+1
if ans==0:
    ans = -1

print(ans)

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

int modpow(int x, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) {  // nが奇数のとき
            res *= x;
            res %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

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

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


signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    COMinit();

    int H, W, K;
    cin >> H >> W >> K;
    int ans = 0;
    rep(i,H){
        ans += COM(H*W-2, K-2) * i * (H-i) * W * W;
        ans %= MOD;
    }
    rep(i,W){
        ans += COM(H*W-2, K-2) * i * (W-i) * H * H;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

#include <vector>
#include <set>
using namespace std;

struct union_find {
  vector<int> par;
  vector<int> rank;
  union_find(int n) : par(n) , rank(n) {
    for(int i = 0;i < n;i++) par[i] = i;
  }
  int root(int i) {
    return par[i] == i ? i : par[i] = root(par[i]);
  }
  /* unite x, y return parent */
  int unite(int x,int y) {
    x = root(x);
    y = root(y);
    if(x == y) return -1;
    if(rank[x] < rank[y]) {
      par[x] = y;
      return y;
    }
    else {
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
      return x;
    }
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
};

int main() {
  i64 n, h, w;
  cin >> n >> h >> w;
  using P = pair<i64, pair<i64, i64>>;
  vector<P> vec;
  rep(i,0,n) {
    i64 r, c, a;
    cin >> r >> c >> a;
    r--;
    c--;
    vec.push_back(P(a, { r, c }));
  }
  sort(all(vec));
  reverse(all(vec));
  union_find uf(h + w);
  vector<i64> in(h + w);
  vector<i64> out(h + w, 1);
  i64 ans = 0;

  for(auto p: vec) {
    i64 a = p.first;
    i64 r = p.second.first;
    i64 c = p.second.second;
    r = uf.root(r);
    c = uf.root(c + h);
    if(r == c) {
      if(in[r] < out[r]) {
        in[r]++;
        ans += a;
      }
    }
    else if(in[r] + in[c] + 1 <= out[r] + out[c]) {
      i64 p = uf.unite(r, c);
      in[p] = in[r] + in[c] + 1;
      out[p] = out[r] + out[c];
      ans += a;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7920
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double hj=2*pi*(h+m/60)/12;
    double mj=2*pi*m/60;
    double ans=a*a+b*b-2*a*b*cos(hj-mj);
    printf("%.12lf\n",sqrt(ans));
    return 0;
}


Measured memory_bytes: 4276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,a,b,c,ans;
int main(void){
    cin>>a>>b>>c>>n;
    for(int i=0;i*a<=n;i++){
		for(int j=0;j*b+i*a<=n;j++){
			int m=n-i*a-j*b;
			if(m%c==0)ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
/*
// シンプルな構文解析用
typedef string::const_iterator State;
class ParseError {};
//*/
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;



int main(void) {
	int N;
	cin >> N;
	vi a(N);
	rep(i, N) {
		cin >> a[i];
	}
	sort(all(a));
	reverse(all(a));
	int l1 = 0;
	rep(i, N - 1) {
		if (a[i] == a[i + 1]) {
			if (l1 == 0) {
				l1 = a[i];
				i++;
			}
			else {
				cout << (ll)l1*a[i] << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e5+200;
int a[N],b[N],c[N],x[N][3];


int main(){
    int n;
    cin >> n;
    for (int i=0 ; i<n ; i++){
        for (int j=0  ; j<3 ; j++){
            cin >> x[i][j];
        }
    }
    a[0]=x[0][0];
    b[0]=x[0][1];
    c[0]=x[0][2];
    for (int i=1 ; i<n ; i++){
        a[i]=max(b[i-1]+x[i][0],c[i-1]+x[i][0]);
        b[i]=max(a[i-1]+x[i][1],c[i-1]+x[i][1]);
        c[i]=max(b[i-1]+x[i][2],a[i-1]+x[i][2]);
    }
    int w=max( max( a[n-1], b[n-1] ) , c[n-1] );
    cout << w;
}


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

int main() {
  ll n;
  cin >> n;
  ll count = 0;
  ll arr[n+1];
  for(int i = 1; i <= n; i++){
    cin >> arr[i];
  }
  map <ll,ll> m;
  for(int i = 1; i <= n; i++){
    m[i+arr[i]]++;
  }
  for(int j = 1; j <= n; j++){
    count += m[j-arr[j]];
  }
  cout << count;
}

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

long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}

int main() {
  srand (time(NULL));
  int n;
  cin >> n;
  vector<int> c(26);
  vector<array<int, 26>> s(n);
  
  vector<int> last(26, -1);
  
  for (int i = 0; i < 26; ++i)
    cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1);
    for (int j = 0; j < 26; ++j) neg -= c[j] * (i - last[j]);
    int max_score = -1e9;
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  /* reversed: 109149564 */
  /* sorted: 110465449 */
  /* stocahstic */
  
  for (int t = 1; t <= 200000; ++t) {
    vector<pair<int, int>> idxs(2);
    int dt = 0;
    for (int x = 0; x < 2; ++x) {
      int dd = idxs[x].first = rand() % n;
      int tt = rand() % 26;
      int ot = idxs[x].second = options[dd];
      
      while (ot == tt) tt = rand() % 26;
      options[dd] = tt;
      long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                          options, dd, tt, ot);
      dt += ns;
    }
    if (dt < 0) {
      for (int i = 0; i < 2; ++i)
        options[idxs[i].first] = idxs[i].second;
    } else {
      total += dt;
    }
  }
  for (const int& i: options) cout << i + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**17
    #mod = 10**9 + 7

    N,X,Y = map(int, input().split())
    X -= 1
    Y -= 1
    res = [0]*(N+1)
    for i in range(N-1):
        for j in range(i+1, N):
            a = min(j-i, abs(X-i)+1+abs(j-Y))
            res[a] += 1
    for k in range(1, N):
        print(res[k])


if __name__ == '__main__':
    main()

Measured memory_bytes: 45148
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
char charin() {char c; cin>>c; return c;}
string strin() {string s; cin>>s; return s;}
ll mod=1000000007;
int main(){
    int n=in();
    vec a(2*n);
    string s=strin();
    rep(i,2*n){
        a[i]=s[i]=='W'?0:1;
    }
    if(n==1){
        if(a[0]+a[1]<=1){
            cout<<0<<endl;
        }else{
            cout<<1<<endl;
        }
        return 0;
    }
    vecll perm(n+1);
    perm[0]=1;
    rep(i,n){
        perm[i+1]=perm[i]*(i+1)%mod;
    }
    ll ans=1;
    int cnt=0;
    rep3(i,2*n-1,0){
        if((((i%2==0)&(a[i]==0)||((i%2==1)&(a[i]==1))))){
            cnt++;
        }else{
            ans*=cnt;
            cnt--;
        }
        ans%=mod;
    }
    if(cnt>0)cout<<0<<endl;
    else cout<<ans*perm[n]%mod<<endl;
}


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

int main(){
  long long n;
  cin >> n;
  
  if (n % 2) {
    cout << 0;
    return 0;
  }
  
  long long sum = 0;
  long long denom = 10;
  while (denom <= n){
    sum += n / denom;
    denom *= 5;
  }
  
  cout << sum;
  
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque

N = int(input())

ans = deque([])
if N == 0:
    print(0)
else:
    while N != 0:
        if N % -2 != 0:
            N -= 1
            ans.appendleft('1')
        else:
            ans.appendleft('0')
        N /= -2
    print(''.join(ans))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int a,b;
	cin >> a >> b;
	cout << a + b / 2 << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3600