akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int N,W,V[15],i,j,t,m,M;
double r;
int main()
{
	for(;scanf("%d%d",&N,&W),N;)
	{
		memset(V,0,sizeof(V));
		for(i=m=0;i<N;i++)
		{
			scanf("%d",&t);
			for(j=0;t>W*(j+1)-1;j++,m=m>j?m:j);
			V[j]++;
		}
		for(i=M=0;i<=m;i++)
			M=M<V[i]?V[i]:M;
		for(i=r=0;i<=m;i++)
			r+=((double)(m-i)/m)*((double)V[i]/M);
		printf("%.8lf\n",r+0.01);
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000 + 5;
int ans;
int n,k;
bool d[10];
bool check(int x)
{
	if(x==0)
	{
		return true;
	}
	else
	{
		int a=x%10;
		x/=10;
		if(d[a]==true)
		{
			return false;
		}
		check(x);
	}
}
int main()
{
	cin>>n>>k;
	while(k--)
	{
		int x;
		cin>>x;
		d[x]=true;
	}
	for(int i=n;i<maxn;i++)
	{
		if(check(i))
		{
			cout<<i;
			return 0;
		}
	}
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int x=0;
    while(b<=a)
    {
        b*=2;
        x++;
    }
    while(c<=b)
    {
        c*=2;
        x++;
    }
    if(x<=k) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 2 == 1) {
            System.out.println(n / 2);
        } else {
            System.out.println((n - 2) / 2);
        }
    }

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k, best = 0;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	for (ll i = 0 ; i < n ; i++) {
		cin >> a[i];
	}
	for (ll i = 0 ; i < m ; i++) {
		cin >> b[i];
	}
	partial_sum(a.begin(), a.end(), a.begin());
	partial_sum(b.begin(), b.end(), b.begin());
	auto ita = upper_bound(a.begin(), a.end(), k);
	do {
		ll kact = k;
		ll br = 0;
		if (ita != a.begin()) {
			ita--;
			kact -= *ita;
			br = distance(a.begin(), ita) + 1;
		}
		auto itb = upper_bound(b.begin(), b.end(), kact);
		br += distance(b.begin(), itb);
		best = max(best, br);
	} while (ita != a.begin());
	best = max(best, ll(distance(b.begin(), upper_bound(b.begin(), b.end(), k))));
	cout << best << "\n";

	return 0;
}


Measured memory_bytes: 6340
#ABC102C
N=int(input())
series = list(map(int,input().split()))
seriesSub = [series[i] - (i+1) for i in range(len(series))]

def cry(a):
	ret=0
	for s in seriesSub:
		ret += abs(s-a)
	return ret

def BinarySeach(hi,lo):
	mid = (hi + lo) // 2
	while hi > lo:
		mid = (hi + lo) // 2
		if mid != len(series):
			if cry(mid+1) >= cry(mid):
				hi = mid
		if mid != 0:
			if cry(mid-1) >= cry(mid):
				lo = mid
	else:
		return cry(mid)
h = max(seriesSub)
l = min(seriesSub)
print(BinarySeach(h,l))

Measured memory_bytes: 25744
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
ll N,all=0;
cin>>N;
ll A[N];
rep(i,N){
    cin>>A[i];
    all^=A[i];
}
ll ans[N];
rep(i,N){
    ans[i]=all^A[i];
}
rep(i,N){
    if(i==N-1){
    cout<<ans[i]<<endl;
    }
    else{
        cout<<ans[i]<<" ";
    }
}

return 0;
}

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

const int N = 1e5 + 9;

int x, y, z, n;
using ll = long long;
ll ret, sum, f[N], ans = -1e18;

struct p {
	int a, b, c;
}e[N];

bool operator < (const p &A, const p &B) { return A.a - A.b > B.a - B.b; }

void Max (ll &A, ll B) { if (A < B) A = B; }

priority_queue<int, vector<int>, greater<int> >Q;
void Add (int x, int n) {
	if (Q.size() == n && Q.top() < x) sum -= Q.top(), Q.pop();
	if (Q.size() == n) return ;
	Q.push(x); sum += x;
}

int main () {
	scanf("%d%d%d", &x, &y, &z); n = x + y + z;
	for (int i = 1; i <= n; ++i) scanf("%d%d%d", &e[i].a, &e[i].b, &e[i].c), ret += e[i].c;
	sort(e + 1, e + n + 1);
	for (int i = 1; i <= n; ++i) {
		Add(e[i].a - e[i].c, x);
		f[i] = sum;
	}
	while (!Q.empty()) Q.pop(); sum = 0;
	for (int i = n; i > x; --i) {
		Add(e[i].b - e[i].c, y);
		if (i <= n - y + 1)
		Max(ans, f[i - 1] + sum);
	}
	printf("%lld\n", ret + ans);
	return 0;
}

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

