akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class SegmentTree {
private:
  int mSize;
  vector<int> scores[300001];
public:
  SegmentTree(int n) {
    mSize = 1;
    while(mSize < n) mSize *= 2;
  }

  int getSize() const{
    return mSize;
  } 

  void insert(const vector<int>& sequence){
    for(int i = mSize - 1,j=0; i < mSize * 2 - 1; i++,j++){
      int score = INF;
      if(j < sequence.size()){
        score = sequence[j];
      }
      scores[i].push_back(score);
    }

    for(int idx = mSize - 2; idx >= 0; idx--){
      int lhs = 2 * idx + 1;
      int rhs = 2 * idx + 2;
      scores[idx].resize(scores[lhs].size() + scores[rhs].size());
      merge(scores[lhs].begin(),scores[lhs].end(),scores[rhs].begin(),scores[rhs].end(),scores[idx].begin());
    }
  }

  int query(int left_i,int right_i,int current_idx,int current_lhs,int current_rhs,int min_v,int max_v){
    if(current_rhs <= left_i || right_i <= current_lhs){
      return 0;
    }
    if(left_i <= current_lhs && current_rhs <= right_i) {
      int upper = upper_bound(scores[current_idx].begin(),scores[current_idx].end(),max_v) - scores[current_idx].begin();
      int lower = lower_bound(scores[current_idx].begin(),scores[current_idx].end(),min_v) - scores[current_idx].begin();
      int unused = scores[current_idx].end() - lower_bound(scores[current_idx].begin(),scores[current_idx].end(),INF);
      return scores[current_idx].size() - (upper - lower) - unused;
    }
    else {
      int vl = query(left_i,right_i,current_idx * 2 + 1, current_lhs, (current_lhs + current_rhs) / 2, min_v, max_v);
      int vr = query(left_i,right_i,current_idx * 2 + 2, (current_lhs + current_rhs) / 2, current_rhs, min_v, max_v);
      return vl + vr;
    }
  }
};

int main(){
  int sequence_length;
  while(~scanf("%d",&sequence_length)){
    vector<int> sequence;
    for(int seq_i = 0; seq_i < sequence_length; seq_i++){
      int x;
      scanf("%d",&x);
      sequence.push_back(x);
    }

    SegmentTree seg_tree(sequence_length);
    seg_tree.insert(sequence);

    int total_queries;
    scanf("%d",&total_queries);
    for(int query_i = 0; query_i < total_queries; query_i++){
      int left_i;
      int right_i;
      int offset;
      scanf("%d %d %d",&left_i,&right_i,&offset);
      left_i--;
      right_i--;
      int max_v = max(sequence[left_i],sequence[right_i]) + offset;
      int min_v = min(sequence[left_i],sequence[right_i]) - offset;
      int n = seg_tree.getSize() - 1;
      printf("%d\n",seg_tree.query(left_i,right_i,0,0,n,min_v,max_v));
    }
  }
}

Measured memory_bytes: 23844
while True:
    month,day=list(map(int, input().split()))
    if month==day==0:
        break
    month_day=[30,29,31,30,31,30,31,31,30,31,30,31]             #1から12
    tmp_day=0
    for i in range(month-1):
        tmp_day+=month_day[i]
    tmp_day+=day
    amari=tmp_day%7
    if month==day==1:
        print("Thursday")
    elif amari==0:
        print("Thursday")
    elif amari==1:
        print("Friday")
    elif amari==2:
        print("Saturday")
    elif amari==3:
        print("Sunday")
    elif amari==4:
        print("Monday")
    elif amari==5:
        print("Tuesday")
    elif amari==6:
        print("Wednesday")



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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    
    int ans=0;
    for(int i=0;i<N;i++){
        if(S[i] != S[i+1]) ans++;
    }
    cout << ans;
}

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

long long N;
long long A[100005];

