akhauriyash/Code-Regression huggingface dataset:
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL _t1 = -1, _t2, _a1, _a2, _b1, _b2;
		cin >> _t1 >> _t2 >> _a1 >> _a2 >> _b1 >> _b2;
		if (_t1 < 0) return 0;
		LL t1 = _t1, t2 = _t2, a1 = _a1, a2 = _a2, b1 = _b1, b2 = _b2;
		LL p = (a1 - b1) * t1, q = (a2 - b2) * t2;
		if (p < 0) {
			p = -p, q = -q;
		}
		if (p + q == 0) {
			cout << "infinity" << endl;
		} else {
			LL ans = 0;
			if (p + q < 0) {
				LL r = p / -(p + q), s = p % -(p + q);
				ans = (LL)r * 2 + (s != 0);
			}
			cout << ans << endl;
		}
	}
	return 0;
}


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

int main(){
  long long int n,k;
  cin>>n>>k;
  
  long long int ans=0;
  while(n>0){
    n=n/k;
    ans++;
  }  
  
  if(ans==0){ans++;}
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
def main
  d, n = ARGF.gets.split.map(&:to_i)

  n += 1 if n == 100
  if d == 0
    puts n
  elsif d == 1
    puts n * 100
  else
    puts n * 100 * 100
  end
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll Q;
  cin>>N>>M>>Q;
  mat dp(N+1,vec(N+1,0));
  ll l,r;
  rep(i,M) { 
    cin>>l>>r;
    ++dp.at(l).at(r);
  } 
  rep(i,N){ 
    rep(j,N) { 
      dp.at(i+1).at(j+1) += dp.at(i+1).at(j); 
    }
  } 
  for(ll i = N-1; i >= 0; --i){ 
    rep(j,N) { 
      dp.at(i).at(j+1) += dp.at(i+1).at(j+1); 
    }
  } 
  rep(i,Q){ 
    cin>>l>>r; 
    cout<<dp.at(l).at(r)<<endl;
  } 
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int *A, int n, int g) {
  for (int i=g; i<n; i++) {
    int v = A[i];
    int j = i-g;
    while (j>=0 && A[j]>v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int *A, int n) {
  for (int h=1; h<=n; h=3*h+1) {
    G.push_back(h);
  }
  for (int i=G.size()-1; i>=0; i--) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d", &A[i]);
  }
  cnt = 0;
  shellSort(A,n);
  printf("%ld\n", G.size());
  for (int i=G.size()-1; i>0; i--){
    printf("%d ", G[i]);
  }
  printf("%d\n", G[0]);
  printf("%lld\n", cnt);
  for (int i = 0; i < n; ++i){
    printf("%d\n", A[i]);
  }

  return 0;
}

Measured memory_bytes: 7172
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

  cin >> a >> b >> c;

 if(a <= c){
  if(c - a <= b){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
 }
  else{
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int number[] = new int[n];
      	boolean a = true;
      	int count = 0;
      
      	for (int i=0; i<n; i++) {
          number[i]=sc.nextInt();
        }
      	sc.close();
      
        while (a==true) {
          for (int i=0; i<n; i++) {
            if (number[i]%2!=0) {
              a = false;
            }
          }
          if (a == false) {
            break;
          }
          for (int i=0; i<n; i++) {
            number[i]/=2;
          }
          count++;
        }
      System.out.println(count);
	}
}

Measured memory_bytes: 35912
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int INF=1e10 +5;

signed main()
{
    int n,k;
    cin>>n>>k;
    
    int arr[n];
    
    for(int i=0;i<n;i++)
        cin>>arr[i];
        
    int dp[n];
    
    fill(dp,dp+n,INF);
    
    dp[0]=0;
    
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
                dp[j]=min (dp[j] , dp[i] + abs(arr[j]-arr[i]) );
        }
    }
    
    cout<<dp[n-1];
    
    return 0;
}

Measured memory_bytes: 5192
#include<iostream>
using namespace std;
long long a,b,c,n;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<1<<endl;
        return 0;
    }
    if(c>=b)
    {
        cout<<-1<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)
	{
		n=1;
	}
    cout<<((a-b)/(b-c)+n)*2+1<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

long long int compute_gcd(long long int smaller, long long int bigger) {
  if (smaller > bigger) {
    return compute_gcd(bigger, smaller);
  }

  if (smaller == 0) {
    return bigger;
  }
  return compute_gcd(smaller, bigger % smaller);
}

long long int compute_lcm(long long int a, long long int b) {
  long long int gcd = compute_gcd(a, b);
  return a * b / gcd;
}

int main(void)
{
  long long int a, b;
  while (scanf("%lld%lld", &a, &b) != EOF) {
    printf("%lld %lld\n", compute_gcd(a, b), compute_lcm(a, b));
  }
  return 0;
}

