akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		 long double   ld;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;


int main()
{
    ll n,m;
    cin>>n>>m;
    ll a1=0,a2=0;
    map<ll,ll>mp1;
    map<ll,ll>mp2;
    for(ll i=0; i<m; i++)
    {
        ll p;
        string s;
        cin>>p>>s;
        if(s=="AC")
        {
            if(mp1[p]==0)
            {
                a1++;
                a2+=mp2[p];
                mp1[p]=1;
            }
            // mp2[p]=1;
        }
        else
        {
            if(mp1[p]==0)
            {
                mp2[p]++;
            }
        }


    }

    cout<<a1<<ss<<a2<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






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

int main(){
    map<string, int> name2id;
    vector<int> lengths;

    int n;
    cin >> n;
    REP(i, n){
        string s;
        int len;
        cin >> s >> len;
        name2id.insert(pair<string, int>(s, i));
        lengths.push_back(len);
    }
    string lastname;
    cin >> lastname;

    int res = 0;
    for(int i=name2id[lastname]+1; i < n; i++){
        res += lengths[i];
    }

    printf("%d\n", res);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

/*******************************************************/

int main() {
  int n, m; cin >> n >> m;
  vector<queue<int>> ques(n);
  Loop(i, n) {
    Loop(j, m) {
      int a; cin >> a;
      ques[i].push(a);
    }
  }
  vector<bool> b(m + 1, true);
  vi cnt(m + 1, 0);
  int ans = INT_MAX;
  Loop(k, m) {
    cnt = vi(m + 1, 0);
    Loop(i, n) {
      while (!b[ques[i].front()]) ques[i].pop();
      cnt[ques[i].front()]++;
    }
    int max_cnti = 0;
    Loop(i, m + 1) {
      if (cnt[max_cnti] < cnt[i]) max_cnti = i;
    }
    ans = min(ans, cnt[max_cnti]);
    b[max_cnti] = false;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	long long A, B, K;
	cin >> A >> B >> K;
	if (K <= A) {
		cout << A - K << " " << B << endl;
	}
	else if (K <= A + B) {
		cout << 0 << " " << B - (K - A) << endl;
	}
	else {
		cout << 0 << " " << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def func1(N):
    li = [1] * (N)
    for i in range(N-1):
        li[i+1] = li[i] *2+1
    return(li[N-1])
def func2(N):
    lia = [1] * (N)
    for i in range(N-1):
        lia[i+1] = lia[i] * 2 + 3
    return(lia[N-1])
N,X = [int(i) for i in input().split()]
def f(N,X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X<=1+func2(N):
        return f(N-1,X-1)
    else:
        return func1(N) + 1 + f(N-1,X-2-func2(N))
print(f(N,X))

Measured memory_bytes: 3064
(setq n(read))
(setq s(concatenate 'list(read-line)))
(setq ans 0)
(loop for i from 1 to(1- n)do
	  (setq a())
	  (setq b())
	  (loop for j from 0 to(1- i)do(setq a(cons(nth j s)a)))
	  (loop for j from i to(1- n)do(setq b(cons(nth j s)b)))
	  (setq ans(max(length(delete-duplicates(intersection a b)))ans)))
(princ ans)


Measured memory_bytes: 15972
#include <stdio.h>
int main(void){
    int N,L;
    int tas[200];
    scanf("%d %d",&N,&L);
    int i;
    int t=0;
    int T;
    for(i=0;i<N;i++){
        tas[i]=L+i;
        t=t+tas[i];
        
    
    
    }
    if(tas[N-1]<0){
        T=t-tas[N-1];
        printf("%d",T);
    }
    else if(tas[0]>0){
        T=t-tas[0];
        printf("%d",T);
    }
    else printf("%d",t);
}

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

int main(){
  int n;
  int a[100010];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  if(n<3){
    cout<<1<<endl;
    return 0;
  }
  vector<int> v;
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1])continue;
    v.push_back(a[i]<a[i+1]);
  }
  int cnt=1;
  for(int i=0;i<v.size()-1;i++){
    cnt+=(v[i]!=v[i+1]);
    i+=(v[i]!=v[i+1]);
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 1276
// 2020-08-26 12:24:11
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
ll dp[50][2][2];
void answer() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  memset(dp, -1, sizeof dp);
  {
    ll tot = 0;
    rep(i, n) {
      cin >> a[i];
      tot += a[i];
    }
    dp[45][0][0] = tot;
  }
  vector<ll> b(50, 0);
  REPCM(j, 44, 0) rep(i, n) b[j] += ((a[i] >> j) & 1);
  REPCM(j, 44, 0) {
    bool kk = ((k >> j) & 1);
    rep(smaller, 2) rep(m, 2) if (dp[j + 1][smaller][m] >= 0) {
      chmax(dp[j][smaller || kk][0], dp[j + 1][smaller][m]);
      if (smaller || kk) {
        chmax(dp[j][smaller][1],
              dp[j + 1][smaller][m] + (1LL << j) * (n - 2 * b[j]));
      }
    }
  }
  ll ans = 0;
  rep(smaller, 2) rep(m, 2) chmax(ans, dp[0][smaller][m]);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  string s;
  cin>>s;
  int i=0,j=s.size()-1;
  int ans=0;

  while(j>i){
    if(s[i]==s[j]){
      i++;
      j--;
    }else if(s[i]=='x'){
      ans++;
      i++;
    }else if(s[j]=='x'){
      ans++;
      j--;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 512
N,P=map(int,input().split());S,a,i,j,c=input(),0,0,1,[1]+[0]*P
if 10%P:
	for v in S[::-1]:i,j=(i+int(v)*j)%P,j*10%P;a+=c[i];c[i]+=1
else:
	for v in S:
		i+=1
		if int(v)%P<1:a+=i
print(a)

Measured memory_bytes: 3560
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, A, B, C, D, E = [INT() for _ in range(6)]

# 別解？
"""
trans = [A, B, C, D, E]
num_city = [N, 0, 0, 0, 0, 0]
time = 0
for i in range(5):
	# print(num_city)
	if not i==4:
		if trans[i] == 1:
			tmp = 1
		else:
			tmp = num_city[i]%trans[i]
		num_city[i+1] = N-tmp
		if N-tmp <= trans[i+1]*((time+(ceil(num_city[i]/trans[i])))-(i+1)):
			num_city[i+1] = 0
		else:
			num_city[i+1] -= trans[i+1]*((time+(ceil(num_city[i]/trans[i])))-(i+1))
		num_city[i+1] += tmp
		time += ceil(num_city[i]/trans[i])
		num_city[i] = 0
	else:
		time += ceil(num_city[4]/E)
print(time)
"""
# 解法
print(ceil(N/min(A,B,C,D,E))+4)

Measured memory_bytes: 3900
n = int(input())
c, s, f = [0]*(n-1), [0]*(n-1), [0]*(n-1)
for i in range(n-1):
  c[i], s[i], f[i] = map(int, input().split())

for i in range(n):
  ans = 0
  for j in range(i, n-1):
    ans = c[j] + max([s[j], (1+(ans-1)//f[j])*f[j]])
  print(ans)

Measured memory_bytes: 3064
import sys
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    a =list(map(int,input().split()))
    L.append(a[0])
    R.append(a[1])
LL = L[0]
RR = R[0]
for i in range(1,M):
    if L[i]>RR or LL>R[i]:
        print(0)
        sys.exit()
    elif LL>=L[i] and RR>=R[i]:
        RR=R[i]
    elif LL>=L[i] and RR<R[i]:
        continue
    elif L[i]>=LL and R[i]>=RR:
        LL = L[i]
    elif L[i]>=LL and R[i]<RR:
        continue
print(RR-LL+1)




Measured memory_bytes: 57048
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int> > VVi;
typedef vector<vector<ll> > VVl;

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

const ll linf = 1LL << 60;

ll N;

int main()
{
	cin >> N;
	ll ans = linf;
	for (ll i = 1; i * i <= N; ++i)
	{
		if (N % i)
			continue;

		ll j = N / i;

		chmin(ans, i + j - 2);
	}

	cout << ans << endl;
}


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

typedef long long ll;
using namespace std;

#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll n, d;	cin >> n >> d;
	ll ans = 0;
	double x, y;

	REP(i, n){
		cin >> x >> y;

		if( x*x + y*y <= d*d ){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[n];
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        cin>>a[i];
        v.push_back(make_pair(a[i],i));
    }
    sort(v.begin(),v.end());

    long long ans=0;
    set<int> st;
    st.insert(-1);
    st.insert(n);

    for(int i=0;i<n;i++){
        auto itr = st.upper_bound(v[i].second);
        
        int t=*itr;
        itr--;

        ans+= (long long)v[i].first * (t - v[i].second) * (v[i].second - *itr );
        st.insert(v[i].second);
    }

    cout<<ans;

}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int n;
pair<int,int> a[100010];
vector<int> dict;

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
    }
}

void solve() {
    sort(a,a+n);
    int ans = 0;
    int l = 1, r = 1e9;
    multiset<int> st;
    for (int i = 0; i < n; i++) {
        l = max(l,a[i].fi);
        r = min(r,a[i].se);
        st.insert(a[i].se);
    }
    for (int i = 0; i < n; i++) {
        ans = max(ans, max(0,r-l+1) + a[i].se - a[i].fi + 1);
    }
    for (int i = 0; i < n - 1; i++) {
        st.erase(st.find(a[i].se));
        ans = max(ans, max(0,r - a[i].fi + 1) + max(0,*st.begin() - l + 1));
    }
    cout << ans << endl;
}

int main(int argc, char *argv[]){
    input();
    solve();
    return 0;
}


Measured memory_bytes: 5760
import math
N, M = list(map(int, input().split()))
ans = 0
if N > 1:
  ans += math.factorial(N) // (math.factorial(N-2) * math.factorial(2))
if M > 1:
  ans += math.factorial(M) // (math.factorial(M - 2) * math.factorial(2))
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  const int INF = 1 << 25;
  vector<vector<int>> G(N, vector<int>(N, INF));
  REP(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a][b] = c;
    G[b][a] = c;
  }
  vector<vector<int>> dist = G;
  REP(k, N) REP(i, N) REP(j, N) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  int ans = 0;
  REP(i, N) REP(j, i) {
    if (G[i][j] != INF && G[i][j] > dist[i][j]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#include <stdlib.h>

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	while(1){
		int n;
		cin >> n;
		if( n == 0 ) break;
		vector< vector < int > > m;
		vector< int > v;
		for(int i = 0; i < n; i++)
			v.push_back( 0 );
		for(int i = 0; i < n; i++)
			m.push_back( v );

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

		int ssum = 0;
		for(int i = 0; i < n; i++) {
			int sum = 0;
			for(int j = 0; j < n; j++) {
				printf("%5d", m[j][i]);
				sum += m[j][i];
			}
			ssum += sum;
			printf("%5d\n", sum);
		}
		for(int i = 0; i < n; i++) {
			int sum = 0;
			for(int j = 0; j < n; j++) {
				sum += m[i][j];
			}
			printf("%5d", sum);
		}
		printf("%5d\n", ssum);

	}
 
	//while (1){}
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll dp[4][4][4], np[4][4][4];

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

	dp[3][3][3]=1;

	rep(g, n) {
		memset(np, 0, sizeof np);
		rep(a,4) rep(b,4) rep(c,4){
			rep(d,4){
				if(b==0 && c==1 && d==2) continue;
				if(b==1 && c==0 && d==2) continue;
				if(b==0 && c==2 && d==1) continue;
				if(a==0 && c==1 && d==2) continue;
				if(a==0 && b==1 && d==2) continue;
				(np[b][c][d] += dp[a][b][c])%=MD;
			}
		
		}
		swap(dp, np);
	}
	ll ans =0;
	rep(a,4) rep(b,4) rep(c,4) (ans += dp[a][b][c])%=MD;
	cout << ans <<"\n";

}



Measured memory_bytes: 256
//Written by Shagoto
import java.util.*;
public class Main
{
  public static void main(String[]args)
  {
    Scanner read = new Scanner(System.in); 
    
    int n = read.nextInt();
    int d = read.nextInt();
    int count = 0;
    for(int x = 1; x<=n; x++)
    {
      long a = read.nextInt();
      long b = read.nextInt();
      double dist = Math.sqrt((a*a)+(b*b));
      
      if(dist <= d)
      {
        count++;
      }
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 59352
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	for (int i = 0; i < 3; i++) {
		if (n.at(i) == '1') cout << 9;
		else cout << 1;
	}
	cout << endl;
}

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

int main() {
  
  int K,N;
  
  
  	cin>>K;
  
 	cin>>N;
  
  vector<int> A(N);
  
 
  for(int i=0 ; i<N ; i++){
    
  	cin >> A.at(i);
    
   
  }
 
  sort(A.begin(), A.end());
  
  vector<int> sa(N);
  
  for(int i=0; i<N-1;i++){
  	sa.at(i)=A.at(i+1)-A.at(i);
  }
  
    sa.at(N-1)=K-(A.at(N-1)-A.at(0));
  
  sort(sa.begin(), sa.end());
  
  int ans= K-sa.at(N-1);
  
  cout << ans << endl;
  
}



Measured memory_bytes: 1792
class Vertex
  include Comparable
  attr_reader :parent, :id, :children
  def initialize(n, degree)
    @id = n
    @parent = -1
    @degree = degree
    @type = "root"
  end
  
  def set_child(*children)
    if @degree != 0
      @children = children
    else
      @children = []
    end
  end
  
  def to_s
    return "node #{@id}: parent = #{@parent == -1 ? @parent: @parent.id}, depth = #{depth}, #{@type}, [#{@children.join(", ")}]"
  end
  
  def depth
    if @parent != -1
      return @parent.depth + 1
    else
      return 0
    end
  end
  
  def set_parent(parent)
    @parent = parent
    if @degree == 0
      @type = "leaf"
    else
      @type = "internal node"
    end
  end
  
  def <=>(other)
    @id <=> other.id
  end
end
def main
  arr = []
  gets.to_i.times do
    str = gets.split(" ").map(&:to_i)
    arr << Vertex.new(*str[0, 2])
    arr.last.set_child(*str[2..-1])
  end
  arr.sort!
  arr.each{|item|
    item.children.each{|child|
      arr[child].set_parent(item)
      }
    }
  puts arr
end
def test
  arr = []
  file = open("tree1.txt")
  file.gets.to_i.times do
    str = file.gets.split(" ").map(&:to_i)
    arr << Vertex.new(*str[0, 2])
    arr.last.set_child(*str[2..-1])
  end
  arr.sort!
  arr.each{|item|
    item.children.each{|child|
      arr[child].set_parent(item)
      }
    }
  puts arr
end
main

Measured memory_bytes: 118864
import math
n = int(input())
a = list(map(int, input().split()))

b = [[i+1,a[i]] for i in range(n)]
b.sort(key=lambda x: x[1])
c = []
for i in range(n):
    c.append(b[i][0])
print(' '.join(map(str, c)))


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


int main(){
  int n,T; cin>>n>>T;
  vector<int> c(n); vector<int> t(n); 
  //各々のtが条件をみたすときにcのminを更新する
   int min=1000;
   bool check=false;
  for(int i=0;i<n;i++){
    cin>>c.at(i)>>t.at(i);
    if(t.at(i)<=T){
      check=true;
      if(c.at(i)<min)min=c.at(i);
    }      
  }
  
  if(check)cout<<min<<endl;
  else cout<<"TLE"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();
		int[] c = new int[26];
		for (int i = 0; i < 26; i++) {
			c[i] = Integer.parseInt(sc.next());
		}

		int[][] s = new int[d][26];
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < 26; j++) {
				s[i][j] = Integer.parseInt(sc.next());
			}
		}

		int[] ans = new int[d];

		for (int i = 0; i < d; i++) {
			int max = 0;
			for (int j = 0; j < 26; j++) {
				for (int k = 0; k < 26; k++) {
					if (max < s[i][j] - c[k]) {
						max = s[i][j] - c[k];
						ans[i] = j;
					}
				}
			}
		}

		for (int i = 0; i < d; i++) {
			System.out.println(ans[i] + 1);
		}
	}

}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ja = 0, ov = 0;
  char c;
  while (n--) {
    cin >> c;
    if (c == 'a') {
      if (ja + ov < a + b) {
        cout << "Yes\n";
        ++ja;
      } else {
        cout << "No\n";
      }
    } else if (c == 'b') {
      if (ja + ov < a + b && ov < b) {
        cout << "Yes\n";
        ++ov;
      } else {
        cout << "No\n";
      }
    } else {
      cout << "No\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 300006;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<bool> bad(n);
    for(int& x : a) cin >> x;
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (a[y] <= a[x]) bad[y] = true;
        if (a[x] <= a[y]) bad[x] = true;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) ans += (!bad[i]);
    cout << ans << '\n';
    return 0; 
}
 

Measured memory_bytes: 3728
#include <cstdio>

const int MAXN = 5e5, MOD = 998244353;
int n, m, fac[MAXN * 2 + 5], ifac[MAXN * 2 + 5];

inline int qkpow ( int a, int b, const int p = MOD ) {
	int ret = 1;
	for ( ; b; a = 1ll * a * a % p, b >>= 1 ) ret = 1ll * ret * ( b & 1 ? a : 1 ) % p;
	return ret;
}

inline void init ( const int n ) {
	fac[0] = 1;
	for ( int i = 1; i <= n; ++ i ) fac[i] = 1ll * i * fac[i - 1] % MOD;
	ifac[n] = qkpow ( fac[n], MOD - 2 );
	for ( int i = n - 1; ~ i; -- i ) ifac[i] = ( i + 1ll ) * ifac[i + 1] % MOD;
}

inline int C ( const int n, const int m ) {
	return n < m ? 0 : 1ll * fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int main () {
	scanf ( "%d %d", &n, &m );
	if ( n < m ) n ^= m ^= n ^= m;
	init ( n + m );
	int ans = n, inv = ( MOD + 1ll ) / 2 * qkpow ( C ( n + m, n ), MOD - 2 ) % MOD;
	for ( int i = 1; i <= m; ++ i ) {
		ans = ( ans + 1ll * inv * C ( 2 * i, i ) % MOD * C ( n + m - 2 * i, n - i ) ) % MOD;
	}
	printf ( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 11024
#include <iostream>
#include <string>

using namespace std;

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

  int cnt[2] = {0};
  for (auto c : s) {
    cnt[c - '0']++;
  }
  cout << 2 * min(cnt[0], cnt[1]) << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
  int N;
  double a;
  scanf("%d",&N);
  if(N%2==0)
  {
  	a=N/2.0;
    printf("%f",a/N);
  }
  else if(N%2==1)
  {
  	a=(N+1)/2.0;
      printf("%f",a/N);
  }
}

Measured memory_bytes: 128
n, k = input().split()
N = int(n)
K = int(k)

h_array = []
for i in range(N):
    tree = int(input())
    h_array.append(tree)

h_array.sort()

#最小値を更新していくので、初期値を無限として設定しておく
result = float("inf")
#indexに注意
for i in range(K - 1, N):
    result = min(result, h_array[i] - h_array[i - K + 1])

print(result)


Measured memory_bytes: 7444
/*---------------------------------
 *File name: B.cpp
 *Creation date: 2020-05-31 20:00
 *-------------------------------*/
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define PII pair<int, int>
#define Pque priority_queue 
#define loop(c, a, b) for(int c = a; c <= b; ++c)
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;

int main(){
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n,t; cin >>n>>t;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    vector<ll> profit(n);
    ll mn = INFLL;
    for (ll i = 0; i < n; i++) {
        mn = min(mn, a[i]);
        profit[i] = a[i] - mn;
    }

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

    ll ans = 1;
    ll mp = profit[0];
    for (ll i = 1; i < n; i++) {
        if (profit[i] == mp) {
            ans++;
        } else {
            break;
        } 
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]
d = {}
ans = 0
for i in ab:
    a = i[0] - 1
    b = i[1] - 1
    mi = False
    ma = False
    if h[a] == h[b]:
        pass
    elif h[a] > h[b]:
        mi = True
    else:
        ma = True
    if a not in d:
        d[a] = mi
    elif d[a] == True:
        d[a] = mi
    if b not in d:
        d[b] = ma
    elif d[b] == True:
        d[b] = ma
    else:
        pass
for i in d.values():
    if i:
        ans += 1
ans += n - len(d)
print(ans)

Measured memory_bytes: 37540
require 'prime'
require 'set'
require 'tsort'
include Math
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def pr?(num);              Prime.prime?(num)                          end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

a,b,c = gi
puts a+b >= c ? "Yes" : "No"


Measured memory_bytes: 2428
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    ll n;
    cin>>n;
    int sq=floor(sqrt(n));
    ll ans=0;
    for (sq;sq>=1;sq--){
        if (n%sq==0){
            ans=sq+n/sq;
            break;
        }
    }
    ans-=2;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int main() {
	int a, b;
	while(cin >> a && a) {
		rep(i, 9) {
			cin >> b;
			a -= b;
		}

		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
  long long N;
  cin >> N;
  vector<int> dist(N+1, -1);
  queue<int> que;
  dist[0] = 0;
  que.push(0);
  
  int front;
  while(!que.empty()) {
    front = que.front();
    que.pop();
    if (front == N) break;
    
    if (dist[front+1] == -1) {
      que.push(front+1);
      dist[front+1] = dist[front] + 1;
    }
    for (int i = 6; i <= N-front; i = i * 6) {
      if (dist[front+i] != -1) continue;
      que.push(front+i);
      dist[front+i] = dist[front] + 1;
    }
    for (int i = 9; i <= N-front; i = i * 9) {
      if (dist[front+i] != -1) continue;
      que.push(front+i);
      dist[front+i] = dist[front] + 1;
    } 
  }
  cout << dist[N] << endl;
  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(n);i++)
ll kaijou(ll n)
{
    if(n==1) return 1;
    else return n*kaijou(n-1);
}

int main()
{
    ll n;
    double ans=0;
    cin>>n;
    vector<double> x(n),y(n);
    vector<ll> data(n);
    rep(i,n) cin>>x[i]>>y[i];
    rep(i,n) data[i]=i;
    do{
        rep(i,n-1)
        {
            ans+=sqrt((x[data[i]]-x[data[i+1]])*(x[data[i]]-x[data[i+1]])+(y[data[i]]-y[data[i+1]])*(y[data[i]]-y[data[i+1]]));
        }
    }while(next_permutation(data.begin(),data.end()));
    ans/=kaijou(n);
    printf("%.10f",ans);
}

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

int main() {
    int n, y;
    int a, b, c;
    int flag = 0;
    cin >> n >> y;
    for (a = 0; a <= n; a++) {
        for (b = 0; b <= n - a; b++) {
            c = n - a - b;
            int tmp;
            tmp = a * 1000 + b * 5000 + c * 10000;
            if (tmp == y) {
                flag = 1;
            }
            if (flag) {
                break;
            }
        }
        if (flag) {
            break;
        }
    }
    if (flag) {
        cout << c << ' ' << b << ' ' << a << endl;
    } else {
        cout << "-1 -1 -1" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  string S1, S2;
  cin >> S1 >> S2;
  vector<long> data;
  for(int i = 0; i < S1.size(); i++){
    if(S1.at(i) == S2.at(i)){
      data.push_back(0);
    } else{
      data.push_back(1);
      i++;
    }
  }
  long ans;
  if(data.at(0) == 0)ans = 3;
  else ans = 6;
  for(int i = 1; i < data.size(); i++){
    if(data.at(i - 1) == 0){
      if(data.at(i) == 0)ans *= 2;
      else ans *= 2;
    } else {
      if(data.at(i) == 0)ans *= 1;
      else ans *= 3;
    }
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
ka = [li() for _ in range(n)]

food = [0]*m
for i in range(n):
    for j in range(1,ka[i][0]+1,1):
        food[ka[i][j]-1] += 1
print(food.count(n))

Measured memory_bytes: 9428
N = int(input())

guidebook = {}

for i in range(N):
    S, P = input().split()
    if S not in guidebook:
        guidebook[S] = []
    guidebook[S] += [(int(P), i+1)]

for city in sorted(guidebook.keys()):
    data = sorted(guidebook[city])
    for d in data[::-1]:
        print(d[1])



Measured memory_bytes: 3060
A, B, C, D = map(int, input().split())

n=0
while True:
  if n%2==0:
    C-= B
    if C <= 0:
      print('Yes')
      exit(0)
  else:
    A-= D
    if A <= 0:
      print('No')
      exit(0)
  n+=1
  

Measured memory_bytes: 9000
N = int(input())
T, A = map(int, input().split())
H = [int(x) for x in input().split()]

ans, tmp = None, float('inf')
for i in range(N):
    t = T - H[i] * 0.006
    d = abs(A - t)
    if d < tmp:
        ans = i + 1
        tmp = d
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

ll memo[100100][100];
ll combination(ll n, ll r){
    if( memo[n][r] ) return memo[n][r];
    if( r == 0 || r == n) return memo[n][r] = 1;
    return memo[n][r] = (combination(n-1, r-1) + combination(n-1, r)) % MOD;
}


int main(){
    ll N,M,i,j;
    cin >> N >> M;

    ll p = 2;
    ll x = M;
    ll ans = 1;

    while( p*p <= M){
        int cnt = 0;
        while( x%p == 0){
            x /=  p;
            ++cnt;
        }
        if( cnt ){
            ans = (ans * combination(N+cnt-1, cnt)) % MOD;
        }
        ++p;
    }

    if( x != 1) ans = (ans * N)%MOD;
    cout << ans << endl;

    return 0; 
}


Measured memory_bytes: 83200
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int N, M;
    


    //入力
    cin >> N >> M;

    vector<int> L(M), R(M);
    rep(i, M) cin >> L[i] >> R[i];
    
    if(*min_element(R.begin(), R.end()) - *max_element(L.begin(), L.end()) +1 < 0) cout << "0" << endl;
    else cout << *min_element(R.begin(), R.end()) - *max_element(L.begin(), L.end()) +1 << endl;

    return 0;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second


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

    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < sz(s); i++) {
        ans += (s[i] != t[i]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int flg = 0;
	string s;
	cin>>s;
	for(int i=0; i<3; i++)
	{
		if(s[i]=='7')
		{
			flg = 1;
			break;
		}
	}
	if(flg==1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
//template end

ll a[500010]={};

int main(){
    string s; cin>>s; int n=s.size();
    rrep(i,n-1,-1){
        if(s[i]=='>')a[i]=a[i+1]+1; else a[i]=0;
    }
    ll ans=a[0],add=a[0];
    rep(i,0,n){
        if(s[i]=='<'){
            add++; chmax(add,a[i+1]);
        }
        else{
            add--; chmin(add,a[i+1]);
        } 
        ans+=add;
        cerr<<add<<endl;
    }
    printf("%lld\n",ans);
    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 all(vec) vec.begin(),vec.end()
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  int X;
  cin >> X;
  int a=X/100;
  int b=105*a;
  if(X<=b)
    cout << 1 << endl;
  else
    cout << 0 << endl;
}

Measured memory_bytes: 256
coins = []
line = input()
n, v = list(map(int, line.split()))
for _ in range(0, 4):
    line = input()
    c = list(map(int, line.split()))
    coins += [c]

def solve(n, v):
    ab = {}
    for i in range(0, n):
        for j in range(0, n):
            a = coins[0][i] + coins[1][j]
            if a not in ab:
                ab[a] = 1
            else:
                ab[a] += 1
    cd = {}
    low = 10 ** 17
    high = 0
    for i in range(0, n):
        for j in range(0, n):
            a = coins[2][i] + coins[3][j]
            if a not in cd:
                cd[a] = 1
                low = min(low, a)
                high = max(high, a)
            else:
                cd[a] += 1
    ans = 0
    for k in ab:
        if v - k < low or high < v - k:
            continue
        if v - k in cd:
            ans += ab[k] * cd[v - k]
    return ans

print(solve(n, v))


Measured memory_bytes: 203432
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    string s;
    map<char, int>mp;
    cin >> s;
    for (auto ss : s)mp[ss]++;
    int a = mp['N'];
    int b = mp['S'];
    int c = mp['E'];
    int d = mp['W'];
    bool ans = false;
    if (a > 0 && b > 0 && c == 0 && d == 0)ans = true;
    if (c > 0 && d > 0 && a == 0 && b == 0)ans = true;
    if (a > 0 && b > 0 && c > 0 && d > 0)ans = true;
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

ans = 0
#if N % 2 == 1:
if (B - A) % 2 == 0:
    ans = (B - A) // 2

else:
    a = A - 1
    b = N - B

    if a > b:
        bb = b + 1
        A += bb
        ans += (N - A) // 2
        ans += bb

    else:
        aa = a + 1
        B -= aa
        ans += (B - 1) // 2
        ans += aa

print(ans)





Measured memory_bytes: 3060
// https://atcoder.jp/contests/abc049/tasks/abc049_a
// AtCoder Beginner Contest 049
// A - 居合を終え、青い絵を覆う

function main(arg) {
  const c = arg.trim();
  
  switch (c) {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
    console.log('vowel');
    break;
  default:
    console.log('consonant');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll x;
  cin >> x;
  ll q=x%11;
  ll p=x/11;
  ll ans=2*p;
  if(q>0 && q<=6){
    ans++;
  }else if(q>0 &&q<=12){
    ans+=2;
  }
  cout << ans;
}
      

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
   int H,W,N;
   cin>>H>>W>>N;
   
   int c=0;
   c=max(H,W);
   int a=0;
   if(N%c==0)cout<<N/c<<endl;
   else cout<<N/c+1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = 10000; i >= 0; i--) {
		if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) ans = i;
	}
	if (ans != 0) cout << ans << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Node {
  double sim;
  string str;
  struct Node *left, *right;
  set< string > subtree;
  Node():left((struct Node *)NULL), str(""), right((struct Node *)NULL),sim(0.0){}
};
 
string S;
int idx;
 
int MoveLeftSim(Node *left, Node *right)
{
  if(left == NULL) return(0);
  if(abs(left -> sim - right -> sim) < 1e-10) {
    int ret = MoveLeftSim(left -> left, right -> left);
    if(ret == 0) ret = MoveLeftSim(left -> right, right -> right);
    return(ret);
  } else if(left -> sim < right -> sim) {
    return(1);
  } else {
    return(-1);
  }
}
 
Node* rec()
{
  Node *node = new Node();
  if(S[idx++] == '(') {
    node -> left = rec();
    ++idx;
    node -> right = rec();
    ++idx;
 
    set< string >::iterator it1 = node -> left -> subtree.begin();
    set< string >::iterator it2 = node -> right -> subtree.begin();
    int common = 0;
    while(it1 != node -> left -> subtree.end() && it2 != node -> right -> subtree.end()) {
      if(*it1 == *it2) ++common;
      if(*it1 < *it2) ++it1;
      else ++it2;
    }
 
    node -> subtree.insert(node -> left -> subtree.begin(), node -> left -> subtree.end());
    node -> subtree.insert(node -> right -> subtree.begin(), node -> right -> subtree.end());
     
    node -> sim = (double)common / node -> subtree.size();
    if(MoveLeftSim(node -> left, node -> right) == -1) {
      swap(node -> left, node -> right);
    }
    node -> str = "(" + node -> left -> str + " " + node -> right -> str + ")";
  } else {
    node -> str = "x";
  }
  node -> subtree.insert(node -> str);
  return(node);
}
 
void SwapNode(Node *root, bool isRight)
{
  if(root -> left == NULL) return;
  if(isRight) swap(root -> left, root -> right);
  SwapNode(root -> right, true);
  SwapNode(root -> left, false);
  root -> str = "(" + root -> left -> str + " " + root -> right -> str + ")";
}
 
void deleteNode(Node *node) {
 
  if(node != NULL) {
    deleteNode(node -> right);
    deleteNode(node -> left);
    delete node;
  }
}
 
int main()
{
  char buff[1024];
  while(fgets(buff, sizeof(buff), stdin), buff[0] != '0') {
    buff[strlen(buff) - 1] = '\0';
    stringstream sss;
    sss << buff;
    S = sss.str();
    idx = 0;
    Node *root = rec();
     
    SwapNode(root, false);
    cout << root -> str << endl;
    deleteNode(root);
  }
}

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

int main(void){
	int N,b=0;
	string s;
	cin>>N>>s;
	rep(i,N){
		if(s[i]=='(')b++;
		else if(b>0)b--;
		else cout<<"(";
	}
	cout<<s;
	rep(i,b)cout<<")";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
sa = list(str(input()))
sb = list(str(input()))
sc = list(str(input()))

tmp = 'a'
while True:
    if tmp == 'a':
        tmp = sa.pop(0)
    elif tmp == 'b':
        tmp = sb.pop(0)
    elif tmp == 'c':
        tmp = sc.pop(0)
    if len(sa) == 0 and tmp == 'a':
        print('A')
        exit()
    elif len(sb) == 0 and tmp == 'b':
        print('B')
        exit()
    elif len(sc) == 0 and tmp == 'c':
        print('C')
        exit()


Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll a, b;
ll ca, cb;
int main(){
	cin >> a >> b;
	if(a > b) swap(a,b);
	REP(i,0,b){
		ca *= 10;
		ca += a;
	}
	p(ca);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,m,a[50][2],b[50],i,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
		scanf("%d%d",&a[i][0],&a[i][1]);
	for(j=1;j<=n;j++)
	{
		b[j]=0;
	  for(i=0;i<m;i++)
	  {
		  if(a[i][0]==j)
			b[j]++;
		 if(a[i][1]==j)
			b[j]++;
	  }
	}
	for(j=1;j<=n;j++)
	printf("%d\n",b[j]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;

int main(){
    string s;   cin >> s;
    string ans="YES";
    int n = s.size(), flag=1;
    reverse(s.begin(), s.end());
    while(flag){
        flag = 0;
        
        if(7<=n && s.substr(0, 7)=="remaerd"){
            n -= 7;
            s = s.substr(7, n); flag = 1;
        }
        if(6<=n && s.substr(0, 6)=="resare"){
            n -= 6;
            s = s.substr(6, n); flag = 1;
        }

        if(5<=n && (s.substr(0, 5)=="esare" || s.substr(0, 5)=="maerd")){
            n -= 5;
            s = s.substr(5, n); flag = 1;
        }
        
        //cout << s << endl;
    }
    if(0<s.size()) ans = "NO";
    cout << ans << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す
  return a*b/gcd(a,b);
}
ll pow(ll x,ll y){//x^yを返す
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  int N,K;
  cin>>N>>K;
  vector<ll> P(N);
  for(ll i=0;i<N;i++){
    cin>>P.at(i);
  }
  sort(P.begin(),P.end());
  ll ans=0;
  for(ll i=0;i<K;i++){
    ans+=P.at(i);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596