akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a));
  int idx=0;
  while(idx<n-1){
    fori(i,idx+1,n){
      a[i]%=a[idx];
    }
    sort(all(a));
    auto firstNonZero=upper_bound(all(a),0);
    idx=firstNonZero-a.begin();
  }
  std::cout<<a[n-1]<<endl;
  return 0;
}


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

ll n,m,u,v,s,t,d[100009][3];
vector<ll> e[100009];

int main(){
    cin>>n>>m;
    rep(i,n)rep(j,3)d[i+1][j]=1e18;
    rep(i,m){
        cin>>u>>v;
        e[u].push_back(v);
    }
    cin>>s>>t;
    queue<pair<int,int>> que;
    que.push({s,0});
    d[s][0]=0;
    while(!que.empty()){
        int v=que.front().first,x=que.front().second;
        que.pop();
        int y=(x+1)%3;
        rep(i,e[v].size()){
            if(d[e[v][i]][y]==1e18){
                que.push({e[v][i],y});
                d[e[v][i]][y]=d[v][x]+1;
            }
        }
    }
    cout<<(d[t][0]!=1e18?d[t][0]/3:-1)<<endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-8;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    double m1=0,m2=0;
    int m=360;
    rep(i,n-1){
      int tmp;
      cin>>tmp;
      m-=tmp;
      m1+=sin(PI*tmp/180.0);
    }
    m1+=sin(PI*m/180.0);
    cin>>n;
    m=360;
    rep(i,n-1){
      int tmp;
      cin>>tmp;
      m-=tmp;
      m2+=sin(PI*tmp/180.0);
    }
    m2+=sin(PI*m/180.0);
    if(abs(m1-m2)<ESP)cout<<0<<endl;
    else if(m1>m2)cout<<1<<endl;
    else cout<<2<<endl;
  }

}

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

typedef long long ll;
using namespace std;

bool kaibun(string S) {
  for(int i = 0; i < S.length(); i++) {
    if(i >= S.length() - i - 1) return true;
    if(S[i] != S[S.length() - i - 1]) return false;    
  }
  return false;
}