Measured memory_bytes: 596
//FIRST THINK THEN CODE.

  #include <bits/stdc++.h>


  using namespace std;

  typedef long long ll;

  #define rep(i,a,b) for(ll i=a;i<b;++i)
  #define rrep(i,a,b) for(ll i=a;i>b;--i)
  #define FOR(i,n)  for(ll i=0;i<n;i++)
  #define vi vector<int>
  #define vl vector<ll>
  #define ld long double
  #define vld vector<ld>
  #define vvi vector<vector<int>>
  #define vvl vector<vector<long long>>
  #define vvld vector<vector<ld>>
  #define pii pair<int,int>
  #define pll pair<long,long>
  #define vpii vector<pii>
  #define vpll vector<pll>
  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define d1(x) cout<<(x)<<endl
  #define d2(x,y) cout<<(x)<<" "<<(y)<<endl
  #define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
  #define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
  #define PI 3.1415926535897932384626433832795
  #define fix(f,n) fixed<<setprecision(n)<<f
  #define all(x) x.begin(),x.end()
  #define rev(p) reverse(p.begin(),p.end());
  #define endl "\n"
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define popcount(x) __builtin_popcountll(x)
  #define sz(x) ((ll)x.size())
  const ll M=1000000007;
  const ll MM=998244353;
  ll begtime = clock();
  #define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
  //#define _Find_next 
  //#define _Find_first 



  ll newmod(ll a,ll b)
  {
  return ((a%b)+b)%b;
  }


  ll powM(ll a,ll b,ll m )
  { 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
  if(b&1)ans=ans*a%m;
  a=a*a%m;
  b>>=1;
  }

  return ans;
  }



  ll poww(ll a,ll b)
  { 

  ll ans=1;
  while(b)
  {
  if(b&1)ans=ans*a;
  a=a*a;
  b>>=1;
  }

  return ans;

  }

  template<typename T,typename F>
  void chmax( T &a,F b){
  if(b>a)a=b;
  }

  template<typename T,typename F>
  void chmin( T &a,F b){
  if(b<a)a=b;
  }

string tostring(ll x){
  stringstream sss;
  sss<<x;
  string ans=sss.str();
  return ans;
}


  const ll N=1e3+5;



  int main()
  { 

ll k,s;
cin>>k>>s;

ll c=0;

FOR(i,k+1) {
  FOR(j,k+1){
    ll rem=s-i-j;
    if(rem>=0&&rem<=k)c++;
  }
}

cout<<c;

  return 0;

  }

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

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	ll all=0L;
	rep(i,n) all ^= a[i];
	rep(i,n) cout << (all^a[i]) << endl;
	return 0;
}


Measured memory_bytes: 3900
//Breadth First Search
#include <iostream>
#include <queue>

using namespace std;

static const int N = 100;

int d[N];

void bfs(vector<vector<int>> &graph, int u) {
    queue<int> q;
    q.push(u);
    d[u] = 0;

    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto w: graph[v]) {
            if(d[w] != -1) continue;
            q.push(w);
            d[w] = d[v] + 1;
        }
    }
}

int main() {
    int n;
    cin >> n;
    int u, k, v;
    vector<vector<int>> graph(n);
    for(int i=0; i<n; i++) {
        cin >> u >> k;
        for(int j=0; j<k; j++) {
            cin >> v;
            graph[u-1].push_back(v-1);
        }
    }
    for(int i=0; i<n; i++) d[i] = -1;

    bfs(graph, 0);

    for(int i = 0; i < n; i++) cout << i+1 << " " << d[i] << endl;
    return 0;
}



Measured memory_bytes: 3144
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next())-1;
        int y = Integer.parseInt(sc.next())-1;
        
        ArrayList<Integer>[] g = new ArrayList[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }
        for(int i=0; i<n-1; i++){
            g[i].add(i+1);
            g[i+1].add(i);
        }
        g[x].add(y);
        g[y].add(x);
        int[] dist = new int[n];
        ArrayDeque<Integer> q = new ArrayDeque<>();
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i=0; i<n; i++){
            q.addLast(i);
            Arrays.fill(dist, (int)1e9);
            dist[i] = 0;
            while(q.size()!=0){
                int now = q.pollFirst();
                for(int next : g[now]){
                    if(dist[now]+1 < dist[next]){
                        dist[next] = dist[now]+1;
                        map.put(dist[next], map.getOrDefault(dist[next], 0)+1);
                        q.addLast(next);
                    }
                }
            }
        }
        
        for(int i=1; i<n; i++){
            System.out.println(map.getOrDefault(i, 0)/2);
        }
    }
}


Measured memory_bytes: 137720
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,K;