int main(){
	cin >> N;
	long long neg_count = 0;
	for(long long i = 0; i < N; i++){
		cin >> A[i];
		if(A[i] < 0){
			neg_count++;
		}
	}

	long long count = 0;
	if(neg_count % 2 == 0){
		for(long long i = 0; i < N; i++){
			count += abs(A[i]);
		}
	} else {
		long long mini = INT_MAX;
		for(long long i = 0; i < N; i++){
			count += abs(A[i]);
			mini = min(mini, abs(A[i]));
		}
		count -= 2*mini;
	}
	cout << count << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
	double a = 0.00;
	double b = 0.00;

	cin >> a >> b;
	cout << static_cast<int>(a/b) << ' ' << static_cast<int>(a)%static_cast<int>(b)
        << ' ' << fixed << setprecision(5) << a/b << endl;
}


Measured memory_bytes: 3260
n=int(input())
tree=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
def dist(k):
  l=[-1]*n
  node=[k]
  while node:
    s=node.pop()
    d=l[s]
    for t in tree[s]:
      if l[t]!=-1:
        continue
      l[t]=d+1
      node.append(t)
  return l
from_fennec=dist(0)
from_snuke=dist(n-1)
res=0
for i,j in zip(from_fennec,from_snuke):
  if i<=j:
    res+=1
  else:
    res-=1
print('Snuke' if res<=0 else 'Fennec')

Measured memory_bytes: 28976
import sys

def solve(n, h):
  if n == 1:
    return "Yes"

  for i in xrange(n):
    if i == n - 1:
      break

    if h[n-1 - i - 1] <= h[n-1 - i]:
      continue
    elif h[n-1 - i - 1] - 1 == h[n-1 - i]:
      h[n-1 - i - 1] -= 1
    else:
      return "No"

  return "Yes"


if __name__ == '__main__':

  n = int(sys.stdin.readline().strip())
  h = map(int, sys.stdin.readline().strip().split(" "))
  print solve(n, h)

Measured memory_bytes: 36844
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	int x,y,z;
	cin>>x>>y>>z;
	swap(x,y);
	swap(x,z);
	cout<<x<<" "<<y<<" "<<z<<endl;
	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


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

using namespace std;

int main()
{
  string str, key = "qwertasdfgzxcvb";

  while(cin>>str && str != "#"){
    int cnt = 0, hand = 2;

    for(int i = 0; i < str.size(); i++){
      bool f = true;
      for(int j = 0; j < key.size(); j++){
	if(str[i] == key[j]){
	  f = false;
	  break;
	}
      }

      if(f && hand != 1){
	hand = 1;
	cnt++;
      } else if(!f && hand != 0){
	hand = 0;
	cnt++;
      }
    }
    cnt--;

    cout << cnt << endl;
  }


  return 0;
}

Measured memory_bytes: 0
x = int(input())

for a in range(10**3):
    for b in range(10**3):
        if(a**5 + b**5 == x):
            print(a, -b)
            break
        elif(a**5 - b**5 == x):
            print(a, b)
            break
    else:
        continue
    break


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

prev = S[0]
cur = 'R'
count = 0
wNum = 0
changedPoint = -1
changed = False
for i in range(N-1, -1, -1):
    cur = S[i]
    changed = False
    if cur == 'R':
        for j in range(wNum, i):
            wNum = j + 1
            if S[j] == 'W':
                changedPoint = j
                changed = True
                break
        if changed == True:
            count += 1
        elif changedPoint != -1 and wNum < i:
            count += 1
            break
        else:
            break

    prev = cur
    if wNum == i-1:
        break

print(count)


Measured memory_bytes: 68384
#include <iostream>
    using namespace std;
     
    int main() {
    	int h,w,i,j;
    	for(;;){
    		cin>>h>>w;
    		if (h==0&&w==0){break;}
    		for(i=0;i<h;i++){
    			for(j=0;j<w/2;j++){
    				if(i%2==0){
    					cout<<"#"<<".";
    				}
    				else{
    					cout<<"."<<"#";
    				}
    			}
    			if(w%2==1&&i%2==0){
    				cout<<"#";
    			}
    			if(w%2==1&&i%2==1){
    				cout<<".";
    			}	
    			cout<<endl;
    		}
    		cout<<endl;
    	}
    }


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	vpi ok;
	forn(i, n) {
		int input; scanf("%d", &input);
		ok.pb({input, i});
	}
	sort(all(ok));
	int ans[n];
	forn(i, n) {
		if(i != n - 1)
			ans[ok[i].second] = ok[n - 1].first;
		else
			ans[ok[i].second] = ok[n - 2].first;
	}
	for(auto a : ans)
		printf("%d ", a);







	return 0;
}

