akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String str = br.readLine();
	    int n = Integer.parseInt(str);
	    str = br.readLine();
	    String [] ary = str.split(" ");
//	    int[] kaka = new int[n];
//	     for (int i=0 ; i<n ; i++){
//	    	 kaka[i] = Integer.parseInt(ary[i]);
//	     }

    //     Collection.reverse(ary);
	   //  System.out.println(Arrays.toString(kaka));
	    
	    for (int i= n-1; i>=0 ; i--){
	    	if (i !=0 ){
	    	 System.out.print(ary[i]+" ");}
	    	else { System.out.print(ary[i]);
	    	       System.out.print("\n");
	    	}
	     }

	}

	}

Measured memory_bytes: 24416
//abc103_d.cpp
//Sat Jul 21 20:51:00 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 100000000
using namespace std;
using ll=long long;
typedef pair<int,int> P;
vector<int> G[100000];

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];
		a[i]--;
		b[i]--;
		G[a[i]].push_back(b[i]);
	}
	int ans = 0;
	int rend = INF;
	for (int i=0;i<n;i++){
		if (rend <= i){
			ans++;
			rend = INF;
		}
		for (int j=0;j<G[i].size();j++){
			if (rend>G[i][j]){
				rend = G[i][j];
			}
		}
	}

	if (rend!=INF){
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 6528
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B, C = map(int, raw_input().split())
print max(0, C - (A - B))

Measured memory_bytes: 2812
#include<iostream>
#include<vector>
#include<string>

using namespace std;

char returnc(char c){
  if('a'<=c && c<='z'){
    if(c=='z')return 'a';
    return ++c;
  }
  return c;
}
int main(void){
  string s;
  getline(cin,s);
  string ss;
  vector<string> str;
  for(int i = 0 ; i < s.size() ; i ++){
    if(s[i] == ' ' || s[i] == ','|| s[i] == '.'){
      if(3<=ss.size() && ss.size() <= 6){
      str.push_back(ss);
      }
      ss="";
    }else{
      ss+= s[i];
    }
  }
  for(int i = 0 ; i < str.size()-1 ; i ++){
    cout<<str[i]<<" ";
  }
  cout<<str[str.size()-1]<<endl;
}

Measured memory_bytes: 1180
package main

import "fmt"

func main() {
	var  N, A, B int64
	fmt.Scanf("%d %d %d", &N, &A, &B)
	s := N / (A + B)
	var t int64
	if N % (A + B) < A{
		t = N % (A + B)
	} else {
		t = A
	}
	fmt.Printf("%d\n", s * A + t)
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
    ll ans = -K;
    ans += 60 * (H2 - H1);
    ans += (M2 - M1);
    cout << ans << endl;
}

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


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

#define int long long

void solve(int tt)
{
    int n,m;
    cin>>n>>m;
    int h[n+5],ans[n+5];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    for(int i=1;i<=n;i++)    
        ans[i]=1;
    for(int i=1;i<=m;i++)    
    {
        int u,v;
        cin>>u>>v;
        if(h[u]<=h[v])
            ans[u]=0;
        if(h[u]>=h[v])    
            ans[v]=0;
    }
    int res=0;
    for(int i=1;i<=n;i++)
    {
        if(ans[i])
            res++;
    }
    cout<<res;
}

int32_t main()
{
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
        solve(i);
}

Measured memory_bytes: 5200
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    r = 0
    l = 0
    ans = [0] * len(s)
    for i in range(1, len(s)):
        if s[i] == "L" and s[i-1] == "R":
            l = i
        elif s[i] == "R" and s[i-1] == "L":
            ans[l-1] = ((l-r) + 1) // 2 + (i-l) // 2
            ans[l] = ((l-r) + (i-l)) - ans[l-1]
            r = i
    ans[l - 1] = ((l - r) + 1) // 2 + (i - l + 1) // 2
    ans[l] = ((l - r) + (i - l + 1)) - ans[l - 1]
    print(*ans)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 47548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        ll v,p;
        cin>>n>>m>>v>>p;
        ll a[n],a1[n];
        fo(i,n)cin>>a1[i];
        sort(a1,a1+n);
        fo(i,n)a[i]=a1[n-1-i];
        ll ans=0;
        ll sum=0;
        fo(i,n){
            if(i<p )ans++;
            else if(p-1+ n-i >=v){
                //cout<<4;
                if(m+a[i]>=a[p-1])ans++;
            }
            else {
                flag=0;
                ll temp=p-1+n-i;
                if((sum+(v-temp)*m )%(n-temp)!=0)flag=1;
                if(m+a[i]>= max(a[p-1], (sum+(v-temp)*m )/(n-temp)+ flag ) )ans++;
                else break;
            }
            if(i>=p-1)sum+=a[i];
        }
        cout<<ans;
        
        
    }

    return 0;
}


