akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

ll X;

int main(){
    cin>>X;
    out(X/11*2+(X%11+5)/6);   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, m;
VI a, b, ans;
VVI connect;
deque<int> done;
set<int> not_done;

int main()
{
	cin>>n>>m;
	a.resize(m); b.resize(m);
	ans.resize(n+1);
	connect.resize(n+1);

	FOR(i,2,n+1) {
		not_done.insert(i);
	}

	REP(i, m) {
		cin>>a[i]>>b[i];
		connect[a[i]].push_back(b[i]);
		connect[b[i]].push_back(a[i]);
		if (a[i] == 1) {
			ans[b[i]] = 1;
			not_done.erase(b[i]);
			done.push_back(b[i]);
		}
		if (b[i] == 1) {
			ans[a[i]] = 1;
			not_done.erase(a[i]);
			done.push_back(a[i]);
		}
	}

	done.push_back(1);
	while (!done.empty()) {
		int tmp = done.front();
		done.pop_front();
		REPALL(i, connect[tmp]) {
			//cout<<tmp<<" "<<connect[tmp][i]<<endl;
			if (not_done.find(connect[tmp][i]) != not_done.end()) {
				done.push_back(connect[tmp][i]);
				not_done.erase(connect[tmp][i]);
				ans[connect[tmp][i]] = tmp;
			}
		}
	}

	if (not_done.empty()) {
		cout<<"Yes"<<endl;
		FOR(i,2, n+1) {
			cout<<ans[i]<<endl;
		}
	} else {
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 16248
ss=raw_input().split()
w=int(ss[0])
h=int(ss[1])
a=[]
b=[]
for i in range( w):
    p=input()
    a.append( p)
for i in range( h):
    p=input()
    b.append( p)
a.sort()
b.sort()
h1=0
h2=0
ans=0
while ((h1<w) and (h2<h)):
    if a[h1]<b[h2]:
        ans+=a[h1]*(h - h2+1)
        h1+=1
    else :
        ans += b[h2] * (w-h1+1)
        h2 += 1
while (h1<w):
    ans+=a[h1]
    h1+=1
while (h2<h):
    ans+=b[h2]
    h2+=1
print ans

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
  if (x == 0) return 0;
  return counter(x >> 1) + (x & 1);
}

void solve() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    for (int j = 1; j <= A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  int ans = 0;
  for (int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for (int i = 1; i <= N; i++) {
      if(!(bits & (1 << (i-1)))) continue;
      for (int j = 1; j <= A[i]; j++) {
        if(((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]) ok = false;
      }
    }
    if(ok) ans = max(ans, counter(bits));
  }
  cout << ans << endl;
  return;
}
int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char a;
	scanf("%c",&a);
	if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o'){
		printf("vowel\n");
	}
	else{
		printf("consonant\n");
	}
	return 0;
}

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

int main(){
	std::string c;
	std::cin >> c;
	if (c == "a") {
		std::cout << "vowel" << std::endl;
	}
	else if(c=="e"){
		std::cout << "vowel" << std::endl;
	}
	else if (c == "i") {
		std::cout << "vowel" << std::endl;
	}
	else if (c == "u") {
		std::cout << "vowel" << std::endl;
	}
	else if (c == "o") {
		std::cout << "vowel" << std::endl;
	}
	else {
		std::cout << "consonant" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node
{
	ll x,tb;
}h,rs,ls,tp;
ll l,ans[100005],cnt=0,uv,tot=0,att,f,n,i,a[100005],b[100005],res,dir[100005],t;
node operator+(node a,node b)
{
	node c;
	c.x=a.x+b.x;
	c.tb=a.tb+b.tb;
	if(c.tb==2)c.x++,c.tb=0;
	return c;
}
node operator-(node a,node b)
{
	node c;
	c.x=a.x-b.x;
	c.tb=a.tb-b.tb;
	if(c.tb==-1)c.x--,c.tb=1;
	return c;
}
node operator/(node a,node b)
{
	ll u,v;
	node c;
	u=2LL*a.x+a.tb;
	v=2LL*b.x+b.tb;
	c.x=u/v;c.tb=0;
	return c;
}
node div(node a)
{
	if(a.x%2)return (node){a.x/2LL,1LL};
	else return (node){a.x/2LL,0LL};
}
ll ad(ll p)
{
	if(p==n)return 1;
	return p+1;
}
int main()
{
	scanf("%lld%lld%lld",&n,&l,&t);
	if(n==1)
	{
		ll x,y;
		scanf("%lld%lld",&x,&y);
		if(y==1)printf("%lld\n",(x+t)%l);
		else printf("%lld\n",(x-t%l+l)%l);
		return 0;
	}
	for(i=1;i<=n;i++)scanf("%lld%lld",&a[i],&dir[i]),dir[i]--;
	for(i=2;i<=n;i++)
	{
		if(dir[i]==dir[1])continue;
		if(dir[1]==0)
		{
			if(a[i]>a[1])res=a[i]-a[1];
			else res=l-a[1]+a[i];
		}
		else
		{
			if(a[i]>a[1])res=a[1]+l-a[i];
			else res=a[1]-a[i];
		}
		rs.x=res;rs.tb=0;tot=0;
		tp.x=t;tp.tb=0;
		ls.x=l;ls.tb=0;
		rs=div(rs);
		if((tp/rs).x==0)continue;
		tot=1;tp=tp-rs;
		ls=div(ls);
		tot+=(tp/ls).x;
		cnt+=tot;
	}
	if(dir[1]==0)att=1;
	else att=0,cnt=-cnt;
	for(i=1;i<=n;i++)
	{
		if(dir[i]==0)b[i]=(a[i]+t)%l;
		else b[i]=(a[i]-t%l+l)%l;
	}
	uv=b[1];
	sort(b+1,b+n+1);
	for(i=1;i<=n;i++)
	{
		if(b[i]==uv)
		{
			if(b[ad(i)]!=uv)break;
			else
			{
				if(att==0)break;
				else 
				{
					i=ad(i);
					break;
				}
			}
		}
	}
	f=(1+cnt%n+n)%n;
	for(;ans[f]==0;ans[f]=b[i],f=ad(f),i=ad(i));
	for(i=1;i<=n;i++)printf("%lld\n",ans[i]);
	return 0;
} 

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
    
typedef long long ll;
typedef unsigned long long ull;
    
#define MOD 1000000007
#define mi 18446744073709551615



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin>>T;
  while(T--)
  {
    string s,t;
    int n=0;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
      if(s[i]!=t[i])
        n++;
    cout<<n;
  }
  return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

vector<ll>used,sum;
void solve(){
	ll n,k;
	cin>>n>>k;
	vector<ll>p(n+5),c(n+5);
	rep(i,n)cin>>p[i+1];
	rep(i,n)cin>>c[i+1];
	ll ans=-INF;
	int cur;
	for(int ccur=1;ccur<=n;++ccur){
		cur=ccur;
		bool ok=false;
		used=vector<ll>(n+5);
		sum=vector<ll>(n+5);
		ll start,loop;
		for(ll i=1;i<=k;++i){
			cur=p[cur];
			sum[i]=sum[i-1]+c[cur];
			chmax(ans,sum[i]);
			if(i==k){
				ok=true;
				break;
			}
			if(used[cur]>0){
				loop=i-used[cur];
				start=used[cur];
				break;
			}
			used[cur]=i;
		}
		if(ok)continue;
		for(int finish=1;finish<=n;++finish){
			ll res=0;
			if(used[finish]<start)continue;
			if(sum[start+loop]-sum[start]>0){
				ll len=(k-used[finish])/loop;
				res+=len*(sum[start+loop]-sum[start]);
			}
			res+=sum[used[finish]];
			chmax(ans,res);
		}
	}
	cout<<ans;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3776
n = int(input(''))
l = list(map((int),input('').split()))

cnt=0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            l1 = l[i]
            l2 = l[j]
            l3 = l[k]
            if (l1 != l2 and l2 != l3 and l1 != l3) and (l1+l2 >l3 and l2+l3 > l1 and l1+l3 > l2):
               # print("{}[{}]/{}[{}]/{}[{}]".format(i,l1,j,l2,k,l3))
                cnt+=1
print(cnt)

            


Measured memory_bytes: 9196
n,m=map(int,input().split())
L=list(map(int,input().split()))
Lh=list(map(lambda x: x*(-1), L))
import heapq
#heapqは置き直さなくてOK
heapq.heapify(Lh)
for _ in range(m):
    x=heapq.heappop(Lh)
    heapq.heappush(Lh,(x+1)//2)#負の数の割り算のため+1
print(sum(Lh)*(-1))

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> a(n);
	ll xt, yt;
	rep(i, n)
	{
		cin >> xt >> yt;
		a[i] = pair<ll, ll>(xt, yt);
	}
	vector<pair<ll, ll>> b(m);
	rep(i, m)
	{
		cin >> xt >> yt;
		b[i] = pair<ll, ll>(xt, yt);
	}
	vector<ll> p(n);
	rep(i, n)
	{
		ll mini = 1e18;
		ll x1 = a[i].fi, y1 = a[i].se;
		//cout << "i:" << i << " " << x1 << " " << y1 << " " << endl;
		rep(j, m)
		{
			ll x2 = b[j].fi, y2 = b[j].se;
			//cout << "j:" << j << " " << x2 << " " << y2 << " " << abs(x1-x2)+abs(y1-y2) << endl;
			if (chmin(mini, abs(x1 - x2) + abs(y1 - y2)))
			{
				p[i] = j;
			}
		}
	}
	rep(i, n) cout << p[i] + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; if(n>1)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template< class T >
struct edge {
  int fr, to;
  T w;

  edge(int to, T w) : fr(-1), to(to), w(w) {}

  edge(int fr, int to, T w) : fr(fr), to(to), w(w) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< class T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.w;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n>>m; WeightedGraph<int>g(n*3);
  rep(i,m){
    cin>>x>>y; x--; y--;
    g[x].eb(y+n,1);
    g[x+n].eb(y+n*2,1);
    g[x+n*2].eb(y,1);
  }
  cin>>x>>y; x--,y--;
  auto ans=dijkstra(g,x);
  pri1(ans[y]>1e9?-1:ans[y]/3);
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
/**  '' "\n" ^ - = + **/


typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,
                 tree_order_statistics_node_update>
        new_data_set;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k,m;
    cin>>n>>m;
    map<int,int> mp;
    map<int,int> np;
    int x;
    string str;
    int ac=0,wa=0;
    in(i,m)
    {
        cin>>x>>str;
        if(str=="AC")
        {
            if(mp[x]==1)continue;
            else
            {
                ac++;
                mp[x]=1;
            }
        }
        if(str=="WA")
        {
            if(mp[x]==1)continue;
            else
            {
                //wa++;
                np[x]++;
            }
        }
    }
    map<int,int>::iterator it;
    it=np.begin();
    while(it!=np.end())
    {
        x=it->first;
        if(mp[x]==1)
            wa+=it->second;
        it++;
    }
    cout<<ac;ps();pf(wa);
}


Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    


    int n, x; cin >> n >> x;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];

    int ans = 1;
    int cur = 0;
    for(int i = 0; i < n; i++){
        cur = cur + l[i];
        if(cur <= x) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())

Dist = [[] for j in range(N)]
Seen = [-1] * N

for i in range(N-1):
    u, v, w = map(int, input().split())
    Dist[u-1].append([v-1, w])
    Dist[v-1].append([u-1, w])

que = [0]
Seen[0] = 0
flag = True
while -1 in Seen:
    now = que.pop()
    for next, distance in Dist[now]:
        if Seen[next] == -1:
            que.insert(0, next)
            if distance % 2 == 0:
                Seen[next] = Seen[now]
            else:
                Seen[next] = 1 - Seen[now]
for i in range(N):
    print(Seen[i])

Measured memory_bytes: 81952
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007LL
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    rep(i, sz(v)) cout << v[i] << ",";
    cout << "]";
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}
 
#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N, M;
int dist[100001];
bool visited[100001];
vector<int> adj[100001];
vector<int> top;

void topology_sort(int c) {
    repi(i, adj[c]) if (not visited[i]) topology_sort(i);
    visited[c] = true;
    top.pb(c);
}

int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    cin >> N >> M;
    repp(i, 1, N+1) {
        adj[0].pb(i);
    }
    rep(i, M) {
        int a, b; cin >> a >> b;
        adj[a].pb(b);
    }

    topology_sort(0);
    reverse(all(top));
    repi(i, top) repi(j, adj[i]) get_max(dist[j], dist[i]+1);

    cout << *max_element(dist+1, dist+N+1)-1 << endl;
}

Measured memory_bytes: 9208
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int holidays = sc.nextInt();
        int homeworks = sc.nextInt();

        int sum = 0;
        for (int i=0; i<homeworks; i++) {
            sum += sc.nextInt();
        }

        if (sum > holidays) System.out.println(-1);
        else System.out.println(holidays - sum);
    }
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>>data(h, vector<char>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> data[i][j];
		}
	}

	vector<bool>row(h, false);
	vector<bool>col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (data[i][j]=='#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j])cout << data[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String moji_one = sc.next();;
		String moji_second = sc.next();
		String moji_third = sc.next();
		moji_one = moji_one.substring(0,1);
		moji_second = moji_second.substring(0,1);
		moji_third = moji_third.substring(0,1);
		String answer = moji_one.toUpperCase() + moji_second.toUpperCase() + moji_third.toUpperCase();
		System.out.println(answer);
		
		
	}

}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m;