int main()
{
  cin>>N;

  int ans = 180 * (N - 2);
  cout << ans << endl;
  return 0;
}

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

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

  vector<int> cnt(3);
  for(int i=0;i<n;i++){
    int a; cin >> a; cnt[a%3]++;
  }
  
  if(cnt[1] == 0 && cnt[2] == 0){
    cout << min(cnt[0], 1) << endl;
    return 0;
  }

  int ans = 0;
  if(cnt[1]) ans = min(3, cnt[1]);
  if(cnt[1]>=2){
    int chain = min(cnt[1]-2, cnt[2]);
    ans = max(ans, 2 + 2*chain + max(min(1, cnt[1]-2-chain), min(2, cnt[2]-chain) ) );
  }
  if(cnt[2]>=1){
    int chain = min(cnt[1], cnt[2]-1);
    ans = max(ans, 1 + 2*chain + max(min(1, cnt[1]-chain), min(2, cnt[2]-1-chain) ) );
  }

  cout << ans + cnt[0] << endl;
}

Measured memory_bytes: 3188
N = int(input())
XU = [list(input().split()) for i in range(N)]

ans = 0
for i in range(N):
    if XU[i][1] == 'JPY':
        ans += float(XU[i][0])
    else:
        ans += 380000 * float(XU[i][0])
        
print(ans)        

Measured memory_bytes: 3060
n,t=map(int,input().split())
l=list(map(int,input().split()))
#最大利益を実現する買い方の組がいくつあるか考えたい
#ある地点で売るときはそれより前の地点の一番安いところで買うのが良いーnowminで判断しよう
count=0
max=0
nowmin=l[0]
nowmincount=1
for i in range(1,n):
  if l[i]-nowmin>max:
    max=l[i]-nowmin
    count=nowmincount
  elif l[i]-nowmin==max:
    count+=nowmincount
  elif nowmin>l[i]:
    nowmincount=1
    nowmin=l[i]
  elif nowmin==l[i]:
    nowmincount+=1
print(count)

Measured memory_bytes: 15060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
const ld pi = 3.14159265358979323846;
const ll mod = 1000000007;
const ll inf = 1LL << 60;
 