int main() {
  string S;
  cin >> S;
  if (kaibun(S) && kaibun(S.substr(0, (S.length() - 1) / 2)) && kaibun(S.substr((S.length() + 1) / 2, (S.length() - 1) / 2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    int p[100010];
    string S[100010];
    rep(i, M) cin >> p[i] >> S[i];

    int flag[100010];
    int wa[100010];

    rep(i, M) {
        if (S[i] == "WA" && (flag[p[i]] == 0)) wa[p[i]]++;
        if (S[i] == "AC") flag[p[i]] = 1;
    }

    int ac = 0;
    int pe = 0;

    rep(i, N) {
        ac += flag[i+1];
        if (flag[i+1] == 1) pe += wa[i+1];
    }

    cout << ac << " " << pe << endl;
    return 0;
}


Measured memory_bytes: 6784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		HashSet<Integer> set = new HashSet<Integer>();
		for(int i = 0; i < n; i++) set.add(sc.nextInt());
		out.println(set.size());
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22484
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
string s;
bool check(ll l,ll r){
  while(l<r) {
    if(s[l]!=s[r]) return 0;
    else l++,r--;
  }
  return 1;
}
void solve()
{
  cin>>s;
  if(check(0,sz(s)-1)&&check(0,(sz(s)-1)/2-1))cout<<"Yes";
  else cout<<"No";
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

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

class Program
{
    #region Lib

    static int Gcd(int a, int b)
    {
        if (a % b == 0)
            return b;
        else
            return Gcd(b, a % b);
    }

    #endregion

    static void Main()
    {
        var tree = new Tree(ReadInts()[0]);

        for (int i = 0; i < tree.NodeNum - 1; i++)
        {
            var nums = ReadInts();
            tree.Add(nums[0], nums[1]);
        }

        tree.Coloring();
        var colors = tree.Colors.ToArray();
        Console.WriteLine(colors.Max());
        foreach (var item in colors)
        {
            Console.WriteLine(item);
        }
    }

    #region Utils
    public static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    #endregion



}

class Tree
{

    private readonly TreeNode[] _nodes;

    private readonly List<Bar> _bars = new List<Bar>();

    public Tree(int nodeNum)
    {
        NodeNum = nodeNum;
        _nodes = Enumerable.Range(1, nodeNum).Select(_ => new TreeNode()).ToArray();
    }

    public int NodeNum { get; }


    public void Add(int a, int b)
    {
        var bar = new Bar(_bars.Count, a, b);
        _bars.Add(bar);
        _nodes[a-1].Bars.Add(bar);
        _nodes[b-1].Bars.Add(bar);
    }

    class TreeNode
    {
        public List<Bar> Bars { get; } = new List<Bar>();
    }


    public void Coloring()
    {
        foreach (var item in _nodes)
        {
            Coloring(item);
        }
    }

    private void Coloring(TreeNode node)
    {
        var bars = node.Bars;
        var nums = Enumerable.Range(1, bars.Count).Except
            (bars.Select(p => p.Color)).ToArray();

        var stack = new Queue<int>(nums);

        foreach (var item in bars.Where(p=>p.Color == 0))
        {
            item.Color = stack.Dequeue();
        }
    }

    public IEnumerable<int> Colors => _bars.Select(p => p.Color);

}

class Bar
{
    public Bar(int index, int a, int b)
    {
        Index = index;
        A = a;
        B = b;
    }

    public int Index { get; }
    public int A { get; }
    public int B { get; }

    public int Color { get; set; }


    //public List<Bar> AFriends { get; } = new List<Bar>();
    //public List<Bar> BFriends { get; } = new List<Bar>();

}





Measured memory_bytes: 38120
import sys

# import re
import math
import collections
# import decimal
import bisect
# import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()

    ans = 0
    for i in range(1, int(n ** (1 / 2) + 1)):
        if n % i == 0:
            diff = n // i - n // (i + 1) - 1
            if diff * i >= i:
                ans += n // i - 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
	int n;
	string s1, s2;
	long ans;
	bool prev_tate;
	cin >> n >> s1 >> s2;
	int i = 0;
	if(s1[i] == s2[i]) {
		ans = 3;
		prev_tate = true;
		i++;
	} else {
		ans = 6;
		prev_tate = false;
		i +=2;
	}
	for(; i<n; i++){
		if(s1[i] == s2[i]) {
			if(prev_tate) {
				ans = ans * 2 % 1000000007;
			}else{
				// * 1
			}
			prev_tate = true;
		} else {
			if(prev_tate) {
				ans = ans * 2 % 1000000007;
			}else{
				ans = ans * 3 % 1000000007;
			}
			prev_tate = false;
			i++;
		}
	}
	cout << ans;
}



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

long long dp[105][100005];
int main()
{
  int n,W;
  int w[105],v[105];

  cin>>n>>W;
  for(int i=0;i<n;i++) cin>>w[i]>>v[i];
  
  for(int i=0;i<n;i++){
    for(int j=0;j<=W;j++){
      if(w[i]<=j){
	dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }else{
	dp[i+1][j]=dp[i][j];
      }
    }
  }
  cout<<dp[n][W]<<endl;
  return 0;
}


Measured memory_bytes: 79360
# -*- coding: utf-8 -*-

line = input().split()
h = int(line[0])
w = int(line[1])

a = []
hr = []
for hi in range(h):
    line = list(input())
    if len(set(line))==1 and line[0]==".":
        hr.append(hi)
    a.append(line)


wr = []
wi = 0
for line in zip(*a):
    if len(set(line))==1 and line[0]==".":
        wr.append(wi)
    wi += 1

for hi in range(h):
    if hi in hr:
        continue
    for wi in range(w):
        if wi not in wr:
            print(a[hi][wi], end="")
    print("")


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    string S, T; cin >> S >> T;
    T.pop_back();
    if(S == T) cout << "Yes" << endl;
    else cout << "No" << endl;    

    return 0;
}



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

using namespace std;

struct Edge {
	int dest, len;
};

Edge children[131075][2];

long long lim;

vector<pair<long long, long long>> g(const vector<pair<long long, long long>> &r0, const vector<pair<long long, long long>> &r1) {
	vector<pair<long long, long long>> result;
	for (auto il = r0.cbegin(), ir = r1.cbegin(); il != r0.cend() || ir != r1.cend(); ) {
		if (il != r0.cend() && (ir == r1.cend() || il->first < ir->first || (il->first == ir->first && il->second == ir->second))) {
			if (result.empty() || il->second < result.back().second)
				result.push_back(*il);
			++il;
		} else {
			if (result.empty() || ir->second < result.back().second)
				result.push_back(*ir);
			++ir;
		}
	}

	return result;
}

vector<pair<long long, long long>> f(int x) {
	if (children[x][0].dest == 0) return {{0, 0}};
	
	vector<pair<long long, long long>> ls = f(children[x][0].dest), rs = f(children[x][1].dest), result0, result1;

	auto check = [=](vector<pair<long long, long long>>::const_iterator i1, vector<pair<long long, long long>>::const_iterator i2) {
		return i1->second + i2->first <= lim - (children[x][0].len + children[x][1].len);
	};

	for (auto il = ls.cbegin(), ir = rs.cbegin(); il != ls.cend(); ++il) {
		while (ir != rs.cend() && check(il, ir)) ++ir;
		if (ir != rs.cbegin()) result0.emplace_back(il->first + children[x][0].len, (ir - 1)->second + children[x][1].len);
	}

	for (auto ir = rs.cbegin(), il = ls.cbegin(); ir != rs.cend(); ++ir) {
		while (il != ls.cend() && check(ir, il)) ++il;
		if (il != ls.cbegin()) result1.emplace_back(ir->first + children[x][1].len, (il - 1)->second + children[x][0].len);
	}

	auto result = g(result0, result1);
	// cerr << '[' << lim << ']' << ' ' << x << endl;
	// cerr << '0' << '\t';
	// for (auto p: result0) cerr << '(' << p.first << ',' << ' ' << p.second << ')' << '\t';
	// cerr << endl << '1' << '\t';
	// for (auto p: result1) cerr << '(' << p.first << ',' << ' ' << p.second << ')' << '\t';
	// cerr << endl << 'g' << '\t';
	// for (auto p: result) cerr << '(' << p.first << ',' << ' ' << p.second << ')' << '\t';
	// cerr << endl;

	return result;
}

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

	for (int i = 2; i <= n; ++i) {
		int a, v;
		cin >> a >> v;
		if (children[a][0].dest == 0) {
			children[a][0] = (Edge){i, v};
		} else {
			children[a][1] = (Edge){i, v};
		}
	}

	long long low = 0, high = 131072LL * (n - 1);
	while (low < high) {
		long long mid = (low + high) / 2;
		lim = mid;
		if (!f(1).empty()) high = mid; else low = mid + 1;
	}

	cout << low << endl;

	return 0;
}

Measured memory_bytes: 19712
def calc(a, b, c):
    return max(a, b, c) - min(a, b, c)


h, w = map(int, input().split())
if h % 3 == 0 or w % 3 == 0:
    ans = 0
else:
    ans0 = min(h, w)
    ans1 = h * w

    for i in range(1, h+1):
        s1 = i * w
        if w % 2 == 0:
            x = w // 2
            s2 = (h-i) * x
            s3 = s2
        else:
            x = w // 2 + 1
            s2 = (h-i) * x
            s3 = (h-i) * (w-x)
        ans1 = min(ans1, calc(s1, s2, s3))


    ans2 = h * w
    for i in range(1, w+1):
        s1 = i * h
        if h % 2 == 0:
            x = h // 2
            s2 = (w - i) * x
            s3 = s2
        else:
            x = h // 2 + 1
            s2 = (w - i) * x
            s3 = (w - i) * (h - x)
        ans2 = min(ans2, calc(s1, s2, s3))

    ans = min(ans0, ans1, ans2)
print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		char[] pp = new char[]{'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'};
		String ss = sc.next();
		char ch = ss.charAt(0);
		for( int i=0; i<26; i++ ){
			if( ch==pp[i] ){
				System.out.println(pp[i+1]);
				break;
			}
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.ST << ", " << p.ND << ")";
}

template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto &e : x)
        	out << e << (&e == &*--x.end() ? "" : ", ");
	return out << '}';
}