Measured memory_bytes: 4080
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;++i){
    cin >> a[i];
    if(a[i]%2==0){
		if(a[i]%3!=0&&a[i]%5!=0){
          cout << "DENIED";
      	  return 0;
        }
    }
  }
  cout << "APPROVED";
  return 0;
}


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

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

int gcd_arr(int arr[], int n) {
    if(n == 1) return arr[0];
    if(n == 2) return gcd(arr[0], arr[1]);
    arr[n-2] = gcd(arr[n-2], arr[n-1]);
    return gcd_arr(arr, n-1);
}

int main() {
    int N,X;
    cin >> N >> X;

    int x[110000];
    for(int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        x[i] = abs(tmp - X);
    }

    cout << gcd_arr(x, N) << endl;

  
}


Measured memory_bytes: 640
using System;
namespace test
{
    class test
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            bool[] S = new bool[13];
            bool[] H = new bool[13];
            int[] C = new int[13];
            int[] D = new int[13];

            for (int i = 0; i < n; i++)
            {
                var data = Console.ReadLine().Split(' ');
                int rank = int.Parse(data[1]);
                if (data[0] == "S") S[rank - 1] = true;
                if (data[0] == "H") H[rank - 1] = true;
                if (data[0] == "D") D[rank - 1] = 1;
                if (data[0] == "C") C[rank - 1] = 1;
            }

            for (int i = 0; i < 13; i++)
                if (S[i] == false) Console.WriteLine("S {0}", i + 1);
            for (int i = 0; i < 13; i++)
                if (H[i] == false) Console.WriteLine("H {0}", i + 1);
            for (int i = 0; i < 13; i++)
                if (C[i] == 0) Console.WriteLine("C {0}", i + 1);
            for (int i = 0; i < 13; i++)
                if (D[i] == 0) Console.WriteLine("D {0}", i + 1);
        }
    }
}

Measured memory_bytes: 9132
#include <stdio.h>
long long absol(long long);
int main(){
  int n;
  long long a[100000],sum=0,par=0,min=1000000001;
  scanf("%d",&n);
  for (int i=0;i<n;i++){
    scanf("%lld",&a[i]);
    if (a[i]<0) par++;
    a[i]=absol(a[i]);
    sum+=a[i];
    if (min>a[i]) min=a[i];
  }
  if (par%2) printf("%lld\n",sum-2*min);
  else printf("%lld\n",sum);
  return 0;
}

long long absol(long long x){
  if (x<0) x=-x;
  return x;
}

Measured memory_bytes: 896
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    ll suml1 = 0, suml2, sumr1, sumr2;
    int mi = -1;
    while (suml1 * 2 < sum) {
        ++mi;
        suml1 += a[mi];
    }
    sumr1 = sum - suml1;
    suml2 = suml1 - a[mi];
    sumr2 = sum - suml2;
    cout << min(abs(suml1 - sumr1), abs(suml2 - sumr2)) << '\n';
    return 0;
}