int main() {
  char letter;
  cin >> letter; 
  
  if (letter == 'A' || letter == 'B' || letter == 'C' || letter == 'D' || letter == 'E' || letter == 'F' || letter == 'G' || letter == 'H' || letter == 'I' || letter == 'J' || letter == 'K' || letter == 'L' || letter == 'M' || letter == 'N' || letter == 'O' || letter == 'P' || letter == 'Q' || letter == 'R' || letter == 'S' || letter == 'T' || letter == 'U' || letter == 'V' || letter == 'W' || letter == 'X' || letter == 'Y' || letter == 'Z')
    cout << "A" << endl;  
  else
    cout << "a" << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
	int n,a,b,ans=0;
	
	cin >> n;
	vector<int> vec(n,0);
	for(int i=0;i<n;i++){
		cin >> vec[i];
		}
			for(int i=0;i<n;i++){
		cin >> a;
				vec[i]-=a;
		}

	sort(vec.rbegin(),vec.rend());
		
	for(int i=0;vec[i]>0&&i<n;i++)ans+=vec[i];
	
		cout << ans;
	return 0; 
	
	}

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

int main(){
    int S;
    while(cin>>S,S){
        int In,N=0;
        for(int i=0;i<9;i++){
            cin>>In;
            N+=In;
        }
        printf("%d\n",S-N);
    }
    return 0;
}

Measured memory_bytes: 1144
import math
 
A, B, H, M = map(int, input().split())
 
m_rad = 360 / 60 * M
h_rad = 360 / 12 * H + (360 / 12 * M / 60)

rad = abs(m_rad - h_rad)

print((A**2 + B**2 - 2 * A * B * math.cos(math.radians(rad))) **(1/2))


Measured memory_bytes: 9504
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	vector<int> v;
	int num,tmp,min = 0;
	cin >> num;
	for (int i = 0; i < num; i++)
	{
		cin >> tmp;
		v.push_back(tmp);
	}
	for (int i = 1; i < num-1; i++)
	{
		vector<int> v2 = { v[i - 1],v[i],v[i + 1] };
		sort(v2.begin(), v2.end());
		if (v2[1] == v[i])
			min++;
	}
	cout << min;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#pragma GCC optimize("O3")
#include <algorithm>
#include <iostream>
#include <vector>
#include <chrono>

using namespace std;

constexpr int D = 365;
constexpr int LIMIT = 1950;
std::chrono::system_clock::time_point start;

int score(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& t) {
	int S = 0;

	vector<int> last(26, 0);
	for (size_t i = 0; i < t.size(); i++) {
		S += s[i][t[i]-1];

		last[t[i] - 1] = i+1;
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i+1 - last[j]);
		}
	}

	return S;
}

int score_alpha(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& t, const int& k) {
	int S = 0;

	vector<int> last(26, 0);
	for (size_t i = 0; i < t.size(); i++) {
		S += s[i][t[i] - 1];

		last[t[i] - 1] = i + 1;
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i + 1 - last[j]);
		}
	}

	for (size_t i = t.size(); i < min(int(t.size() + k), D); i++) {
		for (size_t j = 0; j < 26; j++) {
			S -= c[j] * (i + 1 - last[j]);
		}
	}
	return S;
}

vector<int> greedy(const vector<int>& c, const vector<vector<int>>& s, const int& k) {
	vector<int> t;
	t.reserve(D);

	for (size_t i = 0; i < D; i++) {
		int mscore = INT32_MIN, idx = 1;
		
		for (size_t j = 0; j < 26; j++) {
			t.push_back(j+1);
			int dscore = score(c, s, t);
			dscore = score_alpha(c, s, t, k);

			if (dscore > mscore) {
				mscore = dscore;
				idx = j+1;
			}
			t.pop_back();
		}

		t.push_back(idx);
	}

	return t;
}

vector<int> local(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& init) {
	constexpr int iter = 100;
	int i = 1;

	vector<int> t(init);
	int mscore = score(c, s, t);

	auto end = std::chrono::system_clock::now();
	while (std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() < LIMIT) {
		vector<int> nt(t);

		if (rand() % 2 == 0) {
			int rl = rand() % D;
			int rr = rand() % D;

			swap(nt[rl], nt[rr]);
		} else {
			int ri = rand() % D;
			int rc = rand() % 26;

			nt[ri] = rc + 1;
		}
		int nscore = score(c, s, nt);

		if (mscore < nscore) {
			mscore = nscore;
			copy(nt.begin(), nt.end(), t.begin());
		}
		if (i++ % iter ==0) end = std::chrono::system_clock::now();
	}
	return t;
}

