akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<vector>
int ans[200005];
using namespace std;
int main() {
	int n,m;
	cin >> n >> m;
	queue<int>q;
	vector<int>u[200005];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		if (x == 1) {
			q.push(y); ans[y] = 1;
		}
		else u[x].push_back(y);
		if (y == 1) {
			q.push(x); ans[x] = 1;
		}
		else u[y].push_back(x);

	}

	while (!q.empty()) {
		int now = q.front();
		for (int i = 0; i < u[now].size(); i++) {
			if (ans[u[now][i]] == 0)
			{
				ans[u[now][i]] = now;
				q.push(u[now][i]);
			}
		}
		q.pop();
	}
	for (int i=2;i<=n;i++)
		if (ans[i] == 0) {
			cout << "No" << endl;
			return 0;
		}

	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++)
		cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 12748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
typedef long long lint;
const int N=1e5+5;
const int mod=1e9+7;
int n;

namespace utils{
	template <class T> inline void apx(T &x,const T y){
		x<y?x=y:0;
	}
	template <class T> inline void apn(T &x,const T y){
		x>y?x=y:0;
	}
	inline int nxi(FILE *fd=stdin){
		int x=0;
		char c;
		while(((c=fgetc(fd))>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=fgetc(fd));
		while(x=x*10-48+c,(c=fgetc(fd))>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

template <class T>
inline int fpow(int x,T t){
	int ans=1;
	for(; t; x=(lint)x*x%mod,t>>=1){
		if(t&1) ans=(lint)ans*x%mod;
	}
	return ans;
}

namespace G{
	int rt,ans,cnt,fir[N<<1];
	int cir_dep,dep[N<<1];
	int eg_cnt,nd_cnt;
	bool vis[N<<1];
	std::vector <int> cir_l;
	struct edge{
		int to,nx;
	}eg[N<<2];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}

	bool dfs_cir(const int x,const int fa){
		++nd_cnt;
		vis[x]=1;
		bool on_cir=0;
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			++eg_cnt;
			if(y==fa) continue;
			if(vis[y]){
				if(~cir_dep) continue;
				cir_dep=dep[y];
				on_cir=1;
			}
			else{
				dep[y]=dep[x]+1;
				on_cir|=dfs_cir(y,x);
			}
		}
		on_cir&=dep[x]>=cir_dep;
		if(on_cir) cir_l.push_back(x);
		return on_cir;
	}

	int dfs_tot(const int x,const int fa){
		int sz=1;
		for(int i=fir[x]; i; i=eg[i].nx){
			const int y=eg[i].to;
			if(y==rt&&y!=fa) assert(y>fa);
			if(y==fa||y==rt) continue;
			if(y<fa) sz+=dfs_tot(y,x);
			else dfs_tot(y,x);
		}
		ans=(lint)ans*sz%mod;
		return sz;
	}

	int solve(const int x){
		cir_l.clear();
		eg_cnt=nd_cnt=0;
		cir_dep=-1;
		dfs_cir(x,0);
		if(eg_cnt!=nd_cnt<<1) return 0;
		const int sz=cir_l.size();
		assert(sz);
		int r=0,res=0;
		for(int i=1; i<(int)cir_l.size(); ++i){
			if(cir_l[i]<cir_l[r]) r=i;
		}
		{
			int f,x;
			if((f=r-1)<0) f=sz-1;
			if((x=f-1)<0) x=sz-1;
			ans=1;
			G::rt=cir_l[x];
			dfs_tot(cir_l[x],cir_l[f]);
			res=(res+fpow(ans,mod-2))%mod;
		}
		{
			int f,x;
			if((f=r+1)==sz) f=0;
			if((x=f+1)==sz) x=0;
			ans=1;
			G::rt=cir_l[x];
			dfs_tot(cir_l[x],cir_l[f]);
			res=(res+fpow(ans,mod-2))%mod;
		}
		return res;
	}
}

int main(){
	n=nxi();
	for(int i=1; i<=n<<1; ++i){
		int x=nxi(),y=nxi();
		G::add(x,y+n);
		G::add(y+n,x);
	}
	int res=1;
	for(int i=1; res&&i<=n<<1; ++i){
		if(!G::vis[i]) res=(lint)res*G::solve(i)%mod;
	}
	for(int i=1; i<=n<<1; ++i){
		res=(lint)res*i%mod;
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 2000000000
#define MOD 1000000007
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to, cost;
};
int dp[3001][3001][2];
int main() {
    int n, t;
    cin >> n >> t;
    vi a(n), b(n);
    t -= 1;
    rep(i, t) { dp[0][i][0] = 0; }
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, n) {
        rep(j, t + 1) {
            rep(k, 2) {
                if(j >= a[i]) {
                    chmax(dp[i + 1][j][k],
                          max(dp[i][j][k], dp[i][j - a[i]][k] + b[i]));
                } else {
                    chmax(dp[i + 1][j][k], dp[i][j][k]);
                }
                if(k == 0) {
                    chmax(dp[i + 1][j][k + 1], dp[i][j][k] + b[i]);
                }
            }
        }
    }
    // REP(i, 2, n + 1) {
    //     rep(j, t + 1) cout << dp[i][j][1] << " ";
    //     cout << endl;
    // }
    cout << max(dp[n][t][0], dp[n][t][1]) << endl;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  if (A==B) cout << "Draw" << endl;
  else if (A==1) cout << "Alice " << endl;
  else if (B==1) cout << "Bob" << endl;
  else if (A>B) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}


Measured memory_bytes: 256
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
	import java.util.*;
public class Main
{
	public static void main(String[] args) {
    Scanner sc  = new Scanner(System.in);
   String s = sc.next();
  
   if( s.charAt(2)==s.charAt(3)&&s.charAt(4) == s.charAt(5)){
       System.out.println("Yes");
   }else{
     System.out.println("No");}
}}


Measured memory_bytes: 21844
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d",&W);
	scanf("%d",&H);
	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&r);
	if(W>=x+r&&H>=y+r&&0<=x-r&&0<=y-r) {
		printf("Yes\n");
	}
	else {
	    printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 1976
S = gets.chomp; x, y = gets.split.map(&:to_i)

x -= $~[0].size if /^F+/ =~ S
hs, vs, h_f = [], [], true
S.scan(/(T+)(F+)/).each do |ts, fs|
  h_f = !h_f if ts.size.odd?
  (h_f ? hs : vs) << fs.size
end

def go(as)
  as.inject([0]){|res, a| res.flat_map{|k| [k + a, (k - a).abs]}.uniq}
end

puts go(hs).member?(x.abs) && go(vs).member?(y.abs) ? 'Yes' : 'No'

Measured memory_bytes: 5372
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N, X = [], []


def set_inputs():
    global N, X
    while True:
        n, x = get_li()
        if n == x == 0:
            break
        N.append(n)
        X.append(x)
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    for n, x in zip(N, X):
        s = set()
        for i in range(1, min(n + 1, x - 1)):
            for j in range(1, min(n + 1, x - i)):
                k = x - i - j
                if i == j or j == k or k == i or k < 1 or n < k:
                    continue
                a, b, c = sorted([i, j, k])
                s.add((a, b, c))
        print(len(s))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()



Measured memory_bytes: 6936
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
//const int INF = 100100100;
const int INF = (1LL<<32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

string divide[4] = { "dream","dreamer","erase","eraser" };

string s;
bool can = false;

bool DFS(int f) {
	if (f == s.size()) return true;
	bool can2 = false;
	rep(i, 4) {
		string d = divide[i];
		if (s.substr(f, d.size()) == d) {
			can2 = DFS(f + d.size());
		}
		if (can2) {
			return true;
		}
	}
	return false;
}

signed main() {
	ios::sync_with_stdio(false);
	cin >> s;
	can = DFS(0);
	if (can) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}



Measured memory_bytes: 2640
n = gets.to_i;
i = 1;

loop do
  x = i
  if (x % 3 == 0) then
    printf " %d", i
  else
    loop do
      if (x % 10 == 3 ) then
        printf " %d", i
        break
      end
      x /= 10
      break if x == 0
    end
  end
  i += 1
  break if (i > n)
end

printf "\n";

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<long long> v;
    long long ans = 0;
    for(int i = 0; i < n; i++){
        long long a, b;
        cin >> a >> b;
        v.push_back(a+b);
        ans -= b;
    }
    sort(v.rbegin(), v.rend());
    for(int i = 0; i < n; i++){
        if(i%2 == 0) ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <functional>


#define rep(i, n) for(int i = 0, end = (int)(n); i < end; i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    ll n;
    ll a = 0;
    ll b = 0;
    vector<ll> input;
    cin >> n;
    rep(i, n) {
        ll temp;
        cin >> temp;
        input.push_back(temp);
    }

    sort(input.begin(), input.end(), greater<ll>());

    rep(i, n) {
        if (i % 2 == 1) {
            b += input[i];
        } else {
            a += input[i];
        }
    }
    cout << a - b << endl;
    return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n;
	cin >> n;

	vector<int> a;
	vector<int> pos;
	a.resize(n);
	pos.resize(n);

	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		pos[a[i] - 1] = i;
	}

	multiset<int> s = {-1, -1, n, n};

	long long ans = 0;

	for(int i = n - 1; i >= 0; --i) {
		auto it = s.lower_bound(pos[i]);

		int x = *it;
		int y = *next(it);
		int w = *prev(it);
		int v = *prev(prev(it));

		ans += 1LL * (i + 1) * ((y - x) * (pos[i] - w) + (w - v) * (x - pos[i]));

		s.emplace(pos[i]);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383
#define pb push_back
#define all(s) s.begin(),s.end()


int main (){
    fast;
    
    string s;
    cin>>s;
    int n=  s.length();
    if(s[n-1] == 's'){
        s += "es";
    }else{
        s += "s";
    }
    cout<<s<<endl;
}

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

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

  string s;
  cin >> s;
  int n=(int)s.size();
  for(int i=0;i<n;i++){
    if(i%2){
      if(s[i] == 'R'){
        cout << "No\n";
        return 0;
      }
    }else{
      if(s[i] == 'L'){
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}


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

int time(int x) {
  return (x+9)/10 * 10;
}

int restime(int y) {
  return time(y) - y;
}

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  
  int ans = time(a) + time(b) + time(c) + time(d) + time(e);
  ans -= max({restime(a) , restime(b) , restime(c) , restime(d) , restime(e)});
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    ll m1=-1;
    ll m2=-1;
    rep(i,n){
        cin >> x[i];
        y[i]=x[i];
    }
    sort(x.begin(),x.end());
    m1=x[n/2-1];
    m2=x[n/2];
    rep(i,n){
        if(y[i]<=m1){
            cout << m2 << endl;
        }
        else{
            cout << m1 << endl;
        }
    }
    
    return 0;
} 

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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	int a[3];
	for(int i=0;i<3;++i){
		scanf("%d",&a[i]);
	}

	sort(a,a+3,greater<int>());
	int ans = a[0]*10 + a[1] + a[2];
	printf("%d\n",ans);

	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long x,y;
    cin>>x>>y;
    
    int ct=0;
    while(x<=y){
        x*=2;
        ct++;
    }
    cout<<ct;
    
    
    
    return 0;
}

Measured memory_bytes: 256
s='#';n,*a=open(0).readlines();n=int(n);f=sum(n==t.count(s)for t in zip(*a));r=range(n);print(-all(not s in t for t in a)or min(n*2-f-a[i].count(s)+all(s<a[j][i]for j in r)for i in r))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  string t; cin >> t;
  for (char& c: t) if (c == '?') c = 'D';
  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3744
#for  _ in range(int(input())):
    #n, k = map(int, input().split())

n = int(input())

arr = list(map(int, input().split()))
arr.sort()
if arr[0]==0:
    print(0)
else:
    arr=arr[::-1]
    ans=1
    for i in range(n):
        ans*=arr[i]
        if ans>10**18:
            ans=-1
            break
    print(ans)


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

int main() {
  long T1, T2, A1, A2, B1, B2; cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  if (T1*A1+T2*A2==T1*B1+T2*B2) { cout << "infinity" << endl; return 0; }
  long M1 = T1*A1-T1*B1, M2=T2*A2-T2*B2;
  if (M1+M2<0) {M1 = -M1; M2=-M2;}
  if (M2 > 0) cout<<(max(0L, (M2-1)/(M1+M2)-1) + max(0L, M2/(M1+M2)))<<endl;
  else cout<<(max(0L, (M2)/(M1+M2)-1) + max(0L, (M2+1)/(M1+M2)-1))<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std ;
ll rr[1010][3];
vector<vector<pair<double,ll> > >g;
const double INF = 100000000000000;
set < pair<double,ll> > q;
int main()
{
    ios_base::sync_with_stdio(false);
   ll x1,y1,x2,y2;
   cin>>rr[0][0]>>rr[0][1]>>rr[1][0]>>rr[1][1];
   ll n;
   cin>>n;
   g.resize(n+4);
   for(int i=2;i<=n+1;i++)
    {
        cin>>rr[i][0]>>rr[i][1]>>rr[i][2];
    }
    for(int i=0;i<=n+1;i++)
    {
        for(int j=0;j<=n+1;j++)
        {
            if(j!=i)
            {

                double p=sqrt((rr[i][0]-rr[j][0])*(rr[i][0]-rr[j][0])+(rr[i][1]-rr[j][1])*(rr[i][1]-rr[j][1]));
              //  cout<<p<<endl;
                p-=(rr[i][2]+rr[j][2]);
            //    cout<<i<<"  "<<j<<"  "<<p<<endl;
                if(p<0)p=0;
                g[i].pb(mp(p,j));
            }
        }
    }


    int s = 0;
    vector<long double> d ;
    d.resize(n+4,INF);
    d[s] = 0;

    q.insert (make_pair (d[s], s));
    while (!q.empty()) {
        ll v = q.begin()->second;
        q.erase (q.begin());

            for (ll j=0; j<g[v].size(); ++j) {
                    ll to = g[v][j].second;
                    double len = g[v][j].first;
                    if (d[v] + len < d[to]) {
                        q.erase (make_pair (d[to], to));
                        d[to] = d[v] + len;

                        q.insert (make_pair (d[to], to));
                    }
                }
            }
    cout<<setprecision(10) << fixed << d[1]<<endl;

}


Measured memory_bytes: 16512
import java.util.Scanner;

class NumTh{
	static long mod=1000000007; // 10e9 + 7
	static long GCD(long x, long y) {
		if(Math.max(x, y) % Math.min(x, y) == 0) return Math.min(x, y);
		return GCD(Math.min(x, y), Math.max(x, y) % Math.min(x, y));
	}
	static int GCD(int x, int y) {
		return (int)GCD((long)x, (long)y);
	}
    // $a^x$ mod m
	static long pow(long a, long x, long m){
		if(x == 1) return a % m;
		else if(x % 2 == 0) return pow((a * a) % m, x / 2, m) % m;
		else return (a * pow((a * a) % m, x / 2, m)) % m;
	}
	static long Choose(long n, long k) {
		long res = 1;
		for(long i = n; i >= n - k + 1; i--) {
			res *= i; res %= mod;
			res *= inv(k - n + i, mod); res %= mod;
		}
		return res % mod;
	}
	static long inv(long a, long mod) {
		if(GCD(a, mod) != 1) return -1; // there is no inverse
		x = 0; y = 0;
		extGCD(a, mod, 0);
		return (x + mod) % mod;
	}
	/* Calculate the solution of ax + by = gcd(a, b) */
	// Usage: extgcd(a, b, 0)
	static long x = 0, y = 0;
	static long extGCD(long a, long b, int c) {
		long d = a;
		if(b != 0) {
			d = extGCD(b, a % b, (c + 1) % 2);
			if(c == 0) y -= (a / b) * x;
			else x -= (a / b) * y;
		}else {
			x = (c == 0) ? 1 : 0;
			y = (c == 0) ? 0 : 1;
		}
		return d;
	}
}

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong(), M = sc.nextLong(), K = sc.nextLong();
		long A = N * M; A %= NumTh.mod; A *= (M - 1); A %= NumTh.mod; A *= (M + 1); A %= NumTh.mod; A *= NumTh.inv(6, NumTh.mod); A %= NumTh.mod;
		long B = M * N * (long)(N - 1); B %= NumTh.mod;
		long D = ((M * (long)(N + 1) + (long)(M - 1) * (long)(M + 1))); D %= NumTh.mod;
		B *= D; B %= NumTh.mod; B *= NumTh.inv(6, NumTh.mod); B %= NumTh.mod;
		long C = NumTh.Choose(N * M - 2, K - 2);
		System.out.println((((A + B) % NumTh.mod) * C) % NumTh.mod);
	}
}

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    set < ll > s;
    ll a, b, c;
    cin >> a >> b >> c;
    s.ins(a), s.ins(b), s.ins(c);
    cout << (sz(s) == 2 ? "Yes\n" : "No\n");
    
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意
MOD = 10**9+7


n,k = [int(i) for i in readline().split()]
g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

ans = 1
ok = [k]*n

def dfs(v,p): #p: 親
#    print(v,p)
    global ans
    ans *= ok[p]
    ans %= MOD
    if p!=v: ok[p] -= 1
    ok[v] -= 1
    for c in g[v]:
        if c == p: continue
        ok[c] -= 1
        dfs(c,v)

dfs(0,0)
#print(ok)
print(ans)


Measured memory_bytes: 88108
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;
const long long mod = 1e9 + 7;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;

	vector<int> oks(N + 1, true);
	for (int i = 0; i < M; i++) {
		int a;
		cin >> a;
		oks[a] = false;
	}
	vector <long long int> dp(N + 1);
	dp[0] = 1;
	for (int now = 0; now < N; now++) {
		for (int next = now + 1; next <= min(N, now + 2); next++) {
			if (oks[next]) {
				dp[next] += dp[now];
				dp[next] %= mod;
			}
		}
	}

	cout << dp[N] << endl;
}




Measured memory_bytes: 1408
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,k,x,y,ans;
vector <LL> g[100010];

void dfs(int pos,int no)
{
	LL all=k-1-(no==0 ? 0:1),now=all;
	rep(i,g[pos].size()) 
	{
		if(g[pos][i]==no) continue;
		ans=ans*(now--)%MOD;
		dfs(g[pos][i],pos);
	}
}

int main()
{
	cin>>n>>k;
	rep(i,n-1)
	{
		scanf("%I64d%I64d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	repn(i,n)
	{
		if(g[i].size()>k)
		{
			puts("0");
			rt0;
		}
	}
	ans=k;
	dfs(1,0);
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 11520
#include<iostream>
#include<algorithm>
using namespace std;
int a[10001],ans=0,n;
int main()
{
    cin>>n;
    for(int i=1;i<=2*n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+2*n);
    for(int j=1;j<=2*n;j+=2) ans+=a[j];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let a = xs[0] + xs[1];
   let b = xs[0] - xs[1];
   let c = xs[0] * xs[1];
   if(a >= b && a >= c){
    console.log(a);
   }else if(b >= a && b >= c){
    console.log(b);
   }else if(c >= a && c >= b){
    console.log(c);        
   }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	string s; cin >> s;
	s = "2018" + s.substr(4);
	cout << s << endl;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() string {
	return scanString(sc)
}

func resolve(str string) int {
	lMax, r := 0, 0
	for i := 0; i < len(str); {
		h, l := str[i], 0
		{
			j := i
			for ; j < len(str); j++ {
				if str[j] != h {
					break
				}
				l++
			}
			i = j
		}
		r += (l - 1) * l >> 1
		switch h {
		case '>':
			r += max(lMax, l)
			lMax = 0
		case '<':
			lMax = l
		}
	}
	r += lMax
	return r
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

#define MAX_N 160000

class UnionFind {
private:
  // 親と木の深さ
  int par[MAX_N];
  int rank[MAX_N];
public:
  void init(int n);
  int find(int x);
  void unite(int x, int y);
};

// 要素数nで初期化
void UnionFind::init (int n) {
  for(int i=0; i<n; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}

// 要素xの親を求める
int UnionFind::find(int x) {
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void UnionFind::unite(int x, int y) {
  // xとyの親
  x = find(x);
  y = find(y);
  if(x == y) return;

  // yのほうが深さが深い　xの親はyの親
  if(rank[x] < rank[y]) par[x] = y;
  else {
    par[y] = x;
    if( rank[x] == rank[y] ) rank[x]++;
  }
}

int h, w;
string s[400];
UnionFind uf;
const int dx[]={-1,0,1,0}, dy[]={0,1,0,-1};

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

	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	uf.init(h*w);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			for (int k = 0; k < 4; k++) {
				int nx = i+dx[k], ny = j+dy[k];
				if(nx>=0 && nx<h && ny>=0 && ny<w && s[i][j]!=s[nx][ny]){
					uf.unite(j+w*i, ny+w*nx);
				}
			}
		}
	}
	map< int, pair<int, int> > mp;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if(s[i][j] == '#') mp[uf.find(j+w*i)].first++;
			else mp[uf.find(j+w*i)].second++;
		}
	}
	ll ans = 0;
	for(auto itr : mp){
		ans += (ll)itr.second.first * (ll)itr.second.second;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10240
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {
	static int[] vx = new int[] {-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0 ,0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1};
	static int[] vy = new int[] {-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1};
	static int[] vz = new int[] {-1, 0, 1,-1, 0 ,1,-1, 0, 1,-1, 0, 1,-1, 1,-1, 0, 1,-1, 0, 1,-1, 0 ,1,-1, 0, 1};
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int caseX = 1;
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			boolean[][][] state = new boolean[5][5][5];
			for(int i = 0; i < 5; i++) {
				for(int j = 0; j < 5; j++) {
					String in = sc.next();
					for(int k = 0; k < 5; k++) {
						if(in.charAt(k) == '1') state[i][j][k] = true;
					}
				}
			}
			int m1 = sc.nextInt();
			int[] a = new int[m1];
			for(int i = 0; i < m1; i++) {
				a[i] = sc.nextInt();
			}
			int m2 = sc.nextInt();
			int[] b = new int[m2];
			for(int i = 0; i < m2; i++) {
				b[i] = sc.nextInt();
			}
			Arrays.sort(a);
			Arrays.sort(b);
			for(int day = 0; day < n; day++) {
				int[][][] count = new int[5][5][5];
				for(int i = 0; i < 5; i++) {
					for(int j = 0; j < 5; j++) {
						for(int k = 0; k < 5; k++) {
							for(int l = 0; l < vx.length; l++) {
								int tx = i + vx[l];
								int ty = j + vy[l];
								int tz = k + vz[l];
								if(!rangeCheck(tx,ty,tz)) continue;
								count[i][j][k] += state[tx][ty][tz]?1:0;
							}
						}
					}
				}
				for(int i = 0; i < 5; i++) {
					for(int j = 0; j < 5; j++) {
						for(int k = 0; k < 5; k++) {
							int tmp = count[i][j][k];
							if(state[i][j][k]) {
								if(Arrays.binarySearch(b, tmp) < 0) state[i][j][k] = false;
							}
							else {
								if(Arrays.binarySearch(a, tmp) >= 0) state[i][j][k] = true;
							}
						}
					}
				}
			}	
			if(caseX != 1) System.out.println();
			System.out.println("Case " + caseX++ + ":");
			for(int i = 0; i < 5; i++) {
				for(int j = 0; j < 5; j++) {
					for(int k = 0; k < 5; k++) {
						System.out.print(state[i][j][k]?"1":"0");
					}
					System.out.println();
				}
				if(i != 4)
				System.out.println();
			}
		}
	}
	static boolean rangeCheck(int a, int b, int c) {
		if(a < 0 || b < 0 || c < 0 || a >= 5 || b >= 5 || c >= 5) return false;
		return true;
	}
 }

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

using namespace std;

typedef long long ll;

const int N=1e5+5;

vector<int> a[N];

int main()
{

    string  c;
    cin >> c;
    int ans=0,ma=0;
    for(int i=0;i<c.size();i++){
    if(c[i]=='A') ans++;
    else if(c[i]=='G') ans++;
    else if(c[i]=='C') ans++;
    else if(c[i]=='T') ans++;
    else ma=max(ma,ans),ans=0;}
    cout << max(ma,ans) << endl;
    return 0;
}


Measured memory_bytes: 2560
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b = na()

c = int(min(a//0.08,b//0.1))

while True:
	d = int(c*0.08)
	e = int(c*0.1)
	if d == a and e == b:
		print(c)
		exit()
	if d > a or e > b:
		print(-1)
		exit()
	c+=1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

struct mod_int {
    ll val;
    constexpr mod_int(ll v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr mod_int operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr mod_int operator + (const mod_int& r) const noexcept { return mod_int(*this) += r; }
    constexpr mod_int operator - (const mod_int& r) const noexcept { return mod_int(*this) -= r; }
    constexpr mod_int operator * (const mod_int& r) const noexcept { return mod_int(*this) *= r; }
    constexpr mod_int operator / (const mod_int& r) const noexcept { return mod_int(*this) /= r; }
    constexpr mod_int& operator += (const mod_int& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr mod_int& operator -= (const mod_int& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr mod_int& operator *= (const mod_int& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr mod_int& operator /= (const mod_int& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            ll t = a / b;
            ll tmp = 0;
            // tmp = a; a = b; b = tmp; としてるのは、
            // swap()がconstexprじゃなくて使えないから
            a -= t * b; tmp = a; a = b; b = tmp; 
            u -= t * v; tmp = u; u = v; v = tmp;
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const mod_int& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const mod_int& r) const noexcept {
        return this->val != r.val;
    }
    friend ostream& operator << (ostream &os, const mod_int& x) noexcept {
        return os << x.val;
    }
    friend constexpr mod_int modpow(const mod_int &a, ll n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = mod_int;

int main() {
    int n;
    cin >> n;
    vector<int> cnt(65, 0); // cnt[i]:下から見てiビット目が立っているaの数
    rep(i, 0, n)
    {
        ll a;
        cin >> a;

        int pos = 0;
        while (a > 0)
        {
            if (a & 1 == 1) cnt[pos]++;
            a >>= 1;
            pos++;
        }
    }

    mint ans = 0;
    mint mn = n;
    rep(i, 0, cnt.size())
    {
        mint num1 = cnt[i];
        mint num0 = mn - num1;
        mint res = num1 * num0;
        ans += modpow(mint(2), i) * res;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#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 1000005
//#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);
}
int64 N,A;

void Solve() {
    read(N);read(A);
    int64 ans = N;
    for(int i = 2 ; i <= 40 ; ++i) {
	if((1LL << i) > N) break;
	int64 tmp = (i - 1) * A;
	int64 l = 1,r = N;
	while(l < r) {
	    int64 mid = (l + r + 1) >> 1;
	    int64 t = 1;
	    bool f = 1;
	    for(int j = 1 ; j <= i ; ++j) {
		if(mid > N / t) {f = 0;break;}
		t = t * mid;
	    }
	    if(f) l = mid;
	    else r = mid - 1;
	}
	int64 t = 1;
	for(int j = 1 ; j <= i ; ++j) {
	    t = t * l;
	}
	int64 cnt = l * i;
	while(t < N) {
	    t /= l;
	    if((l + 1) <= N / t) {t = t * (l + 1); ++cnt;}
	    else {++cnt;break;}
	}
	ans = min(ans,tmp + cnt);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


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

int main(){
    int W, H;
    int x, y;
	cin >> W >> H >> x >> y;
  	float A;
    A = (float)H*float(W)/(float)2;
    int B = 0;
  	if((x == W/2 && x == (W+1)/2) && (y == H/2 && y == (H+1)/2)) B = 1;
    cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
# 2209~
# 2211 左端からひとつずつ移動していって，カウントする．今の場所より高くなったらカウントを0にして繰り返す

N = int(input())
H = list(map(int,input().split()))
from collections import deque
H = deque(H)

max_count = 0
count = 0
prev = -1
while H:
    now = H.popleft()
    if prev>=now:
        count += 1
        prev = now
        continue
    max_count = max(max_count, count)
    count = 0
    prev = now
max_count = max(max_count, count)
print(max_count)


Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
const ll mod = 1000000007;
int main(){
	ll N, T;
	cin >> N >> T;
	vl t(N);
	REP(i,N){
		cin >> t[i];
	}
	ll ans = 0;
	REP(i, N-1){
		if(t[i+1] - t[i] > T){
			ans += T;
		} else {
			ans += t[i+1] - t[i];
		}
	}
	ans += T;
	cout << ans << endl;
}

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

signed main(){
    long long n;
    cin >> n;
    vector<long long> v(n);
    for(int i = 0; i < n; ++i){
	        cin >> v[i];
	    }
	    long long ans = 0,temp = v[0];
	    for(int i = 1; i < n; ++i){
	        if(temp > v[i]){
	            ans += (temp - v[i]);
	        }
	        temp = max({temp,v[i],v[i-1]});
	    }
	    cout << ans << endl;
    return 0;
}


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

int main()
{
	int K, S;

	cin >> K >> S;

	int ans = 0;

	for (int x = 0; x <= K; x++)
	{
		for (int y = 0; y <= K; y++)
		{
			int z = S - x - y;

				if (0<=z && z<=K)
				{
					ans++;
				}
			
		}
	}

	cout << ans;

}

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

const int maxn(1e5 + 5);

int n, m, b[maxn], que[maxn], len, vis[maxn];
ll k, f[maxn], g[maxn];

int main() {
	int i, j;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%lld", &f[i]), b[i] = i;
	for (i = n; i; --i) f[i] -= f[i - 1];
	scanf("%d%lld", &m, &k);
	for (i = 1; i <= m; ++i) scanf("%d", &j), swap(b[j], b[j + 1]);
	for (i = 1; i <= n; ++i)
		if (!vis[i]) {
			j = b[i], len = 1, que[0] = i, vis[i] = 1;
			while (!vis[j]) que[len++] = j, vis[j] = 1, j = b[j];
			for (j = 0; j < len; ++j) g[que[j]] = f[que[(k + j) % len]];
		}
	for (i = 1; i <= n; ++i) g[i] += g[i - 1], printf("%lld\n", g[i]);
	return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

ll dp[1010][1010];

int main(){
  int H, W; cin >> H >> W;
  string S[H];
  rep(i, H){
    cin >> S[i];
  }
  dp[0][0] = 1;
  rep(i, W){
    rep(j, H){
      if(i+1<W && S[j][i+1]=='.' && S[j][i]=='.'){  
        dp[i+1][j] += dp[i][j];   dp[i+1][j] %= mod;
      }
      if(j+1<H && S[j+1][i]=='.' && S[j][i]=='.'){
        dp[i][j+1] += dp[i][j]; dp[i][j+1] %= mod;
      }
    }
  }
  cout << dp[W-1][H-1] << endl;
  
}

Measured memory_bytes: 9216
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let S = scan.word::<String>();

    println!("{}", &S[..3]);
}


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

const int SIZE = 1e6;

bool cmp_(int A, int B){
	return A > B; 
}

int main() {
	int Arr[4]; cin >> Arr[1] >> Arr[2] >> Arr[3];
	sort(Arr + 1, Arr + 4, cmp_);
	cout << Arr[1] * 10 + Arr[2] + Arr[3] << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ABs = []
for i in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  ABs.append((a, b))
r = 0
for i in range(M):
  E = [[] for i in range(N)]
  for j in range(M):
    if j == i:
      continue
    a, b = ABs[j]
    E[a].append(b)
    E[b].append(a)
  V = [False]*N
  V[0] = True
  q = [0]
  while q:
    c = q.pop()
    ns = E[c]
    for n in ns:
      if not V[n]:
        V[n] = True
        q.append(n)
  if not all(V):
    r += 1
print(r)


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

using namespace std;

int main()
{
   int A, B, M;
   cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    for (int i = 0; i < A; i++)cin >> a[i];
    for (int i = 0; i < B; i++)cin >> b[i];
    int minA = *min_element(a.begin(), a.end());
    int minB = *min_element(b.begin(), b.end());
    int ans = minA+minB;
    for (int i = 0; i < M; i++) {
          int x, y, c;
          cin >> x >> y >> c; x--; y--;
          ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	map<int, int>m;
	rep(i, N) {
		int num;
		cin >> num;
		m[num]++;
	}
	int cnt = 0;
	for (auto i : m)if (i.second & 1)cnt++;
	cout << cnt;
}

Measured memory_bytes: 6528
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;

int main(){
    long long int a=1000000000000;
    long long int b=0;
    for(long long int i=1;i<=a;i++)b++;
    int alice,bob;cin>>alice>>bob;
    if(alice==1)alice+=100;if(bob==1)bob+=100;
    if(alice==bob)printf("Draw");
    else if(alice<bob)printf("Bob");
    else printf("Alice");
    
    return 0;
}




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

int main() {
    int n; cin >> n;
    int x[1000];
    rep(i,n) cin >> x[i];
    sort(x, x+n);
    cout << ((x[n-1] - x[0])+1) / 2 << endl;
}


Measured memory_bytes: 3144
#include <stdio.h>

int main() {
     int n, count=0, max=0;
     scanf("%d", &n);
     int h[100005];
     for (int i = 0; i < n; i++) {
          scanf("%d", &h[i]);
     }

     for (int i = 1; i < n; i++) {
          if (h[i-1] < h[i]) {
               count=0;
          } else {
               ++count;
               if (count>max) {
                    max = count;
               }
          }
     }
     printf("%d\n", max);

     return 0;
}


Measured memory_bytes: 512
from functools import reduce
from operator import add

inputs = input().split()

num = int(inputs[0])
begin = int(inputs[1])
end = int(inputs[2])
result = list()

for i in range(1, num + 1):
    l = [int(x) for x in list(str(i))]
    if begin <= reduce(lambda x, y: x + y, l) <= end:
        result.append(i)

print(sum(result))

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int w, a, b = 0;
	cin >> w >> a >> b;
	int ans = 0;

	if (a <= b && b <= a + w)
	{
		ans = 0;
	}
	else if (a > b)
	{
		ans = abs(a - (b + w));
	}
	else if (a < b)
	{
		ans = abs(b - (a + w));
	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 256