akhauriyash/Code-Regression huggingface dataset:
x,y=list(map(int, input().split()))
list=[]
for i in range(x):
	list.append(int(input()))
list.sort()
ans=10**10

for j in range(x-y+1):
	if list[j+y-1]-list[j]<ans:
		ans=list[j+y-1]-list[j]
print(ans)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

string S;
map<char,int> alp;
int main(){
    cin >> S;
    rep(i,sz(S)) alp[S[i]]++;
    repi(i,'a','z') if(alp[i]==0){ cout<<(char)i<<endl; return 0; }
    cout << "None" <<'\n';
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define fastio std::ios_base::sync_with_stdio(false), std::cout.tie(0), std::cin.tie(0);
#define N 1000000007
#define mxx INT_MAX
const double pi = 3.14159265359;

typedef long long ll;
//using namespace __gnu_pbds;
/*typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;*/

void solve() {
	std::string name;
	std::cin >> name;
	int n = name.size();
	for (int x = 0; x < n; x++) {
		if (name[x] == '?')
			name[x] = 'D';
	}
	
	std::cout << name;
}

int main() {
	int t;
	/*std::cin>>t;
	while(t--)*/
	solve();
}

Measured memory_bytes: 3716
const input = require("fs").readFileSync("/dev/stdin", "utf8");
// const input = '2018\n218';

function Main(input) {
	input = input.split('\n');
  	const N = parseInt(input[0]);
    	const A = parseInt(input[1]);
  console.log(N%500 <= A?'Yes':'No');
}

// Don't edit this line!
Main(input);

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

int main() {
  int n,i,two;
  
  cin >> n;
  
  two = 1;
  
  while (true) {
    if (n > two) {
      two = two * 2;
    }
    else if (n == two) {
      cout << two << endl;
      break;
    }
    else if (n < two) {
      two = two/2;
      cout << two << endl;
      break;
    }
  }
  
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
//typedef int Def;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};
int main(){
	ll T;
	int n;
	cin>>T>>n;
	vi a(n+1,inf),b(n+1,inf);
	rep(i,n)cin>>a[i]>>b[i];
	vi dp(n+1);
	rep(i,n)dp[i+1]=b[i]-a[i];
	rep(i,n)dp[i+1]+=dp[i];
	ll ma=0;
	rep(i,n){
		ll t=upper_bound(all(a),a[i]+T)-a.begin();
		t--;
		ma=max(ma,dp[t]-dp[i]+min(b[t],a[i]+T)-a[t]);
	}
	cout<<ma<<endl;
}













Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	ll a,b,k;
	cin>>a>>b>>k;
	ll kk=k;
	k-=min(a,k);
	a-=min(a,kk);
	b-=min(b,k);
	cout<<a<<" "<<b<<endl;
}

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

int main() {
  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=n;++i)
constexpr ll COM_MAX = (ll)1e6;
constexpr ll MOD = (ll)1e9+7;
std::vector<ll> fac(COM_MAX),finv(COM_MAX),inv(COM_MAX);
// 前処理
void comb_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<COM_MAX;++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
// 二項係数計算
ll comb(ll n,ll k){
  if(n<k)return 0;
  if(n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
main(){
  
  comb_init();

  ll n,k;
  cin>>n>>k;
  ll red=n-k,blue=k;

  reps(i,k){
    ll sukima=red+1;
    ll ans=comb(sukima,i);
    ans%=MOD;
    ll aosukima=blue-1;
    ll tmp=comb(aosukima,i-1);
    ans*=tmp;
    ans%=MOD;
    cout<<ans<<endl;
  }


}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    char field[h][w];
    int l[h][w], r[h][w], u[h][w], b[h][w];
    for(int x=0;x<h;x++){
        for(int y=0;y<w;y++){
            cin >> field[x][y];
        }
    }

    int d = 0;
    for(int x=0;x<h;x++){
        d = 0;
        for(int y=0;y<w;y++){
            if(field[x][y] == '#') d = 0;
            else l[x][y] = d++;
        }
        d = 0;
        for(int y=w-1;y>=0;y--){
            if(field[x][y] == '#') d = 0;
            else r[x][y] = d++;
        }
    }
    for(int y=0;y<w;y++){
        d = 0;
        for(int x=0;x<h;x++){
            if(field[x][y] == '#') d = 0;
            else u[x][y] = d++;
        }
        d = 0;
        for(int x=h-1;x>=0;x--){
            if(field[x][y] == '#') d = 0;
            else b[x][y] = d++;
        }
    }

    int ans = 0;
    for(int x=0;x<h;x++){
        for(int y=0;y<w;y++){
            if(field[x][y] != '#')
                ans = max(ans, l[x][y] + r[x][y] + u[x][y] + b[x][y] + 1); 
        }
    }
    cout << ans << endl;

}

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

int main(void){
    char c;
    int y,m,d;

    cin>>y>>c>>m>>c>>d;

   // cout<<y<<" "<<m<<" "<<d<<endl;

    if(y<2019){
      cout<<"Heisei"<<endl;
    }
    else if(m<4){
        cout<<"Heisei"<<endl;
    }
    else if(m==4&&d<=30){
        cout<<"Heisei"<<endl;
    }
    else{
         cout<<"TBD"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int A, B;
	cin >>A>>B;
	
	cout << 6-A-B<< endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

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

Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int H, W;
  ll L;
  string NESW = "NESW";
  int dx[4] = {0, 1, 0, -1};
  int dy[4] = {-1, 0, 1, 0};
  while(cin>>H>>W>>L && H){
    vector<string> grid(H);
    REP(i, H)cin>>grid[i];
    int nx, ny, dir;
    REP(y, H)REP(x, W)REP(r, 4)if(grid[y][x] == NESW[r]){
      nx = x, ny = y, dir = r;
    }
    int memo[100][100][4];
    memset(memo, -1, sizeof(memo));
    for(int time = 0; time < L; time++){
      if(~memo[ny][nx][dir]){
        int base = memo[ny][nx][dir];
        int cycle = time - base;
        int ans = (L - base) % cycle + base;
        REP(y, H)REP(x, W)REP(r, 4)if(memo[y][x][r] == ans){
          ny = y, nx = x, dir = r;
        }
        break;
      }else{
        memo[ny][nx][dir] = time;
        while(true){
          int nextx = nx + dx[dir], nexty = ny + dy[dir];
          if(nextx >= 0 && nextx < W && nexty >= 0 && nexty < H && grid[nexty][nextx] != '#'){
            nx = nextx, ny = nexty;
            break;
          }else{
            dir = (dir + 1) % 4;
          }
        }
      }
    }
    printf("%d %d %c\n", ny + 1, nx + 1, NESW[dir]);
  }
  return 0;
}

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

int main(){
	int n, m, l, r;
	int min, max, res;
	cin >> n >> m;
	min = 0;
	max = n;
	
	for(int i = 0; i < m; i++){
		cin >> l >> r;
		if(l > min) min = l;
		if(r < max) max = r;
	}
	
	res = max - min + 1;
	cout << (res < 0 ? 0 : res) << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;

	int cA = 0, cB = 0;
	REP(i, S.size()) {
		if (S[i] == 'a') {
			if (cA + cB < A + B) cout << "Yes" << endl;
			else cout << "No" << endl;
			++cA;
		}
		else if (S[i] == 'b') {
			if (cA + cB < A + B && cB < B) {
				cout << "Yes" << endl;
				++cB;
			}
			else cout << "No" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int H = s.nextInt();
		int R = s.nextInt();
		
		if (H < 0){
			int a = H + R;
			if(a < 0){
				System.out.println("-1");
			}else if(a == 0){
				System.out.println("0");
			}else{
				System.out.println("1");
			}
		}else{
			System.out.println("1");
		}
		
	}
}

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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n;
	 cin>>n;

	 vector<pair<ll,ll> >vect;
	 f(i,0,n)
	 {
	 	ll x;
	 	 cin>>x;
	 	 vect.push_back({x,i+1});
	 }

	 sort(vect.begin(),vect.end());


	 for(int i=0;i<n;i++)
	 	cout<<vect[i].second<<" ";
	 cout<<"\n";



	 

	return 0;
}

Measured memory_bytes: 5316
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int a[m],b[m];
	for(int i=0;i<m;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<n;i++)
	{
		int ans=0;
		for(int j=0;j<m;j++)
		{
			if(a[j]==i+1)
			{
				ans++;
			}
			if(b[j]==i+1)
			{
				ans++;
			}
		}
		if(i+1==n)
		{
			cout<<ans;
		}
		else
		{
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
//#define SIZE 200105
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
typedef pair<pair<ll, ll>,int> PP;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};


int N,M;
vi gr[114514];
int used[114514]={0};
int treeoya[114514];
pii depth[114514];
void dfs(int now,int dep){
	depth[now]=mp(dep,now);
	rep(i,gr[now].size()){
		int nex=gr[now][i];
		if(used[nex]==0){
			
			used[nex]=1;
			treeoya[nex]=now;
			dfs(nex,dep+1);
		}
	}
}
pii hen[114514];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;a--;b--;
		gr[a].pb(b);
		gr[b].pb(a);
		hen[i]=mp(a,b);
	}
	if(M%2==1){
		cout<<-1<<endl;
	}else{
		used[0]=1;
		treeoya[0]=-1;
		dfs(0,0);
		int mod2out[114514]={0};
		rep(i,M){
			int a=hen[i].first;
			int b=hen[i].second;
			if(treeoya[a]!=b && treeoya[b]!=a){
				cout<<a+1<<" "<<b+1<<endl;
				mod2out[a]+=1;
				mod2out[a]%=2;
			}
		}
		//rep(i,N)cout<<depth[i].first<<" "<<endl;
		sort(depth,depth+N);
		reverse(depth,depth+N);
		rep(i,N){

			int now=depth[i].second;
			if(now==0)continue;
			if(mod2out[now]==1){
				mod2out[now]=0;
				cout<<now+1<<" "<<treeoya[now]+1<<endl;
			}else{
				mod2out[treeoya[now]]=1-mod2out[treeoya[now]];
				cout<<treeoya[now]+1<<" "<<now+1<<endl;
			}
		}

	}
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9;
const int maxn=1e5+5;
typedef long long ll ;
int main()
{
    int n,h,w;
    scanf("%d%d%d",&n,&h,&w);
    if(n<w || n<h)return 0*printf("0\n");
    int ans=(n-h+1)*(n-w+1);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
lis = [[1,0] for i in range(n)]
lis[0][1] = 1
for i in range(m):
  a,b = map(int,input().split())
  if lis[a-1][1] == 1:
    lis[b-1][1] = 1
    if lis[a-1][0] == 1:
      lis[a-1][1] = 0
  lis[a-1][0] -= 1
  lis[b-1][0] += 1
cou = 0
for i in range(n):
  if lis[i][1] == 1:cou += 1
print(cou)

Measured memory_bytes: 13172
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int tmp=0;
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}
	if(b>c){
		tmp=b;
		b=c;
		c=tmp;
	}
	if(a>b){
		tmp=a;
		a=b;
		b=tmp;
	}		
	cout<<a<<" "<<b<<" "<<c<<"\n";
	return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N; cin >> N;
    vector<int> L;
    int x;
    rep(i, N)
    {
        cin >> x;
        L.push_back(x);
    }
    sort(L.begin(), L.end());

    int ans = 0;

    for (int c = 2; c < N; c++) for (int b = 1; b < c; b++)
    {
        auto a = upper_bound(L.begin(), L.begin() + b, L[c] - L[b]);
        ans += distance(a, L.begin() + b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define N (1000 + 10)

#define max(a, b) (a < b ? b : a)

int kansu(int i){
  if(i==25964)
    return 0;
    else return i;
}

int dp[N][N];
char a[N], b[N];

int LCS(void)
{
  const int a_size = strlen(a) - 1; // last one is '\n'
  const int b_size = strlen(b) - 1;
  int i, j;

  memset(dp, 0, sizeof(dp));

  for (i = 1; i < a_size + 1; ++i) {
    for (j = 1; j < b_size + 1; ++j) {
      int mx = max(dp[i][j - 1], dp[i - 1][j]);
      if (a[i - 1] == b[j - 1]) {
        mx = max(mx, dp[i - 1][j - 1] + 1);
      }
      dp[i][j] = mx;
    }
  }

  return dp[a_size][b_size];
}

int main(void)
{
  /*
  while (fgets(a, N, stdin) && fgets(b, N, stdin)) {
    printf("%d\n", LCS());
  }
  */
  int n, i;
  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    fgets(a, N, stdin);
    fgets(b, N, stdin);
    printf("%d\n", LCS());
  }
  return 0;
}


Measured memory_bytes: 5828
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long i,j,k,a,b,c=0,n;
  cin>>a>>b;
  if(a==1 ) c+=300000;
  else if(a==2) c+=200000;
  else if(a==3) c+=100000;
  if(b==1 ) c+=300000;
  else if(b==2) c+=200000;
  else if(b==3) c+=100000;
  if(a==1 && b==1) cout<<"1000000"<<endl;
  else cout<<c<<endl;
return 0;
}


Measured memory_bytes: 3520
#include <stdio.h>

int main(void)
{
    int ans = 0, max = 0;
    int n;

    scanf("%d", &n);
    int h[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &h[i]);
        if (i != 0)
            if (h[i] <= h[i - 1])
                max++;
            else
            {
                if (max > ans)
                    ans = max;
                max = 0;
            }
    }
    if (ans < max)
        ans = max;

    printf("%d\n", ans);

    return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    cout << min(B / A, C) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define Mod1(x) (x>=mod?x-mod:x)
#define Mod2(x) (x<0?x+mod:x)
#define maxn 1000010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
ll f[maxn];
int n,d,h;
inline ll power(ll a,ll b)
{
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ans=ans*a%mod;
	return ans;
}
int main()
{
	n=read(); h=read(); d=read();
	ll val=0,fac=1;
	for(int i=1;i<=n;i++){
		fac=fac*i%mod;
		val=Mod1(val+fac);
	}
	f[0]=1;
	ll cur=1;
	for(int i=1;i<=h;i++){
		f[i]=cur*val%mod;
		cur=Mod1(cur+f[i]);
		if(i>=d)cur=Mod2(cur-f[i-d]);
	}
	writeln(f[h]*power(val,mod-2)%mod*fac%mod);
	return 0;
}

Measured memory_bytes: 7936
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{

  long long H, A;

  cin >> H >> A;

  long long tmp = H/A;
  if(H%A==0)
    tmp--;
  cout << tmp+1 << endl;
  

  return 0;
}



Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
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; }
static const lint MOD = (lint)1e9+7;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    rep (i, N)
    {
        cin >> A[i];
        A[i]--;
    }
    rep (i, N)
    {
        cin >> B[i];
    }
    rep (i, N-1)
    {
        cin >> C[i];
    }


    lint ans = 0;
    int before = -1;
    for (int i = 0; i < N; ++i)
    {
        ans += B[A[i]];
        if (before+1 == A[i] && C.size() >= before)
        {
            ans += C[before];
        }
        before = A[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
    int intave;
    double a,b,ave;
    cin >> a >> b;

    ave = (a + b)/2;
    intave = (int)ave;
    if(ave > (double)intave) cout << intave + 1 << endl;
    else cout << intave  << endl; 


    return 0;
}

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

struct point {
    double x,y;
};

void koch(int n, point a ,point b) {
    if(n==0) return;
    point s,t,u;
    double rad = M_PI*60.0/180.0;
    
    s.x = (2.0*a.x + 1.0*b.x)/3.0;
    s.y = (2.0*a.y + 1.0*b.y)/3.0;
    t.x = (1.0*a.x + 2.0*b.x)/3.0;
    t.y = (1.0*a.y + 2.0*b.y)/3.0;
    u.x = (t.x - s.x)*cos(rad) - (t.y - s.y)*sin(rad) + s.x;
    u.y = (t.x - s.x)*sin(rad) + (t.y - s.y)*cos(rad) + s.y;
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n-1,t,b);
}

int main() {
    point a,b;
    int n;
    scanf("%d",&n);
    
    a.x = 0.0;
    a.y = 0.0;
    b.x = 100.0;
    b.y = 0.0;
    
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n", b.x, b.y);
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

const int N = 4001;
const int MOD = 998244353;
long long dp[N][N];
int main() {
    string s;
    cin >> s;

    dp[0][0] = 1;

    int n = s.size() * 2;
    int r = 0, b = 0, sum = 0;
    for (int i = 0; i < n; ++i) {
        if (i < s.size()) {
            if (s[i] == '0') r += 2;
            if (s[i] == '1') r += 1;
        }

        for (int j = 0; j <= i; ++j) {
            if (j < r) (dp[i + 1][j + 1] += dp[i][j]) %= MOD;
            if (i - j < (i + 1) * 2 - r) (dp[i + 1][j] += dp[i][j]) %= MOD;
        }
    }

    cout << dp[n][r] << endl;
}

Measured memory_bytes: 123520
//???????????????????????°???????????´???wwww
#include <stdio.h>
int main(void){
	int i,s,o,n[4],q[4],toread,L,S,a,b,c,A;
	while(1){
		for(i=0;i<=3;i++){
			scanf("%1d",&n[i]);
			q[i]=n[i];
		}
		A=0;
		if(n[0]==n[1]&&n[1]==n[2]&&n[2]==n[3]){
			if(n[0]==0){
			break;
			}
			printf("NA\n");
		}
		else if(n[0]==6&&n[1]==1&&n[2]==7&&n[3]==4){
			printf("0\n");
		}
		else{
			for(s=0;A!=6174;s++){
			for(o=0;o<=3;o++){
				for(i=0;i<=3;i++){
					if(n[i]<n[o]){
						toread=n[i];
						n[i]=n[o];
						n[o]=toread;
					}
				}
			}
			L=n[0]*1000+n[1]*100+n[2]*10+n[3];
			for(o=0;o<=3;o++){
				for(i=0;i<=3;i++){
					if(n[i]>n[o]){
						toread=n[i];
						n[i]=n[o];
						n[o]=toread;
					}
				}
			}
			S=n[0]*1000+n[1]*100+n[2]*10+n[3];
			A=L-S;
			a=A/1000;
			n[0]=a;
			n[1]=(A-(n[0]*1000))/100;
			n[2]=(A-((n[0]*1000)+(n[1]*100)))/10;
			n[3]=A-((n[0]*1000)+(n[1]*100)+(n[2]*10));
			}
		printf("%d\n",s);
		}
	}
	return 0;
}

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

int main(){
        int K,T;
        int a[100];
        int amax=-1, sumofnotmax=0;

        cin >> K >> T;
        for(int i=0;i<T;i++){
                cin >> a[i];
        }

        for(int i=0; i<T; i++){
                sumofnotmax+=a[i];
                if(amax<a[i]){
                        amax=a[i];
                }
        }
        sumofnotmax -= amax;

        if(sumofnotmax >= amax-1){
                cout << "0" << endl;
        }else{
                cout << amax-1-sumofnotmax << endl;
        }

        return 0;
}


Measured memory_bytes: 256
def main():
    from string import ascii_lowercase
    dic = {i: s for i, s in enumerate(ascii_lowercase)}
    N = int(input())
    ans = []

    def dfs(s, mx):
        if len(s) == N:
            ans.append(s)
            return
        else:
            for i in range(mx+2):
                mx = max(mx, i)
                dfs(s + dic[i], mx)
    dfs("a", 0)
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 71900
#include <iostream>

using namespace std;

int a1[3];
int a2[3];
int a3[3];

int main(){
    int start = 1;
    for(int i = 0; i < 3; i++){
        cin >> a1[i];
    }
    for(int i = 0; i < 3; i++){
        cin >> a2[i];
    }
    for(int i = 0; i < 3; i++){
        cin >> a3[i];
    }

    int tmp1 = a2[0] - a1[0];
    int tmp2 = a3[0] - a1[0];
    bool flag = true;
    for(int i = 1; i < 3; i++){
        if(tmp1 != a2[i] - a1[i]) flag = false;
        if(tmp2 != a3[i] - a1[i]) flag = false;
        if(flag == false){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main (){
	char s1[10];
	char s2[10];
	char s3[10];
	scanf("%s %s %s",s1,s2,s3);
	if(s1[0]>=97&&s1[0]<=122){
		s1[0]=(s1[0]-32);
	}
    printf("%c",s1[0]);
    
    
    
		if(s2[0]>=97&&s2[0]<=122){
		s2[0]=(s2[0]-32);
	}
	printf("%c",s2[0]);
	
	
		if(s3[0]>=97&&s3[0]<=122){
		s3[0]=(s3[0]-32);
	}
	printf("%c",s3[0]);
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e9+9;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
const int N = 5e6;
ll a[N];

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    
    int n; cin >> n;
    int mn = inf, ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if(a[i] < mn) {
            ans++;
            mn = a[i];
        }
    }
    cout << ans << "\n";


 
    return 0;
    
}

Measured memory_bytes: 1792
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let x: i64 = s.next().unwrap().parse().unwrap();
	let a: i64 = s.next().unwrap().parse().unwrap();
	let b: i64 = s.next().unwrap().parse().unwrap();
	if b <= a {
		println!("delicious");
	} else {
		if b - a > x {
			println!("dangerous");
		} else {
			println!("safe");
		}
	}
}


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

int main() {
	int n;
	cin >> n;
	vector<int> w(n);
	int sum = 0;
	rep(i, n) {
		cin >> w[i];
		sum += w[i];
	}
	int mini = sum;
	int p_sum = 0;
	rep(i, n) {
		p_sum += w[i];
		mini = min(mini, abs(p_sum - (sum - p_sum)));
	}
	cout << mini << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n, m; cin >> n >> m;
    map<int, int> mp;
    rep(i,n) {
        mp[i+1] = -1;
    }
    if (m == 0) {
        if (n == 1)
            cout << 0 << endl;
        if (n == 2)
            cout << 10 << endl;
        if (n == 3)
            cout << 100 << endl;
        return 0;
    }

    rep(i,m) {
        int s, c; cin >> s >> c;
        if (mp[s] == -1) {
            mp[s] = c;
        } else if (mp[s] != c) {
            cout << -1 << endl;
            return 0;
        }
    }

    rep(i,n) {
        if (i == 0) {
            if (mp[i+1] == 0) {
                if (n == 1)
                    cout << 0 << endl;
                else
                    cout << -1 << endl;
                return 0;
            }
            if (mp[i+1] == -1) {
                cout << 1;
            } else {
                cout << mp[i+1];
            }
            continue;
        }
        if (mp[i+1] == -1) {
            cout << 0;
        } else {
            cout << mp[i+1];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;
}
int main(){
    ll m,n;cin >> m >>n;
    cout <<modpow(m,n,MOD) <<endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

typedef struct Edge{
    int to;
    int num;
} Edge;

vector<vector<Edge>> G;
vector<int> col;

void DFS(int v,int c=-1,int p=-1){
    int k = 1;
    rep(i,G[v].size()){
        int u = G[v][i].to;
        int id = G[v][i].num;
        if(u == p)continue;
        if(c == k)k++;
        col[id] = k;k++;
        DFS(u,col[id],v);
    }

    return;
}

int main(){
    // 入力
    int N;cin >> N;
    G.resize(N);
    col.resize(N);
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back((Edge){b,i});
        G[b].push_back((Edge){a,i});
    }

    DFS(0);

    int ans = 0;
    rep(i,N){
        ans = max(ans,(int)G[i].size());
    }
    cout << ans << endl;
    rep(i,N-1)cout << col[i] << endl;
}



Measured memory_bytes: 8320
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,i,t,c = 0;
	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> t;
		if(i%2 == 1 && t%2 == 1)
			c++;
	}
	cout << c << "\n";
}

Measured memory_bytes: 3616
use std::io;
use std::str::FromStr;

struct Edge {
    to: i32,
    id: i32
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn dfs(node: i32, pre: i32, pre_color: i32, tree: &Vec<Vec<Edge>>, colors: &mut Vec<i32>) {
    let mut c = 1;
    for edge in &tree[node as usize] {
        // println!("node = {}, edge = {}, pre = {}", node, edge.to, pre.to);
        if pre == edge.to {
            continue;
        }
        if c == pre_color {
            c += 1;
        }
        colors[edge.id as usize] = c;
        dfs(edge.to, node, c, tree, colors);
        c += 1;
    }
}

fn main() {
    let n: i32 = input();
    let mut tree: Vec<Vec<Edge>> = Vec::new();
    let mut colors: Vec<i32> = vec![-1; (n - 1) as usize];
    for _ in 0..n {
        tree.push(Vec::new());
    }
    for i in 0..(n-1) {
        let (a, b) = input_tuple();
        tree[(a - 1) as usize].push(Edge {to: (b - 1), id: i} );
        tree[(b - 1) as usize].push(Edge {to: (a - 1), id: i} );        
    }
    dfs(0, -1, -1, &tree, &mut colors);
    let mut max = 0;
    for c in &colors {
        if *c > max {
             max = *c;
        }
    }
    println!("{}", max);
    for c in colors {
        println!("{}", c);
    }    
}


Measured memory_bytes: 11004
#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() {
  ll n;
  cin>>n;
  if(n%2==1) {
    cout<<0<<endl;
    return 0;
  }
  ll d=10;
  ll ans=0;
  while(d<=n){
    ans+=n/d;
    d*=5;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;



int main(){
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int>v(2*n);
  rep(i, 2*n) v[i] = i+1;
  int k;
  rep(i, m){
    scanf("%d", &k);
    vector<int>tmp;
    if(k){
      REP(i, k, 2*n) tmp.PB(v[i]);
      rep(i, 2*n) tmp.PB(v[i]);
    }else{
      rep(i, n){
	tmp.PB(v[i]);
	tmp.PB(v[n+i]);
      }
    }
    v.swap(tmp);
  }

  rep(i, v.size()) printf("%d\n", v[i]);
  return 0;
}

Measured memory_bytes: 1212
N = int(input())
T = [int(x) for x in input().split()]
M = int(input())
PX = [[int(x) for x in input().split()] for i in range(M)]
for i in range(len(PX)):
  R = T[PX[i][0]-1]
  T[PX[i][0]-1] = PX[i][1]
  print(sum(T))
  T[PX[i][0]-1] = R

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

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

  int sum = 0;
  for (int i = 0; i < s.length()/2; i++) {
    if (s[i] != s[s.length()-1-i]) sum++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
// マニ

#include<bits/stdc++.h>
#define ll            long long 
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define rrep(i,a,b) for(ll int i=a;i>=b;i--)
#define all(a)      (a).begin(),(a).end()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define PI 3.14159265358979323846
#define tr(i, cont) for(auto i=cont.begin();i!=cont.end();i++)
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define trace(x)                 cerr << #x << ": " << x << "\n";
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
#define ar array
#define endl "\n"
using namespace std;

int main(){
    ios;
    ll n;
    cin>>n;
    cout<<1000-((n%1000 ==0)?1000:(n%1000));
}


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

int main() {
    int h, v, w, b, K=50;
    char map[2*K][2*K];
    cin >> w >> b;
    cout << 2 * K << " " << 2 * K << endl;
    for(h=0; h<2*K; h++){
        for(v=0; v<2*K; v++){
            if(h < K) map[h][v] = '#';
            else map[h][v] = '.';
        }
    }
    
    for(int i=0; i<w-1; i++){
        map[i%2 + 2*(i/K)][2*(i%K)] = '.';
    }
    
    for(int i=0; i<b-1; i++){
        map[2*K - i%2 - 2*(i/K) - 1][2*(i%K)] = '#';
    }
    
    for(h=0; h<2*K; h++){
        for(v=0; v<2*K; v++){
            cout << map[h][v];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
from collections import deque


def resolve():
    H, W = map(int, input().split())
    A, q = [], deque([])
    for i in range(H):
        A.append(list(input()))
        if '#' in A[i]:
            for j in range(W):
                if A[i][j] == '#':
                    q.append((i, j))

    dy = [0, 1, 0, -1]
    dx = [1, 0, -1, 0]
    cnt = -1

    # 1回目で各黒マスを拡張して，2回目以降は拡張した黒マスから拡張してく
    nq = deque([])
    while q:
        y, x = q.popleft()
        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]
            if 0 <= ny < H and 0 <= nx < W and A[ny][nx] == '.':
                nq.append((ny, nx))
                A[ny][nx] = '#'
        if q == deque([]):
            q = nq
            nq = deque([])
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 147420
int main(){
  int A,B,C;
   scanf("%d",&A);
   scanf("%d",&B);
   scanf("%d",&C);
  if (A==B&&A==C&&B==C){
     printf("No");
  }
  else if (A!=B&&A!=C&&B!=C) {
    printf("No");
  }
  else{
    printf("Yes");
  }
  return 0;
}

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

class Main{
/*
1
1
1
1
1
1
2
1
5
3
5
8
9
7
9
*/
	public void run(){
		int N = ni();
		long ans = 0;
		long pmax = 0;
		long[] a = new long[N];
		for(int i=0;i<N;i++){
			a[i] = ni();
		}
		for(int i=0;i<N;i++){
			long tmp = 0;
			if(a[i] % (pmax + 1) == 0){
				tmp = a[i] / (pmax + 1) - 1;
				ans += tmp;
				if(i > 0 && a[i] >= pmax + 2){
					
				}else{
					pmax++;
				}
			}else{
				tmp = a[i] / (pmax + 1);
				ans += tmp;
			}
//			debug(tmp);
		}
		out.println(ans);
	}

	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().run();
		out.flush();
	}

	public Main(){
	}

	int ni(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;	}

	long nl(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}

	double nd(){
		return Double.parseDouble(next());
	}

	String next(){
		int c;
		while(!isAlNum(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	String nextLine(){
		int c;
		while(!isAlNumOrSpace(c = read()));
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNumOrSpace(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
	private static boolean isAlNumOrSpace(int c){
		return isAlNum(c) || c == ' ' || c == '\t';
	}
	void debug(Object... os){
		out.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 23504
def a_kenken_race(N, A, B, C, D, S):
    # cond1: 道のりの途中に岩が2つ連続する場所があると、ゴールに到達できない
    # cond2: ふぬけ君の道のりの途中に空きが3マス分ないと、すぬけ君が追い越せない
    cond1 = '##' in S[A - 1:C] or '##' in S[B - 1:D]
    cond2 = '...' not in S[B - 2:D + 1]

    if cond1:
        ans = 'No'
    elif C > D and cond2:
        ans = 'No'
    else:
        ans = 'Yes'  # ふぬけ君から順にゴールさせる/すぬけ君が追い越す ことができる
    return ans

N, A, B, C, D = [int(i) for i in input().split()]
S = input()
print(a_kenken_race(N, A, B, C, D, S))

Measured memory_bytes: 3572