int main() {
	start = std::chrono::system_clock::now();
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int ig;
	cin >> ig;

	vector<int> c(26);
	vector<vector<int>> s(D, vector<int>(26));
	
	for (int i = 0; i < 26; i++) {
		cin >> c[i];
	}

	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			cin >> s[i][j];
		}
	}

	vector<int> bt = greedy(c, s, 0);
	int sc = score(c, s, bt);

	for (int i = 1; i < 10; i++) {
		auto t = greedy(c, s, i);
		auto tsc = score(c, s, t);
		if (sc < tsc) {
			sc = tsc;
			bt = t;
		}
	}
	
	bt = local(c, s, bt);

	for (size_t i = 0; i < D; i++) cout << bt[i] << endl;
	
	return 0;
}

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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef long long int lli; 
 
int main(){
    
//	lli n,t,k;
	AndIamIronMan;
	string s,t,temp="";
	cin>>s>>t;
	temp=s+t[t.length()-1];
//	cout<<temp;
	if(temp==t){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
    return 0;
}	

Measured memory_bytes: 3644
#include<stdio.h>
#define N 100000
#define Q 50000
  
int binarysearch(int);
int S[N];
int n;
void sort(void);

main(){
    
  int q,T[N],x,count=0,i,j;
    
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);}
  
  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);}
   
  for(i=0;i<q;i++){
    x= binarysearch(T[i]);
    
    if(x!=n){
      count++;
    }
  } 
  printf("%d\n",count);
  return 0;
}



void sort(void){
  
  int flag,i,j,x,minj;
  
  for(i=0;i<=n-1;i++){
    minj=i;
    flag=0;
    
    for(j=i;j<=n-1;j++){
      
      if(S[j]<S[minj]){
	minj=j;
	flag=1;}
    }
    
    if(flag==1){
      x=S[i];
      S[i]=S[minj];
      S[minj]=x; 
    }
  }
}
  