int main(){
  ll ans=0;
  cin >> n >> m;

  vi h(n),a(m),b(m),miticnt(n),hh(n);
  REP(i,n) cin>>h[i];

  REP(i,m){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
    miticnt[a[i]]++;
    miticnt[b[i]]++;
  }


  REP(i,m){
    if (h[a[i]]>h[b[i]]){
      hh[a[i]]++;
    }
    if (h[a[i]]<h[b[i]]){
      hh[b[i]]++;
    }
  }

  REP(i,n){
    ans+=(miticnt[i]==hh[i]);
  }
  






  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7220
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<set>
#include<utility>
#include<algorithm>

typedef long long ll;

using namespace std;

int main()
{
    
    ll n,k;
    cin>>n>>k;
    ll prev=abs(n-k);
    if(k==1){
        cout<<"0";
        return 0;
    }
    if(n==0){
        cout<<"0";
        return 0;
    }
    if(n%k==0){
        cout<<"0";
        return 0;
    }
    if(n<k){
        if(abs(n-k)<n){
            cout<<abs(n-k);
            return 0;
        }
        else{
            cout<<n;
            return 0;
        }
    }
    else{
        if(abs((n%k)-k)<(n%k)){
            cout<<abs((n%k)-k);
            return 0;
        }
        else{
            cout<<n%k;
            return 0;
        }
    }
    

    
}

Measured memory_bytes: 256
function main(input) {
  const args = input.split('\n');
  const [N, K] = args[0].split(' ').map((n) => parseInt(n, 10));
  const sunukes = new Array(N).fill(false);

  for (let i = 2; i <= K * 2; i += 2) {
    args[i].split(' ').map((n) => parseInt(n, 10)).map((A) => {
      sunukes[A - 1] = true;
    });
  }

  console.log(sunukes.reduce((num, sunuke) => {
    return sunuke ? num : num + 1;
  }, 0));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 32348
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    int64_t N;
    char s[101];
    char *p;
    int64_t red = 0;

    scanf("%"PRId64, &N);
    scanf("%s", s);

    p = s;

    while (*p) {
        if (*p == 'R') red++;
        p++;
    }

    if ((red * 2) > N) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 128
import sys

import numpy as np
MOD = 10 ** 9 + 7
def cumprod(a, p):
  l = len(a); sql = int(np.sqrt(l) + 1)
  a = np.resize(a, sql ** 2).reshape(sql, sql)
  for i in range(sql - 1): a[:, i+1] *= a[:, i]; a[:, i+1] %= p
  for i in range(sql - 1): a[i+1] *= a[i, -1]; a[i+1] %= p
  return np.ravel(a)[:l]

def make_tables(n=10 ** 9, r=5 * 10 ** 6, p=MOD):
  fac = np.arange(r + 1); fac[0] = 1; fac = cumprod(fac, p)
  ifac = np.arange(r + 1, 0, -1); ifac[0] = pow(int(fac[-1]), p - 2, p)
  ifac = cumprod(ifac, p)[n::-1]
  n_choose = np.arange(n + 1, n - r, -1); n_choose[0] = 1;
  n_choose[1:] = cumprod(n_choose[1:], p) * ifac[1:r+1] % p
  return fac, ifac, n_choose

fac, ifac, n_choose = make_tables(r=10**5)

def choose(n, r, p=MOD):
  if r > n or r < 0: return 0
  return fac[n] * ifac[r] % p * ifac[n-r] % p

n, k, *a = map(int, sys.stdin.read().split())
a.sort()

def main():
  res = 0
  for i in range(n):
    res += choose(i, k - 1) * a[i] % MOD
    res -= choose(n - i - 1, k - 1) * a[i] % MOD
    res %= MOD
  print(res)
    
if __name__ == '__main__':
  main()

Measured memory_bytes: 28280
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  getline(cin,s);
  transform(s.begin(),s.end(),s.begin(),::toupper);
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3116
using System;
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var max = 0;
            var maxResult = 1;
            for(var i = 1;i<=N;i++)
            {
                var count = 0;
                var ii = i;
                while(true)
                {
                    if (ii % 2 != 0) break;
                    count++;
                    ii /= 2;
                }
                if (max < count)
                {
                    max = count;
                    maxResult = i;
                }
            }
            Console.WriteLine(maxResult);
        }
    }

