akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e8;
const int maxx = 1e6;

int main()
{
	int n, m;
	while(~scanf("%d %d",&n, &m))
	{
		cout << m - n + 1;
		for(int i = m - n + 2; i <= m + n - 1; i ++)
		{
			cout << " " << i;
		}
		puts("");
	}

	return 0;
}


Measured memory_bytes: 256
from collections import deque
N,M=map(int,input().split())
to=[[] for _ in range(N)]
for _ in range(M):
  a,b=map(int,input().split())
  to[a-1].append(b-1)
  to[b-1].append(a-1)

q=deque([0])
r=[None]*N
r[0]=0
while q:
  x=q.popleft()
  for i in to[x]:
    if r[i] is None:
      q.append(i)
      r[i]=x+1
      
print('Yes')
for i in range(N):
  if r[i]!=0:
    print(r[i])

Measured memory_bytes: 36864
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int32_t main() {
    fastio
    int n, m;
    cin>>n>>m;
    vector<int> vec(n);
    for(auto& it : vec) cin>>it;

    int ans = 0;
    map<pii, int> mp;
    int done[100005] = {0};
    for(int i = 0; i<m; ++i) {
        int u, v;
        cin>>u>>v;
        if(mp[{u-1, v-1}] || mp[{v-1, u-1}]) continue;
        u-=1, v-=1;
        if(vec[u]>vec[v]) {
            done[v] = 1;
        }
        if(vec[u]<vec[v])
            done[u] = 1;
        if(vec[u]==vec[v]) {
            done[u] = done[v] = 1;
        }
    }

    for(int i = 0; i<n; ++i) {
        ans += done[i] == 0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 16508
#include<iostream>
using namespace std;
int m(int *p,int n){
  int top = 1;
  for(int i=0;i<=n;i++){
    if(p[i]>p[top]) top = i;
  }
  return top;
}
int main(){
  int n,q,a,v;
  int max=0;
  cin >> n >> q;
  int p[n+1];
  for(int i=0;i<=n;i++) p[i] = 0;
  for(int i=0;i<q;i++){
    cin >> a >> v;
    p[a] += v;
    if(v>=0){
      if(p[max]<p[a]) max = a;
      if(p[max]==p[a]&&a<max) max = a;
    }else if(max==a) max = m(p,n);
    cout << max << ' ' << p[max] << endl;
  }
  return 0;
}

Measured memory_bytes: 5064
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
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;
}

#pragma endregion

int main() {
  int a = in(), b = in(), c = in(), d = in();

  if (ceil(c / (double)b) <= ceil(a / (double)d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
   ll H,N;
   cin>>H>>N;
   vector<ll> A(N),B(N);
   vector<vector<ll>> dp(1010,vector<ll> (10010,INF));
   dp[0][0]=0;
   for(ll i=0;i<N;i++) cin>>A[i]>>B[i];
   for(ll i=0;i<N;i++){
       for(ll j=0;j<=H;j++){
           chmin(dp[i+1][j],dp[i][j]);
           chmin(dp[i+1][min(j+A[i],H)],dp[i+1][j]+B[i]);
       }
   }
   cout<<dp[N][H]<<endl;
}


Measured memory_bytes: 79360
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**7
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h,w = inm()
s = []
for i in range(h):
    s.append(ins())
d = [[BIG]*w for i in range(h)]
z = 1 if s[0][0]=='#' else 0
q = deque([(0,0,z)])
while len(q)>0:
    x,y,z = q.popleft()
    #ddprint(f"1 {x=} {y=} {z=} {d=}")
    if z>=d[x][y]:
        continue
    #ddprint(d[x])
    d[x][y] = z
    incx = 1 if x<h-1 and s[x+1][y]=='#' and s[x][y]=='.' else 0
    incy = 1 if y<w-1 and s[x][y+1]=='#' and s[x][y]=='.' else 0
    if x<h-1 and d[x+1][y]>z+incx:
        q.append((x+1,y,z+incx))
    if y<w-1 and d[x][y+1]>z+incy:
        q.append((x,y+1,z+incy))
print(d[h-1][w-1])


Measured memory_bytes: 60908
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    ll a, b, x, s;
    cin >> a >> b >> x;
    if(a == 0) s = b/x+1;
    else s = b/x - (a-1)/x;
    cout << s << endl;
}


Measured memory_bytes: 256
import sys

N=int(sys.stdin.readline())

d={"AC":0,"WA":0,"TLE":0,"RE":0}

for i in range(N):
  s=sys.stdin.readline().strip()
  d[s]+=1
  
print("AC x",d["AC"])
print("WA x",d["WA"])
print("TLE x",d["TLE"])
print("RE x",d["RE"])

Measured memory_bytes: 67852
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
 
int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  
  vsort(a);
  int ans=a[0];
  irep(i,1,n){
    ans=GCD(ans,a[i]);
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long

int main(void)
{
    int n, i, ans = 0;
    int left = 0, right;
    char c[200001];
    scanf("%d", &n);
    right = n;
    scanf("%s", c);
    for (i = 0; i < n; i++)
    {
        if (c[i] == 'W')
        {
            left = i;
            break;
        }
    }
    if (i == n)
    {
        printf("0\n");
        return 0;
    }
    for (i = n - 1; i >= 0; i--)
    {
        if (c[i] == 'R')
        {
            right = i;
            break;
        }
    }
    if (i == -1)
    {
        printf("0\n");
        return 0;
    }

    char a;
    while (left < right)
    {
        a = c[left];
        c[left] = c[right];
        c[right] = a;
        ans++;
        left++;
        right--;
        while (c[left] == 'R')
            left++;
        while (c[right] == 'W')
            right--;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1924
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mp make_pair

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    ll x;
    cin>>x;
    ll ans = 1000*(x/500);
    ans += 5*((x%500)/5);
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
N,P = map(int, input().split())
S = input()

ans = 0
mod_P = [0] * P
mod_P[0] += 1
# P が 10と互いに素でないなら、U_i - U_jのうちのU_jがPで割り切れるだけでよい
if P in [2,5]:
    
    for i in range(N):
            """
            今見ているiかそれより左側にある物をU_iとして選択する場合に割り切れるようになるので、
            いまのiを含む左にあるものの個数を足す
            """
            if int(S[i]) % P == 0:
                ans += i+1
    
    print(ans)

else:
    """
    右端から見て、
    ([右端からi番目までの数字] - [右端からj番目までの数字]) % Pが0になるならOK
    [右端からi番目までの数字] % P = X となるなら、[右端からj番目までの数字] % P = X であれば割り切れる
    なので、i番目までを見ているときに、そこより右側で、余りがi番目までをPで割った時と同じになる個数が分かればよい。

    毎回律義にi番目までを数値化して、mod P をとってるとTLEになるので、
    右からi番目の数字 10 ** i + それまで
    の形で積み重ねていく。
    また、余りの問題なので、余りの世界で現在値を保存しておく(今回みたいな大きな値について毎回modをとるとめちゃくちゃ遅い)

    例１の3543と3のときのように、
    うしろから最後まで見切って3543について考えるとする。
    このとき、、
    ・端までとるU_5：U=3543
    ・右端の3だけのU_4：U=354
    ・543のU_1：U=3
    の３パターンで余りを0にしうる
    みたいなかたち
    """
    curr = 0
    for i in range(N):
        curr = int(S[N-1-i]) * pow(10, i, P) + curr
        curr %= P
        ans += mod_P[curr]
        mod_P[curr] += 1
    print(ans)


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

int main(){
    string s; cin >> s;
    int n = s.size();
    for(char c = 'a'; c <= 'z'; ++c){
        int prev = -1;
        rep(i,n){
            if(s[i] == c){
                if(prev != -1 && i-prev <= 2){
                    cout << prev+1 << " " << i+1 << endl;
                    return 0;
                }
                prev = i;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
}

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

int main() {
    string S,T;

    //cout << "IDを入力してください => "; //debug

    cin >> S >> T;

    //cout << S << endl;
    //cout << T << endl;

    string originalT = T;

    string trueT = T.erase(T.size() - 1);

    //cout << "trueT = " << trueT << endl;

    if (1 <= S.size() && S.size() <= 10 ) {

        //cout << "S.size()=" << S.size() << endl; //debug
        //cout << "T.size()=" << T.size() << endl; //debug

        if (originalT.size() == S.size() + 1) {

            //cout << "coutの比較" << endl;

            if (trueT == S) {
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;

        }
        else cout << "No" << endl;

    }

    else cout << "No" << endl;
    
}

Measured memory_bytes: 3052
while 1:
    s1 = input().split('\"')
    if s1[0] == '.': break
    s2 = input().split('\"')

    jdg = 1
    cnt_d = 0
    #print(s1)
    #print(s2)

    if len(s1) != len(s2): print("DIFFERENT")
    else:
        l = len(s1)
        i = 0
        while i < l:
            if s1[i] != s2[i]:
                cnt_d += 1
                if cnt_d == 1 and i % 2 == 1:
                    jdg = 1
                else:
                    jdg = 0
                    break
            i += 1

        if jdg == 1 and cnt_d == 1: print("CLOSE")
        elif jdg == 0 or cnt_d > 1: print("DIFFERENT")
        else: print("IDENTICAL")



Measured memory_bytes: 5584
n, m = (int(i) for i in input().split())
xyz = [[int(i) for i in input().split()] for i in range(n)]

res = 0
for i in [-1, 1]:
    for j in [-1, 1]:
        for k in [-1, 1]:
            l = []
            for x,y,z in xyz:
                l.append(x*i + y*j + z*k)

            res = max(res, abs(sum(sorted(l, reverse=True)[:m])))


print(res)

Measured memory_bytes: 41968
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int first = in.nextInt();
        int second = in.nextInt();
        if (first == second) {
            System.out.println(first);
        } else {
            for (int i = Math.min(first,second) / 2; i >= 2; i--){
                if (first % i == 0 && second % i == 0) {
                    System.out.println(i);
                    break;
                }
                if (i == 2) {
                    System.out.println(1);
                }
            }
        }
    }
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	string s;
	cin >> s;
	FOR(i, 1, s.size()) {
		cout << 'x';
	}
	cout << endl;
	return(0);
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; i++){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int result = 0;
  for(int i = 0; i < K; i++){
    result += p.at(i);
  }
  cout << result << endl;
}


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

void solve()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		vector<int> x(n);
		for (int i = 0; i < n; ++i)
		{
			cin >> x[i];
		}
		if (n <= k)
		{
			cout << 0 << endl;
			continue;
		}
		int sum = x[n - 1] - x[0];
		vector<int> diff(n - 1);
		for (int i = 0; i < n - 1; ++i)
		{
			diff[i] = x[i + 1] - x[i];
		}
		sort(diff.begin(), diff.end(), greater<int>());
		for (int i = 0; i < k - 1; ++i)
		{
			sum -= diff[i];
		}
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> c(9,0);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(3200<=a)c[8]++;
        else if(2800<=a)c[7]++;
        else if(2400<=a)c[6]++;
        else if(2000<=a)c[5]++;
        else if(1600<=a)c[4]++;
        else if(1200<=a)c[3]++;
        else if(800<=a)c[2]++;
        else if(400<=a)c[1]++;
        else c[0]++;
    }
    int ans1=0,ans2=0,count=0;
    for(int i=0;i<8;i++){
        if(c[i]>0)count++;
    }
    ans1=max(count,1);
    ans2=count+c[8];
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
char c;
int main(){
    cin>>c;
    c++;
    puts(c);
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n, k, s[100], t;

	while(true) {
		scanf("%d%d", &n, &k);
		if(n == 0 && k == 0) break;
		for(int i = 0; i < k; ++i) {
			scanf("%d", &t);
			s[i] = t;
		}
		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < k; ++j) {
				scanf("%d", &t);
				s[j] -= t;
			}
		}

		bool empty = false;
		for(int i = 0; i < k; ++i) {
			if(s[i] < 0) {
				empty = true;
				break;
			}
		}
		if(empty) printf("No\n");
		else printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B=1,C;
  cin >>A;
  for(int i=0;i<26;i++){
    for(int j=0;j<26;j++){
      if(A==C){
      B=0;
      break;
      }else if(B){
        C=0;
        C+=4*i+7*j;
      }
    }
  }
  if(B)cout << "No" << endl;
  else cout << "Yes" << endl;
}
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int t;
   cin>>t;
   for(int i=0;i<t;i++)
   {
       int a,b,c;
       int flag=0;
       cin>>a>>b>>c;
       int max1=max(a,b);
       int max2=max(max1,c);
       if(max2==a)
       {
           if(b*b+c*c==max2*max2)
           {
               cout<<"YES"<<endl;
                flag=1;

           }
       }
       if(max2==b)
       {
           if(a*a+c*c==max2*max2)
           {
               cout<<"YES"<<endl;
             flag=1;
           }
       }
       if(max2==c)
       {
           if(a*a+b*b==max2*max2)
           {
               cout<<"YES"<<endl;
                flag=1;

           }
       }
       if(flag==0)
        cout<<"NO"<<endl;
   }
   return 0;
}

Measured memory_bytes: 3044
import java.util.*;
import java.io.*;
import java.text.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        DecimalFormat df = new DecimalFormat("0.000000000000");
        int l = in.nextInt();
        double n = l/3.0;
        // double ans = n*n*n;
        double ans = Math.pow(n,3);
        out.println(df.format(ans));
        
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

int main(){
	ios::sync_with_stdio(false);
	int n,x,y;
	cin>>n;
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		ans+=y-x+1; 
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int BinarySearch(int);
int n,S[100000];
int main(){
  int i,q,count=0;
  int judge;
  int T[50000];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);
  for(i=0;i<q;i++){
    judge=BinarySearch(T[i]);
  if(judge >= 0)
    count++;
  }
  printf("%d\n",count);
  
  return 0;
}

int BinarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  
  while(left < right){
    mid = (left + right)/2; 
  if(S[mid] == key)
    return mid;
  else if(key < S[mid])
    right = mid;
  else
    left = mid + 1;
  }
  return -5;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v;
    pair<string, long long> n;
    set<string> y;
    long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=1,l=0,r=0,z,m,h,p;
    string t,s,x;
    double q,u;
    cin>>a>>b>>c>>d>>e;
    if(a<c){
        a=a+b*e;
        c=c+d*e;
        if(a>=c){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }
    else{
        a=a-b*e;
        c=c-d*e;
        if(a<=c){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                String s = sc.next();
                if (s.equals("0"))
                    break;
                int answer = 0;
                for (int i = 0; i < s.length(); i++) {
                    answer += Character.digit(s.charAt(i), 10); // answer += s.charAt(i) - '0'; も可能
                }
                System.out.println(answer);
            }
        }
    }
}


Measured memory_bytes: 26316
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

n, m = map(int, input().split())
s = list(input())
t = list(input())

for i in range(gcd(n, m)):
    if s[i * (n // gcd(n, m))] != t[i * (m // gcd(n, m))]:
        print(-1)
        break
    if i == gcd(n, m) - 1:
        print(lcm(n, m))

Measured memory_bytes: 4500
#include <stdio.h>

int main(void){
        long int num[3][100][100]={0};
        int n,m,l,i,j,k;
        scanf("%d %d %d",&n,&m,&l);
        for(i=0;i<n;i++){
                for(j=0;j<m;j++)
                        scanf("%d",&num[0][i][j]);
        }
        for(i=0;i<m;i++){
                for(j=0;j<l;j++)
                        scanf("%d",&num[1][i][j]);
        }
        for(i=0;i<n;i++){
                for(j=0;j<l;j++){
                        for(k=0;k<m;k++)
                                num[2][i][j]+=num[0][i][k]*num[1][k][j];
                }
        }
        for(i=0;i<n;i++){
                for(j=0;j<l;j++){
                        printf("%ld",num[2][i][j]);
                        if(j!=(l-1))
                                putchar(' ');
                }
                putchar('\n');
        }
        return 0;
}

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

using namespace std;

template< typename T >
vector< T > slide_min(const vector< T > &v, int k)
{
  deque< int > deq;
  vector< T > ret;
  for(int i = 0; i < v.size(); i++) {
    while(!deq.empty() && v[deq.back()] <= v[i]) {
      deq.pop_back();
    }
    deq.push_back(i);
    if(i - k + 1 >= 0) {
      ret.emplace_back(v[deq.front()]);
      if(deq.front() == i - k + 1) deq.pop_front();
    }
  }
  return (ret);
}

using int64 = long long;

int main()
{
  int N, M, K, A[100000];

  cin >> N >> M >> K;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  vector< int64 > dp(N);
  for(int i = 0; i < N; i++) {
    dp[i] = A[i];
  }
  for(int i = 1; i < K; i++) {
    vector< int64 > dp2(N);
    reverse(begin(dp), end(dp));
    dp.resize(N + M - 1);
    reverse(begin(dp), end(dp));
    auto p = slide_min(dp, M);


    for(int j = i; j < N; j++) {

      dp2[j] = max(dp2[j], p[j - 1] + 1LL * (i + 1) * A[j]);

    }
    dp.swap(dp2);
  }

  cout << *max_element(begin(dp), end(dp)) << endl;

}


Measured memory_bytes: 5112
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    string s[110];
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++){
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const int INF = 1<<29;


int main(){
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> a[i][j];
    }
  }
  bool flag = true;
  bool jump1 = false,jump2 = false;
  long long s = 0;
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      bool f = true;
      for(int j=0;j<n;j++){
        if(a[i][j] > a[i][k] + a[k][j]){
          flag = false;
          break;
        }
        if(a[i][k] == a[i][j] + a[j][k] && j != i && k != j && f){
          s += a[i][k];
          f = false;
        }
      }
      if(jump1)break;
    }
    if(jump2)break;
  }
  if(!flag)cout << -1 << endl;
  else{
  long long ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans += a[i][j];
    }
  }
    ans -= s/2;
    cout << ans << endl;
  }
}

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