int main() {
    string s,t;
    cin>>s>>t;
    ll ans=t.size();
    rep(i,s.size()-t.size()+1){
        ll cnt=0;
        rep(j,t.size()){
            if (s[i+j]!=t[j]){
                cnt+=1;
            }
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#define N 200
#define mod
#define inf
#define rg register
using namespace std;
typedef long long ll;
char ch[N];
int main(){
	scanf ("%s",ch);
	int sr=strlen(ch);
	cout<<ch[0]<<sr-2<<ch[sr-1];
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll n,a,b; cin >> n >> a >> b;
  vi x(n); rep(i,n) cin >> x[i];

  ll ans = 0;
  rep(i,n-1){
    ans += min(b,(x[i+1]-x[i])*a);
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3712
import collections

n,p = map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(p))

clist = list(c.items())
res = 1
for pr , qu in clist:
    res *= pr ** (qu // n)

print(res)

Measured memory_bytes: 3316
//1240
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
char table[10]={'0','1','2','3','4','5','6','7','8','9'};
string now;
void A(){
reverse(now.begin(),now.end());
}
void J(){
char tmp=now[0];
for(int i=0;i<now.size()-1;i++)now[i]=now[i+1];
now[now.size()-1]=tmp;
}
void E(){
string a="",b="",c="";
for(int i=0;i<now.size();i++){
if(i<now.size()/2)a.push_back(now[i]);
else if(i==now.size()/2&&now.size()%2==1)c.push_back(now[i]);
else b.push_back(now[i]);
}
//reverse(a.begin(),a.end());
//reverse(b.begin(),b.end());
now=b+c+a;
}
void C(){
char tmp=now[now.size()-1];
for(int i=now.size()-1;i>0;i--)now[i]=now[i-1];
now[0]=tmp;
}
void P(){
for(int i=0;i<now.size();i++){
	if(now[i]-'0'==0)now[i]='9';
else 	if(now[i]-'0'==1)now[i]='0';
else 	if(now[i]-'0'==2)now[i]='1';
else 	if(now[i]-'0'==3)now[i]='2';
else 	if(now[i]-'0'==4)now[i]='3';
else 	if(now[i]-'0'==5)now[i]='4';
else 	if(now[i]-'0'==6)now[i]='5';
else 	if(now[i]-'0'==7)now[i]='6';
else 	if(now[i]-'0'==8)now[i]='7';
else 	if(now[i]-'0'==9)now[i]='8';
	}
}
void M(){
for(int i=0;i<now.size();i++){
	if(now[i]-'0'==0)now[i]='1';
	else if(now[i]-'0'==1)now[i]='2';
	 else if(now[i]-'0'==2)now[i]='3';
else 	if(now[i]-'0'==3)now[i]='4';
else 	if(now[i]-'0'==4)now[i]='5';
else 	if(now[i]-'0'==5)now[i]='6';
else 	if(now[i]-'0'==6)now[i]='7';
else 	if(now[i]-'0'==7)now[i]='8';
else 	if(now[i]-'0'==8)now[i]='9';
else 	if(now[i]-'0'==9)now[i]='0';
	}
}

int main(){
	int n;
	cin>>n;
for(int kki=0;kki<n;kki++){
	string a;
	cin>>a>>now;
	for(int i=a.size();i>=0;i--){
		if(a[i]=='A')A();
		if(a[i]=='C')J();
		if(a[i]=='P')P();
		if(a[i]=='M')M();
		if(a[i]=='E')E();
		if(a[i]=='J')C();
	//cout<<now<<endl;	
	}
	cout<<now<<endl;
}

	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
  ll n;
  cin>>n;
  ll a,b;
  cin>>a>>b;
  if((b-a)%2==0)cout<<(b-a)/2LL<<"\n";
  else cout<<min(a+(b-a)/2LL,(n-b+1)+(b-a)/2LL)<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n;
map<char,ll>a;
string s;
ll ans;
int main()
{
	cin>>n>>s;
	rep(i,n) a[s[i]]++;
	ans=a['R']*a['G']*a['B'];
	rep(i,n) rep2(j,i+1,n)
	if(2*j-i<n&&s[i]+s[j]+s[2*j-i]=='R'+'G'+'B') ans--;
	re(ans)
	return 0;}

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

int main() {
    ll a, b, x;
    cin >> a >> b >> x;

    ll d = b/x;

    if(a==0){
        cout << d+1 << endl;;
    }else{
        cout << d-(a-1)/x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;

int N, Q, A[100010], B[100010], C[100010], D[100010], E[100010], x[100010], y[100010], ANS[100010];
vector <int> T[100010], Y[100010];
priority_queue <pair <int, int> > q;

int main () {
	scanf ("%d", &N);
	for (int i = 1; i <= N; i++) scanf ("%d%d", &A[i], &B[i]);
	for (int i = 1; i <= N + 1; i++) scanf ("%d", &C[i]);
	scanf ("%d", &Q);
	for (int i = 1; i <= Q; i++) scanf ("%d%d", &D[i], &E[i]);
	
	sort (C + 1, C + N + 2);
	for (int i = 1; i <= N; i++)
		A[i] = lower_bound (C + 1, C + N + 2, A[i]) - C,
		B[i] = lower_bound (C + 1, C + N + 2, B[i]) - C;
	for (int i = 1; i <= Q; i++)
		D[i] = lower_bound (C + 1, C + N + 2, D[i]) - C,
		E[i] = lower_bound (C + 1, C + N + 2, E[i]) - C;
	
	for (int i = 1; i <= N + 1; i++) x[i] = -1;
	for (int i = 1; i <= N; i++) if (A[i] <= N + 1) x[A[i]]++;
	for (int i = 2; i <= N + 1; i++) x[i] += x[i - 1];
	
	for (int i = 1; i <= N; i++) if (B[i] < A[i]) T[A[i] - 1].push_back (B[i]);
	
	int Ans = N;
	for (int i = N + 1, w = 0; i >= 1; i--) {
		sort (T[i].begin (), T[i].end ());
		for (unsigned int p = 0; p < T[i].size (); p++) q.push (make_pair (-T[i][p], i));
		for (int j = x[i] + w; j < -1; j++) {
			if (q.empty ()) { while (Q--) printf ("-1\n"); return 0; }
			pair <int, int> p = q.top (); q.pop ();
			T[p.second].erase (T[p.second].begin ());
			y[-p.first]++, y[p.second + 1]--, Ans--, w++;
		}
		w -= y[i];
	}
	
	for (int i = 1; i <= N + 1; i++) y[i] += y[i - 1], x[i] += y[i];
	while (!q.empty ()) q.pop ();
	
	for (int i = N + 1; i >= 1; i--)
		for (unsigned int p = 0; p < T[i].size (); p++)
			Y[T[i][p]].push_back (i);
	
	memset (y, 0, sizeof (y));
	memset (ANS, -1, sizeof (ANS));
	for (int i = 1, w = 0; i <= N + 1; i++) {
		ANS[i] = Ans;
		for (unsigned int p = 0; p < Y[i].size (); p++) q.push (make_pair (Y[i][p], i));
		for (int j = x[i] + w; j < 0;j++) {
			if (q.empty ()) goto end;
			pair <int, int> p = q.top (); q.pop ();
			y[p.first]++, Ans--, w++;
		}
		w -= y[i];
	}
	ANS[N + 2] = Ans;
	end:;
	
	for (int i = 1; i <= Q; i++) {
		int p = ANS[D[i]], q = ANS[E[i]];
		if (p != -1) p++;
		printf ("%d\n", max (p, q));
	}
	
	return 0;
}

Measured memory_bytes: 15728
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int y, m, d;
  char a, b;
  cin >> y >> a >> m >> b >> d;
  cout << (m < 5 ? "Heisei" : "TBD") << endl;
  return 0;
}
//templete by private_yusuke

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

int main(){
  int K, A, B;
  cin >> K >> A >> B;
  bool ans = false;
  
  for(int i = A; i <= B; i++){
    if(K > i)
      continue;
    if(i%K == 0){
      ans = true;
      break;
    }
  }
  
  if(ans)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
  
  return 0;
  
}

Measured memory_bytes: 3636
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val temp=readLine()!!.split(" ")
    val d = temp[0].toInt()-1
    val x = temp[1].toInt()
    val a=IntArray(n,{i: Int -> readLine()!!.toInt()})
    print(a.map{item:Int -> d/item+1}.sum()+x)
}

Measured memory_bytes: 37820
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(register ll(i)=(ll)(a);(i)<=(ll)(b);++i)
const ll inf=1e9+7;
#define y1 _y_1_
#ifndef gc
	#define gc getchar
#endif
#ifndef pc
	#define pc putchar
#endif
inline ll read(){ll f=0,x=0;register char c=gc();while(!isdigit(c))f^=c=='-',c=gc();while(isdigit(c))x=(x<<3)+(x<<1)+(c^'0'),c=gc();return x=f?-x:x;}
inline ll read(ll&x){ll f=0;x=0;register char c=gc();while(!isdigit(c))f^=c=='-',c=gc();while(isdigit(c))x=(x<<3)+(x<<1)+(c^'0'),c=gc();return x=f?-x:x;}
inline void writeln(){pc('\n');}
inline void write(ll x){if(x<0)pc('-'),x=-x;if(x>9)write(x/10);pc(x%10+'0');}
inline void writeln(const ll&x){write(x),pc('\n');}
using namespace std;
namespace Computation_Geometry{
	const ld eps=1e-6;
	struct vec{
		ld x,y;
		inline bool is_zero(){return (abs(x)<=eps)&(abs(y)<=eps);}
		inline void scan(){x=read(),y=read();}
		inline vec(){x=y=0;}
		inline vec(const ld&X,const ld&Y){x=X,y=Y;}
		inline friend vec operator +(const vec&A,const vec&B){return vec(A.x+B.x,A.y+B.y);}
		inline friend vec operator -(const vec&A,const vec&B){return vec(A.x-B.x,A.y-B.y);}
		inline ld len(){return sqrt(x*x+y*y);}
		inline ld len(const ll&X,const ll&Y){return sqrt((x-X)*(x-X)+(y-Y)*(y-Y));}
		inline ld k(){return (x==0)?inf:y/x;}
		inline ld k(const ll&X,const ll&Y){return (x==X)?inf:(y-Y)/(x-X);}
		inline friend ld Dot(const vec&A,const vec&B){return A.x*B.x+A.y*B.y;}
		inline friend ld Cross(const vec&A,const vec&B){return A.x*B.y-B.x*A.y;}
		inline friend ld Theta(vec A,vec B){return acos(Cross(A,B)/A.len()/B.len());}
	};
	struct line{
		ld A,B,C;
		inline line(){A=B=C=0;}
		inline line(const ld&_A,const ld&_B,const ld&_C){A=_A,B=_B,C=_C;}
		inline line(const ld&x1,const ld&y1,const ld&x2,const ld&y2){A=y2-y1,B=x1-x2,C=x2*y1-x1*y2;}
		inline line(const vec&_A,const vec&_B){A=_A.y-_B.y,B=_B.x-_A.x,C=Cross(_A,_B);}
		inline vec Vec(){return vec(A,B);}
		inline friend bool parallel(line A,line B){return abs(Cross(A.Vec(),B.Vec()))<=eps;}
		inline friend bool perpendicular(line A,line B){return abs(Dot(A.Vec(),B.Vec()))<=eps;}
	};
}
using namespace Computation_Geometry;
ll Q;
ld x1,y1,x2,y2;
line l1,l2;
signed main(){
	read(Q);while (Q--){
		x1=read(),y1=read(),x2=read(),y2=read();
		l1=line(x1,y1,x2,y2);
		x1=read(),y1=read(),x2=read(),y2=read();
		l2=line(x1,y1,x2,y2);
		if (parallel(l1,l2)) puts("2");
		else if (perpendicular(l1,l2)) puts("1");
		else puts("0");
	}
	fclose(stdin);fclose(stdout);return 0;
}


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

int main(){
	int k,a,b;
  	cin >> k;
  	cin >> a >> b;
  int cnt=0;
  	for (int i=0 ; i < 1001 ; i ++){
    int kake;
    kake = k*i;
    
   	if (a<=kake && kake<=b){    
    cnt++;
      //cout << "OK" << endl;
    }
    }
    if(cnt > 0){
    cout << "OK" << endl; 
    }
    else{
      cout << "NG" << endl;     
    }
}

Measured memory_bytes: 3652
/*
?§???????????????°???????????°

goto ?????????C/C++?¨????????????§???????????¨?????§???????????§????????????????????¨????????¶????????????????????????????????????????£?????????????????????° goto CHECK_NUM; ??¨?????????????????????????????¨???????????°??????????????§ CHECK_NUM: ??¨????????????????????????????§?????????????????????????????????£????????°?????????????????????????????????????????¨?????§????????????

?????????goto ???????????±??????????????????????????°?????????????????§?????±??????????????????????????????????????????????????¨?????¨?\¨?????????????????????

?¬????C++?¨???????????????°????????¨?????????????????????????????°????????????????????????????????????????????????goto ????????????????????§????£?????????????????????????

void call(int n){
int i = 1;
CHECK_NUM:
int x = i;
if ( x % 3 == 0 ){
cout << " " << i;
goto END_CHECK_NUM;
}
INCLUDE3:
if ( x % 10 == 3 ){
cout << " " << i;
goto END_CHECK_NUM;
}
x /= 10;
if ( x ) goto INCLUDE3;
END_CHECK_NUM:
if ( ++i <= n ) goto CHECK_NUM;

cout << endl;
}

*/
#include <iostream>
#include <math.h>

int main() {
	int n;
	std::cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (i % 3 == 0) {
			std::cout << " " << i;
			
		}
		else {
			for (int j = 0; j < 4; j++)
			{
				int d = pow(10, j);
				if ((i / d) % 10 == 3) {
					std::cout << " " << i;
					//std::cout << "(" << i << "/(10^" << j << ")) % 10 =" << (i / 10 * j) % 10 << std::endl;
					break;
				}
			}
			//else if ((i / 10) %10 == 3) std::cout << " " << i;
		}
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Alice":"Brown")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll s,t;
	bool ans=false;
	cin >>s>>t;
	if(s+t <=1){
		ans=false;
	}else{
		if(abs(s-t) <=1){
			ans=false;
		}else{
			ans=true;
		}
	}

	cout<<solve(ans)<<endl;
}
/*
fin: 1,0 or 1,1 -> 0,2 or 0,3 -> 2,1 or 4,1 or 2,2 -> 4,0 or  1,3 or 0,5
determent:(0,0)second | (1,0)second| (1,1)second (2,0)first, |(1,2)second, (3,0)first| (1,3)first (2,2) second (4,0) first |(5,0)first (4,1)first (3,2) second|
S 0
SS 1
FSF 2
FSSF 3
FFSFF 4
FFSSFF 5 (3,2)
FFFSFFF 6  (3,3)

(1,2) ,(2,3), (3,4,5,6),(4,5,6,7,8) (5-)
3, 2,1 second
5,0 -> (4(3,1)->second,3(1,2)-> first)->()
*/

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

S = input()
T = input()

s = Counter(S)
t = Counter(T)

# azzelをappleにするとき
# 問題参照

# aplezをappleにする時
# c1 = z c2 = aにすると
# apleaにできる
# c1 = a, c2 = pにすると
# aalep ⇄ できない

# Sの文字列にaがi1個、bがi2個,,,
# Tの文字列にaがj1個、bがj2個,,,あるとすると
# sort(i1, i2...)とsort(j1, j2...)が一致していればいい
# 構成要素の個数の集合が一致していればいい
if sorted(s.values()) == sorted(t.values()):
	print("Yes")
else:
	print("No")

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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() {
    int N,A,B;
    cin >> N >> A >> B;
    
    ll ans = 0;
    vector<int> f(N,0);
    for ( int i = 1; i <= N; ++i){
        int val = i;
        int c = 0;
        for ( int j = 0; j < 5; ++j){
            c += (val % 10);
            val /= 10;
        }
        if ( c >= A and c <= B ) ans += i;
    }
    

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

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A * N, B) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b;
   cin >> a >> b;

   int ans = max({a+b,a-b,a*b});

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
import bisect

def main():
	n = int(input())
	a = list(map(int,input().split()))
	a.sort()
	idx = bisect.bisect_left(a,0)
	if idx == 0:
		idx = 1
	elif idx == n:
		idx = -1
	cur_min = a[0]
	cur_max = a[-1]
	res = []
	for n in a[1:idx]:
		res.append('{} {}'.format(cur_max,n))
		cur_max -= n
	for n in a[idx:-1]:
		res.append('{} {}'.format(cur_min,n))
		cur_min -= n
	res.append('{} {}'.format(cur_max,cur_min))
	print(cur_max-cur_min)
	for r in res:
		print(r)

if __name__ == '__main__':
	main()

Measured memory_bytes: 17832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
struct graph
{
    int head[maxn],nxt[maxn<<1],to[maxn<<1],w[maxn<<1],sz;
    void init(){memset(head,-1,sizeof(head));}
    graph(){init();}
    void push(int a,int b,int c){nxt[sz]=head[a],to[sz]=b,w[sz]=c,head[a]=sz++;}
    int& operator[](const int a){return to[a];}
}g;
int a[maxn],sum[maxn],SIZE[maxn];
ll ans[maxn];
ll get(int x)
{
    return 1ll*x*(x+1)/2;
}
void dfs(int now,int pre)
{
    SIZE[now]=1;
    int tmp = sum[a[now]];
    for(int i = g.head[now];~i;i = g.nxt[i]){
        if(g[i]==pre)continue;
        sum[a[now]]=0;
        dfs(g[i],now);
        SIZE[now]+=SIZE[g[i]];
        ans[a[now]]-=get(SIZE[g[i]]-sum[a[now]]);
    }
    sum[a[now]]=tmp+SIZE[now];
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;++i)scanf("%d",&a[i]);
    for(int i = 1,a,b;i < n;++i){
        scanf("%d%d",&a,&b);
        g.push(a,b,0);
        g.push(b,a,0);
    }
    for(int i = 1;i <= n;++i)ans[i]=get(n);
    dfs(1,0);
    for(int i = 1;i <= n;++i){
        ans[i]-=get(n-sum[i]);
    }
    for(int i = 1;i <= n;++i)printf("%lld\n",ans[i]);
    return 0;
}


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

#define ll long long
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1000000007;

using namespace std;

int n,W;
ll w[110],v[110],d[110][100100];

int main(){
    //ios;
	cin>>n>>W;
	for (int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
	}
    for (int i=0;i<=n;i++){
        for (int j=0;j<=W;j++){
            if (i==0 or j==0){
                d[i][j]=0;
                continue;
            }
            if (j>=w[i]){
                d[i][j]=max(d[i-1][j],v[i]+d[i-1][j-w[i]]);
            }
            else{
                d[i][j]=d[i-1][j];
            }
        }
    }
    cout<<d[n][W];
	return 0;
}


Measured memory_bytes: 80128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    char s[20];
    int count;
    int out=0;
    scanf("%s",s);
    for(count=0;s[count]!='\0';count++){
        if(s[count]=='1'){out++;}

    }
    printf("%d",out);
}

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

using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string s;
   cin >> s;
   bool flag = false;
   for(int i=0;i<s.size();i++){
      if(s[i] == 'C')flag = true;
      if(flag && s[i] == 'F'){
         cout << "Yes" << endl;
         return 0;
      }
   }
   cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
template<class Type> class BinaryTree
{
    struct Node
    {
        Type val;
        Node *left, *right;
    };
    public:
        Node *root = NULL;
        Node *insert(Node *p, Type x)
        {
            if(p == NULL)
            {
                Node *q = new Node;
                q->val = x;
                q->left = q->right = NULL;
                if(root == NULL) root = q;
                return q;
            }
            else
            {
                if(x < p->val) p->left = insert(p->left, x);
                else p->right = insert(p->right, x);
                return p;
            }
        }
        bool find(Node *p, Type x)
        {
            if(p == NULL) return false;
            else if(x == p->val) return true;
            else if(x < p->val) return find(p->left, x);
            else return find(p->right, x);
        }
        void inorder(Node *p)
        {
            if(p->left != NULL) inorder(p->left);
            cout << " " << p->val;
            if(p->right != NULL) inorder(p->right);
        }
        void preorder(Node *p)
        {
            cout << " " << p->val;
            if(p->left != NULL) preorder(p->left);
            if(p->right != NULL) preorder(p->right);
        }
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    BinaryTree<int> T;
    for(int i = 0; i < n; i++)
    {
        string s; cin >> s;
        if(s == "insert") 
        {
            int n; cin >> n;
            T.insert(T.root, n);
        }
        if(s == "find")
        {
            int n; cin >> n;
            cout << (T.find(T.root, n) ? "yes" : "no") << endl;
        }
        if(s == "print")
        {
            T.inorder(T.root);
            cout << endl;
            T.preorder(T.root);
            cout << endl;
        }
    }
    return 0;
}




Measured memory_bytes: 15664
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    cout << x + y/2;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, w;
	cin >> n >> w;
	vector<int>weight(n), value(n);
	for (int i = 0; i < n; i++) {
		cin >> weight[i] >> value[i];
	}
	ll dp[n + 1][w + 1];
	for (int i = 0; i <= n; i++)dp[i][0] = 0;
	for (int i = 0; i <= w; i++)dp[0][i] = 0;
	for (int i = 1; i <= n; i++) {
		for (int k = 1; k <= w; k++) {
			if (weight[i - 1] <= k) {
				dp[i][k] = max(value[i - 1] + dp[i - 1][k - weight[i - 1]], dp[i - 1][k]);
			}
			else
				dp[i][k] = dp[i - 1][k];
		}
	}
	cout << dp[n ][w] << endl;
}


Measured memory_bytes: 79232
N = int(input())
dic = {}
lt = []
for i in range(N):
	S, P = map(str, input().split())
	lt.append([S, int(P)])
	dic.setdefault(S, []).append(int(P))
dic = sorted(dic.items())
for i in range(len(dic)):
	key = dic[i][0]
	value = dic[i][1:][0]
	value.sort(reverse=True)
	for j in range(len(value)):
		print(lt.index([key, value[j]]) + 1)


Measured memory_bytes: 3064
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<List<String>> result = new ArrayList<List<String>>();
		
		long[] x = new long[3];
		for(int i = 0; i < 3; i++){
			x[i] = stdIn.nextLong();
		}
		while( x[0] != 0 || x[1] != 0 || x[2] != 0 ){
			List<String> list = new ArrayList<String>();
			for(int i = 0; i < 3; i++){
				int max = i;
				for(int j = i+1; j < 3; j++){
					if( x[j] > x[max] ){
						max = j;
					}
				}
				long temp = x[max];
				x[max] = x[i];
				x[i] = temp;
			}
			long r = x[1]*x[1]+x[2]*x[2];
		
			int n = stdIn.nextInt();
			for(int i = 0; i < n; i++){
				long m = stdIn.nextLong();
				if( 4*m*m <= r ){
					list.add("NA");
				} else {
					list.add("OK");
				}
			}
			result.add(list);
			x[0] = stdIn.nextLong();
			x[1] = stdIn.nextLong();
			x[2] = stdIn.nextLong();
		}
		for(List<String> ans : result){
			for(String str : ans){
				System.out.println(str);
			}
		}
	}
}

Measured memory_bytes: 12000
def C158():
    A, B = [int(_) for _ in input().split()]
    N = 1
    while N <= 10000:
        if int(N * 8/100) == A and int(N * 10/100) == B:
            break
        N += 1
    if N <= 10000:
        print(N)
    else:
        print(-1)
        
if __name__ == "__main__":
    C158()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    bool same;
    for (int i = 0; i < N; i++)
    {
        same = true;
        for (int j = 0; j < N - i; j++)
        {
            if (s[i + j] != t[j]) same = false;
        }
        if (same)
        {
            cout << 2 * N - (N - i) << endl;
            return 0;
        }
        
    }
    
    cout << 2 * N << endl;

    return 0;
}