template<class... Args> void dump(Args&&... args) {
	((cerr << args << ";  "), ...);
}
 
#ifdef DEBUG
#  define debug(x...) cerr << "[" #x "]: ", dump(x), cerr << "\n"
#else
#  define debug(...) false
#endif
 
template<class T> int size(T && a) { return (int) a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n, m;
	cin >> n >> m;

	vector<vector<int>> adj(n);
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		adj[a - 1].emplace_back(b - 1);
		adj[b - 1].emplace_back(a - 1);
	}

	vector<int> par(n), dep(n), sum(n);
	function<void(int, int)> dfs = [&](int v, int p) {
		par[v] = p;
		for(int u : adj[v]) {
			if(u != p) {
				dep[u] = dep[v] + 1;
				dfs(u, v);
			}
		}
	};
	dfs(0, -1);

	auto add_path = [&](int a, int b) {
		while(a != b) {
			if(dep[a] < dep[b])
				swap(a, b);
			sum[a]++;
			a = par[a];
		}
	};

	vector<vector<PII>> edges(n);
	vector<PII> ans;
	auto add_edge = [&](int u, int v) {
		edges[u].emplace_back(v, size(ans));
		edges[v].emplace_back(u, size(ans));
		ans.emplace_back(-1, -1);
	};

	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		add_path(a, b);
		add_edge(a, b);
	}

	REP(i, n)
		if(sum[i] % 2)
			add_edge(i, par[i]);

	vector<int> ptr(n);
	function<void(int)> get_cycle = [&](int v) {
		while(ptr[v] < size(edges[v])) {
			auto &[u, id] = edges[v][ptr[v]++];
			if(ans[id] == PII(-1, -1)) {
				ans[id] = {v, u};
				get_cycle(u);
			}
		}
	};
	REP(i, n) get_cycle(i);

	int s = 0;
	for(int &f : sum)
		s += min(f, 2);

	cout << s << "\n";
	REP(i, m) {
		auto &[u, v] = ans[i];
		cout << u + 1 << " " << v + 1 << "\n";
	}
}