Measured memory_bytes: 11092
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		long n=in.nextLong();
		long ans=1;
		while(ans<=n)
			ans<<=1;
		System.out.println(ans-1);
	}
}
	

Measured memory_bytes: 23892
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)


int h, w;
char fld[1010][1010];
int dp[1010][1010];
const int mod = 1e9+ 7;


int main(){
    INIT;
    cin >> h >> w;
    REP(i, h)REP(j, w)cin >> fld[i][j];
    dp[0][0] = 1;
    REP(i, h)REP(j, w){
        if(i == 0 && j == 0)continue;
        if(i == 0){
            if(fld[i][j] == '.')dp[i][j] += dp[i][j - 1];
        }else if(j == 0){
            if(fld[i][j] == '.')dp[i][j] += dp[i - 1][j];
        }else{
            if(fld[i][j] == '.')(dp[i][j] += dp[i - 1][j] + dp[i][j - 1]) %= mod;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;  
  	int x;
  	cin>>x;
  	int p=100,t=0;
  	while(p<x)
    {
    	t++;
    	p+=p/100;
    }
  	cout<<t;
}

Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

N = In()
A = InMap()

res = False
for num in A:
    if(num % 2 == 1):
        continue
    if(num % 3 != 0 and num % 5 != 0):
        res = True

if res:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

int main() {
    long long a, b;
    long long k;
    std::cin >> a >> b >> k;

    if(a + k - 1 <= b - k + 1) {
        for (long long i = a; i <= b; i++) {
            if(i >= a && i <= a + k - 1 || i <= b && i > b - k) {
                std::cout << i << "\n";
            }
        }
    } else {
        for (long long i = a; i <= b; i++) {
            std::cout << i << "\n";
        }
    }
}

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

int main(){
    string O, E;
    cin >> O >> E;
    if(O.size() == E.size()){
        for (int i = 0; i < E.size(); i++)
        {
            cout << O[i] << E[i];
        }
    }
    else if (O.size() > E.size())
    {
        for (int i = 0; i < E.size(); i++)
        {
            cout << O[i] << E[i];
        }
        cout << O[O.size() - 1];
    }
    else if (O.size() < E.size())
    {
        for (int i = 0; i < O.size(); i++)
        {
            cout << O[i] << E[i];
        }
        cout << E[E.size() - 1];
    }
    cout << endl;
}


Measured memory_bytes: 256
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
  ans = (b - a) // 2
elif (a - 1) < (n - b):
  ans = (a - 1) + 1 + (b - a - 1) // 2
else:
  ans = (n - b) + 1 + (b - a -1) // 2
print(ans)

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

int main() {
  int N; cin >> N;
  int t, x, y, pt = 0, px = 0, py = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t >> x >> y;
    int dis = abs(x - px) + abs(y - py);
    if (dis <= abs(t - pt) && dis % 2 == abs(t - pt) % 2) pt = t, px = x, py = y;
    else break;
  }
  if (pt == t && px == x && py == y) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
while 1:
    n = int(input())
    if n == 0:
        break
    objects = []
    for i in range(n):
        h,r = (int(x) for x in input().split())
        objects.append((h,r))
    n = int(input())
    for i in range(n):
        h,r = (int(x) for x in input().split())
        objects.append((h,r))

    objects = sorted(objects,key=lambda w:(w[0],-1*w[1]))
    r = [i[1] for i in objects]
    t = [1] * len(r)
    
    for i in range(len(r)):
        for j in range(i):
            if r[j] < r[i]:
                t[i] = max(t[i],t[j] + 1)
    print(max(t))


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,m,x;
  cin >> n >> m >> x;
  x--;
  vector<int> a(m);
  vector<int> b(n+1,0);
  rep(i,m){
    cin >> a.at(i);
    a.at(i)--;
    b.at(a.at(i))=1;
  }
  int sum = 0;
  rep(i,x){
    sum+=b.at(i);
  }
  int ans = sum;
  sum=0;
  for(int i = x; i<n+1; i++){
    sum+=b.at(i);
  }
  ans=min(ans,sum);
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	t := []rune("CODEFESTIVAL2016")
	var s string
	fmt.Scan(&s)
	ans := 0
	for i, c := range s {
		if c != t[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    x = ii()
    print('YES') if x == 3 or x == 5 or x == 7 else print('NO')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

from itertools import permutations

def main():
	n,m,R=MI()
	r=LI()

	G=[[10**9]*(n+1) for _ in range(n+1)]
	for i in range(n+1):
		G[i][i]=0



	for _ in range(m):
		a,b,c=MI()
		G[a][b]=min(G[a][b],c)
		G[b][a]=min(G[b][a],c)
	#print(G)

	for k in range(n+1):
		for i in range(n+1):
			for j in range(n+1):
				G[i][j]=min(G[i][j],G[i][k]+G[k][j])
	#print(G)

	ans=10**9
	for i in permutations(r,R):
		#print(i)
		ret=0
		for j in range(R-1):
			ret+=G[i[j]][i[j+1]]
		#print(ret)
		ans=min(ans,ret)
	print(ans)





if __name__ == "__main__":
	main()


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

class Progaram
{
    static void Main(String[] args)
    {
        var x = Int64.Parse(Console.ReadLine());
        var f = 100L;
        var year = 0;
        while (f < x)
        {
            f += (Int64)(f * 0.01);
            year++;
        }
        Console.WriteLine(year);
        
    }
}

Measured memory_bytes: 27480
def partition(arr, start, end):
    criteria = arr[end]
    idx1 = start
    for idx2 in range(start, end):
        if arr[idx2] <= criteria:
            arr[idx1],arr[idx2] = arr[idx2],arr[idx1]
            idx1 += 1
    arr[idx1],arr[end] = arr[end],arr[idx1]
    return idx1


num = int(input())
arr = list(map(int, input().split()))
criteria = partition(arr, 0, num-1)
arr[criteria] = "[" + str(arr[criteria]) + "]"
print(" ".join(map(str, arr)))


Measured memory_bytes: 16388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)

const ll INF = 1e9+7;
const int MAXN = 1e5;
int N,M;
bool a[MAXN+2]={}; // broken
ll dp[MAXN+2]={};

int main() {
  // cin >> N >> M;
  scanf("%d %d", &N, &M);
  REP(i,M) {
    int idx;
    // cin >> idx;
    scanf("%d", &idx);
    a[idx+1] = true;  // 1段目->idx=2
  }
  dp[0] = 0;
  dp[1] = 1; // 0段目
  REP(i,N) {
    if (!a[i+1]) dp[i+2] += dp[i+1];
    if (!a[i]) dp[i+2] += dp[i];
    dp[i+2] %= INF;
  }
  cout << dp[N+1] << endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <queue>
#include <string>
#include <utility>

using namespace std;

int main()
{
  int n;
  string str;
  queue<pair<int, int> > q;
  pair<int, int> p;

  while (1) {
    cin >> n;
    if (n == 0) break;
    cin.ignore();
    cin >> str;
    int run = 1;
    while (n--) {
      str += "-";
      while (!q.empty()) q.pop();
      for (int i = 0; i < str.size() - 1; i++) {
        if (str[i] == str[i + 1]) {
          run++;
        } else {
          p.first = run;
          p.second = str[i] - '0';
          q.push(p);
          run = 1;
        }
      }
      str.clear();
      while (!q.empty()) {
        str += to_string(q.front().first) + to_string(q.front().second);
        q.pop();
      }
    }
    cout << str << endl;
  }
}



Measured memory_bytes: 3416
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    int i, data;
    int min = n + 1;
    int count = 0;
    for(i = 0; i < n; i ++)
    {
    	cin >> data;
    	if(data < min)
    	{
    		min = data;
    		count ++;
    	}
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		if(A%2!=B%2) {
			System.out.println("IMPOSSIBLE");
		}
		else {
			System.out.println((A+B)/2);
		}

	}

}

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

int main()
{
    int n;
    cin >> n;
    while(n)
    {
        n--;
        string X,Y;
        int i=0,j=0;
        cin >> X;
        cin >> Y;
        int L[1001][1001];
        for(i=0;i<1001;i++)
            for(j=0;j<1001;j++)
               L[i][j]=0;
        for(i=1;i<=X.size();i++)
            for(j=1;j<=Y.size();j++)
            {
                if(X[i-1]==Y[j-1])
                    L[i][j]=1+L[i-1][j-1];
                else    L[i][j]=max(L[i][j-1],L[i-1][j]);
            }
        cout << L[X.size()][Y.size()] << endl;
    }
    return 0;
}


Measured memory_bytes: 7068
#include <iostream>
#include <algorithm>

using namespace std;

const int mod = 1'000'000'007;
const int size_max = 2'000'005;

long long fac[size_max], finv[size_max];

long long mpow(int a, int b);
void com_init();
long long com(int n, int k);

int main()
{
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	r1--;
	c1--;
	
	com_init();

	long long ans = com(r2 + c2 + 2, r2 + 1) - 1;
	ans -= com(r1 + c2 + 2, r1 + 1) - 1;
	ans -= com(r2 + c1 + 2, r2 + 1) - 1;
	ans += com(r1 + c1 + 2, r1 + 1) - 1;
	ans += mod;
	ans %= mod;

	cout << ans << endl;

	return 0;
}

long long mpow(int a, int b)
{
	long long t = a;
	long long ans = 1;
	for (int i = 0; i < 31; i++) {
		if ((b & 1) == 1) {
			ans *= t;
			ans %= mod;
		}
		t *= t;
		t %= mod;
		b >>= 1;
	}

	return ans;
}

void com_init()
{
	fac[0] = fac[1] = 1;

	for (int i = 2; i < size_max; i++) {
		fac[i] = fac[i - 1] * i;
		fac[i] %= mod;
	}

	finv[size_max - 1] = mpow(fac[size_max - 1], mod - 2);

	for (int i = size_max - 2; i >= 2; i--) {
		finv[i] = finv[i + 1] * (i + 1) % mod;
	}
	finv[0] = finv[1] = 1;
}

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

Measured memory_bytes: 31488
import java.util.*;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); Student[] a = new Student[n];
        for (int i = 0; i < n; i++) a[i] = new Student(i, sc.nextInt());
        Arrays.sort(a); long [][] dp = new long [n+1][n+1];
        dp[0][0] = 0;
        for (int sum = 1; sum <= n; sum++) {
            Student toPut = a[sum - 1];
            int idx = toPut.index; long act = toPut.act;
            for (int left = 0; left <= sum; left++) {
                int right = sum - left;
                if (left == 0) {
                    dp[left][right] = dp[left][right - 1] + Math.abs(idx - (n - right)) * act;
                } else if (left == sum) {
                    dp[left][right] = dp[left - 1][right] + Math.abs(idx - (left - 1)) * act;
                } else {
                    dp[left][right] = Math.max(dp[left][right - 1] + Math.abs(idx - (n - right)) * act,
                            dp[left - 1][right] + Math.abs(idx - (left - 1)) * act);
                }
            }
        }
        long res = 0;
        for (int i = 0; i <= n; i++) {
            res = Math.max(res, dp[i][n-i]);
        }
        System.out.println(res);
    }

    static class Student implements Comparable<Student> {
        int index; long act;
        Student(int index, long act) {
            this.index = index; this.act = act;
        }

        @Override
        public int compareTo(Student o) {
            return -1*Long.compare(act, o.act);
        }
    }



}


