akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int dp[3001][3001] = {};
pair<int, int> parent[3001][3001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s >> t;

    for (int i=0; i<=s.length(); i++)
        parent[i][0] = {-1, -1};
    for (int j=0; j<=t.length(); j++)
        parent[0][j] = {-1, -1};
    for (int i=1; i<=s.length(); i++)
        for (int j=1; j<=t.length(); j++) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                parent[i][j] = {i-1, j-1};
            } else if (dp[i-1][j] > dp[i][j-1]) {
                dp[i][j] = dp[i-1][j];
                parent[i][j] = {i-1, j};
            } else {
                dp[i][j] = dp[i][j-1];
                parent[i][j] = {i, j-1};
            }
        }

    string ret;
    int i = s.length(), j = t.length();
    while (i != -1 && j != -1) {
        pair<int, int> p = parent[i][j];
        if (p.first == i - 1 && p.second == j - 1 && i > 0)
            ret += s[i-1];
        i = p.first, j = p.second;
    }

    reverse(ret.begin(), ret.end());
    cout << ret << "\n";

    return 0;
}


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

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

	vector<string>a;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j + i <= s.size(); j++) {
			a.push_back(s.substr(j, i));
		}
	}
	sort(a.begin(), a.end());
	unique(a.begin(), a.end());
	cout << a[k] << endl;

	return 0;
}

Measured memory_bytes: 1660
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <random>

//AtCoderC++.cpp

using namespace std;


#define rep(i,from,to) for(int i=from;i<to;i++)
#define ints(name,n) vector<int> name;name.resize(n)