Measured memory_bytes: 1792
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,d,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,b);
  if(a*b%2==0) OUT("Even");
  else OUT("Odd");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    while (n > 1) {
        n = (n+2)/3;
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3040
N, M = map(int, input().split())
H = [0] + list(map(int, input().split())) 
AB = [tuple(map(int, input().split())) for _ in range(M)]
good_num = N
pair = [set(e)  for e in set(AB)]
bad_tenbodai = []
for a,b in pair:
    i, j = H[a], H[b]
    if i < j:
        bad_tenbodai.append(a)
    elif i == j:
        bad_tenbodai.extend([a,b])
    else:
        bad_tenbodai.append(b)
print(N - len(set(bad_tenbodai)))

Measured memory_bytes: 53596
n,k = map(int,input().split())
a = list(map(int,input().split()))

#n,k = 10,3
#a = [5,1,3,2,4,1,1,2,3,4]

count = [0] * (n+1)
for i in a:
  count[i] += 1
count2 = []
for i in count:
  if i:
    count2.append(i)
count2 = sorted(count2)
target = len(count2) - k 
target = max(target,0)


ans = 0
if target:
  for i in range(target):
    ans += count2[i]
print(ans)

Measured memory_bytes: 24996
/*
Author : N_o_o_B
Created : December 28 2019 17:52:48 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll n,m,v,p;
    cin >> n >> m >> v >> p;
    vl a(n);
    fori(i,n) cin >> a[i];
    sort(all(a));
    ll ans = p;
    ll sum = 0;
    fori(i,n-p+1){
        sum += a[i];
    }
    fori(i,n-p){
        sum -= a[i];
        ll req = v - (i+1);
        if(req < p){
            if(a[i] + m >= a[n-p]){
                ans++;
            }
            continue;
        }
        if(a[i] + m < a[n-p]){
            continue;
        }
        ll rem = v - (i+p);
        ll can = (a[i]+m)*(n-p-i) - sum;
        if(can >= m*rem) {ans++;}
    }
    cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  print(N/3);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    string s = string(min(a, 4), 'A')+string(min(b, 4), 'B');
    do {
        if(a == 5 && b != 5) cout << s << "A" << "\n";
        else if(b == 5 && a != 5) cout << s << "B" << "\n";
        else if(a == 6) cout << s << "AA" << "\n";
        else if(b == 6) cout << s << "BB" << "\n";
        else if(max(a, b) == 5){
            cout << s << "AB" << "\n";
            cout << s << "BA" << "\n";
        }else cout << s << "\n";
    }while(next_permutation(s.begin(),s.end()));
    return 0;
}


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

using namespace std;

int main(void){
    string a, b;
    cin >> a >> b;
    a += b;
    int c = atoi(a.c_str());
    int d = sqrt(c);

    if(d*d == c) cout << "Yes" <<endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;


int main(){
	ll n,k;
	cin>>n>>k;
	if(n>=k){
		ll flag=(n/k)*k;
		ll temp=abs(n-flag);
		ll temp2=abs(temp-k);
		cout<<min(temp,temp2)<<endl;
	}
	else{
		ans=abs(n-k);
		cout<<min(n,ans);
	}
}



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

int main() {
  int n, k; cin >>n >>k;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >>a[i];
  }

  for (int i = k; i < n; i++) {
    cout << (a[i-k] < a[i] ? "Yes" : "No") << endl;
  }

  return 0;
}

Measured memory_bytes: 4716
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int h,w;
  std::cin >> h >> w;
  char s[100][100];
  int t[100][100];

  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++) std::cin >> s[i][j];
  }

  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(s[i][j]=='.') t[i][j]=0;
      else t[i][j]=9;
    }
  }

  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(t[i][j]>8){t[i-1][j-1]++; t[i-1][j]++; t[i-1][j+1]++; t[i][j-1]++; t[i][j+1]++; t[i+1][j-1]++; t[i+1][j]++;
        t[i+1][j+1]++;}
    }
  }



  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(t[i][j]>8)std::cout << '#';
      else std::cout << t[i][j] ;
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		int result = 0;
		int a = 0;
		int b = 0;
		for(int i = 0; i < s.length(); i++){
		    char c = s.charAt(i);
		    if(i%2 == 0){
		        if(c == '0') a++;
		        if(c == '1') b++;
		    }else{
		        if(c == '1') a++;
		        if(c == '0') b++;
		    }
		}
		result = min(a, b);
		
		// 出力
		System.out.println(result);
        
	}
}


Measured memory_bytes: 24312
import itertools
n = int(input())
l = list(map(int,input().split()))

a = 0
for i in itertools.permutations(l,3):
    if i[0] < i[1] and i[1] < i[2] and i[0] + i[1] > i[2] and i[0] + i[2] > i[0] and i[1] + i[2] > i[0]:
        a += 1

print(a)


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

A = list(map(int, input().split()))

cnt = 0
f = True
while f:
  for a in A:
    if a % 2 != 0:
      print (cnt)
      f = False
      break
  else:
    A = list(map(lambda x : x//2, A))
    cnt += 1

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
#初期データ、構造
N,Q = (int(x) for x in input().split())
# 隣接リスト表現
connection ={i:set() for i in range(1,N+1)}
for _ in range(N-1):
    a,b = (int(x) for x in input().split())
    connection[a].add(b)
    connection[b].add(a)

point ={i:0 for i in range(1,N+1)}
for _ in range(Q):
    p,x = (int(x) for x in input().split())
    point[p] += x

def DFS(now,prev = -1):
    for next in connection[now]:
        # 親へのエッジはスキップ
        if next == prev:
            continue
        point[next] += point[now] 
        DFS(next,now)

DFS(1)
print(*point.values())


Measured memory_bytes: 350068
n = int(input())
al = list(map(int, input().split()))

count2 = 0
count4 = 0

for a in al:
    if a % 4 == 0:
        count4 += 1
    elif a%2==0:
        count2+=1

v=count2//2

n-=v*2
if count4 >= n//2:
    ans='Yes'
else:
    ans='No'

print(ans)

Measured memory_bytes: 19944
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=0
n=int(input())
print(*d(list(map(int,input().split()))))
print(c-n)


Measured memory_bytes: 63168
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem0544 : Sugoroku **/
int main()
{
	int N, M;
	
	while (cin>>N>>M, N||M) {
		int board[1000]={0}, dice[1000]={0};
		for (int i=0; i<N; i++) {
			cin>>board[i];
		}
		
		for (int i=0; i<M; i++) {
			cin>>dice[i];
		}
		
		int now = 0;
		rep(i, M) {
			now += dice[i];
			if (now<N-1)
				now += board[now];
			if (now>=N-1) {
				cout << i+1 << endl;
				break;
			}
		}
	}
}

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

struct StronglyConnectedComponents {
  int n;
  int time;
  vector<vector<int>> g;
  vector<int> num, low;
  vector<vector<int>> scc;
  stack<int, deque<int>> S;
  vector<bool> inS;

  StronglyConnectedComponents(int n) : n(n), g(n), num(n, -1), low(n, -1), inS(n, false) {}

  void addEdge(int u, int v) {
    g[u].push_back(v);
  }
  void dfs(int u) {
    num[u] = low[u] = time++;
    S.push(u);
    inS[u] = true;
    for (auto&& v : g[u]) {
      if (num[v] == -1) {
        dfs(v);
        low[u] = min(low[u], low[v]);
      } else if (inS[v]) {
        low[u] = min(low[u], num[v]);
      }
    }
    if (low[u] == num[u]) {
      scc.push_back({});
      while (true) {
        int v = S.top(); S.pop();
        inS[v] = false;
        scc.back().push_back(v);
        if (u == v) break;
      }
    }
  }
  void build() {
    for (int i = 0; i < n; ++i) {
      if (num[i] == -1) dfs(i);
    }
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  StronglyConnectedComponents g(n);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i], a[i]--, b[i]--;
    g.addEdge(a[i], b[i]);
  }
  g.build();
  int idx = -1;
  for (int i = 0; i < g.scc.size(); i++) {
    if (g.scc[i].size() > 1) {
      idx = i;
      break;
    }
  }
  if (idx == -1) {
    cout << -1 << endl;
    return 0;
  }
  vector<bool> used(n, false);
  for (auto x : g.scc[idx]) {
    used[x] = true;
  }
  vector<vector<int>> sg(n);
  for (int i = 0; i < m; i++) {
    if (used[a[i]] && used[b[i]]) {
      sg[a[i]].push_back(b[i]);
    }
  }
  int sz = g.scc[idx].size();
  int mn = 1e9;
  vector<int> ans;
  for (auto s : g.scc[idx]) {
    vector<int> dist(n, 1e9);
    vector<int> prev(n, -1);
    queue<int> q;
    q.push(s);
    dist[s] = 0;
    while(!q.empty()) {
      auto u = q.front();
      q.pop();
      for (auto v : sg[u]) {
        if (dist[v] < 1e9) continue;
        dist[v] = dist[u] + 1;
        prev[v] = u;
        q.push(v);
      }
    }
    for (auto u : g.scc[idx]) {
      if (u == s) continue;
      if (find(begin(sg[u]), end(sg[u]), s) == end(sg[u])) continue;
      vector<int> path = {s};
      int t = u;
      for (; t != s; t = prev[t]) path.push_back(t);
      if (path.size() < mn) {
        mn = path.size();
        ans = path;
      }
    }
  }
  cout << mn << endl;
  for (auto x : ans) {
    cout << x + 1 << endl;
  }
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

class Program
{

    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int N = int.Parse(array[0]);
        int T = int.Parse(array[1]);
        List<int> list = new List<int>();
        for (int i = 0; i < N; i++)
        {
            array = Console.ReadLine().Split(' ');
            int c = int.Parse(array[0]);
            int t = int.Parse(array[1]);
            if (t <= T) list.Add(c);
        }
        if (list.Count == 0)
        {
            Console.WriteLine("TLE");
        }
        else
        {
            list.Sort();
            Console.WriteLine(list[0]);
        }
    }

}

Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int cond(int *k,int n,int *a,int *b){
  int t[51];
  int i;
  for(i=0;i<n;i++){
    int aa=a[i];
    int bb=b[i];
    int j;
    for(j=0;j<51;j++) t[j]=0;
    t[aa]=1;
    for(j=50;j>0;j--){
      int kk=k[j];
      if(kk==-1) continue;
      int l;
      for(l=0;l<=aa;l++){
	if(t[l]==1){
	  t[l%kk]=1;
	}
      }
    }
    if(t[bb]==0) return 0;
  }
  return 1;
}