Measured memory_bytes: 1792
#ifndef call_from_test
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#endif
//BEGIN CUT HERE
template<typename T>
struct BellmanFord{
  struct edge{
    int u,v;
    T w;
    edge(){}
    edge(int u,int v,T w):u(u),v(v),w(w){}
  };

  int n;
  vector< vector<int> > G;
  vector<int> used,reach;
  BellmanFord(int n):n(n),G(n),used(n,0),reach(n,1){}

  vector<edge> es;
  void add_edge(int u,int v,T c){
    es.emplace_back(u,v,c);
    G[u].emplace_back(v);
  }

  vector<T> build(int from,int &neg_loop){
    const T INF = numeric_limits<T>::max();
    vector<T> ds(n,INF);
    ds[from]=0;
    for(int j=0;j<n;j++){
      bool update=0;
      for(auto e:es){
        if(!reach[e.u]||!reach[e.v]||ds[e.u]==INF) continue;
        if(ds[e.v]>ds[e.u]+e.w){
          ds[e.v]=ds[e.u]+e.w;
          update=1;
        }
      }
      if(!update) break;
      if(j==n-1){
        neg_loop=1;
        return ds;
      }
    }
    neg_loop=0;
    return ds;
  }

  void dfs(int v){
    if(used[v]) return;
    used[v]=1;
    for(int u:G[v]) dfs(u);
  }

  T shortest_path(int from,int to,int &neg_loop){
    for(int i=0;i<n;i++){
      fill(used.begin(),used.end(),0);
      dfs(i);
      reach[i]=used[to];
    }
    return build(from,neg_loop)[to];
  }
};
//END CUT HERE
#ifndef call_from_test
//INSERT ABOVE HERE
signed main(){
  int n,m,p;
  cin>>n>>m>>p;
  BellmanFord<int> G(n);
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G.add_edge(a,b,p-c);
  }
  int neg_loop;
  int res=G.shortest_path(0,n-1,neg_loop);
  if(neg_loop){
    cout<<-1<<endl;
    return 0;
  }
  cout<<max(-res,0)<<endl;
  return 0;
}
/*
  verified on 2019/08/10
  https://atcoder.jp/contests/abc137/tasks/abc137_e
*/
#endif


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

int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if (H==0 && W==0) return 0;
        rep(i,H) {
            rep(j,W) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
datalist = []
Flag = True
for i in range(3000):
    if Flag:
        x, y = map(int, input().split())
        if x == 0 and y == 0:
            Flag = False
        else:
            datalist.append((x, y))
#print(datalist)
for (i,j) in datalist:
    if i < j :
        print("{} {}".format(i, j))
    else:
        print("{} {}".format(j, i))



Measured memory_bytes: 6020
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cctype>
#include <complex>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1<<30;
const int EPS = 1e-15;
#define PB push_back
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int > Pii;
int main(){
	int m;
	scanf("%d",&m);
	while(m--){
		map<string,int> memo;
		string str;
		cin >> str;
		reps(i,1,str.size()){
			string s(str,0,i);
			string e(str,i,str.size());
			string r_s,r_e;
			r_s = s;
			r_e = e;
			reverse(r_s.begin(),r_s.end());
			reverse(r_e.begin(),r_e.end());
			memo[s+e]++;
			memo[e+s]++;
			memo[s+r_e]++;
			memo[r_e+s]++;
			memo[r_s+e]++;
			memo[e+r_s]++;
			memo[r_s+r_e]++;
			memo[r_e+r_s]++;
		}
		printf("%d\n",memo.size());
	}
	return 0;
}

Measured memory_bytes: 1332
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N);
    multiset<long long int> ms;
    for(int n=0; n<N; n++) {
        cin >> A[n];
        
        auto itr=ms.lower_bound(A[n]);
        if(itr!=ms.begin()) {
            itr--;
            ms.erase(itr);
        }
        ms.insert(A[n]);
    }
    
    cout << ms.size() << endl;


    return 0;
    
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
    string ans="No";
    vector<vector<int>>board(3,vector<int>(3));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>board.at(i).at(j);
        }
    }
    int n;
    cin>>n;
    vector<int>bingo(n);
    for(int i=0; i<n; i++){
        cin>>bingo.at(i);
    }