Measured memory_bytes: 888
N = int(input())
S = input()

W = []
w_count = 0
for s in S:
    W.append(w_count)
    if s == "W":
        w_count += 1

e_count = 0
E = [-1 for _ in range(N)]
for i in range(N-1, -1, -1):
    E[i] = e_count
    if S[i] == "E":
        e_count += 1

mi = N
for i in range(N):
    mi = min(mi, E[i] + W[i])

print(mi)

Measured memory_bytes: 17824
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    long long N,M;
    cin>>N>>M;

    long long ans = 0;
    if (N >= 3 && M >= 3)ans = N*M - ((N*2) + (M*2) -4);
    else if (N == 2 || M == 2)ans = 0;
    else if (N == 1 && M == 1) ans = 1;
    else if (N == 1 || M == 1) ans = N*M - 2;
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n-1)

	for i := 0; i < n; i++ {
		a[i] = nextInt() - 1
	}
	for i := 0; i < n; i++ {
		b[i] = nextInt()
	}
	for i := 0; i < n-1; i++ {
		c[i] = nextInt()
	}

	fmt.Println(solve(n, a, b, c))
}

func solve(n int, a, b, c []int) int {
	r := b[a[0]]

	for i := 1; i < n; i++ {
		r += b[a[i]]
		if a[i] == a[i-1]+1 {
			r += c[a[i-1]]
		}
	}

	return r
}