Measured memory_bytes: 84564
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	long long n,k;
	scanf("%lld%lld",&n,&k);
	if(n>k){
		n=n%k;
	}
	if(k-n<n){
		n=k-n;
	}
	printf("%lld\n",n);
	return 0;
} 

Measured memory_bytes: 256
def main():
    A,B,C=map(int,input().split())
    ans=0
    tmp=set()
    while A%2==0 and B%2==0 and C%2==0:
        A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
        if (A,B,C) in tmp:
            print(-1)
            exit()
        else:
            tmp.add((A,B,C))
        ans += 1
    print(ans)

main()

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

using namespace std;

int main() {
	int N, K;
	std::cin >> N >> K;

	double result = 0;
	double k = K;
	int upper = N;
	int count = 0;
	while(upper >= 1) {
		const int lower = std::ceil(k);

		const int num = upper - lower + 1;
		if(num >= 1) {
			result += (double)num / N / std::pow(2, count);
			upper = lower - 1;
		}
		count++;
		k /= 2;

	}

	printf("%.16f\n", result);

	return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
A = np.array(input().split(), dtype = np.int32)

counter = np.bincount(A)
B = counter.copy() # そのままとる
B[1:] += counter[:-1] # 1増やして回収
B[:-1] += counter[1:] # 1減らして回収

answer = B.max()
print(answer)

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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a, b, c; cin >> a >> b >> c;
    cout << (c-(a-b)>=0 ? c-(a-b) : 0) << '\n';
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())