template<typename T> void Show(vector<vector<T>> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(vector<T> v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	rep(i, 0, h) {
		rep(j, 0, w) {
			if (!ts[i][j])return false;
		}
	}
	return true;
}

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	auto Bs = vector<int>();
	Bs.resize(M);
	for (int i = 0; i < M; i++) {
		cin >> Bs[i];
	}
	auto As = vector<vector<int>>();
	As.resize(N);
	for (int i = 0; i < N; i++) {
		As[i].resize(M);
		for (int j = 0; j < M; j++) {
			cin >> As[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++) {
			sum += As[i][j] * Bs[j];
		}
		sum += C;
		if (sum > 0)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
{AT1977}
var
i,x,s1,s2:longint;
begin
s1:=0;
s2:=0;
for i:=1 to 3 do
begin
read(x);
 if x=5 then
 inc(s1);
 if x=7 then
 inc(s2);
end;
if (s1=2) and (s2=1) then
writeln('YES')
else
writeln('NO');
end.

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n, temp;
    int count[100005] = {0};

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> temp;
        if(temp == 0){
            count[temp]++;
            count[temp + 1]++;
        }else{
            count[temp - 1]++;
            count[temp]++;
            count[temp + 1]++;
        }
    }

    int maxCount = 0;

    for(int i = 0; i < 100005; i++) maxCount = max(maxCount, count[i]);

    cout << maxCount << endl;

    return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <climits>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define INF 1LL << 60;
#include <string>
#include <typeinfo>
#include <bitset>

int main(){
  string S;
  cin >> S;
  ll ans;
  
  for(int i=0; i < (1 << S.size()-1); i++){
    ll sum = 0;
    ll tmp = S[0] - '0';
    for(int j=0; j < S.size()-1; j++){
      if((i >> j & 1) == 1){
        sum += tmp;
        tmp=0;
      }
      tmp = tmp*10 + (S[j+1] - '0');
    }
    sum += tmp;
    ans += sum;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#TIME : 
import sys
from math import sqrt
input = sys.stdin.readline

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

a,b = invr()
print(a*b) 

Measured memory_bytes: 61908
// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

vector<string> Z { "NO", "YES" };

#include <set>
void solve() {
  string s, t;
  cin >> s >> t;
  s += t;
  string u = s;
  reverse(u.begin(), u.end());  
  cout << Z[s == u] << endl;
}


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

int main() {
  int n, k; cin >>n >>k;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  sort(a.begin(), a.end());
  int ret = 0;
  for (int i = 0; i < k; i++) ret += a[i];
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.Math;

public class Main {  
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int qty = Integer.parseInt(br.readLine());
    String[] value = br.readLine().split(" ");
    String [] cost = br.readLine().split(" ");
    int sum = 0;
    
    int[] tValue = new int[qty], tCost = new int[qty];
    for (int i = 0; i < qty; i++) {
      tValue[i] = Integer.parseInt(value[i]);
      tCost[i] = Integer.parseInt(cost[i]);
    }
    
    for (int i = 0; i < qty; i++) {
      int tmp = tValue[i] - tCost[i];
      if (tmp > 0) {
        sum += tmp;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 22740
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M;



int main(){
    cin >> N;
    N = N%10;
    if(N==3){
        cout << "bon" << endl;
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    
}




Measured memory_bytes: 3632
import heapq
N,M = map(int,input().split())
AB = [[] for i in range(M+1)]
for i in range(N):
    a,b = list(map(int,input().split()))
    if a <= M:
        AB[a].append(-b)
work = 0
AB2 = []
heapq.heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heapq.heappush(AB2,j)
    if len(AB2) > 0:
        b = heapq.heappop(AB2)
        work += -b
print(work)

Measured memory_bytes: 23752
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 50;
const int M = 1e5+10;
/*=================================================================================*/

int n, a[N][N], con[N];
ll ans, dp[M], tmp[M];

int main() {
   scanf("%d", &n);
   for0(i, n) for0(j, n) scanf("%d", &a[i][j]);

   for0(now, (1<<n)) {
      int cnt = 0;
      for0(i, 16)
         if(now & (1<<i)) {
            con[cnt++] = i;
         }
      ll sum = 0;
      for0(i, cnt) for(int j = i + 1; j < cnt; ++j) {
         sum += a[con[i]][con[j]];
      }
      dp[now] = tmp[now] = sum;
   }

   for0(now, (1<<n)) for(int last = now; last; last = (last-1) & now) {
      dp[now] = max(dp[now], dp[now ^ last] + tmp[last]);
   }

   cout<<dp[(1<<n) - 1]<<endl;
   return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n;
  cin >> n;
  vector<long> l(n);
  for (long &x : l) {
    cin >> x;
  }

  long ans = 0;
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        long sum = 0;
        long mx = 0;
        sum = l.at(i) + l.at(j) + l.at(k);
        mx = max(l.at(i), max(l.at(j), l.at(k)));
        if (sum <= 2 * mx) {
          continue;
        }

        if (l.at(i) != l.at(j) && l.at(j) != l.at(k) && l.at(k) != l.at(i)) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	else {
		printf("a > b\n");
	}
	return 0 ;
}

Measured memory_bytes: 580
A, B, C, D = map(int, list(str(input())))
ABCD=[A,B,C,D]
#print(ABCD)
for i in range(0, 2**3):
    #print(bin(i))
    answer=A
    shiki='{}'.format(A)
    for j in range(3):
        #print(bin(i), j)
        if ((i >> j) & 1):
            answer+=ABCD[j+1]
            shiki+='+'
        else:
            answer-=ABCD[j+1]
            shiki+='-'
        shiki+='{}'.format(ABCD[j+1])
    #print(answer)
    #print(shiki)
    if answer==7:
        shiki+='=7'
        print(shiki)
        break

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int INF = 1001001001;

int main(){
    int r;
    cin >> r;
    cout << r*r << endl;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n;
	cin >> n;
	int cnt = 0;
	for(int i=1; i<=n; i++){
		if(i%2==0)continue;
		int cur = i; 
		int curr = 0;
		for(int j=1; j<=sqrt(cur); j++){
			if(cur%j==0){
				curr++;
				if(cur/j!=j)curr++;
			}
		}			
		if(curr==8)cnt++;
	}
	cout << cnt;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int main() {
  int N;
  cin >> N;
  vector<ll> a(N),b(N);
  vector<ll> SA;
  ll s=0;
  for(int i=0;i<N;i++) {
    cin >> a[i];
  }

  ll ans=0,need=0;
  for(int i=0;i<N;i++) {
    cin >> b[i];
    if(a[i]-b[i]>=0) {
      SA.push_back(a[i]-b[i]);
    } else{
      need += (b[i]-a[i]);
      ans++;
    }
  }
  sort(SA.begin(),SA.end());

  ll count=0;
  while(need>0) {
    if(SA.size()==0) {
      cout << -1 << endl;
      return 0;
    }
    need -= SA[SA.size()-1];
    SA.pop_back();
    ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N, u, v, md, now, dis = 0;
	vector<pair<int,pair<int,int>>> p;
	vector<pair<int,int>> in;
	vector<int> ans;
	
	cin>>N>>u>>v;
	
	cout<<"? "<<u<<" "<<v<<endl;
	cout.flush();
	cin>>md;
	
	for(int i = 1; i <= N; i++){
		if(i == u || i == v) continue;
		int a, b;
		cout<<"? "<<u<<" "<<i<<endl;
		cout.flush();
		
		cin>>b;
		
		cout<<"? "<<v<<" "<<i<<endl;
		cout.flush();
		
		cin>>a;
		
		if(a + b == md){
			in.push_back(make_pair(b,i));
		}
	}
	
	sort(in.begin(), in.end());
	
	ans.push_back(u);
	now = u;
	
	for(int i = 0; i < in.size(); i++){// cout<<"in "<<in[i].second<<endl;
		int a, b;
		
		cout<<"? "<<v<<" "<<in[i].second<<endl;
		cout.flush();
		cin>>a;
		
		cout<<"? "<<now<<" "<<in[i].second<<endl;
		cout.flush();
		cin>>b;
		
		if(b+a+dis == md){
			ans.push_back(in[i].second);
			now = in[i].second;
			dis = in[i].first;
		}
	}
	
	ans.push_back(v);
	
	cout<<"!";
	
	for(int i = 0; i < ans.size(); i++){
		cout<<" "<<ans[i];
	}
	cout<<endl;
	cout.flush();
	
	return 0;
}


Measured memory_bytes: 4684
n = int(input())
buildings = [[[0] * 10 for i in range(3)] for _ in range(4)]
for i in range(n):
    b,f,r,v = map(int, input().split())
    buildings[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        print(" "+ " ".join([str(i) for i in buildings[i][j]]))
    if i < 3:
        print("####################")


Measured memory_bytes: 5608
n=int(input())
s=input()
q=int(input())
for i in list(map(int,input().split())):
    a=0
    v=[0,0,0]
    for j in range(n):
        if s[j]=="D":
            v[0]+=1
        elif s[j]=="M":
            v[1]+=1
            v[2]+=v[0]
        if j>=i:
            if s[j-i]=="D":
                v[0]-=1
                v[2]-=v[1]
            elif s[j-i]=="M":
                v[1]-=1
        if s[j]=="C":
            a+=v[2]
    print(a)

Measured memory_bytes: 60396
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
signed main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if ((a[0] == a[1] && a[1] != a[2])||(a[0]!=a[1]&&a[1]==a[2])) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int n, i, j, a, k, l;
  int Adj[N][N];

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

  for (i = 0; i < n; i++){
    scanf("%d%d", &a, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &l);
      Adj[a-1][l-1] = 1;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j != n-1) printf("%d ", Adj[i][j]);
      else printf("%d", Adj[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


h, w = rm()
s = [rr() for _ in range(h)]
x = [0, 0, 1, -1, 1, 1, -1, -1]
y = [1, -1, 0, 0, 1, -1, 1, -1]
ans = ['']*h
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            ans[i] += '#'
        else:
            c = 0
            for dx, dy in zip(x, y):
                if 0 <= i + dx < h and 0 <= j + dy < w:
                    if s[i+dx][j+dy] == '#':
                        c += 1
            ans[i] += str(c)
for i in ans:
    print(i)






Measured memory_bytes: 26988
import sys
input = lambda: sys.stdin.readline()

#https://www.slideshare.net/chokudai/union-find-49066733
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * self.n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y: return False
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
        
  def issame(self, x, y):
    return self.find(x) == self.find(y)
  
  def get_node_members(self):
    return [[j for j in range(self.n) if self.issame(i, j)] for i in range(self.n)]
  
  def size(self, x):
    return -self.parents[self.find(x)]
  
N = list(map(int, input().split()))
uf = UnionFind(N[0])
results = [0 for i in range(N[0])]
for i in range(N[1]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  results[x] += 1
  results[y] += 1
  uf.union(x, y)
#print(uf.parents)

for i in range(N[2]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  if uf.issame(x, y):
  	results[x] += 1
  	results[y] += 1
  
#node_members = uf.get_node_members()
#print(node_members, results)

print(" ".join([str(uf.size(i) - results[i] - 1) for i in range(N[0])]))


Measured memory_bytes: 14872
#include<bits/stdc++.h>
#define int long long int 
using namespace std;

int h[100007];
int dp[100007];
int solve(int n,int k){

dp[1]=0;
dp[2]=abs(h[2]-h[1]);

for(int i=3;i<=n;i++)
{   int ans = INT_MAX;
    for(int j=i-1;j>=(i-k) && j>=1;j--)
    {
        ans =min(ans,abs(h[j]-h[i])+dp[j]);
    }
  dp[i]=ans;
}


return dp[n];
}

int32_t main(){

    int n,k;
    cin>>n>>k;
    memset(h,0,sizeof h);
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++)
       cin>>h[i];

    cout<<solve(n,k);

return 0;
    
}


Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<pii> VP;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VP A(N);
	REP(i, N) {
		cin >> A[i].first >> A[i].second;
		A[i].second++;
	}
	SORT(A);
	int s1, s2, t1, t2;
	int ans = -1;
	s2 = A[N - 1].first;

	VI mi(N, INF), mii(N, INF);

	
	mi[N - 1] = A[N - 1].second;
	for (int i = N - 2; i >= 0; i--)mi[i] = min(A[i].second, mi[i + 1]);
	
	mii[0] = A[0].second;
	FOR(i, 1, N)mii[i] = min(mii[i - 1], A[i].second);

	REP(i, N - 1) {

		int cnt=-1;
		s1 = A[i].first;
		t2 = mi[i + 1];
		t1 = mii[i];

		chmax(cnt, max((t1 - s1), 0LL) + max((t2 - s2), 0LL));
		chmax(ans, cnt);

		if (i == 0)continue;

		t1 = A[i].second;
		t2 = min(mii[i - 1], mi[i + 1]);


		chmax(cnt, max((t1 - s1), 0LL) + max((t2 - s2), 0LL));
		
		chmax(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3456
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}




int main() {
	int A, B, C, D,E,F;
	string an = "NO";
	cin >> A >> B >> C >> D >> E >> F;
	vector<int> n(4);
	n.at(A-1)++;
	n.at(B - 1)++;
	n.at(C - 1)++;
	n.at(D - 1)++;
	n.at(E - 1)++;
	n.at(F - 1)++;

	if (Max(max(n.at(0), n.at(1)), n.at(2), n.at(3)) < 3) {
		an = "YES";
	}

	cout << an << endl;
	
}



Measured memory_bytes: 256
import Data.Char

main = interact $ show . sol . get

get = fmap (read . (:[])) . filter isDigit

sol = f =<< length

f 1 [x] = x
f n (x:xs) = x*(4*10^(n-1) + 5*10^(n-2) - 2^(n-2)) `div` 4 + 2*f (n-1) xs


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

using namespace std;

int main(){
    vector<int> v;int n,min = (1 << 29),ans = 0;;
    cin >> n;
    for(int i = 0;i < n;i++){
        int x;cin >> x;
        v.push_back(x);
    }
    for(int i = 0;i < n;i++){
        if(v[i] < min){
            ans++;
            min = std::min(min,v[i]);
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define pb			push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define hastr(s, c)		((s).find(c) != string::npos)
template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int N = 1e7+9;
int a[N], n;
int main() {
#ifndef	ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    for(int i = 1; i <= N; ++i)
    	for(int j = i; j <= N; j += i)
    		a[j]++;
    ll ans = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i)
    	ans += i * 1ll * a[i];
    cout << ans;
    return 0;
}


Measured memory_bytes: 42712
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int n;
int col[110];

int main() {
    int i;

    scanf("%d",&n);
    if (n%2) {
        for (i=0;i<n;i++) col[i] = min(i,n-2-i);
        col[n-1] = n;
    }
    else {
        for (i=0;i<n;i++) col[i] = min(i,n-1-i);
    }
    vector<pii> vec;
    for (i=0;i<n;i++) {
        for (int j=i+1;j<n;j++) {
            if (col[i]!=col[j]) vec.push_back(pii(i,j));
        }
    }
    printf("%d\n",vec.size());
    for (pii &v : vec) printf("%d %d\n",v.first+1,v.second+1);

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};


ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    int s, w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe";
    else
    cout<<"safe";
    
    
} 

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

#define ll long long int
#define vi vector<int>
#define vl vector<ll>

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second > b.second;
}

int main() {

    int N, M;
    cin >> N >> M;

    vl A;
    ll tmp;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A.push_back(tmp);
    }

    ll B, C;
    vector<pair<ll, ll>> vp;
    for (int i = 0; i < M; i++) {
        cin >> B >> C;
        vp.push_back(make_pair(B, C));
    }

    sort(vp.begin(), vp.end(), compare);

    ll count = 0;
    ll sum = 0;

    for (int i = 0; i < N; i++) {
        if (vp[count].first == 0) count++;
        if (count == M) break;
        A.push_back(vp[count].second);
        vp[count].first--;
    }

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

    for (int i = 0; i < N; i++) {
        sum += A[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4976
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	string s;
	cin >> s;
	if (s == "RRR")cout << 3 << endl;
	else if (s == "RRS"||s == "SRR")cout << 2 << endl;
	else if (s == "SSS")cout << 0 << endl;
	else cout << 1 << endl;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N, x; cin >> N >> x;
    
    if (x == 1 or x == 2 * N - 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        
        vector<ll> ans(2 * N, -1);
        vector<bool> used(2 * N, false);
        queue<ll> que;
        if (N != 2) {
            if (x - 2 >= 1) {
                ans[N-1] = x - 1; used[x - 1] = true;
                ans[N]   = x    ; used[x]     = true;
                ans[N+1] = x + 1; used[x + 1] = true;
                ans[N+2] = x - 2; used[x - 2] = true;
            } else {
                ans[N-1] = x + 1; used[x + 1] = true;
                ans[N]   = x    ; used[x]     = true;
                ans[N+1] = x - 1; used[x - 1] = true;
                ans[N+2] = x + 2; used[x + 2] = true;
            }
        }
        
        FOR(i, 1, 2 * N) if (!used[i]) que.push(i);
        FOR(i, 1, 2 * N) if (ans[i] == -1) {
            ll x = que.front(); que.pop();
            ans[i] = x;
        }
        FOR(i, 1, 2*N) cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

/**
 * Slimes
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            //char[] S = sc.next().toCharArray();
            String S = sc.next();

            int count = 0;
            char c = ' ';
            for (int i = 0; i < N; i++) {
                char c2 = S.charAt(i);

                if (c != c2) {
                    c = c2;
                    count++;
                }
            }

            System.out.println(count);
        }
    }

}


Measured memory_bytes: 24248
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=13)
    {
        cout<<b;
    }
    else if(a<=12&&a>=6)
    {
        cout<<b/2;
    }
    else if(a<6)
    {
        cout<<0;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n,a,b;
	cin>>n>>a>>b;
	lvi v;
	if(a*b < n || (a+b-1)>n) 
	{
		cout<<"-1\n";
	}
	else
	{
		ll tp=n;
		for(int i=b;i>=1;i--)
		{
			lvi v1;
			int count=0;
			while(tp>=i)
			{
				if(count==a) break;
				v1.pb(tp);
				count++;
				tp--;
			}
			reverse(all(v1));
			for(int j=0;j<v1.size();j++)v.pb(v1[j]);
		}
		for(int i=0;i<v.size();i++)
		{
			cout<<v[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 12140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,int> pdi;
const int N = 50005;
string str[N];
int main()
{
    string a;
    cin >> a;
    int k, cnt = 0;
    scanf("%d",&k);
    int siz = a.size();
    int mini;
    for(int i= 0; i < siz;i++)
    {
        str[++cnt] = a[i];
        mini =min(k,siz-i);
        for(int j = 1 + i; j < mini + i; j ++,cnt++)
            str[cnt + 1] = str[cnt] + a[j];
    }
    sort(str + 1, str + cnt + 1);
    unique(str + 1, str + cnt + 1);
    cout<< str[k] <<endl;
    return 0;
}









Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}
 
/* brownsands :Arpit */		

void solve()
{   string s;int i,j,ans=0,n,r,g,b,r1,g1,b1,r2,g2,b2;
    cin >> n >> s;int dp[n+5][3];
    dp[n][0]=dp[n][1]=dp[n][2]=0;
    for(i=n-1;i>=0;i--)
    {
        for(j=0;j<3;j++)
        dp[i][j]=dp[i+1][j];

        if(s[i]=='R')dp[i][0]++;
        else if(s[i]=='G')dp[i][1]++;
        else dp[i][2]++;
    }
    for(i=0;i<n-3;i++)
    {   r=0;g=0;b=0;
        if(s[i]=='R')r++;
        else if(s[i]=='G')g++;
        else b++;
        r2=r;g2=g;b2=b;
        for(j=i+1;j<n-1;j++)
        {   r=r2;g=g2;b=b2;
            r1=r;g1=g;b1=b;
            if(s[j]!=s[i])
            {   r=r1;g=g1;b=b1;
                if(s[j]=='R')r++;
                else if(s[j]=='G')g++;
                 else b++;

                 if(r==0)
                 {
                     ans+=dp[j+1][0];
                     if((j-i+j)<n && s[j-i+j]=='R')
                     ans--;
                 }
                 else if(b==0)
                 {
                    ans+=dp[j+1][2];
                     if((j-i+j)<n && s[j-i+j]=='B')
                     ans--;   
                 }

                 else
                 {
                     ans+=dp[j+1][1];
                     if((j-i+j)<n && s[j-i+j]=='G')
                     ans--;
                 }
            }
        }
    }

    cout << ans;
}
signed main()
{ 
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int test=0,t;
  //  cin>>t;
    t=1;
   while(test++ <t){         
   	//cout<<"Case# "<<test<<": ";
        solve();}
  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  }


Measured memory_bytes: 3900
import java.util.*;

class Main{
	public static void main(String[] A){
		Scanner s=new Scanner(System.in);
		
		int[][]f=new int[10][10];
		while(true){
			int h=s.nextInt(),w=s.nextInt();
			if(h+w==0)
				return;
			for(int i=0;i<h;++i)
				for(int j=0;j<w;++j)
					f[i][j]=s.nextInt();
			
			int r=0;
			
			for(int i=0;i<h-2;++i) {
				for(int j=0;j<w-2;++j) {
					for(int k=i+2;k<h;++k) {
						loop:
						for(int l=j+2;l<w;++l) {
							
							int edge=9;
							for(int I=i;I<=k;++I)
								edge=Math.min(edge,Math.min(f[I][j],f[I][l]));
							for(int J=j;J<=l;++J)
								edge=Math.min(edge,Math.min(f[i][J],f[k][J]));
							
							int res=0;
							for(int I=i+1;I<k;++I) {
								for(int J=j+1;J<l;++J) {
									if(f[I][J]>=edge)
										continue loop;
									res+=edge-f[I][J];
								}
							}
							r=Math.max(r,res);
						}
					}
				}
			}
			System.out.println(r);
		}
	}
}



Measured memory_bytes: 37668
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n,m; cin >> n >> m;
  vvi G(n);
  rep(i,m) {
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].pb(b);
  }
  int s,t; cin >> s >> t; s--; t--;
  
  vvi dist(n,vi(3,-3));
  queue<pii> q;
  
  q.push(mp(s,0));
  dist[s][0] = 0;

  while(!q.empty()){
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for(auto nv : G[v]) {
      int nl = (l+1)%3;
      if(dist[nv][nl] != -3) continue;
      dist[nv][nl] = dist[v][l] + 1;
      q.push(mp(nv,nl));
    }
  }

  cout << dist[t][0]/3 << endl;
}

Measured memory_bytes: 11136
#include <iostream>
using namespace std;
int main(void){
    long long n,m,l,a,sum = 0;
    cin >> n >> m >> l;
    long long A[n][m];
    long long B[m][l];
    long long L[n][l];
    for(long long i = 0; i < n; i++){
        for(long long j = 0; j < m; j++){
            cin >> a;
            A[i][j] = a;
        }
    }
    for(long long i = 0; i < m; i++){
        for(long long j = 0; j < l; j++){
            cin >> a;
            B[i][j] = a;
        }
    }
    for(long long i = 0; i < l; i++){
        for(long long j = 0; j < n; j++){
            for(long long k = 0; k < m; k++){
                sum += B[k][i]*A[j][k];
            }
            L[j][i] = sum;
            sum = 0;
        }
    }
    for(long long i = 0; i < n; i++){
        for(long long j = 0; j < l-1; j++){
            cout << L[i][j] << " ";
        }
        cout << L[i][l-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
int n;
signed main(){
	acc_io;
	cin>>n;
	if(n%10==7){cout<<"Yes"<<endl;return 0;}
	if((n/10)%10==7){cout<<"Yes"<<endl;return 0;}
	if(n/100==7){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3668
N, M = map(int, input().split())
l = [[] for _ in range(N)]
ab = []
ans = 0
for _ in range(M):
    ab.append([int(i)-1 for i in input().split()])
    l[ab[-1][0]].append(ab[-1][1])
    l[ab[-1][1]].append(ab[-1][0])
for a, b in ab:
    stack = []
    seen = [False]*N
    stack.append(0)
    seen[0] = True
    while len(stack) != 0:
        v = stack.pop()
        for v2 in l[v]:
            if v == a and v2 == b or v == b and v2 == a:
                continue
            if not seen[v2]:
                stack.append(v2)
                seen[v2] = True
    if False in seen:
        ans += 1

print(ans)


Measured memory_bytes: 40176
program abc
	implicit none
	character(len=6) :: fname
    character(len=1) :: a,b,c,d,e,f

	read(*,*) fname
	c = fname(3:3)
	d = fname(4:4)
	e = fname(5:5)
	f = fname(6:6)

    if(c == d .and. e == f) then
    	write(*,*) "Yes"
    else
    	write(*,*) "No"
    endif
    
end program abc

Measured memory_bytes: 640
L = [ [ 0, "black",     0,  0,    0 ],
      [ 1, "blue",      0,  0,  255 ],
      [ 2, "lime",      0, 255,   0 ],
      [ 3, "aqua",      0, 255, 255 ],
      [ 4, "red",     255,   0,   0 ],
      [ 5, "fuchsia", 255,   0, 255 ],
      [ 6, "yellow",  255, 255,   0 ],
      [ 7, "white",   255, 255, 255 ] ]

while True:
    T = []
    s = input()
    if s == "0":
        break
    code = []
    for i in range(3):
        code.append( int(s[1+2*i:3+2*i], 16) )
    for i in range(len(L)):
        m = 0
        for j in range(3):
            m += (L[i][2+j] - code[j])**2
        T.append( [ L[i][0], m] )
    T.sort(key=lambda x: (x[1], x[0]))
    print(L[T[0][0]][1])



Measured memory_bytes: 5580
function main(lines) {
  const input = lines.split('\n').filter(function(val){return (1<=val && val<=10000);})
  for(let i=0; i<input.length; i++){
      console.log('Case' + ' ' + (i+1) + ': ' + input[i])
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22672
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
let mut s=1;
let m=1000000007;
let n:usize=read();
for i in 0..n{s=s*(i+1)%m}
println!("{}",s);
}

Measured memory_bytes: 4352
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	ll count=0;
	ll n;
	cin>>n;
	
	count+=n/500*1000;
	n%=500;
	count+=n/5*5;
	cout<<count;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


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

int main()
{
	int n;
	while (cin>>n)
	{
		if (n == 0)break;
		int data[11][11] = { 0 };

		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{
				cin >> data[i][j];
			}
		}

		for (int i = 0; i < n; i++)          //??????????¨????
		{
			for (int j = 0; j < n; j++)
			{
				data[i][n] += data[i][j];
			}
		}

		for (int i = 0; i < n; i++)           //??????????¨????
		{
			for (int j = 0; j < n+1; j++)     //n??????????????????
			{
				data[n][j] += data[i][j];
			}
		}


		for (int i = 0; i < n+1; i++)
		{
			for (int j = 0; j < n+1; j++)
			{
				cout.width(5);
				cout << data[i][j];
			}
			cout << endl;
		}
	}


	return 0;
}

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

int main() {
  int N;
  cin>>N;
  if(N==1)cout<<setprecision(10)<<1<<endl;
  else if(N%2==0) {
    cout<<0.5<<endl;
  }
  else {
    double ans=((double)N+1)/(2*(double)N);
    cout<<setprecision(10)<<ans<<endl;
  }
  return 0;
}


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

int main() {
    std::string s, t;
    std::cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        char c = s[s.size()-1];
        s.pop_back();
        s.insert(0, {c});
        if (s == t) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }
    std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, K = MAP()
x = LIST()
ans = INF

for i in range(N-K+1):
	tmp = x[i+K-1] - x[i] + min(abs(x[i+K-1]), abs(x[i]))
	ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 16320
n = int(input())
m3 = n // 3
m5 = n // 5
m15 = n // 15
a = (1 + n) * n // 2
a -= (3 + m3 * 3) * m3 // 2
a -= (5 + m5 * 5) * m5 // 2
a += (15 + m15 * 15) * m15 // 2
print(a)


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

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var input = Console.ReadLine().Split();
            int value = int.Parse(input[0] + input[1]);
            bool isSquare = false;
            for (int i = 1; i < Math.Pow(100, 2); i++)
            {
                if (i * i == value)
                {
                    isSquare = true;
                }
            }

            Console.WriteLine(isSquare ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	ll n;ll x, a, b[2000];
	cin >> n >> x;
	ll i, j; ll sum = 0;
	for (i = 0; i < n; i++) {
		cin >> a; b[i] = a; sum += a;
	}
	ll out=sum;
	for (i = 1; i < n; i++){
		sum = i*x;
		ll memo = b[n-1];
		for (j = n-1; j > 0; j--) {
			b[j] = min(b[j], b[j - 1]);
		}
		b[0] = min(b[0], memo);
		for (j = 0; j < n; j++) {
			sum += b[j];
		}
		out = min(out, sum);
	}
	cout << out << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

Measured memory_bytes: 384
import sys
 
A, B, M = map(int, sys.stdin.readline().split())
*a, = map(int, sys.stdin.readline().split())
*b, = map(int, sys.stdin.readline().split())
xyc = zip(*[map(int, sys.stdin.read().split())] * 3)
 
def main():
    res = min(a) + min(b)
 
    for x, y, c in xyc:
        res = min(res, a[x-1] + b[y-1] - c)
    return res
    
if __name__ == '__main__':
    ans = main()
    print(ans)

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

using namespace std;

string s, t;

void input() {
    cin >> s;
    cin >> t;
}

void judge() {
    t.pop_back();
    if(s == t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    input();
    judge();
    return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
  
int main(){
  
    int n[3];
    int t;
    scanf("%d %d %d\n", &n[0], &n[1], &n[2]);
  
   if(n[0]>n[1]){
      t=n[0];
      n[0]=n[1];
      n[1]=t;
   }
   if(n[1]>n[2]){
      t=n[1];
      n[1]=n[2];
      n[2]=t;
   }
   if(n[0]>n[1]){
      t=n[0];
      n[0]=n[1];
      n[1]=t;
   }
   printf("%d %d %d\n", n[0], n[1], n[2]);
  
  return 0;
 
}

Measured memory_bytes: 600