long double  n,m,d,x;

int main(){
  cin >> n >> m >> d;
  if(d==0)x=1.0;
  else x= 2.0;
  printf("%.9f\n",(double)((n-d)*x*(m-1))/(double)(n*n));
  //cout << n << endl;
  //cout << (double)((n-d)*x*(m-1))/((long double)n*n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  for (int i = 1;i < n-1;i++){
    if (min({v[i-1],v[i],v[i+1]}) != v[i] && max({v[i-1],v[i],v[i+1]}) != v[i]) cnt++;
  }
  cout << cnt << endl;

  return 0;
  
}


Measured memory_bytes: 3616
# coding: utf-8
n = int(input())
s = input()
ans = 0

for i in range(1000):
    tmp = str('{:03}'.format(i))
    s0 = s.find(tmp[0])
    if s0 == -1:
        continue
    else:
        s1 = s.find(tmp[1], s0 + 1)
        if s1 == -1:
            continue
        else:
            s2 = s.find(tmp[2], s1 + 1)
            if s2 == -1:
                continue
            else:
                ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MOD 998244353LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll fact[514514];

ll extgcd(ll a,ll b,ll& x,ll &y){
	ll d=a;
	if(b!=0LL){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll& e){
	e=0;
	if(n==0)return 1;
	ll res=mod_fact(n/p,p,e);
	e+=n/p;
	if(n/p%2!=0){
		return res*(p-fact[n%p])%p;
	}	
	return res*fact[n%p]%p;
}

ll mod_comb(ll n,ll k,ll p){
	if(n<0 || k<0 || n<k)return 0;
	ll e1,e2,e3;
	ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
	if(e1>e2+e3)return 0;
	return a1*mod_inverse(a2*a3%p,p)%p;
}

int n;
ll a,b,k;

int main(void){
	scanf("%d%lld%lld%lld",&n,&a,&b,&k);
	fact[0]=1;
	for(ll i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%MOD;
	}
	ll ans=0;
	for(ll i=0;i<=n;i++){
		ll rest=k-i*a;
		if(rest>=0 && rest%b==0){
			ll j=rest/b;
			if(j>n)continue;
			ans+=mod_comb(n,i,MOD)*mod_comb(n,j,MOD)%MOD;
			ans%=MOD;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<map>
using namespace std;
char mg[60][60];
int dire[8]={-1,-1,-1,0,0,1,1,1};
int dire2[8]={-1,0,1,-1,1,-1,0,1}; 
int main()
{
	int H,W;
	scanf("%d %d",&H,&W);
	for(int i=0;i<H;i++)
		scanf("%s",mg[i]);
	for(int i=0;i<H;i++)
		for(int k=0;k<W;k++)
		{
			if(mg[i][k]=='.')
			{
				int sum=0;
				for(int p=0;p<8;p++)
				{
					int newrow=i+dire[p];
					int newcol=k+dire2[p];
					if(newrow>=0 && newrow<H && newcol>=0 && newcol<W && mg[newrow][newcol]=='#')
						sum++;
				 } 
				mg[i][k]='0'+sum;
			} 
		}
	for(int i=0;i<H;i++)
	{
		for(int k=0;k<W;k++)
			printf("%c",mg[i][k]);
		printf("\n"); 
	}
	return 0;
 } 

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

using namespace std;

int h,n;

int main() {
	scanf("%d %d",&h,&n);
	for(int v; n; --n) {
		scanf("%d",&v);
		h-=v;	
	}
	puts(h>0 ? "No":"Yes");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }

int main(){
    char a;
    cin >> a;
    a++;
    PRINT(a);
}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;

int main()
{
int N,A;

cin >> N >> A;

N = N*N;

cout << N -A <<endl;

 
}


Measured memory_bytes: 256
N=int(input())
X=[]
U=[]
ans=0
for i in range(N):
	A,B=input().split()
	X.append(float(A))
	U.append(B)
for i in range(N):
	if U[i]=="JPY":
		ans+=X[i]
	elif U[i]=="BTC":
		ans+=(X[i]*380000.0)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int X;
  cin >> X;
  ll ans = 1;
  repe(i, 1, X) {
    rep(j, 2, X) {
      ll x = pow(i, j);
      if (x > X) break;
      ans = max(ans, x);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4004
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

int N;

vector<double> dijkstra(int s, vector<vector<pair<int, double>>> adj) {
    vector<bool> visit(N + 2);
    vector<double> dist(N + 2, 1e12);
    vector<int> par(N + 2);
    priority_queue<pair<double, int>> q;
    dist[s] = 0; q.push(make_pair(0.0, s)); visit[s] = true;
    while (!q.empty()) {
        pair<double, int> tmp = q.top(); q.pop();
        int t = tmp.second; visit[t] = true;
        if (dist[t] < tmp.first * (-1) ) continue;  //別のルートでdist[t]が更新されていれば無視
        for (int i = 0; i < adj[t].size(); i++) {
            int next = adj[t][i].first;
            if (visit[next]) continue;
            if (dist[next] > dist[t] + adj[t][i].second) {
                dist[next] = dist[t] + adj[t][i].second;
                par[next] = t;
                q.push(make_pair(dist[next] * (-1), next));
            }
        }
    }
    return dist;
}

int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    cin >> N;
    vector<long long> x(N + 2), y(N + 2), r(N + 2);
    x[0] = sx; y[0] = sy; x[N + 1] = tx; y[N + 1] = ty; r[0] = 0; r[N + 1] = 0;
    for (int i = 1; i < N + 1; i++) {
        cin >> x[i] >> y[i] >> r[i];
    }
    vector<vector<pair<int, double>>> adj(N + 2);
    for (int i = 0; i < N + 2; i++) {
        for (int j = i + 1; j < N + 2; j++) {
            double d = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
            adj[i].push_back(make_pair(j, max(0.0, d - r[i] - r[j])));
            adj[j].push_back(make_pair(i, max(0.0, d - r[i] - r[j])));
        }
    }
    vector<double> dist = dijkstra(0, adj);
    cout << setprecision(20) << dist[N + 1] << endl;
}





Measured memory_bytes: 37892
#include<iostream>
#include<math.h>
#include<algorithm>
#include<numeric>
#include <type_traits>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];
    int ans = 1000000001;
    REP(i,n-1){
        int j = max(a[i],a[i+1]);
        int k = min(a[i],a[i+1]);
        int r = j%k;
        while(r != 0){
            j = k;
            k = r;
            r = j%k;
        }
        ans = min(ans,k);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

#define pii pair<ll,ll>

const int maxn=4e5+20;

pii a[maxn];
int n;
int x[maxn],y[maxn];

inline void init()
{
	n=read();
	REP(i,1,n)x[i]=read(),y[i]=read(),a[i*2-1]=mkr(x[i],i),a[i*2]=mkr(y[i],i);
	REP(i,1,n)if(x[i]>y[i])swap(x[i],y[i]);
	sort(a+1,a+n*2+1);
}

ll Ans=1ll<<60;
int vis[maxn];

inline void doing()
{
	// 1
	if(a[1].se!=a[n*2].se)
	{
		memset(vis,0,sizeof(vis));
		ll L,R;
		vis[a[n*2].se]++;
		REP(i,1,n*2-1)
		{
			if(!vis[a[i].se])vis[a[i].se]++;
			else { L=i;break;}
		}
		memset(vis,0,sizeof(vis));
		vis[a[1].se]++;
		DREP(i,n*2,1)
		{
			if(!vis[a[i].se])vis[a[i].se]++;
			else {R=a[i].fi; break;}
 		}
		memset(vis,0,sizeof(vis));
		REP(i,2,L)
		{
			chkmin(Ans,1ll*(a[n*2].fi-a[1].fi)*(R-a[i].fi));
			chkmax(R,(ll)y[a[i].se]);
		}
		//chkmin(Ans,1ll*(a[n*2].fi-a[1].fi)*(R-L));
	}

	//2
	ll mn1=1ll<<60,mx1=0,mn2=1ll<<60,mx2=0;
	memset(vis,0,sizeof(vis));
	REP(i,1,n*2)
	{
		if(!vis[a[i].se])vis[a[i].se]++,chkmin(mn1,a[i].fi),chkmax(mx1,a[i].fi);
		else chkmin(mn2,a[i].fi),chkmax(mx2,a[i].fi);
	}
	chkmin(Ans,1ll*(mx2-mn2)*(mx1-mn1));
	printf("%lld\n",Ans);
	
}

int main()
{
	init();
	doing();
	return 0;
}



Measured memory_bytes: 11136
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  ll N;
  cin >> N;
  vector<ll> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }
  ll ans = T[0];
  for (int i = 1; i < N; i++) {
    ans = lcm(ans, T[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int x, a;
    cin >> x >> a;
    if (x < a)
        cout << 0;
    else
        cout << 10;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main(){
	int n,i,j,cnt=0;
	int tmp,m,a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<n-1;i++){
		m=i;
		for(j=i;j<=n-1;j++){
			if(a[j]<a[m]){
				m=j;
			}
		}
		if(m!=i)cnt++;
		tmp=a[i];
		a[i]=a[m];
		a[m]=tmp;
	}
	for(i=0;i<n-1;i++)printf("%d ",a[i]);
	printf("%d\n",a[i]);
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

int kaijou(int n){
    if(n==0) return 1;
    else{
        return ((n%MOD)*(kaijou(n-1)%MOD))%MOD;
    }
}

bool ispow(int n){
    int rn=sqrt(n);
    if(rn*rn==n) return true;
    else return false;
}

signed main() {
    int x,k,d;
    cin>>x>>k>>d;

    int res;

    if(x>0){
        int cnt=x/d;
        if(cnt>k){
            res=x-d*k;
        }else{
            if((k-cnt)%2==0) res=abs(x-d*cnt);
            else res=abs(x-d*(cnt+1));
        }
    }else{
        int cnt=abs(x)/d;
        if(cnt>k){
            res=abs(x+d*k);
        }else{
            if((k-cnt)%2==0) res=abs(x+d*cnt);
            else res=abs(x+d*(cnt+1));
            //res=min(abs(x+d*cnt),abs(x+d*(cnt+1)));
        }
    }

    cout<<res<<endl;
}


Measured memory_bytes: 3548
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct state{int x,y;};
 
bool f[50][50][2];
int H,W,N;
int six,siy,tix,tiy;
 
int d[50][50];
state prev[50][50];
 
int dfs(){
  for(int i=0;i<50;i++)
    for(int j=0;j<50;j++)
      d[i][j]=-1;
 
  d[six][siy]=0;
  queue<state> Q;
  Q.push((state){six,siy});
 
  while(!Q.empty()){
    state s=Q.front();Q.pop();
    int y=s.y,x=s.x;
    int cost=d[x][y];
    // cout<<x<<' '<<y<<' '<<cost<<endl;
 
    if(y+1<H && d[x][y+1]==-1 && !f[x][y][0]){
      d[x][y+1]=cost+1;
      prev[x][y+1]=s;
      Q.push((state){x,y+1});
    }
     
    if(x+1<W && d[x+1][y]==-1 && !f[x][y][1]){
      d[x+1][y]=cost+1;
      prev[x+1][y]=s;
      Q.push((state){x+1,y});
    }
 
    if(y>0 && d[x][y-1]==-1 && !f[x][y-1][0]){
      d[x][y-1]=cost+1;
      prev[x][y-1]=s;
      Q.push((state){x,y-1});
    }
 
    if(x>0 && d[x-1][y]==-1 && !f[x-1][y][1]){
      d[x-1][y]=cost+1;
      prev[x-1][y]=s;
      Q.push((state){x-1,y});
    }
  }
 
  return d[tix][tiy];
}
 
void init(){
  for(int i=0;i<50;i++)
    for(int j=0;j<50;j++)
      f[i][j][0]=f[i][j][1]=false;
}
 
 
int main(){
  while(cin>>W>>H>>N){
    init();
    for(int i=0;i<N;i++){
      int ax,ay,bx,by;
      cin>>ax>>ay>>bx>>by;
      if(ax==bx){// |
    if(ay>by)swap(ay,by);
    for(int y=ay;y<by;y++){
      if(ax)f[ax-1][y][1]=true;
    }
      }else if(ay==by){// -
    if(ax>bx)swap(ax,bx);
    for(int x=ax;x<bx;x++){
      if(ay)f[x][ay-1][0]=true;
    }
      }
    }
    cin>>six>>siy>>tix>>tiy;
    int A=dfs();
    if(A==-1){
      cout<<0<<endl;
      continue;
    }
    vector<state> vec;
    state s=(state){tix,tiy};
    while(1){
      vec.push_back(s);
      if(s.x==six&&s.y==siy)break;
      s=prev[s.x][s.y];
    }
    reverse(vec.begin(),vec.end());
    int B=A;
    for(int i=0;i+1<(int)vec.size();i++){
      int ax=vec[i].x;
      int ay=vec[i].y;
      int bx=vec[i+1].x;
      int by=vec[i+1].y;
 
      if(ax==bx){
    if(ay>by)swap(ay,by);
    f[ax][ay][0]=true;
      }else if(ay==by){
    if(ax>bx)swap(ax,bx);
    f[ax][ay][1]=true;
      }
 
      B=max(B,dfs());
      if(ax==bx){
    if(ay>by)swap(ay,by);
    f[ax][ay][0]=false;
      }else if(ay==by){
    if(ax>bx)swap(ax,bx);
    f[ax][ay][1]=false;
      }
    }
    cout<<B-A<<endl;
  }
  return 0;
}

Measured memory_bytes: 1304
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll a,b;
cin >> a>> b;
cout << max({a - b, a + b, a * b}) << endl;
}

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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;

const int N = 100005;

ll n, c, cur, ans;
// Nutrition, dist
ll mx[N], bmx[N];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n >> c;
	vector<pair<ll, ll>> s;
	for (int i = 0; i < n; ++i) {
		ll x, v; 
		cin >> x >> v;
		s.push_back({v, x});
		cur += v;
		if (i) mx[i] = max(cur - 2 * x, mx[i - 1]);
		else mx[i] = max(cur - 2 * x, 0ll);
	}
	
	cur = 0;
	for (int i = n - 1; i >= 0; --i) {
		cur += s[i].first;
		if (i < n - 1) bmx[i] = max(bmx[i + 1], cur - (2 * (c - s[i].second)));
		else bmx[i] = max(cur - (2 * (c - s[i].second)), 0ll);
	}
	
	cur = 0;
	for (int i = 0; i < n; ++i) {
		cur += s[i].first;
		ans = max(ans, cur + bmx[i + 1] - s[i].second);
		//cout << i << ' ' << ans << '\n';
	}
	
	cur = 0;
	for (int i = n - 1; i >= 0; --i) {
		cur += s[i].first;
		if (i) ans = max(ans, cur + mx[i - 1] - (c - s[i].second));
		else ans = max(ans, cur - (c - s[i].second));
		//cout << i << ' ' << ans << '\n';
	}
	
	cout << ans;
}


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

int main(){
  bool is_prime[100000];

  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<100000;i++){
    is_prime[i] = true;
  }

  for(int i=2;i*i<100000;i++){
    if(is_prime[i]){
      for(int j=i*i;j<100000;j=j+i){
        is_prime[j] = false;
      }
    }
  }

  while(true){
    int n;
    cin >> n;

    if(cin.eof())
        break;

    int high = n;
    int low = n;

    while(1){
      high++;
      if(is_prime[high]){
        break;
      }
    }

    while(1){
      low--;
      if(is_prime[low]){
        break;
      }
    }

    cout << low << " " << high << endl;
  }

  return 0;
}



Measured memory_bytes: 3088
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define BIG 1000000000
#define SIZE 40
using namespace std;

int n;
int A[SIZE];

int solve(int i, int m) {
	if (m == 0) return 1;
	if (i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);
	int q;
	scanf("%d", &q);
	int m;
	for (int i = 0; i < q; i++) {
		scanf("%d", &m);
		if (solve(0, m)) cout << "yes\n";
		else cout << "no\n";
	}



}

Measured memory_bytes: 3112
#include<iostream>

#include<cmath>
#include<algorithm>

using namespace std;

int main(){
	
	int a,b,maxx=-20000000;
	cin>>a>>b;
	int h[3];
	h[0]=a-b;
	h[1]=a*b;
	h[2]=a+b;
	for(int i=0;i<3;i++){
		maxx=max(h[i],maxx);
	}
	cout<<maxx<<endl;;
	
}



Measured memory_bytes: 256
A,B,C,D,E,F = map(int,input().split())
water,k,l = set(),1,1

while k * A * 100 <= F:
    water.add(k * A * 100)
    k += 1
while l * B * 100 <= F:
    water.add(l * B * 100)
    l += 1
for i in range(1,k):
    for j in range(1,l):
        if (i * A + j * B) * 100 <= F:
            water.add((i * A + j * B) * 100)
        else:
            break

water = list(water)
sugar = []
concentration = []
for i in range(len(water)):
    sugar_limit = min(water[i] // 100 * E, F - water[i])
    temp,k = 0,0
    while k * C <= sugar_limit:
        l = (sugar_limit - k * C) // D
        while l >= 0:
            if k * C + l * D > temp:
                temp = k * C + l * D
            l -= 1
        k += 1
    sugar.append(temp)
    concentration.append(sugar[i] / (water[i] + sugar[i]))

i = concentration.index(max(concentration))
print(water[i] + sugar[i],sugar[i])

Measured memory_bytes: 3064
memo = [0] * 100
def f(x):
  global memo
  if x in [0, 1]:
    memo[x] = 1
    return 1
  else:
    if memo[x] > 0:
      return memo[x]
    else:
      memo[x] = x*f(x-1)
      return memo[x]

def comb(n, r):
  a = f(n)
  b = f(r)
  c = f(n-r)
  return a // b // c

N, P = map(int, input().split())
A = list(map(int, input().split()))
A = [a%2 for a in A]
n0 = A.count(0)
n1 = N - n0
base = 2 ** n0
m0 = m1 = 0
for i in range(n1+1):
  if i % 2:
    m1 += comb(n1, i)
  else:
    m0 += comb(n1, i)

if P == 0:
  print(base * m0)
else:
  print(base * m1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m, d; cin >> n >> m >> d;
  cout << fixed << setprecision(10) << (ld)(d==0 ? 1 : 2)*(n-d)*(m-1)/n/n << endk;
  return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
  double l;
  cin>>l;

  cout<<  std::setprecision(18)<<1.0*(l/3)*(l/3)*(l/3)<<endl;


}




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

bool judgeKaibun(string s)
{
    bool isKaibun = true;

    int n = s.length();

    for (int i = 0; i < n / 2; ++i)
    {
        if (s.at(i) != s.at(n - 1 - i))
        {
            isKaibun = false;
            break;
        }
    }

    return isKaibun;
}

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

    int n = s.length();

    string leftStr, rightStr;

    for (int i = 0; i < n / 2; ++i)
    {
        leftStr += s.at(i);
    }

    for (int i = n / 2 + 1; i < n; ++i)
    {
        rightStr += s.at(i);
    }

    bool isStrong = judgeKaibun(s) && judgeKaibun(leftStr) && judgeKaibun(rightStr);

    cout << (isStrong ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256