ans = 0

f = lambda x: (int(str(x)[0]), int(str(x)[-1]))

freq = defaultdict(int)
for i in range(1, n+1):
    p = f(i)
    freq[p] += 1

for i in range(1, n+1):
    p = f(i)
    q = (p[1], p[0])
    ans += freq[q]
print(ans)


Measured memory_bytes: 3316
A = [list(map(int, input().split())) for _ in range(3)]
S = [[False, False, False], [False, False, False], [False, False, False]]
N = int(input())
for _ in range(N):
    B = int(input())
    # print(B in A[0])
    if B in A[0]:
        S[0][A[0].index(B)] = True
    elif B in A[1]:
        S[1][A[1].index(B)] = True
    elif B in A[2]:
        S[2][A[2].index(B)] = True

if S[0][0] and S[0][1] and S[0][2] or \
    S[1][0] and S[1][1] and S[1][2] or \
    S[2][0] and S[2][1] and S[2][2] or \
    S[0][0] and S[1][0] and S[2][0] or \
    S[0][1] and S[1][1] and S[2][1] or \
    S[0][2] and S[1][2] and S[2][2] or \
    S[0][0] and S[1][1] and S[2][2] or \
    S[0][2] and S[1][1] and S[0][2]:
    print('Yes')
else:
    print('No')

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

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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