Measured memory_bytes: 4120
#include <iostream>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);

    for (int i = 0; i < m; i++)
        cin >> x[i];

    if (n >= m)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());

    vector<int> defs(m - 1);
    for (int i = 0; i < m - 1; i++)
        defs[i] = x[i + 1] - x[i];
    int res = x[m - 1] - x[0];

    sort(defs.begin(), defs.end(), greater<>());
    for (int i = 0; i < n - 1; i++)
        res -= defs[i];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
signed main()
{
	int a,b,c,d,e,f,g,h,i;
	return scanf("%d%d%d",&a,&b,&c),printf("%d %d %d\n%d %d %d\n%d %d %d\n",a,b,d,f,c,g,e,c*2-b,c*3-(d=c*3-a-b)-(g=c*2-(f=c*3-a-(e=c*2-d)))),0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a,b;
  cin>>a>>b;
  if(a=='H'&&b=='H'){
    cout<<'H'<<endl;
  }
  else if(a=='H'&&b=='D'){
    cout<<'D'<<endl;
  }
  else if(a=='D'&&b=='H'){
    cout<<'D'<<endl;
  }
  else{
    cout<<'H'<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int (i) = (a);(i) < (n);(i)++)

using namespace std;

int gcd(int a,int b){
	if(b == 0) return a;
	return gcd(b,a%b);
}

int main(){
	
	int n,memo = 0,d[300000];
	cin >> n;
	
	rep(i,0,n){
		cin >> d[i];
	}
	
	
	
	
	rep(i,0,n){
		if(i == 0){
			memo = d[i];
		}
		else{
			memo = max(memo-10,d[i]);
		}
		
		if(memo < 10){
			cout << "no" << endl;
			return 0;
		}
	}
	
	rep(i,0,n){
		if(i == 0){
			memo = d[n-1];
		}
		else{
			memo = max(memo-10,d[n-i-1]);
		}
		
		if(memo < 10){
			cout << "no" << endl;
			return 0;
		}
	}
	
	cout << "yes" << endl;
	
	return 0;
}


Measured memory_bytes: 4264
using System;

class Program
{
    static void Main(string[] args)
    {
        int a = Convert.ToInt32(Console.ReadLine());
        string s = Console.ReadLine();
        if(a >= 3200)
        {
            Console.WriteLine(s);
        }
        else
        {
            Console.WriteLine("red");
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <functional>
#include <math.h>
#include <map>
#include <set>
#include <string>
using namespace std;
#define fio ios::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int INT_INF = 1e9;
const ll LL_INF = 1e18;
const int MAXN = 100003;


int n,m;
vector<int> G[MAXN];
int dis[MAXN][4];
int S,T;

typedef struct V{
	int idx, x;
	int dis;
}V;

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		G[u].push_back(v);
	}
	scanf("%d %d", &S, &T);
	for(int i=1;i<=n;i++)
		sort(G[i].begin(), G[i].end());

	for (int i = 1; i <= n; i++)
		for(int j=1;j<=3;j++)
			dis[i][j] = INT_INF;

	dis[S][3] = 0;
	queue<V> q;
	q.push({S,3,0});

	while (!q.empty()) {
		V cur = q.front();
		q.pop();

		int add=0;
		if(cur.x==3)
			add++;
		
		for (auto nxt : G[cur.idx]) {
			int nrem = cur.x-1;
			if(nrem==0) nrem = 3;

			if(dis[nxt][nrem]>cur.dis+add) {
				dis[nxt][nrem] = cur.dis+add;
				q.push({nxt, nrem, dis[nxt][nrem]});
			}
		}
	}

	if(dis[T][3]==INT_INF)
		puts("-1");
	else
		printf("%d", dis[T][3]);

	return 0;
}

Measured memory_bytes: 7296
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S=sc.next();
      String T=sc.next();
      if(T.substring(0,T.length()-1).equals(S)){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }
   }
}


Measured memory_bytes: 35764
#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
using namespace std;