void run(void){
  int n;
  scanf("%d",&n);
  int a[50],b[50];
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  for(i=0;i<n;i++) scanf("%d",b+i);
  int k[51];
  for(i=1;i<=50;i++) k[i]=i;
  k[0]=-1;
  if(!cond(k,n,a,b)){
    printf("-1\n");
    return;
  }
  for(i=50;i>0;i--){
    k[i]=-1;
    if(!cond(k,n,a,b)) k[i]=i;
  }
  int64 cost=0;
  for(i=0;i<=50;i++) cost+=(k[i]>=0?1:0)*(1LL<<i);
  printf("%lld\n",cost);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
g1 = [2]
g2 = [4,6,9,11]
g3 = [1,3,5,7,8,10,12]

a, b = map(int, input().split())

if g1.count(a) == 1 and  (g1.count(b) == 1) :
    print("Yes")
elif g2.count(a) == 1 and (g2.count(b) == 1) :
    print("Yes")
elif g3.count(a) == 1 and (g3.count(b) == 1) :
    print("Yes")    
else :
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a[101],v,j,t=0;
    cin>>n;
    for (int i=0; i<n; i++)
        cin>>a[i];
    cout<<a[0];
	for (int i=1; i<n; i++){
		cout<<' '<<a[i];
	}
	cout<<"\n";
    for (int i=1; i<n; i++){
    	v=a[i];
    	j=i-1;
    	while (j>=0 && a[j]>v){
    		  a[j+1]=a[j];
    		  a[j]=v;
			  j--;
		}
		cout<<a[0];
	    for (int k=1; k<n; k++){
		    cout<<' '<<a[k];
	    }
	    cout<<"\n";
	} 
	
    return 0;
} 


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
int n,m,i,j;
int main()
{
	cin>>n>>m;
	cout<<n-m+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int a = A * 100 + B * 10 + C;
	if (a % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
N, K = map(int,input().split())
H = []
min_dif = 1000000000000000000000000

for n in range(N):
  h = int(input())
  H.append(h)

H.sort()

for i in range(N-K+1):
  dif = H[i+K-1] - H[i]
  if dif < min_dif:
    min_dif = dif
    
print(min_dif)

Measured memory_bytes: 13320
#include <cassert>

#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 <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
 
int main (int argc, char *argv[]){   
    int x,y;cin>>x>>y;
    cout<<x+y/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD (int)1e9 + 7
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
 
int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
 
int n, m, a, b;
vi dis(100010, INF), ans(100010);
vector<vi> graph(100010);
queue<int> Q;
 
int main() {
	cin >> n >> m;
	FOR(i, m) {
		cin >> a >> b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	dis[1] = 0;
	Q.push(1);
	while (!Q.empty()) {
		int t = Q.front(); Q.pop();
		for (int i = 0; i < graph[t].size(); i++) {
			int v = graph[t][i];
			if (dis[v] == INF) {
				dis[v] = dis[t] + 1;
				ans[v] = t;
				Q.push(v);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		if (dis[i] == INF) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 10648
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std ;

int ans = 0 ;


void input ( ) {
    int n , k ;
    scanf ( "%d%d" ,&n , &k ) ;
    while ( n -- ) {
        int x ;
        scanf ( "%d" , &x ) ;
        ans += ( x >= k ) ;
    }
}

void solve ( ) {
    printf ( "%d\n" , ans ) ;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int move = 0;
		if((a+w)<b) {
			//System.out.println(b);
			//System.out.println(a+w);
			move = b-(a+w);
		} else if((b+w)<a) {
			move = a-(b+w);
		}else {
			move =0;
		}
		System.out.println(move);
}
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    REP(i,n){
        int a,b;
        cin >> a >> b;
        mp[b]+= a;
    }
    ll sum = 0;
    for(const auto& i:mp){
        int limit = i.first;
        int timer = i.second;//timerの時間を順に足していく
        sum  += timer;
        if(sum>limit){
            COUT("No");
            return 0;
        }
    }
    COUT("Yes");
    return 0;
} 

Measured memory_bytes: 9600
// AOJ 1350 There is No Alternative
// 2018.3.2 bal4u
 
#include <stdio.h>
//#include <stdlib.h>
#include <string.h>
 
/* UNION-FIND library */
#define MAX 502
int id[MAX], size[MAX];
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q)
{
    int i = root(p), j = root(q); if (i == j) return;
    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

typedef struct { int s, d, c; } T;
T e[50002], e0[50002];
T ee[50002]; int sz;
int f[10002];


int main()
{
	int N, M, i, j, t, MST, ansf, anss;

	N = in(), M = in();
	for (i = 0; i < M; i++) {
		e0[i].s = in()-1, e0[i].d = in()-1, e0[i].c = t = in();
		f[t]++;
	}
	for (i = 1; i <= 10000; i++) f[i] += f[i-1];
	for (i = M-1; i >= 0; i--) t = e0[i].c, e[--f[t]] = e0[i];

	MST = 0, sz = 0, init(N);
	for (i = 0; i < M; i++) {
		if (!connected(e[i].s, e[i].d)) {
			unite(e[i].s, e[i].d);
			ee[sz++] = e[i], MST += e[i].c;
		}
	}

	ansf = anss = 0;
	for (i = 0; i < sz; i++) {
		int ss = ee[i].s, dd = ee[i].d;
		t = 0, init(N);
		for (j = 0; j < M; j++) {
			if (!connected(e[j].s, e[j].d) && (e[j].s != ss || e[j].d != dd)) {
				unite(e[j].s, e[j].d);
				t += e[j].c; if (t > MST) break;
			}
		}
		if (t != MST) ansf++, anss += ee[i].c;
	}
	printf("%d %d\n", ansf, anss);
	return 0;
}


Measured memory_bytes: 2992
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A')return 1;
  else if (ch=='C') return 2;
  else if (ch=='G') return 3;
  else if (ch=='T') return 4;
  return 0;
}

long long getkey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+key%(M-1);}

int find(char str[]){
  int i,j,k;
  k=getkey(str);
  for(i=0;;i++){
    j=(h1(k)+i*h2(k))%M;
    if(strcmp(str,H[j])==0)return 1;
    else if(strlen(H[j])==0)return 0;
  }
  return 0;
}

int insert(char str[]){
  int i,j,k;
  k = getkey(str);
  for(i=0;;i++){
    j=(h1(k)+i*h2(k))%M;
    if(strcmp(H[j],str)==0)return 1;
    else if(strlen(H[j])==0){
      strcpy(H[j],str);
      return 0;
    }
  }
    
  return 0; 
  
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++)  H[i][0]='\0';

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(str);
    }
    else{
      if(find(str)==1){
	printf("yes\n");
      }
      else {
	printf("no\n");
      }
    }     
  }
  
  return 0;
}



Measured memory_bytes: 16428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var s = Console.ReadLine();
		
		var dp = new long[n+1, n+1];	//i番目とj番目における共通部分の長さ
		long max = 0;
		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < n; j++)
			{
				if(s[i] == s[j])
				{
					dp[i+1, j+1] = Math.Max(dp[i+1, j+1], dp[i, j] + 1);
					max = Math.Max(max, Math.Min(j-i, dp[i+1, j+1]));
				}
			}
		}
		Console.WriteLine(max);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 206304