for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
        for(int k=0; k<3; k++){
            if(bingo.at(i)==board.at(j).at(k)){
                board.at(j).at(k)=0;
            }
        }
    }
}
    int yoko1 = 0;
    int yoko2 = 0;
    int yoko3 = 0;
    int tate1 =0;
    int tate2 =0;
    int tate3 =0;
    int naname1 = 0;
    int naname2 = 0;
for(int i=0; i<3; i++){
    yoko1 += board.at(0).at(i);
    yoko2 += board.at(1).at(i);
    yoko3 += board.at(2).at(i);
    tate1 += board.at(i).at(0);
    tate2 += board.at(i).at(1);
    tate3 += board.at(i).at(2);
    naname1 += board.at(i).at(i);
    naname2 += board.at(i).at(2-i);
}
    if(yoko1==0 or yoko2==0 or yoko3==0 or
       tate1==0 or tate2==0 or tate3==0 or
       naname1==0 or naname2==0) ans="Yes";

cout<<ans<<endl;

}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 20;
int arr[maxd][maxd],k;
int n,m,ans;
int abs(int x){ return (x<0)?-x:x;}
int check(int x,int y)
{
    int sum = 0;
    for(int i=1;i<=m;i++)
        sum+= (arr[x][i]-arr[y][i])*(arr[x][i] - arr[y][i]);

    //printf("%d %d %d\n",x,y,sum);
    for(int i=1;i*i<=sum;i++)
        if(i*i==sum) return 1;
    return 0;
}
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++) scanf("%d",&arr[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            ans += check(i,j);
    printf("%d",ans);
    return 0;
}

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

int main(){
    ll N;
    vector<ll> data;
    cin >> N;

    //１桁目のルンルン数を作る
    for(int i = 1; i <= 9; i++){
        data.push_back(i);
    }
    

    while (true)
    {
        //kが1桁の範囲の値を指定するときは、dataにその値が格納されているので
        //whileの処理を行わない
        if(N <= data.size()){
            cout << data[N -1] << endl;
            break;
        }

        N -= data.size(); // N = 15 なら Nは 15 - 9 = 6　となり、１桁の数からの番号として考えられる。
        
        vector<ll> old;
        swap(old, data); //dataとoldの値を入れ替える。 dataの中身は空になる
        
        ll  add, num;
        for(int i = 0; i < old.size(); i++){
            for(int j = -1; j <= 1; j++){
                add = old[i]%10 + j;
                if(add < 0 or add > 9) continue;
                num = old[i]*10 + add;
                data.push_back(num);
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 1712
#include<iostream>
using namespace std;
int main(){
  int N, count, max, height;
  cin >> N;
  count =0;
  max =0;
  for(int i=0; i<N; i++){
    cin >> height;
    if(max <= height){
      max = height;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define NOT_FOUND -1

int binarySearch(int *, int, int);

int main()
{
  int s[100000],t[50000],n,i,j,m,ret,cnt = 0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&s[i]);
  }

  scanf("%d",&m);
  for(i = 0; i < m; i++){
    scanf("%d",&t[i]);
  }

  for(j = 0; j < m; j++){
    ret = binarySearch(s,n,t[j]);
    if(ret != NOT_FOUND){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  
  return 0;
}

int binarySearch(int A[], int n, int key)
{
  int left,right,mid;

  left = 0;
  right = n;

  while(left < right){
    mid = (left + right) / 2;
    if(A[mid] == key)return mid;
    else if(key < A[mid])right = mid;
    else left = mid + 1;
  }

  return NOT_FOUND;
}



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

int main() {
  int N;
  cin >> N;
  map<char, ll> m;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    m[S[0]]++;
  }
  ll ans = 0;
  char c[5] = {'M', 'A', 'R', 'C', 'H'};
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += m[c[i]] * m[c[j]] * m[c[k]];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define debug(x) cerr << #x << ": " << (x) << endl
#define debug2(x, y) cerr << #x << ": " << (x) << " " << #y << ": " << y << endl;
#define int long long
using namespace std;
using II = pair<int, int>;
using VII = vector<II>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  int N; cin >> N;
  string S; cin >> S;
  int Q; cin >> Q;
  VI ks(Q);
  REP (i, Q) cin >> ks[i];

  VI acc(N + 1);
  REP (i, N) {
    acc[i + 1] = acc[i] + (S[i] == 'M');
  }
  for (int k: ks) {
    int ans = 0;
    int sum = 0;
    int d = 0, m = 0;
    REP (i, k) {
      if (S[i] == 'D') {
        d++;
      } else if (S[i] == 'M') {
        sum += d;
        m++;
      } else if (S[i] == 'C') {
        ans += sum;
      }
    }
    REP (i, N - k) {
      if (S[i] == 'D') {
        sum -= m;
        d--;
      } else if (S[i] == 'M') {
        m--;
      }
      if (S[i + k] == 'D') {
        d++;
      } else if (S[i + k] == 'M') {
        sum += d;
        m++;
      } else if (S[i + k] == 'C') {
        ans += sum;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 9244
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, k;
    cin >> n >> k;
    
    vl h(n+1);
    exrep(i, 1, n) {
        cin >> h[i];
    }
    
    if(n == k) {
        out(0);
        re0;
    }

    vvl dp(n+1, vl(n+1, INF));  // dp[x][y] : 残った項の最も右の項の番号がx、サイズ(h[1]からh[x]で残った項数)がyのときのコストの最小値
    
    exrep(x, 1, n) {
        dp[x][1] = h[x];
    }
    exrep(x, 2, n) {
        exrep(y, 2, x) {
            exrep(i, 1, x-1) {
                chmin(dp[x][y], dp[i][y-1] + max(0LL, h[x] - h[i]));
            }
        }
    }

    ll ans = INF;
    exrep(i, 1, n) {
        chmin(ans, dp[i][n-k]);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include<cstdio>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;

//������
LL exp_mod(LL a, LL b, LL p)
{
	LL res = 1;
	while (b != 0)
	{
		if (b & 1) res = (res * a) % p;
		a = (a*a) % p;
		b >>= 1;
	}
	return res;
}

//C(n,m)=n!/(m!*(n-m)!)=n!*qpow(m!*(n-m)!,MOD-2)%MOD
LL Comb(LL a, LL b, LL p)
{
	if (a < b)   return 0;
	if (a == b)  return 1;
	if (b > a - b)   b = a - b;

	LL ans = 1, ca = 1, cb = 1;
	for (LL i = 0; i < b; ++i)
	{
		ca = (ca * (a - i)) % p;//n!/(n-m)!
		cb = (cb * (b - i)) % p;//m!
	}
	ans = (ca*exp_mod(cb, p - 2, p)) % p;
	return ans;
}

LL Lucas(LL n, LL m, LL p)
{
	LL ans = 1;

	while (n&&m&&ans)
	{
		ans = (ans*Comb(n%p, m%p, p)) % p;
		n /= p;
		m /= p;
	}
	return ans;
}

int main()
{
	LL n,a,b;
	while (~scanf("%lld%lld%lld",&n,&a,&b))
	{
		printf("%lld\n", (((exp_mod(2LL,n,MOD) - 1LL + MOD) % MOD - Lucas(n,a,MOD) + MOD) % MOD - Lucas(n,b,MOD) + MOD) % MOD);
	}
	return 0;
}



Measured memory_bytes: 128
#include <cstdio>
using namespace std;

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	
	if(A >= 13) printf("%d", B);
	else if(A >= 6) printf("%d", B / 2);
	else printf("0");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
	
    public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
System.out.println((10*b+c)%4==0?"YES":"NO");
 }
}
  

Measured memory_bytes: 23252
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys
import math


def _i(): return int(sys.stdin.readline().strip())


def main():
    return 2 * _i() * math.pi


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 62048
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        int b, e, t;
        cin >> b >> e >> t;
        for(int j = 0; j < e - b; j++)
        {
            swap(v[b + j], v[t + j]);
        }
    }
    for(int i = 0; i < n; i++)
    {
        if(i > 0) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N,K;cin>>N>>K;vl A(N);rep(i,N)cin>>A[i];
  vector<int> p(200001);
  rep(i,N){
    p[A[i]]++;
  }
  sort(all(p));
  int ans=0;
  int memo;
  rep(i,200001){
    if(p[i]!=0){
      memo =i;
      break;
    }
  }
  int ai=200001-memo;
  for(int i= memo;i<memo+ai-K;i++){
    ans +=p[i];
  }
  cout<<ans<<endl;

}







Measured memory_bytes: 2560
h,w=gets.split.map &:to_i
w+=1
maze=[false]*w + $<.flat_map{|s| s.chomp.chars.map{|c| c==?. }.push(false) } + [false]*w
cand=(0...maze.size).select{|i| maze[i] }
ans=0
cand.each{|s|
  mw=maze.dup
  mw[s]=false
  q=[s]
  ans=[ans,0.step{|k|
    qn=[]
    q.each{|c|
      [c-w,c-1,c+1,c+w].each{|nc|
        next unless mw[nc]
        mw[nc]=false
        qn.push(nc)
      }
    }
    break k if qn.empty?
    q=qn
  }].max
}
puts ans

Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}




signed main(){
    int m,d;
    cin >> m >> d;
    int cnt = 0;
    FOR(i,1,m+1){
        FOR(j,1,d+1){
            int a,b;
            a = j % 10;
            b = int(j /10);
            if(a == 1 or b == 1){
                continue;
            }
            if(a * b == i){
                cnt ++ ;
            }
        }
    }
    cout << cnt << endl;


}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, M, C) = Slice3<long>();
            var Bi = Sarray();
            var cnt = 0L;
            for (var i = 0; i < N; ++i)
                if (0 < Sarray().Zip(Bi, (a, b) => a * b).Sum() + C) ++cnt;
            WriteLine(cnt);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27932
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    int a;
    cin >> a;
    cout << 24-a+24 << endl;
    
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<iostream>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const ll maxn=1e6+5;
const int mod=998244353;
ll n,m,p;
ll x,y;
ll in[maxn/100];
int work()
{
    for(int i=1;i<=n;i++) if(in[i]>4||in[i]<=1) return 0;
    int a=0,b=0,c=0;//2 3 4
    for(int i=1;i<=n;i++)
    {
        if(in[i]==4) c++;
        else if(in[i]==3) b++;
        else a++;
    }
    if(a!=4) return 0;
    for(int i=1;i*i<=c;i++)
    {
        if(c%i==0)
        {
            int temp=c/i;
            if((temp+i)*2==b) return 1;
        }
    }
    return 0;
}
int main()
{
    scanf("%lld%lld",&n,&m);
    if(m>=n) printf("Yes\n");
    else printf("No\n");
    return 0;
}
/***
***/


Measured memory_bytes: 256
//2017-10-13
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (1000+5)

char s[N];
bool had[N];

int main(){
	scanf("%s", s);
	
	int len = strlen(s);
	For(i, 0, len-1) had[s[i]] = true;
	
	if((had['S']^had['N']) || (had['E']^had['W'])) puts("No");
	else puts("Yes");

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if(a){
        if(b) printf("Open\n");
        else printf("Close\n");
    }
    else if(b) printf("Close\n");
    else if(c) printf("Open\n");
    else printf("Close\n");

    return 0;
}

Measured memory_bytes: 1016
import java.util.Scanner
import scala.io.StdIn._

object Main extends App {

  val x = readLong()


  def solve() = {
    var money = 100L
    var year = 0
    while(money < x) {
      money += money / 100
      year += 1
    }
    year
  }

  println(solve())

}



Measured memory_bytes: 54664
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cassert>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define ALL(A) (A).begin(),(A).end()
#define SZ(A) int(A.size())

using namespace std;

typedef unsigned long long ull;

struct RollingHash{
  static const ull p=100000007;
  string s;
  int n;
  vector<ull> pow, phash;
  
  RollingHash(const string &s) : s(s), n(SZ(s)),pow(n+1),phash(n+1){
    pow[0]=1,phash[0]=0;
    REP(i, n) {
      phash[i+1] = s[i] + phash[i] * p;
      pow[i+1] = pow[i] * p;
    }
  }

  inline bool operator()(const int& i, const int& j) const { 
    const int k=lcp(i,j);
    return i+k >= n ? true : j+k >= n ? false : s[i+k] <= s[j+k];
  }

  /*
  static ull hash(const string &t) {
    ull h=0;
    REP(i,SZ(t))h=t[i]+h*p;
    return h;
  }  
  */

  inline ull hash(const int& b, const int& e) const {
    return phash[e]-phash[b]*pow[e-b];
  }
  /*
  inline int find(string t) {
    int w=t.size(),count=0;
    if(w > SZ(s))return 0;
    ull h=hash(t);
    REP(i,n-w+1)count+=(hash(i,i+w)==h);
    return count;
  }
  */
  
  inline int lcp(const int& i, const int& j) const {
    int l=0,r=n-max(i,j)+1;
    while(l+1<r) {
      const int m=(l+r)>>1;
      (hash(i,i+m) == hash(j,j+m) ? l : r) = m;
    }
    return l;
  }
};

int L[1000000],R[1000000];

inline void merge(int *A, const int left, const int mid, const int right, const RollingHash &rh){
  const int n1 = mid - left, n2 = right - mid;
  REP(i,n1)L[i]=A[left+i];
  REP(i,n2)R[i]=A[mid+i];
  for(int k =left,i=0,j=0;k<right;k++){
    if(n2<=j)A[k]=L[i++];
    else if(n1<=i)A[k]=R[j++];
    else A[k]=rh(L[i],R[j])?L[i++]:R[j++];
  }
}

void mergeSort(int *A,const int left,const int right, const RollingHash &rh){
  if(left+1<right){
    const int mid = (left+right)>>1;
    mergeSort(A,left,mid, rh);
    mergeSort(A,mid,right, rh);
    merge(A,left,mid,right, rh);
  }
}

//O(n (log n)^2)
vector<int> suffixArray(const RollingHash &rh){
  int n=rh.n+1,sa[n];
  REP(i,n)sa[i]=i;
  mergeSort(sa,0,n,rh);
  vector<int>res(n);
  REP(i,n)res[i]=sa[i];
  return res;
}

bool contain(const string &S, const vector<int> &sa, const string &T){
  int a=0, b=SZ(S);
  while(b-a>1){
    const int c=(a+b)/2;
    (S.compare(sa[c],T.length(),T)<0 ? a : b ) = c;
  }
  return S.compare(sa[b], T.length(), T) == 0;
}

int main(void){

  char str[1000002];
  string s,t;
  scanf("%s",str);
  s=str;
  
  RollingHash rh=RollingHash(s);
  vector<int>sa=suffixArray(rh);
  
  int n;
  cin >> n;

  while(n--){
    scanf("%s",str);
    t=str;
    printf("%d\n",contain(s,sa,t));
  }

  return 0;
}

Measured memory_bytes: 32600
#include<iostream>
#include<cstdio>
using namespace std;
long long b[100];

long long  F(int n)
{
	if(n==1) return 1;
	else if(n==0) return 2;
	else if(n>1)
	{
		if(b[n]!=0)  return b[n];
		else 
		{
			b[n]=F(n-1)+F(n-2);
			return b[n];
		}
	}
}

int main()
{
	long long l;
	int n;
	scanf("%d",&n);
	l=F(n);
	printf("%lld\n",l);
    return 0;
	}



Measured memory_bytes: 256
import sys,collections as cl,bisect as bs , heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k][0] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if kkk in se:
            if se[kkk] <= i-n:
                    return True
        else:
            se[kkk] = i
    return False


n = onem()

s = list(input())
l = 0
r = n//2
while True:
    mid = -(-(l+r)//2)
    ans = search(s,mid)
    if l == mid:
        break
    if ans:
        l = mid
    else:
        r = mid-1
print(l)


Measured memory_bytes: 9876
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define ALL(v) v.begin(), v.end()
vector<int> T[100000];
bool used[100000];
bool check(int v, int p) {
	for (int to : T[v]) {
		if (to == p) continue;
		if (!check(to, v)) return 0;
		if (used[to]) continue;
		if (used[v]) return 0;
		used[v] = used[to] = 1;
	}
	return 1;
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		T[a].push_back(b);
		T[b].push_back(a);
	}
	if (check(0, -1) && used[0]) cout << "Second" << endl;
	else cout << "First" << endl;
}


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

int main() {
  string S;
  string A="Good";
  cin >> S;
  for(int i=0;i<3;i++){
    if(S.at(i)==S.at(i+1)){
      A="Bad";
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    string key = "keyence";
    bool flag=false;
    if(s==key){
        flag = true;
    }else{
        for(ll i=0;i<8;i++){
        if(key.substr(0,i)==s.substr(0,i)&&key.substr(i,7-i)==s.substr(s.length()-(7-i),7-i)){
            flag =true;
        }
    }
    }
    
    if(flag == true){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

vi G[100010];
int ind[100010];

int main()
{
    int n = in();
    int m = in();

    rep(i, m) {
        int a = in() - 1, b = in() - 1;
        G[a].PB(b);
        ind[b]++;
    }

    bool f = false;

    vi ans;

    queue<int> q;
    rep(i, n) if (ind[i] == 0) {
        ans.PB(i);
        q.push(i);
    }

    while (q.size()) {
        f |= q.size() > 1;

        int v = q.front(); q.pop();

        int cnt = 0;

        for (int u : G[v]) {
            ind[u]--;

            if (ind[u] == 0) {
                q.push(u);
                ans.PB(u);
                cnt++;
            }
        }
    }

    for (int v : ans) printf("%d\n", v+1);
    printf("%d\n", f);
}

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

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

	vector<int> v;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}

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

	//for (int i = 0; i < n; i++) { cout << v[i] << " " << endl; }

	double ans = 0;

	for (int i = 0; i < n-1; i++) {
		if (i == 0) {
			ans += (v[i]*1.0 + v[i + 1]*1.0)/ 2;
			//cout << "1:" << ans << endl;
		}
		else {
			ans = (ans*1.0 + v[i + 1]*1.0)/ 2;
			//cout << "2:" << ans << endl;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int min(int a,int b) {
    return a<b ? a:b;
}
int abs(int n) {
    return n >= 0 ? n : n*-1;
}
int main(void) {
    int i,n,w[100],sum=0,r_sum=0,r;
    scanf("%d",&n);
    for(i = 0; i < n; i++) {
        scanf("%d",&w[i]);
        sum+=w[i];
    }
    r = sum;
    for(i = 0; i < n-1; i++) {
         r_sum += w[i];
         r = min(r,abs(r_sum*2 - sum));
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
const int MAXN = 2e5+1;
vector<ll>mx(8*MAXN,-INF);
vector<ll>mn(8*MAXN,INF);
	   void upd(int v,int tl,int tr,int pos,PII val){
		   if(tl == tr){
			   mn[v] = val.fi;
			   mx[v] = val.se;
			   return;
		   }
		   int tm = (tl+tr)/2;
		   if(pos <= tm){
			   upd(2*v,tl,tm,pos,val);
		   }else{
			   upd(2*v+1,tm+1,tr,pos,val);
		   }
		   mx[v] = max(mx[2*v],mx[2*v+1]);
		   mn[v] = min(mn[2*v],mn[2*v+1]);
	   }
	   PII query(int v,int l,int r,int tl,int tr){
		   if(l > r)return {INF,-INF};
		   if(l == tl && r == tr){
			   PII res = {mn[v],mx[v]};
			   return res;
		   }
		   int tm = (tl+tr)/2;
		   PII a = query(2*v,l,min(r,tm),tl,tm);
		   PII b = query(2*v+1,max(l,tm+1),r,tm+1,tr);
		   PII c;
		   c.fi = min(a.fi,b.fi);
		   c.se = max(a.se,b.se);
		   return c;
		   
	   }
int main()
{
	owo
	int n;
	cin>>n;
	vector<PII>p(n);
	vector<ll>coords;
	for(int i=0;i<n;i++){
		cin>>p[i].fi>>p[i].se;
		coords.pb(p[i].fi);
		coords.pb(p[i].se);
	}	
	sort(all(coords));
	coords.resize(unique(all(coords))-coords.begin());
	map<ll,int>pos;
	for(int i=0;i<(int)(coords.size());i++){
		pos[coords[i]] = i+1;
	}
	sort(all(p));
	vector<ll>up(2*n+1,-INF),down(2*n+1,INF);
	ll ans = 0;
	for(int i=0;i<n;i++){
		int x = p[i].fi;
		int y = p[i].se;
		x = pos[x];
		y = pos[y];
		down[x] = min(down[x],p[i].fi+p[i].se);
		up[x] = max(up[x],p[i].se-p[i].fi);
		PII c = query(1,1,x-1,1,2*n);
		ans = max(ans,p[i].fi+p[i].se-c.fi);
		ans = max(ans,p[i].fi-p[i].se+c.se);
		upd(1,1,2*n,x,make_pair(down[x],up[x]));
	}
	cout<<ans;
}



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = input[0], m = input[1], x = input[2];
            var a = new int[n][];
            for (int i = 0; i < n; i++)
            {
                a[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }

            int min = int.MaxValue;
            for (int b = 1; b < (1 << n); b++)
            {
                int c = 0;
                var point = new int[m];
                for (int i = 0; i < n; i++)
                {
                    if ((b & 1 << i) != 0)
                    {
                        c += a[i][0];
                        for (int  j = 0; j < m; j++)
                        {
                            point[j] += a[i][j + 1];
                        }
                    }
                }

                if (point.All(p => (p >= x)))
                {
                    min = Math.Min(min, c);
                }
            }
            Console.WriteLine(min == int.MaxValue ? -1 : min);
        }
    }
}

Measured memory_bytes: 19852
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int n;
ll solve(ll a, ll b, int count) {
	if (count == n) return a + b;
	return solve(b, a + b, count + 1);
}
int main(void) {
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << solve(2, 1, 2) << endl;
	return 0;
}


Measured memory_bytes: 256
use proconio::input;


fn main() {
    input! {
        n:usize,
        mut a:[usize;n-1],
    };
    a.iter_mut().for_each(|a|*a-=1);
    let a = a;
    let mut res:Vec<i32> = vec![0;n];
    
    a.iter().for_each(|v| res[*v]+=1);
    res.iter().for_each(|v| println!("{}",v));
}


Measured memory_bytes: 5544
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        if (N == M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

Measured memory_bytes: 21972
a= list(map(int,input().split()))
N = a[0]
K = a[1]

a = [0]*K
mod = 10**9+7

for x in range(K,0,-1):
    a[x-1] = pow(K//x, N,mod)
    for t in range(2,K//x+1):
        a[x-1] -= a[t*x-1]

s = 0
for i in range(K):
    s += (i+1)*a[i]

ans = s%mod

print(ans)

Measured memory_bytes: 11264
from copy import deepcopy
n,k=map(int,input().split())
mod=10**9+7
accum=[0]*(n+1)
for i in range(n):
  accum[i+1]+=accum[i]+i+1
accumrev=deepcopy(accum)
accumrev=accumrev[::-1]+[0]
accum=[0]+accum
#print(accumrev)
#print(accum)
ans=0
for i in range(k,n+2):
  ans+=accumrev[0]-accumrev[i]-accum[i]+1
  ans%=mod
print(ans)

Measured memory_bytes: 24344
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

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

const int mo = 1e9 + 7;

struct Edge {
	int to, idx;
	Edge(int to, int idx) : to(to), idx(idx) {}
};

int N;
vector<Edge> G[100010];
int mx = 0;
int c[100010];

void f(int cur, int par, int used_color)
{
	if (G[cur].size() == 1 and G[cur][0].to == par) { // leaf
		return;
	}

	int counter = 0;
	for (Edge &e : G[cur]) {
		if (e.to == par) continue;
		counter++;
		if (counter == used_color) counter++;
		c[e.idx] = counter;
		f(e.to, cur, counter);
	}

	mx = max(mx, counter);
}

signed main()
{
	scanf("%lld", &N);
	
	rep(i, N-1) {
		int a, b; scanf("%lld%lld", &a, &b);
		--a, --b;
		G[a].push_back(Edge(b, i));
		G[b].push_back(Edge(a, i));
	}

	f(0, -1, -1);

	printf("%lld\n", mx);
	rep(i, N-1) {
		printf("%lld\n", c[i]);
	}
}


Measured memory_bytes: 9856
#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;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#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) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + 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 s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}


void solve(){
	ll N;
	cin >> N;
	vl B(N-1);
	REP(i, N-1){
		cin >> B[i];
	}
	vl A(N);
	A[0] = B[0];
	REP(i, N){
		if(i > 0 && i < N-1){
			A[i] = min(B[i-1], B[i]);
		}
	}
	A[N-1] = B[N-2];
	ll ans = 0;
	REP(i, N){
		ans += A[i];
	}
	cout << ans << endl;
}


const ll mod = 1000000007;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


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

int main(void)
{
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s.find(u) != -1) a--;
	if (t.find(u) != -1) b--;
	cout << a << " " << b;
	return 0;
}

Measured memory_bytes: 256