int binarysearch(int key){
  
  int left=0,right=n;
  int mid;
  
  while(left<right){
    mid=(left+right)/2;
    
    if(S[mid]==key)
      return mid;
    
    else if(key<S[mid])
      right=mid;
    else{
      left=mid+1;
    }
  }

  
  return n;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define PF push_front
#define P push
#define INC(i,a,b) for (ll i = a; i <= b; i++)
#define DEC(i,b,a) for (ll i = b; i >= a ; i--)
#define inf LLONG_MAX
#define neginf LLONG_MIN
#define mod  1000000007
#define eps 1e-9
typedef ostringstream OS ;
typedef stringstream SS ;
typedef long long ll ;
typedef unsigned long long ull;
typedef pair < ll , ll > PLL ;
typedef pair < char,ll > PCL ;
typedef deque < double > DD ;
typedef deque < PCL > DCL ;
typedef deque < ll > DL ;
typedef deque < PLL > DLL ;
typedef deque < char > DC ;
typedef deque < string > DS ;
typedef vector < double > VD;
typedef vector < PCL > VCL ;
typedef vector < ll > VL;
typedef vector < PLL > VLL ;
typedef vector < char > VC ;
typedef vector < string > VS ;
typedef map < ll ,ll > MLL ;
typedef map < char,ll > MCL;
typedef map < ll,char > MLC;
typedef map < string,ll> MSL;
typedef priority_queue < PLL > PQLL ;
typedef priority_queue < ll > PQL ;
typedef stack < ll > SKL ;
typedef stack < PLL > SKLL ;
typedef queue < ll > QL ;
typedef queue < PLL > QLL ;
typedef set < ll > SL ;
typedef set < PLL > SLL ;
typedef set < char > SC ;
 
string numtostr(ll n) {
     OS str1 ;
     str1 << n ;
     return str1.str();
}
ll strtonum(string s) {
     ll x ;
     SS str1(s);
     str1 >> x ;
     return x ;
}
ll GCD(ll a, ll b) {
    if ( b == 0 ) return a ;
    else return GCD(b,a%b);
}
ll LCM(ll a , ll b) {
    ll gcd = GCD(a,b);
     return (a/gcd)*b ;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll itemnumbers,capacity ;
    cin >> itemnumbers >> capacity ;
    ll cost[itemnumbers+5];
    ll weight[itemnumbers+5];
    ll maxprofit = 0;
    INC(i,1,itemnumbers) {
        cin >> weight[i] >> cost[i];
        maxprofit += cost[i];
    }
    ll dp[itemnumbers+5][maxprofit+5];
    INC(i,0,itemnumbers+1) {
        INC(j,0,maxprofit+1) {
            dp[i][j] = 1000000000000 ;
        }
    }

    INC(i,0,itemnumbers+1) dp[i][0] = 0 ;

    INC(i,1,itemnumbers) {
        INC(j,1,maxprofit) {
            if ( cost[i] <= j) 
                dp[i][j] = min(weight[i]+dp[i-1][j-cost[i]],dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    
    ll maximum = -1 ;
    INC(j,1,maxprofit) {
        if ( dp[itemnumbers][j] <= capacity) maximum = j ; 
    }
    cout << maximum << endl ;      
 
    return 0 ;
}

Measured memory_bytes: 83252
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 T,x[MAXN],to[MAXN],ans[MAXN],L;
int id[MAXN],w[MAXN];
void Solve() {
    read(N);read(L);read(T);
    for(int i = 0 ; i < N ; ++i) {
	read(x[i]);read(w[i]);
	if(w[i] == 1) to[i] = (x[i] + T) % L;
	else to[i] = ((x[i] - T) % L + L) % L;
	id[i] = i;
    }
    sort(id,id + N,[](int a,int b){return to[a] < to[b] || (to[a] == to[b] && w[a] < w[b]);});
    int pos = 0;
    for(int i = 1 ; i < N ; ++i) {
	if(w[i] ^ w[0]) {
	    pos += (T / L) * 2 % N;
	    int64 rem = T % L;
	    int64 dis = x[i] - x[0];
	    if(w[0] == 2) dis = L - dis;
	    if(dis + L < 2 * rem) pos += 2;
	    else if(dis < 2 * rem) pos += 1;
	    pos %= N;
	}
    }
    if(w[0] == 1) pos %= N;
    else pos = (N - pos % N) % N;
    for(int i = 0 ; i < N ; ++i) {
	if(id[i] == 0) {
	    int p = i;
	    int cnt = 0;
	    while(cnt < N) {
		ans[pos] = to[id[p]];
		p = (p + 1) % N;
		pos = (pos + 1) % N;
		++cnt;
	    }
	}
    }
    for(int i = 0 ; i < N ; ++i) {
	out(ans[i]);enter;
    }
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

int main()
{
	ios::sync_with_stdio(false);
	
	string s;
	cin>>s;
	int i=s.size()-1;
	
	while(i>0)
	{
		if(s[i]=='r'&&s[i-1]=='e'&&s[i-2]=='m'&&s[i-3]=='a'&&s[i-4]=='e'&&s[i-5]=='r'&&s[i-6]=='d')
			i-=7;
		else if(s[i]=='m'&&s[i-1]=='a'&&s[i-2]=='e'&&s[i-3]=='r'&&s[i-4]=='d')
			i-=5;
		else if(s[i]=='r'&&s[i-1]=='e'&&s[i-2]=='s'&&s[i-3]=='a'&&s[i-4]=='r'&&s[i-5]=='e')
			i-=6;
		else if(s[i]=='e'&&s[i-1]=='s'&&s[i-2]=='a'&&s[i-3]=='r'&&s[i-4]=='e')
			i-=5;
		else
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

dp = [[0] * n for _ in range(n)]

for i in range(n):
    dp[i][(n-1)-i] = a[i]

for i in range(n-2, -1, -1):
    for j in range(i+1):
        dp[j][i-j] = max( a[j] - dp[j+1][i-j],
                            a[-(1+i-j)] - dp[j][i-j+1])

print(dp[0][0])

Measured memory_bytes: 111964
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  vector<int> x(5);
  rep(i,5) cin >> x[i];
  rep(i,5) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
      return;
    }
  }
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <tuple>

int main() {
  intmax_t k;
  size_t n;
  scanf("%jd %zu", &k, &n);

  std::vector<intmax_t> a(n);
  for (auto& ai: a) scanf("%jd", &ai);
  a.reserve(n+1);
  a.push_back(k+a[0]);

  intmax_t res = k+k;
  for (size_t i = 1; i <= n; ++i)
    res = std::min(res, k-(a[i]-a[i-1]));

  printf("%jd\n", res);
}


Measured memory_bytes: 3328
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int mod = (a *100 + b * 10 + c) % 4;

        if(mod == 0){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
	int n,t;
	int time[1000000];
	int i,j,sum=0,tt=0;
	cin>>n>>t;
	int a,b,c;
	for(i=0;i<n;i++){
		cin>>time[i];
	}
	tt=t;
	for(i=1;i<n;i++){
		if(time[i]-time[i-1]<t){
			sum+=time[i]-time[i-1];
		}
		else{
			sum+=t;
		}
	}
	sum+=t;
	cout<<sum<<endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n;cin >> n;
	vector<int> av;
	for(int i = 0; i < n; i++){
		int a; cin >> a;
		av.push_back(a);
	}
	int cnt = 0;
	for(int i = 1; i < n-1; i++){
		int min_a = min(av[i],min(av[i+1], av[i-1]));
		int max_a = max(av[i], max(av[i+1], av[i-1]));
		if(min_a != av[i] && max_a != av[i])cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
const int INF = INT_MAX / 2;

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

    string str;
    int sum = 700;

    cin >> str;
    rep (i, 3)
        if (str[i] == 'o') sum += 100;

    print(sum);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 764
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{	
	auto N = RD;
	auto A = RDR.ARR;

	long cnt;
	long cnt0;
	foreach (i; 0..N)
	{
		if (A[i] < 0)
			++cnt;
		else if (A[i] == 0)
			++cnt0;
	}
	A.sort!"abs(a) < abs(b)"();

	long ans;
	foreach (i; 0..N)
	{
		ans += abs(A[i]);
	}

	debug writeln(ans);
	if (cnt0 == 0 && cnt % 2 == 1)
	{
		ans -= abs(A[0]) * 2;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


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

int main() {
    for (int N, M, Q; cin >> N >> M >> Q, N | M | Q;) {
        if (N == 1) {
            cout << string(M, '0') << endl;
            for (string s; Q--; cin >> s >> s);
            continue;
        }
        vector<long long> zero(M), one(M);
        for (string pS(N, '0'), pB(M, '0'), S, B; Q--; pS = S, pB = B) {
            cin >> S >> B;
            rep(i, M) {
                if (__builtin_popcountll(one[i]) == 1) continue;
                rep(j, N) {
                    if (S[j] == '0') {
                        (B[i] != pB[i] ? zero[i] : one[i]) |= 1ll << j;
                    }
                    else {
                        (B[i] == pB[i] ? zero[i] : one[i]) |= 1ll << j;
                    }
                }
            }
        }
        string table(M, '?');
        rep(i, M) {
            long long b = ~zero[i] & one[i];
            if (__builtin_popcountll(b) != 1) continue;
            table[i] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[__builtin_ctzll(b)];
        }
        cout << table << endl;
    }
}

Measured memory_bytes: 3124
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
#define X first
#define Y second
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
const int maxn=5e5+10;
const ll Inf=1e10;

ll ans;
ll n,k;
set<int>st;

//正向遍历一遍选择最小需要工作的天数，逆向遍历求解最大工作的天数，这样两者之间的交集就一定是需要工作的天数

int main(){

	int n,k,c;
	cin>>n>>k>>c;
	int res1[maxn],res2[maxn];
	string a;
	cin>>a;
	int pos=0;
	for(int i=0;i<n;i++){
		if(a[i]=='o'){
			res1[pos++]=i;
			i+=c;
		}
	}
	pos=k-1;
	for(int i=n-1;i>=0&&pos>=0;i--){
		if(a[i]=='o'){
			res2[pos--]=i;
			i-=c;
		}
	}
	for(int i=0;i<k;i++){
		if(res1[i]==res2[i]){
			cout<<res1[i]+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<string> S(N);
    vector<ll> march(5);
    rep(i, N)
    {
        cin >> S[i];
        switch (S[i][0]) {
        case 'M':
            march[0]++;
            break;
        case 'A':
            march[1]++;
            break;
        case 'R':
            march[2]++;
            break;
        case 'C':
            march[3]++;
            break;
        case 'H':
            march[4]++;
            break;
        default:
            break;
        }
    }
    ll cnt = 0;
    rep(i, 5)
    {
        if (march[i] > 0) {
            cnt++;
        }
    }
    ll ans = 0;
    if (cnt < 3) {
        cout << 0 << endl;
        return 0;
    } else {
        for (int i = 0; i < 5; ++i) {
            for (int j = i + 1; j < 5; ++j) {
                for (int k = j + 1; k < 5; ++k) {
                    ans += march[i] * march[j] * march[k];
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
	int a,b,c,d,s;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		s=((b<d)?b:d)-((a>c)?a:c);
		if(s>0)printf("%d\n",s);
		else printf("0\n");
	}
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll dp[20][2];

int main(){
    ll N;
    cin >> N;

    if(N % 2 == 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    N /= 2;
    while(N){
        ans += N/5;
        N /= 5;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define adrep(i,s,n) for (int i=(s);i<(n);i++)
using namespace std;
typedef long long ll;


int main(){

  ll a[5];
  rep(i,5){
    cin>>a[i];
    if(a[i]==0){cout<<(i+1)<<endl;return 0;}
  }
}


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

int main() {

	string s; cin >> s;
	int a = 0;
	int b = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') a++;
		if (s[i] == '1') b++;
	}
	cout << 2 * min(a, b) << endl;
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

class UnionFind
{
private:
	vector<int> ary;
	vector<int> rank;

public:
	UnionFind( int n ) : ary( n ), rank( n, 0 )
	{
		REP( i, 0, n )
		{
			ary[i] = i;
		}

		return;
	}

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

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

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

		if ( x == y )
		{
			return;
		}

		if ( rank[x] < rank[y] )
		{
			ary[x] = y;
		}
		else
		{
			ary[y] = x;

			if ( rank[x] == rank[y] )
			{
				rank[x]++;
			}
		}

		return;
	}
};

struct Edge
{
	int from, to, cost;

	Edge()
	{
		return;
	}

	Edge( int f, int t, int c ) : from( f ), to( t ), cost( c )
	{
		return;
	}

	bool operator < ( const Edge &a ) const
	{
		return cost < a.cost;
	}
};

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

	while ( true )
	{
		int n, m;
		cin >> n >> m;

		if ( !( n | m ) )
		{
			break;
		}

		vector< Edge > E( m );

		EACH( e, E )
		{
			cin >> e.from >> e.to >> e.cost;
		}

		sort( ALL( E ) );

		int res = 0;
		UnionFind uf( n );

		REP( i, 0, m )
		{
			auto &e = E[i];

			if ( uf.same( e.from, e.to ) )
			{
				continue;
			}

			uf.unite( e.from, e.to );

			res += e.cost;
		}

		cout << res << endl;
	}

	return 0;
}

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

int main(){
  long long a, b, c, k; cin >> a >> b >> c >> k;
  if (a >= k) cout << k << endl;
  else {
    if (a + b >= k) cout << a << endl;
    else cout << 2 * a + b - k << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
// type
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 100005, MAX_M = 200010;
// code
#define int long long
int dp[5050][5050];

void Solve() {
    int n, m;
    string s;
    cin >> n >> s;
    m = s.length();
    // value of s is not necessary
    dp[0][0] = 1; // way obtain string length k using n operations
    if (n == m){
        cout << 1;
        return;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= i; j++){
            if (j == 0 && i == 1)
                dp[i][j] = 1;
            else
                dp[i][j] = (dp[i-1][max(0ll, j-1)] + dp[i-1][j+1] * 2) % mod;
        }
    }
    cout << dp[n][m];
}

signed main(){
    FAST_IO;
    int TC = 1; 
	//cin >> TC;
    while(TC--) Solve();
    return 0;
}


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

int u_f[222222][2];
int N,K,L;

int root0(int x){
	if(x==u_f[x][0])return x;
	else return u_f[x][0]=root0(u_f[x][0]);
}

void unite0(int x,int y){
	int xx=root0(x);
	int yy=root0(y);
	if(xx!=yy)u_f[yy][0]=xx;
}

int root1(int x){
	if(x==u_f[x][1])return x;
	else return u_f[x][1]=root1(u_f[x][1]);
}

void unite1(int x,int y){
	int xx=root1(x);
	int yy=root1(y);
	if(xx!=yy)u_f[yy][1]=xx;
}

int main(){
	for(int i=0;i<222222;i++)u_f[i][0]=u_f[i][1]=i;
	
	cin >> N >> K >> L;
	
	for(int i=0;i<K;i++){
		int p,q;
		cin >> p >> q;
		p--;
		q--;
		unite0(p,q);
	}
	for(int i=0;i<L;i++){
		int r,s;
		cin >> r >> s;
		r--;
		s--;
		unite1(r,s);
	}
	vector<pair<int,int>> vp(N);
	for(int i=0;i<N;i++){
		vp[i].first=root0(u_f[i][0]);
		vp[i].second=root1(u_f[i][1]);
	}
	
	map<pair<int,int>,int> m;
	
	for(int i=0;i<N;i++){
		if(m.find(vp[i])!=m.end())m[vp[i]]++;
		else m.insert(make_pair(vp[i],1));
	}
	
	for(int i=0;i<N;i++){
		cout << m.at(vp[i]);
		if(i==N-1)cout << endl;
		else cout << " ";
	}
	
	return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> l(n);
  rep(i,n) cin >> l[i];
  sort(l.rbegin(), l.rend());
  ll ans = 0;
  for (int a = 0; a < n-2; a++) {
    for (int b = a+1; b < n-1; b++) {
      for (int c = b+1; c < n; c++) {
        if (l[a] < l[b] + l[c]) {
          ans++;
        } else break;
      }
    }
  }
  cout << ans << endl;          
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> cs(n), ss(n), fs(n);
    for(int i = 0; i < n - 1; i++){
        cin >> cs[i] >> ss[i] >> fs[i];
    }
    for(int i = 0; i < n - 1; i++){
        int t = cs[i] + ss[i];
        for(int j = i + 1; j < n - 1; j++){
            if(t > ss[j]){
                int rem = t % fs[j];
                t += (fs[j] - rem) % fs[j];
            }else{
                t = ss[j];
            }
            t += cs[j];
        }
        cout << t << '\n';
    }
    cout << 0 << '\n';
}


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

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

    string s; cin >> s;
    auto n = s.size();
    auto res = 0ll;

    auto f = [](int x) {
        return (long long) x * (x - 1) / 2;
    };

    for(size_t i = 0, j = 0; i < n; i = j) {
        auto a = 0, b = 0;
        while(j < n and s[j] == '<')
            a++, j++;
        while(j < n and s[j] == '>')
            b++, j++;
        
        res += f(a) + f(b) + max(a, b);
    }

    cout << res << "\n";
}


Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#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++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define MOD 1000000007
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string S;
    cin >> S;

    int N=S.size();

    ll dp[N+1][4]={}; // no,A,B,C

    dp[0][0]=1;

    rep(i,N){
        char c=S[i];
        if(c=='A'){
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=dp[i][1]+dp[i][0];
            dp[i+1][2]=dp[i][2];
            dp[i+1][3]=dp[i][3];
        }
        if(c=='B'){
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=dp[i][1];
            dp[i+1][2]=dp[i][2]+dp[i][1];
            dp[i+1][3]=dp[i][3];
        }
        if(c=='C'){
            dp[i+1][0]=dp[i][0];
            dp[i+1][1]=dp[i][1];
            dp[i+1][2]=dp[i][2];
            dp[i+1][3]=dp[i][3]+dp[i][2];
        }
        if(c=='?'){
            dp[i+1][0]=dp[i][0]*3;
            dp[i+1][1]=dp[i][1]*3+dp[i][0];
            dp[i+1][2]=dp[i][2]*3+dp[i][1];
            dp[i+1][3]=dp[i][3]*3+dp[i][2];
        }
        dp[i+1][0]%=MOD;
        dp[i+1][1]%=MOD;
        dp[i+1][2]%=MOD;
        dp[i+1][3]%=MOD;
    }

    cout<< dp[N][3] <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		
		char[] chr = str.toCharArray();
		
		int temp = 0;
		
		for (int i=0 ; i<chr.length; i++ ){
			
			temp += Character.getNumericValue(chr[i]);
		}
		
		if (Integer.valueOf(str) % temp== 0){
			
			System.out.println("Yes");
			
		}
		else
		{
			
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21972
N = input()
v = input().split(" ")
v_list = [int(i) for i in v]
v_list.sort()
temp = 0
for i in range(len(v_list)-1):
    tmep = (v_list[i] + v_list[i + 1]) / 2
    v_list[i + 1] = tmep

print(v_list[len(v_list)-1])


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

int main(void)
{
    long long N;
    cin >> N;
    long long ans = 0;
    for (long long i = 1; i <= N; i++)
    {
        if (i % 2 == 1)
        {
            long long count = 0;
            for (long long j = 1; j < pow(i, 0.5); j++)
            {
                if (j % 2 == 1 && i % j == 0)
                {
                    count++;
                }
            }
            if (count == 4)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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


int main(){
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    string s; cin>>s;
    s = '#' + s + '#';
    bool tri = false;
    for(int i=a; i<=c; i++){
        if(s[i]=='#'){
            if(s[i+1]=='#'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    for(int i=b; i<=d; i++){
        if(s[i]=='#'){
            if(s[i+1]=='#'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(s[i-1]=='.' && s[i+1]=='.') tri = true;
        }
    }
    
    if(c<d){
        cout << "Yes" << endl;
        return 0;
    }
    else if(tri){
        cout << "Yes" << endl;
        return 0;
    }
    else cout << "No" << endl;
}

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

int main () {
  int k, s, ans = 0;
  cin >> k >> s;
  rep(x, k+1) {
    rep(y, k+1) {
      int z = s-x-y;
      if (0 <= z && z <= k) ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int total = sc.nextInt();
		int[] line = new int[total];

		for(int i=0; i < total; i++) {
			line[i] = sc.nextInt();
		}

		Arrays.sort(line);
		int maxDiff = line[total-1] - line[0];

		System.out.println(maxDiff);
	}
}


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

int solve() {
	int a, b, c;
	cin >> a >> b >> c;

	for(int t = 0; t <= 3600; t += a + b) {
		while(c < t) c += 60;
		if(t <= c && c <= t + a) return c;
	}
	return -1;
}

int main() {
	cout << solve() << endl;
	return EXIT_SUCCESS;
}

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

using namespace std;
typedef long long ll;
const int N = 100010;
int _w;

int n, k, a[N];
ll s[N], pf[N], sf[N];
ll ans;

ll sum( int l, int r ) {
	return s[r] - s[l-1];
}

int main() {
	cin >> n >> k;
	for( int i = 1; i <= n; ++i )
		cin >> a[i];
	for( int i = 1; i <= n; ++i )
		s[i] = s[i-1] + a[i];
	for( int i = 1; i <= n; ++i )
		pf[i] = pf[i-1] + max(a[i], 0);
	for( int i = n; i >= 1; --i )
		sf[i] = sf[i+1] + max(a[i], 0);
	for( int i = 1; i+k-1 <= n; ++i ) {
		ans = max(ans, pf[i-1] + sf[i+k]);
		ans = max(ans, pf[i-1] + sf[i+k] + sum(i, i+k-1));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3072
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
ある頂点が白のとき，穴あき度の総和に与える影響を考える，
入力例2の1-2-3-4なら(0,3,3,0)この頂点2に注目，この3は，上下どちらもに黒があれば良い．上(2^1 - 1) * 下(2^2 - 1)=3．つまり全量 - all白

実際には子が多い．どこか2箇所の部分木に黒があれば良い=>余事象．
・全量：pow(2,N-1)，自分は白確定，墓はなんでも良い

・all白=1通り
・1個の部分木が黒*1通り（*1は残りall白の分）
「1この部分木が黒」はどう求める？　その部分木のサイズをnとして，2^n - 1．
その部分木のサイズはどう求める？　全方位木DPか=>端の頂点から詰めていけばいけそう

"""

def main():
    mod=10**9+7
    import queue
        
    N=I()
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        x,y=MI()
        x-=1
        y-=1
        adj[x].append(y)
        adj[y].append(x)
        
    #2べきを持っておくか，
    POW=[1]
    for _ in range(N+5):
        temp=POW[-1]
        POW.append((temp*2)%mod)
        
    #各頂点のじすう
    deg=[0]*N
    for i in range(N):
        deg[i]=len(adj[i])
    
    
    L=[[]for _ in range(N)]#　各頂点からみて，個を根とする部分木のサイズを配列として持っておく    
    
    looked=[0]*N#qに突っ込むか
    used=[0]*N#計算を終えたか
    q=queue.Queue()
    
    for v in range(N):
        if len(adj[v])==1:
            q.put(v)
            L[v].append(0)
            looked[v]=1
            
    ans=[0]*N
    while not q.empty():
        v=q.get()
        
        S=sum(L[v])
        rem=(N-1)-S#まだ見ていない方向の合計，-1は自分自身
        temp=POW[N-1]#全体
        temp-=1#all白
        
        for s in L[v]:#1つの部分木にだけ黒があるパターンを引く
            temp-=POW[s]-1
            temp%=mod
            
        #1つの部分木にだけ黒があるパターンを引く，続き
        temp-=POW[rem]-1
        temp%=mod
            
        ans[v]=temp
        used[v]=1
        
        for nv in adj[v]:
            if used[nv]==0:
                L[nv].append(S+1)
            
            if looked[nv]==0:
                # nvの計算に必要な方向をしっかり見ていれば計算用のqに回す
                if len(L[nv])>=deg[nv]-1:
                    q.put(nv)
                    looked[nv]=1
                
                
    # print(ans)
    
    y=sum(ans)
    x=POW[N]
    
    res=(y*pow(x,mod-2,mod))%mod
    print(res)
    
        
    
        
    
    

main()

Measured memory_bytes: 144848
// 01ナップザック問題 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B&lang=jp
/* 入力例
4 5
4 2
5 2
2 1
8 3
// →出力　13
*/
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N, W;
    cin >> N >> W;
    int v[N], w[N], dp[N][W + 1];
    for(int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            if(i == 0) {
                if(j >= w[i])
                    dp[i][j] = v[i];
                else
                    dp[i][j] = 0;
            } else {
                if(j >= w[i])
                    dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
                else
                    dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[N - 1][W] << endl;
    return 0;
}



Measured memory_bytes: 6984
from collections import deque
import sys
import copy


def input():
    return sys.stdin.readline()[:-1]


while True:
    w, h = map(int, input().split())

    if w == h == 0:
        exit(0)

    M = []
    for _ in range(h*2-1):
        tmp = input()
        if len(tmp) != w*2-1:
            tmp = tmp+' '
        M.append(list(tmp))
    check = copy.deepcopy(M)
    check[0][0] = '1'

    que = deque([])
    que.append((0, 0, 1))
    mv_list = [(1, 0, 2, 0), (-1, 0, -2, 0), (0, 1, 0, 2), (0, -1, 0, -2)]
    while True:
        if not(que):
            print(0)
            break

        nm = que.popleft()
        if nm[0] == (w*2-2) and nm[1] == (h*2-2):
            print(nm[2])
            break

        for mv in mv_list:
            x1 = nm[0] + mv[0]
            x2 = nm[0] + mv[2]
            y1 = nm[1] + mv[1]
            y2 = nm[1] + mv[3]
            if 0 <= x1 <= w*2-1 and 0 <= y1 <= h*2-1 and 0 <= x2 <= w*2-1 and 0 <= y2 <= h*2-1 and M[y1][x1] == '0' and check[y2][x2] == ' ':
                check[y2][x2] = ''
                que.append((x2, y2, nm[2]+1))



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


int main(){
  int n;
  cin>>n;
  set <string> s;
  rep(i,n){
    string x;
    cin>>x;
    s.insert(x);
  }
  cout<<s.size()<<endl;

}


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

int main() {
  string s;
  cin >> s;

  bool p = (s.at(0) == 'R');
  bool q = (s.at(1) == 'R');
  bool r = (s.at(2) == 'R');

  if (p && q && r) {
    cout << 3 << endl;
  } else if ((p && q) || (q && r)) {
    cout << 2 << endl;
  } else if (p || q || r) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
int main(){
    int n1,n2,n3,sum=0;
    scanf("%d%d%d",&n1,&n2,&n3);
    sum=n1+n2+n3;
    if(0<n1 && n1<14 && 0<n2 && n2<14 && 0<n3 && n3<14){
        if(sum>=22){
        printf("bust");
        }
        else{
        printf("win");
        }
    }
    return 0;
}

Measured memory_bytes: 128