s = input()
K = []
for i, l in enumerate(s):
    if l == "A":
        K.append(1)
    elif i+1 < len(s) and l+s[i+1] == "BC":
        K.append(2)
    elif i > 0 and s[i-1]+l == "BC":
        continue
    else:
        K.append(0)
#print(K)
ans = 0
ct_1 = 0
for k in K:
    if k == 1:
        ct_1 += 1
    elif k == 2:
        ans += ct_1
    else:
        ct_1 = 0

print(ans)


Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define N 1000005
int a,b,c,d,e,f;
int dp[3005];

int solve(int n){
    if(n==0) return 1;
    if(n<0) return 0;
    if(dp[n]!=-1) return dp[n];
    return dp[n]=solve(n-c) | solve(n-d);
}

int main()
{
    fastio;
    cin>>a>>b>>c>>d>>e>>f;
    vector<int>v;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<=3000;i++) {
        if(solve(i)) v.pb(i);
    }
    double mx=-1;
    int solution,salt;
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            int pani=(i*a+j*b)*100;
            if(pani>f) continue;
            int baki=f-pani;
            int parbe=(e*pani)/100;
            int x=min(baki,parbe);
            int y = upper_bound(v.begin(),v.end(),x)-v.begin()-1;
            int  lobon=v[y];
            if(lobon+pani==0) continue;
            double density=((double) lobon)/((double)(lobon+pani));
            if(density>mx){
                mx=density;
                solution=lobon+pani;
                salt=lobon;
            }
        }
    }
    cout<<solution<<gap<<salt<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std ;