int main() {
	
	cout<<fixed<<showpoint;
	cout<<setprecision(9);
	
	long double x;
	string s;
	int n;
	cin>>n;
	long double sum = 0;
	while(n--)
	{
		cin>>x>>s;
		if(s == "BTC")
		{
			sum+=(x*380000.0);
		}
		else
		{
			sum+=x;
		}
	}
	cout<<sum;
	
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long
#define inf 3e18

using namespace std;
typedef pair<llint, llint> P;

llint n, T;
vector<P> avec, bvec;
llint dp[200005][45];

bool comp(P x1, P x2)
{
	return x2.first*(x1.second+1) < x1.first*(x2.second+1);
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> T;
	llint a, b;
	for(int i = 1; i <= n; i++){
		cin >> a >> b;
		if(a == 0) bvec.push_back(P(a, b));
		else avec.push_back(P(a, b));
	}
	sort(avec.begin(), avec.end(), comp);
	sort(bvec.begin(), bvec.end());
	
	llint m = avec.size();
	for(int i = 0; i <= m; i++){
		for(int j = 0; j < 45; j++){
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for(int i = 0; i < m; i++){
		llint a = avec[i].first, b = avec[i].second;
		for(int j = 0; j < 45; j++){
			if(dp[i][j] > T) continue;
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			if(j+1 < 45) dp[i+1][j+1] = min(dp[i+1][j+1], (a+1)*(dp[i][j]+1) + b);
		}
	}
	
	llint ans = 0;
	for(int i = 0; i < 45; i++){
		if(dp[m][i] > T) continue;
		llint tmp = i;
		for(int j = 0; j < bvec.size(); j++){
			llint v = bvec[j].second;
			if(dp[m][i] + v + 1 <= T) tmp++, dp[m][i] += v + 1;
			else break;
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	
}

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

int main() {
  cout << fixed << setprecision(10);
  double a, b, x;
  cin >> a >> b >> x;
  
  double xx = b - x/(a*a);
  
  double ss;
  if (xx <= b/2) {
    ss = atan(2*xx/a);
  } else {
    ss = atan(a*b*b/(2*x));
  }
    double s = ss*180/M_PI;
    cout << s << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 100100
using namespace std;
long long high[maxn],f[maxn],num[maxn];//f隶ー蠖穂ク贋ク?アゑシ敬igh隶ー蠖穂ク矩擇譛牙?蝮礼??系um隶ー蠖穂サ・i荳コ譬ケ逧??蟄占鰍轤ケ荳ェ謨ー (豺ア蠎ヲ??
void init()//蛻晏ァ句喧 
{
	for(int i=0;i<maxn;i++)
	{
		f[i]=i;
		high[i]=0;//譬ケ闃らせ逧?ォ伜コヲ荳コ0 
	}
}
int find(int x)
{
	if(x==f[x]) return f[x];
	int r=f[x];
	f[x]=find(f[x]);
	high[x]+=high[r];//霍晄?闃らせ逧?キ晉ヲサ 
	return f[x];//x逧??闃らせ 
}
void unio(int x,int y,int w)
{
	int fx=find(x);
	int fy=find(y);
	if(fx==fy)  return;
	f[fx]=fy;//fx逧??闃らせ蜿倅クコfy 
	high[fx]=high[y]-high[x]-w;
	//cout<<fx<<" "<<fy<<"  "<<high[fx]<<endl;
}
int main()
{
	int t,n,m;
	char s[5];
	int a,b,w;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		if(n==0&&m==0)
		{
			return 0;
		}
		init();
		while(m--)
		{
			scanf("%s",s);
			if(s[0]=='!')
			{
				scanf("%d%d%d",&a,&b,&w);
				unio(a,b,w);
			}
			else
			{
				scanf("%d%d",&a,&b);
				int fx=find(a);
				int fy=find(b);
				if(fx==fy)
				{
					printf("%lld\n",high[b]-high[a]);
				}
				else
				{
					puts("UNKNOWN");
				}
			}
		}
	}
	return 0;
}

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

int n, m;
int ans = 0;

struct Edge{
    /*辺の情報を入れる構造体で行き先とコストを表している*/
    int to;
    Edge(int to) : to(to) {}
};

vector<Edge> g[35];

void dfs(int u, vector<bool> used){
    //cout<<u<<endl;
    bool end = true;
    rep(i, n){
        if(!used[i] && i!=u) end = false;
    }
    if(end) ans++;
    else{
        for(auto p : g[u]){
            int v = p.to;
            if(!used[v]){
                vector<bool> tmp = used;
                tmp[u] = true;
                dfs(v, tmp);
            }
        }
    }
}
int main(void){
    cin>>n>>m;
    rep(i, m){
        int a, b;
        cin>>a>>b;
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<bool>used(n, false);
    dfs(0, used);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    VI vi(101, -1), p(3);
    VVI pp(3, p);
    rep(i, 9){
        cii(a);
        vi[a] = i;
    }
    cii(n);
    rep(i, n){
        cii(b);
        if (vi[b] >= 0){
            pp[vi[b]/3][vi[b]%3] = 1;
        }
    }
    int bingo = 0;
    rep(i, 3){
        int now = 0;
        rep(j, 3){
            now += pp[i][j];
        }
        if (now == 3)
            bingo++;
        now = 0;
        rep(j, 3){
            now += pp[j][i];
        }
        if (now == 3)
            bingo++;
    }
    if (pp[0][0] + pp[1][1] + pp[2][2] == 3)
        bingo++;
    if (pp[0][2] + pp[1][1] + pp[2][0] == 3)
        bingo++;
    auto ans = (bingo>=1)?"Yes":"No";
    co(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(false);cin.tie(0);

int main() {
	optimizar_io
	
	int n, a; 
	set<int> diff;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		diff.insert(a);
	}
	if (n == diff.size())
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

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

//n
int main() {
    int n;
    cin >> n;
    vector<int>c;
    vector<int>v;
    while(n--){
        int i;
        cin >> i;
        c.push_back(i);
        v.push_back(i);
    }
    sort(v.begin(),v.end());
    int count = 0;
    for(int i = 0;i < v.size();i++){
        if(v[i] != c[i])
            count++;
    }
    if(count > 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 3564
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
cd=[list(map(int,input().split())) for _ in range(m)]
cd.reverse()

for i in range(n):
    now=float("inf")
    ans=0
    for j in range(m):
        if now>=(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])):
            now=(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
            ans=j
    print(m-ans)


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

int main(void){
    // Your code here!
    int k,n;cin>>n>>k;
    vector<long long> h(n),flog(n,1000000000);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    flog[0]=0;
    flog[1]=abs(h[1]-h[0]);
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i>=j){
                flog[i]=min(flog[i],flog[i-j]+abs(h[i]-h[i-j]));
            }else{
                break;
            }
        }
    }
    cout<<flog[n-1]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	INT n, d;
	cin >> n >> d;
	vector<vector<INT>> x(n, vector<INT>(d, 0));

	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = 0; j < d; j++)
		{
			cin >> x[i][j];
		}
	}

	int ans = 0;
	for (size_t i = 0; i < n - 1; i++)
	{
		for (size_t j = i + 1; j < n; j++)
		{
			int dist = 0;
			for (size_t k = 0; k < d; k++)
			{
				dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			
			int s = 1;
			while (s * s <= dist)
			{
				if (s * s == dist)
				{
					ans++;
					break;
				}
				s++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int x,y,s,n,ans=0,tmp;
	while(1){
		cin >> x >> y >> s;
		if(x==0&&y==0&&s==0){
			break;
		}
		for(int i=1;i<s;i++){
			for(int j=s;j>1;j--){
				if( ((i*(100+x)/100) + (j*(100+x)/100))==s){
					tmp=(i*(100+y)/100) + (j*(100+y)/100);
					ans=max(ans,tmp);
				}
			}
		}
		cout << ans << endl;
		ans=0;
		tmp=0;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline
def print_ans(N, A, B):
    """Test Case
    >>> print_ans(2, "3 5 2", "4 5")
    9
    >>> print_ans(3, "5 6 3 8", "5 100 8")
    22
    >>> print_ans(2, "100 1 1", "1 100")
    3
    """
    ar = list(map(int, A.split()))
    br = list(map(int, B.split()))
    ans = 0
    for i in range(N):
        if br[i] < ar[i]:
            ans += br[i]
        else:
            ans += ar[i]
            br[i] -= ar[i]
            if ar[i + 1] <= br[i]:
                ans += ar[i + 1]
                ar[i + 1] = 0
            else:
                ans += br[i]
                ar[i + 1] -= br[i]  
    print(ans)

if __name__ == '__main__':
    N= int(input().rstrip())
    A = input().rstrip()
    B = input().rstrip()    
    print_ans(N, A, B)


Measured memory_bytes: 21164
#include<iostream>

using namespace std;


int main(){

  while(true){
    string s[3];
    cin >> s[0];
    if(s[0] == "0")break;
    cin >> s[1];
    cin >> s[2];
    if(s[0][0] == s[0][1] && s[0][1] == s[0][2] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][0] == s[1][0] && s[1][0] == s[2][0] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][0] == s[1][1] && s[1][1] == s[2][2] && s[0][0] != '+'){
      cout << s[0][0] << endl;
      continue;
    }
    if(s[0][1] == s[1][1] && s[1][1] == s[2][1] && s[0][1] != '+'){
      cout << s[0][1] << endl;
      continue;
    }
    if(s[0][2] == s[1][2] && s[1][2] == s[2][2] && s[0][2] != '+'){
      cout << s[0][2] << endl;
      continue;
    }
    if(s[0][2] == s[1][1] && s[1][1] == s[2][0] && s[0][2] != '+'){
      cout << s[0][2] << endl;
      continue;
    }
    if(s[1][0] == s[1][1] && s[1][1] == s[1][2] && s[1][0] != '+'){
      cout << s[1][0] << endl;
      continue;
    }
    if(s[2][0] == s[2][1] && s[2][1] == s[2][2] && s[2][0] != '+'){
      cout << s[2][0] << endl;
      continue;
    }


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

Measured memory_bytes: 1180
#include <stdio.h>

int main() {
    int N, M;
    scanf("%d %d", &N, &M);

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

    int flag[N];
    for(i = 0; i < N; i++) {
        flag[i] = 1;
    }

    int A, B;
    for(i = 0; i < M; i++) {
        scanf("%d %d", &A, &B);
        if(H[A-1] > H[B-1]) {
            flag[B-1] = 0;
        } else if(H[A-1] == H[B-1]){
            flag[A-1] = 0;
            flag[B-1] = 0;
        } else {
            flag[A-1] = 0;
        }
    }

    int ans = 0;
    for(i = 0; i <N; i++) {
        if(flag[i] == 1) {
            ans += 1;
        }
    }

    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 2508
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<pair<int64_t,int64_t>>C(N);
  for(int i=0;i<N;i++){
  int64_t T,A;
    cin>>T>>A;
    pair<int64_t,int64_t>p(T,A);
    C.at(i)=p;
  }int64_t x,y;
  x=1,y=1;
  for(int i=0;i<N;i++){
  int64_t T=C.at(i).first;
    int64_t A=C.at(i).second;
  int64_t a=max((x-1)/T,(y-1)/A);
    a++;
    x=T*a; y=A*a;
  }int64_t ans=x+y;
  cout<<ans<<endl;
     return 0;
}

Measured memory_bytes: 256
def solve():
    N = int(input())
    flag = False

    for i in range(9):
        for j in range(9):
            if((i+1)*(j+1) == N):
                print("Yes")
                flag = True
        if flag:
            break
    else:
        print("No")


if __name__ == "__main__":
    solve()


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

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)
typedef long long ll;

const int N = 200200;
const int mod = 1e9 + 7;
const ll inf = 1e18;

int n, ans = 1e9;
inline int g(int n) {
    int res = 0;
    while(n) res += n % 10, n /= 10;
    return res;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int a = 1; a < n; ++a) ans = min(ans,g(a) + g(n-a));
    cout << ans;
    return 0;
}

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

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];

  int l; cin >> l;
  int j = n - 1;

  vector<vector<int>> go(20, vector<int>(n, -1));
  for (int i = n - 1; i >= 0; --i) {
    while (v[j] - v[i] > l) --j;
    go[0][i] = j;
    for (int k = 0; k < 19; ++k) {
      int nxt = go[k][i];
      if (nxt != -1)
        go[k + 1][i] = go[k][nxt];
    }
  }

  int q; cin >> q;
  while (q--) {
    int a, b; cin >> a >> b; --a; --b;
    if (a > b) swap(a, b);

    int ans = 1;
    for (int k = 19; k >= 0; --k) {
      if (go[k][a] == -1) continue;
      if (go[k][a] < b) {
        ans += (1 << k);
        a = go[k][a];
      }
    }
    cout << ans << '\n';
  }
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
pair<ll,ll> P[101010];
ll A[101010],B[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll ma=0;
	FOR(i,N) {
		cin>>x>>y;
		y++;
		P[i]={x,y};
	}
	/*
	sort(P,P+N);
	ll L=P[0].second,R=P[0].first;
	A[0]=R-L;
	for(i=1;i<N;i++) {
		L=max(L,P[i].second);
		R=min(R,P[i].first);
		A[i]=max(0LL,R-L);
	}
	L=P[N-1].second,R=P[N-1].first;
	B[N-1]=R-L;
	for(i=N-2;i>=0;i--) {
		L=max(L,P[i].second);
		R=min(R,P[i].first);
		B[i]=max(0LL,R-L);
	}
		
	FOR(i,N) {
		ma=max(ma,A[i]+B[i+1]);
	}
	
	FOR(i,N) swap(P[i].first,P[i].second);
	sort(P+1,P+N);
	ZERO(A);
	ZERO(B);
	L=P[0].first,R=P[0].second;
	A[0]=R-L;
	for(i=1;i<N;i++) {
		L=max(L,P[i].first);
		R=min(R,P[i].second);
		A[i]=max(0LL,R-L);
	}
	L=P[N-1].first,R=P[N-1].second;
	B[N-1]=R-L;
	for(i=N-2;i>=0;i--) {
		L=max(L,P[i].first);
		R=min(R,P[i].second);
		B[i]=max(0LL,R-L);
	}
	*/
	sort(P,P+N);
	ZERO(A);
	ZERO(B);
	ll L=P[0].first,R=P[0].second;
	A[0]=R-L;
	for(i=1;i<N;i++) {
		L=max(L,P[i].first);
		R=min(R,P[i].second);
		A[i]=max(0LL,R-L);
	}
	L=P[N-1].first,R=P[N-1].second;
	B[N-1]=R-L;
	for(i=N-2;i>=0;i--) {
		L=max(L,P[i].first);
		R=min(R,P[i].second);
		B[i]=max(0LL,R-L);
	}
	FOR(i,N) {
		ma=max(ma,A[i]+B[i+1]);
	}
	
	
	multiset<int> SL,SR;
	FOR(i,N) SL.insert(P[i].first),SR.insert(P[i].second);
	FOR(i,N) {
		SL.erase(SL.find(P[i].first));
		SR.erase(SR.find(P[i].second));
		
		int AL=*SL.rbegin();
		int AR=*SR.begin();
		ma=max(ma,P[i].second-P[i].first+max(0,AR-AL));
		SL.insert(P[i].first);
		SR.insert(P[i].second);
	}
	
	
	
	cout<<ma<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
Node root;

void insert(int);
void inorder(Node);
void preorder(Node);

void insert(int k){
  Node y = NIL;  //xの親
  Node x = root; //Tの根
  Node z;
 
  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x; // 親を設定
    if( z->key < x->key ) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z; 
  else if( z->key < y->key ) y->left = z;
  else y->right = z;

}
 
void inorder(Node z){ // 中間順巡回の出力
  if( z->left != NIL ) inorder( z->left );
  printf(" %d",z->key);
  if( z->right != NIL ) inorder( z->right );
}

void preorder(Node z){ // 先行順巡回の出力
  printf(" %d",z->key);
  if( z->left != NIL ) preorder(z->left);
  if( z->right != NIL ) preorder(z->right);
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }
  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
using namespace std;
int main(void){
  int number,ac = 0,wa = 0,tle = 0,re =0 ;
  cin >> number;
  for(int i = 0; i<number; i++ ){
  	string score;
    cin >> score;
    if(score =="AC"){
    	ac++;
    }else if(score == "WA"){
    	wa++;
    }else if(score == "TLE"){
    	tle++;
    }else if(score == "RE"){
    	re++;
    }
  }
  cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re<<endl;
	//cout << "XXXXXX" << endl;
	return 0;
}


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

int main() {
  int N;
  cin>>N;
  int count=0;
  if(N%10==7) count++;
  if(N/10%10==7) count++;
  if(N/100==7) count++;
  if(count==0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int k = scanner.nextInt();
			String s = scanner.next();
			System.out.println((k >= s.length()) ? s : s.substring(0, k) + "...");
		}
	}
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll x,y;
    while(cin >> x >> y)
        cout << (x % y == 0? -1 : x) << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long total = 0;
    int N = sc.nextInt();
    for (int i = 0; i < N; i++) {
      total += sc.nextInt() - 1;
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 28144
/*
 * SAD
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using orderd_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define S second
#define F first
#define pb push_back
const int inf = 1e9;
using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, M = 1000 * 1000 * 10 + 5, K = 55, Base = 27, MOD = 1e9
		+ 7, MOD2 = 998244353;
const ll MX = 1e15;
const int blkSz = 200;
const db EPS = 1e-7;
const int PI = 3;
vector<vector<int>> adj;
int n, m;
int u[N + N], v[N + N], c[N + N];
int lowlink[N], dfn[N], comp[N];
bool instack[N];
int num = 0;
bitset<N+N>bridges;
int cmp[N], val[N], cur;
stack<int>stk;
string s;
int sum;
void tarjan(int node, int p) {
	dfn[node] = lowlink[node] = ++num;
	stk.push(node);
	for(auto i : adj[node]){
		int to = node ^ u[i] ^ v[i];
		if(!dfn[to]){
			tarjan(to,node);
			lowlink[node] = min(lowlink[node], lowlink[to]);
			if(lowlink[to] > dfn[node]){
				bridges.set(i);
			}
		}	else if(p != to){
			lowlink[node] = min(lowlink[node],dfn[to]);
		}
	}
	if(dfn[node] == lowlink[node]){
		++cur;
		int tmp, cnt = 0;
		do{
			tmp = stk.top();	stk.pop();
			cmp[tmp] = cur;
			cnt += (s[tmp] == 'H');
			cnt -= (s[tmp] == 'A');
		}while(tmp!=node);
		sum += cnt;
		val[cur] = cnt;
	}
}
ll ans = 0;
int dfs(int node, int p){
	int cur = 0;
	cout << node << '\n';
	for(auto i : adj[node]){
		int to = node ^ u[i] ^ v[i];
		int w = c[i];
		if(to != p){
			int x = dfs(to,node);
			cur += x;
			ans += w * 1ll * min(abs(cur), abs(sum-cur));
		}
	}
	return cur + val[node];
}
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int a, b,c;
	cin >> a >> b >> c;
	if(a==b&&b==c)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256