Measured memory_bytes: 1812
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

aa = [0]
bb = [0]
a.size.times{|i| aa << a[i] + aa.last }
b.size.times{|i| bb << b[i] + bb.last }

i = 0
j = b.size
mx = 0
while i < aa.size && j >= 0
  if aa[i] + bb[j] <= k
    mx = i+j if mx < i+j
    i += 1
  else
    j -= 1
  end
end
p mx


Measured memory_bytes: 45080
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        for(int i = 0 ; i < 3 ; i++){
            if(s.charAt(i) == '1'){
                System.out.print(9);
            }else{
                System.out.print(1);
            }
        }
        System.out.println();
    }
}

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

int main() {
  // 入力
  long N;
  long a, b, c, d, e;
  cin >> N;
  cin >> a >> b >> c >> d >> e;
  
  // 計算
  long time;
  if (N % min(min(min(min(a, b), c), d), e) == 0) {
  	time = N / min(min(min(min(a, b), c), d), e) + 4;
  } else {
    time = N / min(min(min(min(a, b), c), d), e) + 5;
  }
  
  // 出力
  cout << time << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, m;
    map<ll,ll>mp;
    string s;
    cin >> n >> m;
    cin >> s;
    reverse(s.begin(),s.end());
    mp[0] = 1;
    ll now = 0;
    ll ans = 0;
    ll cur = 1;
    int ptr = n;
    for (auto i:s) {
        if (m == 2 || m == 5) {
            if ((i - '0') % m == 0) {
                ans += ptr;
            }
            ptr--;
            continue;
        }
        cur *= 10;
        cur %= m;
        now += (i - '0') * cur;
        now %= m; 
        ans += mp[now];
        mp[now]++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1044