#include<list>
int main (){

    int  x1  , x2 , x3 , sum ;
    cin >> x1 >> x2 >> x3 ;
    sum=x1+x2+x3;
    if(sum>=22)
    cout << "bust" ;
    else
    cout << "win" ;

return 0 ;
}


Measured memory_bytes: 256
import itertools
N = int(input())
P = input().split()
for i in range(N):
    P[i] = int(P[i])
P = tuple(P)
Q = input().split()
for i in range(N):
    Q[i] = int(Q[i])
Q = tuple(Q)
counter = 1
count = 1
N_list = []
NN = [i + 1 for i in range(N)]
for j in itertools.permutations(NN,N):
    N_list.append(j)

k = 0
l = 0
i = 0
j = 0
while k == 0:
    if N_list[i] == P:
        break
    else:
        counter += 1
        i += 1

while l == 0:
    if N_list[j] == Q:
        break
    else:
        count += 1
        j += 1
a = counter
b = count
print(abs(a-b)) 


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

LL fun(LL n, LL m)//写个自定义函数配配对
{
    if((m / 2) < n) return  m / 2;
    LL ans = n;
    m = m - n * 2;
    ans = ans + m / 4;
    return ans;
}

int main()
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    LL ans = fun(n, m);
    printf("%lld\n", ans);//输出与换行
    return 0;
}

Measured memory_bytes: 256