map<int, int> num;

int main(){
    int N, K, ans;
    cin >> N;
    priority_queue<double> queue;
    for(int i = 0; i < N; ++i){
        int tmp;
        cin >> tmp; 
        queue.push(-tmp);
    }
    for(int i = 0; i < N-1; ++i){
        double a = queue.top();
        queue.pop();
        double b = queue.top();
        queue.pop();
        queue.push((a + b) / 2.0);    
    }
    cout << -queue.top() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int a , b;
    cin >> a >> b;
    if(a - b <= 0){
        cout << 0 << endl;
    }
    else{
        cout << a - b << endl;
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    int n; cin >> n;
    vector<vector<P> > v(n);
    for(int i = 0; i < n; i++){
        int a;  cin >> a;
        for(int j = 0; j < a; j++){
            int x,y;  cin >> x >> y;
            x--;
            v[i].push_back(make_pair(x,y));
        }
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        int tmp = 0;
        bool con = false;
        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){
                for(int j = 0; j < v[i].size(); j++){
                    int s = v[i][j].first; 
                    int t = v[i][j].second;
                    if(!(bit & (1<<s)) && t == 1){
                        con = true;
                    }
                    if((bit & (1<<s)) && t == 0){
                        con = true;
                    }
                }
            }
        }
        if(!con){
            for(int i = 0; i < n; i++){
                if(bit & (1<<i)){
                    tmp++;
                }
            }
        }
        ans = max(ans,tmp);
    }
    cout << ans;
}

Measured memory_bytes: 256