akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   int n,l;cin>>n>>l;
   vector<int>v(n);
   int sum = 0;
   rep(i,n){
       v[i] = l+i;
       sum += v[i];
   }
   sort(ALL(v));
   rep(i,n){
       if(v[i]<0 && i != n-1)continue;
     else if(v[i]<0 && i == n-1){
       sum -= v[i];
     }
       else {
         sum -= v[i];
           break;
       }
   }
   cout<<sum;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll num[50];
//ll num2[50];
ll num[10];
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;


int main(void)
{
    long long int sum=0,range=0,ceiling;
    double ans=0.0,d,d1,d2;
    long long int m,n,o,i,j,k=1,money;
    long long int a,a1=0,a2=0,a3=0,ar=1,as=1,at1;
    string s;
    char c;
    a=a1=a2=a3=0;
    //vector <int> v;
    //float f,g,h;
    //int c,d,big=0;
    cin>>a1>>a2;
    for(d=1;d<10005;d++)
    {
        ar=round(d*8);
        as=round(d*10);
        ar/=100;
        as/=100;
        if(ar==a1&&as==a2)
        {
            cout<<d<<endl;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}





Measured memory_bytes: 256
n, a, b = map(int, input().split())

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    if a < b:
        low = a * (n - 1) + b
        high = a + b * (n - 1)
        print(high - low + 1)
    elif a == b:
        print(1)
    else:
        print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

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

    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
/*
[agc035] C - Skolem XOR Tree
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int N;

void solve() {
    int k = 1;
    while ((k << 1) <= N) {
        k <<= 1;
    }
    if (k == N) {
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;

    cout << N + 1 << " " << 3 << endl;
    for (int i = 1; i < (N + 1) / 2; i++) {
        cout << 1 << " " << 2 * i << endl;
        cout << 2 * i << " " << 2 * i + 1 << endl;
        cout << 1 << " " << N + 2 * i + 1 << endl;
        cout << N + 2 * i + 1 << " " << N + 2 * i << endl;
    }
    if (N % 2 == 0) {
        cout << k << " " << N << endl;
        cout << N + (N ^ k ^ 1) << " " << N + N << endl;
    }
}

int main() {
    cin >> N;

    solve();

    return 0;
}


Measured memory_bytes: 2304
from collections import Counter
n,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

A = Counter(a)

if len(A.keys()) <= k:
    print(0)
else:
    lst = A.most_common()
    cnt = 0
    for i in range(k, len(lst)):
        cnt += lst[i][1]
    print(cnt)

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll ans = 0;
	ans += min(a, k);
	k -= min(a, k);
	if (k > 0) {
		k -= min(b, k);
		if (k > 0) {	
			ans -= min(k, c);
		}
	}
	cout << ans;

	
	return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

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

  auto n = s.size(), m = t.size();

  int dp[n + 1][m + 1];
  memset(dp, 0, sizeof(dp));

  for (auto i = 1; i <= n; ++i) {
    for (auto j = 1; j <= m; ++j) {
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }

  string lcs;

  int index = dp[n][m] - 1;
  int i = n;
  int j = m;

  while (i > 0 && j > 0) {
    if (s[i - 1] == t[j - 1]) {
      lcs.push_back(s[i - 1]);
      --i;
      --j;
    } else if (dp[i - 1][j] > dp[i][j - 1]) {
      --i;
    } else {
      --j;
    }
  }

  reverse(lcs.begin(), lcs.end());

  cout << lcs << endl;
}

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

typedef long long LL;
const int INF = int(1e9);
const int MAX = 1000020;
LL N;
LL a[MAX],b[MAX],c[MAX];

void Cin(LL a[]){
    for(int i = 1;i<=N;i++)
        scanf("%lld",&a[i]);
}

int main(){
    cin>>N;
    //if(N==2) return cout<<0,0;
    Cin(a),Cin(b),Cin(c);
    sort(a+1,a+1+N),sort(b+1,b+1+N),sort(c+1,c+1+N);
    LL sum = 0;
    LL ai = 0,ci = 0;
    for(int i = 1;i<=N;i++){
        while(a[ai+1]<b[i]&&ai+1<=N)
            ai++;
        while(c[ci+1]<=b[i]&&ci+1<=N)
            ci++;
        sum += ai*(N-ci);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define REP(i,a,n) for(int i = (a);i < (n);i++)
#define PI 3.14159265359
#define MOD 1000000007
#define chmax(a,b) if(a < b)a = b

using namespace std;

int main(){
    int n,x;
    cin >> n >> x;
    int min = 100000,sum = 0;
    REP(i, 0, n){
        int m;
        cin >> m;
        if(min > m)min = m;
        sum += m;
    }
    x -= sum;
    n += x/min;
    cout << n << endl;
    return 0;
}


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

/*
8 6
50000000 30000000


2 24
10000000 150000000
*/

int A = 0;
int B = 0;

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

    return gcd(b, a % b);
}

void solve() {
    int d = gcd(A, B);
    int m = A / d * B;

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

int main() {
    while (scanf("%d %d", &A, &B) != EOF) {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, q, p;
  p = 0;
  in(n);
  vector<ll> a(n), b(100009, 0);
  rep(i, n){
    in(a[i]);
    b[a[i]]++;
    p += a[i];
  }
  in(q);
  ll d, c;
  rep(i, q){
    in2(d, c);
    p = p + (c - d) * b[d];
    b[c] += b[d];
    b[d] = 0;
    out(p);
    memi;
  }
}

Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>

using namespace std;

int main()
{
  int N;
  cin >> N;
  set<int> s;
  for (int i = 0; i < N; ++i) {
    int d;
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int K, A, B;
    cin >> K >> A >> B;
    for(int i = A; i <= B; i++ ){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> v(N);
  rep(i, N)
  {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < N; i++)
  {
    ans = (ans + v[i]) / 2;
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int n,a[200010],sum[200010];
struct node{
    int l,r,sum;
}t[1600080];
void build(int k,int l,int r){
    t[k].l=l;
    t[k].r=r;
    if(l==r){
        t[k].sum=0;
        return ;
    }
    int mid=(l+r)/2;
    build(k*2,l,mid);
    build(k*2+1,mid+1,r);
    t[k].sum=t[k*2].sum+t[k*2+1].sum;
}
void change(int k,int x){
    if(x==t[k].l&&x==t[k].r){
        t[k].sum++;
        return ;
    }
    int mid=(t[k].l+t[k].r)/2;
    if(x<=mid)
        change(k*2,x);
    else
        change(k*2+1,x);
    t[k].sum=t[k*2].sum+t[k*2+1].sum;
}
int ask(int k,int l,int r){
    if(l>r)
		return 0;
    if(l<=t[k].l&&t[k].r<=r) 
		return t[k].sum;
    int mid=(t[k].l+t[k].r)/2;
    if(r<=mid)
        return ask(k*2,l,r);
    if(l>mid)
        return ask(k*2+1,l,r);
    return ask(k*2,l,mid)+ask(k*2+1,mid+1,r);
}
int check(int x){
    long long ans=0;
    memset(sum,0,sizeof(sum));
    for(int i=1;i<=n;i++)
        sum[i]=sum[i-1]+((a[i]<=x)?1:-1);
    for(int i=0;i<=n;i++)
        sum[i]+=n+1;
    build(1,1,200010);
    for(int i=0;i<=n;i++){
        ans+=ask(1,1,sum[i]-1);
        change(1,sum[i]);
    }
    return ans>=1ll*n*(n+1)/4+1;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int l=1,r=1e9,mid;
    while(l<=r){
        mid=(l+r)/2;
        if(check(mid))
            r=mid;
        else
            l=mid+1;
        if(r-l<=1){
        	mid=check(l)?l:r;
            break;
        }
    }
    cout<<mid;
    return 0;
}

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

int main() 
{
    fastio
    cout<<fixed<<setprecision(10);
    ld n;
    cin>>n;
    cout<<2*PI*n<<endl;
}   

Measured memory_bytes: 3804
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define doubleloop(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define tripleloop(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

int main(){
    long long ans = 0, N, nums[200009];
    
    memset( nums, 0, sizeof(nums));
    
    scnd1( N );
    
    rep(i,N) scnd1(nums[i]);
    
    int light = 0, right = 0;
    long long sum = 0;
    
    while( right<N ) {
        
        if ( (sum^nums[right]) == (sum+nums[right]) || light>=right) {
            ans += right-light+1;
            sum += nums[right++];
        } else {
            sum -= nums[light++];
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main(){
int n;
  scanf("%d",&n);
  vector<int> h(n);
  for(int& x : h){
  	scanf("%d",&x);
  }
  vector<int> ans(n,0);
  ans[n-2]=abs(h[n-1]-h[n-2]);
  if (n>=3) ans[n-3]=abs(h[n-3]-h[n-1]);
  for(int i=n-4;i>=0;i--){
  	ans[i]=min(ans[i+1]+abs(h[i]-h[i+1]),ans[i+2]+abs(h[i]-h[i+2]));
  }
  printf("%d",ans[0]);
}


Measured memory_bytes: 1024
MOD = 10 ** 9 + 7
N = gets.to_i
S = gets.chomp.chars

list = S.map.with_index { |s, i|
  ch = if i.even?
         s == 'W' ? 'B' : 'W'
       else
         s
       end

  ch == 'B' ? 'R' : 'L'
}
 
l_cnt = 0
ans = 1

list.each do |c|
  if c == 'L'
    l_cnt += 1
  else
    if l_cnt == 0
      puts 0
      exit
    end

    ans = (ans * l_cnt) % MOD
    l_cnt -= 1
  end
end

if l_cnt > 0
  puts 0
  exit
end

(1..N).each do |i|
  ans = (ans * i) % MOD
end

puts ans


Measured memory_bytes: 32252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }
  int cost = 1001001001;
  rep(i, (1<<n)) {
    bitset<12> b(i);
    vector<int> cnt(m, 0);
    int costt = 0;
    rep(j, n) {
      if (b.test(j)) {
        rep(k, m) cnt[k] += a[j][k];
        costt += c[j];
      }
    }
    bool ok = true;
    rep(j, m) if (cnt[j] < x) ok = false;
    if (ok && costt < cost) cost = costt;
  }
  if (cost != 1001001001) cout << cost << endl;
  else cout << "-1\n";
}

Measured memory_bytes: 3672
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

ll mod = 1e9 + 7;

int main() {
    int n; cin >> n;
    vector<ll> a(n); 
    rep(i, n) cin >> a.at(i);
    ll ans = 0;
    rep(i, 60){
        ll x = 0;
        rep(j, n) if(a.at(j)>>i&1) ++x;
        ll now = x*(n-x)%mod;
        rep(j, i) now = now*2%mod;
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    a, b = map(int, input().split())
    logging.info("Hello!")

    if a * b < 0:
        print("Zero")
    elif a > 0:
        print("Positive")
    else:
        if (b - a + 1) % 2 == 1:
            print("Negative")
        else:
            print("Positive")
            

    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


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

long long v[55][4];
int n, m, q;

long long ans = 0;

void solve(vector<int> a){
  long long tmp = 0;
  // reverse(all(a));
  for (int i=0; i<q; i++){
    int a_ = v[i][0];
    int b = v[i][1];
    int c = v[i][2];
    long long  d = v[i][3];

    if(a[b] - a[a_] == c){
      tmp += d;
    }
  }
  // for (int i=0; i<n; i++){
  //   cout << a[i] << " ";
  // }
  // cout << endl;
  chmax(ans, tmp);
  
}

void dfs(int pos, int prev, int m_, vector<int> a){
  if (pos == n){
    solve(a);
    return;
  }
  for (int i=prev; i<=m_; i++){
    a[pos] = i;
    dfs(pos + 1, i, m_, a);
  }
}

int main(){

  cin >> n >> m >> q;
  rep(i, 0, q){
    int a_, b, c;
    long long d;
    cin >> a_ >> b >> c >> d;
    a_--; b--;
    v[i][0] = a_;
    v[i][1] = b;
    v[i][2] = c;
    v[i][3] = d;
  }
  vector<int> a(n);
  dfs(0, 1, m, a);

  cout << ans << endl;
}



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

int main(){
  
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  if (N <= K)
    cout << N*X << endl;
  
  else if (N > K)
    cout << K*X + (N-K)*Y << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;

void solve()
{
    string str;
    cin >> str;
    if(str == "ABC")
        cout << "ARC";
    else
        cout << "ABC";
}

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


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll calc(ll R, ll C, ll a, ll b) {
    if (a == 0)
        return b;
    if (a == R)
        return R + C + (C - b);
    if (b == C)
        return C + a;
    return 2 * C + R + (R - a);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R, C, N;
    cin >> R >> C >> N;
    vector<pll> E;
    REP(i, N) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if (a != 0 && a != R && b != 0 && b != C)
            continue;
        if (c != 0 && c != R && d != 0 && d != C)
            continue;
        ll x = calc(R, C, a, b);
        ll y = calc(R, C, c, d);
        E.push_back(pll(min(x, y), max(x, y)));
    }
    N = E.size();
    sort(E.begin(), E.end(), [](pll a, pll b) { return a.second < b.second; });

    std::stack<pll> s;
    REP(i, N) {
        pll e = E[i];
        while (!s.empty()) {
            pll t = s.top();
            if (t.second < e.first)
                break;
            if (t.first < e.first && e.first < t.second) {
                cout << "NO" << endl;
                return 0;
            }
            s.pop();
        }
        s.push(e);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    string S = "";
    ll cur = 1;
    if(N==0){
        cout << 0 << endl;
        return 0;
    }
    while(N){
        if(N % -2){
            S = "1" + S;
            N--;
        }else{
            S = "0" + S;
        }
        N /= -2;
    }
    cout << S << endl;
}

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

int main(void){
	while(1){
		int n;
		cin>>n;
		if(n == 0) break;

		int x[n],y[n];
		x[0] = y[0] = 0;
		int minX=0,minY=0,maxX=0,maxY=0;

		for(int i=1;i<n;i++){
			int a,b;
			cin>>a>>b;

			//ツ債カツ堕、
			if(b == 0){
				x[i] = x[a] - 1;
				y[i] = y[a];
			}
			//ツ可コツ堕、
			else if(b == 1){
				x[i] = x[a];
				y[i] = y[a] - 1;
			}
			//ツ右ツ堕、
			else if(b == 2){
				x[i] = x[a] + 1;
				y[i] = y[a];
			}
			//ツ湘」ツ堕、
			else if(b == 3){
				x[i] = x[a];
				y[i] = y[a] + 1;
			}

			if(minX > x[i]) minX = x[i];
			if(minY > y[i]) minY = y[i];
			if(maxX < x[i]) maxX = x[i];
			if(maxY < y[i]) maxY = y[i];
		}
		cout<<maxX - minX + 1<<" "<<maxY - minY + 1<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vector<int> ts(m),ss(m),ds(m);
		for(int i=0;i<m;i++){
			cin>>ts[i]>>ss[i]>>ds[i];
			ss[i]--,ds[i]--;
		}
		
		map<int,int> ma;
		for(int i=0;i<m;i++)
			ma[ts[i]]=i;
		
		vector<int> flg(n);
		fill(begin(flg),end(flg),false);
		flg[0]=1;
		map<int,int>::iterator it=ma.begin();
		for(int i=0;i<m;i++,it++){
			int j=it->second;
			flg[ds[j]]|=flg[ss[j]];
		}
		
		cout<<count(begin(flg),end(flg),true)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2440
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, res;
char c[500][500];

int main() {
	cin >> N;
	bool b = true;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> c[i][j];
			if (c[i][j] == '#') {
				b = false;
			}
		}
	}
	if (b) {
		cout << -1 << endl;
		return 0;
	}
	bool f = false;
	for (int i = 0; i < N; i++) {
		f = true;
		for (int j = 0; j < N; j++) {
			if (c[i][j] == '.')f = false;
		}
		if (f)break;
	}
	if (!f) {
		res = 0xE869120;
		for (int i = 0; i < N; i++) {
			int a = 0;
			bool ff = false;
			for (int j = 0; j < N; j++) {
				if (c[j][i] == '#') {
					ff = true;
					break;
				}
			}
			if(ff){
				for (int j = 0; j < N; j++) {
					if (c[i][j] == '.')a++;
				}
				res = min(res, a);
			}
			else {
				for (int j = 0; j < N; j++) {
					if (c[i][j] == '.')a++;
				}
				res = min(res, a + 1);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (c[j][i] == '.') {
				res++;
				break;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 512
A, B = map(int, input().split())
S = input()
for i in range(A):
    if not S[i].isdecimal():
        print('No')
        exit()
if S[A] != '-':
        print('No')
        exit()
for i in range(A+1, A+B+1):
    if not S[i].isdecimal():
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 80152
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

vector<int> v;

void init_uf(int n){
    v.assign(n,-1);
}

int find_(int x){
    if(v[x]<0) return x;
    v[x]=find_(v[x]);
    return v[x];
}

int same_(int a,int b){
    if(find_(a)==find_(b)) return 1;
    return 0;
}

void union_(int a,int b){
    if(same_(a,b)) return;
    int a_p=find_(a),b_p=find_(b);
    if(a_p>b_p) swap(a_p,b_p);
    v[a_p]+=v[b_p]; v[b_p]=a_p;
}

void print_v(){
    rep(i,v.size()) cout<<v[i]<<" ";
    cout<<endl;
}

int size_(int a){
    return -v[find_(a)];
}

int main(){
    int n,m; cin>>n>>m;
    init_uf(n);
    rep(i,m){
        int x,y,z; cin>>x>>y>>z;
        x--; y--;
        union_(x,y);
    }
    int ans=0;
    rep(i,n) if(v[i]<0) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() 
{
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n/2; ++i)
  {
    if(s[i] != s[n-i-1])
      ans++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    int res = n*2;
    REP(i,n){
        bool flag = true;
        for(int j=0;i+j<n;++j){
            if(s[i+j]!=t[j]){
                flag = false;
            }
        }
        if(flag){
            res -= n-i;
            break;
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int x,y,z;
  int tmp;

  scanf("%d %d %d",&x,&y,&z);

  tmp = x;
  x = y;
  y = tmp;

  tmp = x;
  x = z;
  z = tmp;

  printf("%d %d %d\n",x,y,z);



  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static int search(int[] a,int key,int n){
		int i = 0;
		a[n]=key;
		while(a[i]!=key){
			i++;
		}
		if(i==n){
			return 0;
		}
		return 1;
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int result=0;
		int n = scan.nextInt();
		int[] S = new int[n+1];
		for(int i = 0 ; i < n ; i ++){
			S[i]=scan.nextInt();
		}
		int q = scan.nextInt();
		int[] T = new int[q];
		for(int i = 0 ; i < q ; i ++){
			T[i]=scan.nextInt();
		}
		for(int i = 0; i < q ; i ++){
			result += search(S,T[i],n);	
		}
		System.out.println(result);
		scan.close();
	}

}

Measured memory_bytes: 31180
#! /bin/ruby

chars= gets.chomp

TARGETS = ['A','G','C','T']
tmp_candidate = ""
candidate = ""
chars.each_char do |c|
  if TARGETS.include?(c)
    tmp_candidate << c
  else
    if tmp_candidate.length > candidate.length
      candidate = tmp_candidate
      tmp_candidate = ""
    end
  end
end

if tmp_candidate.length > candidate.length
  candidate = tmp_candidate
end
puts candidate.length

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
using namespace std;
int Q[1010000][2], head, tail, D[810][810];
int n, m, K, sx, sy;
char p[810][810];
void Ins(int x, int y, int d){
    if(D[x][y]<=d || p[x][y]!='.')return;
    D[x][y]=d;
    tail++;
    Q[tail][0]=x,Q[tail][1]=y;
}
int main(){
    int i, j, x, y;
    scanf("%d%d%d",&n,&m,&K);
    for(i=1;i<=n;i++){
        scanf("%s",p[i]+1);
        for(j=1;j<=m;j++){
            if(p[i][j]=='S')sx=i,sy=j,p[i][j]='.';
            D[i][j]=1e9;
        }
    }
    Ins(sx,sy,0);
    while(head < tail){
        head++;
        x = Q[head][0], y = Q[head][1];
        Ins(x+1,y,D[x][y]+1);
        Ins(x,y+1,D[x][y]+1);
        Ins(x-1,y,D[x][y]+1);
        Ins(x,y-1,D[x][y]+1);
    }
    int res = 1e9;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(D[i][j] <= K){
                res = min(res,1 + (min(min(i-1, n-i), min(j-1, m-j)) + K-1)/K);
            }
        }
    }
    printf("%d\n",res);
}

Measured memory_bytes: 8320
#include <iostream>

bool isPoor(int a, int b, int c)
{
    if (a == b && a == c)
    {
        return false;
    }

    if (a == c)
    {
        return true;
    }

    if (a == b)
    {
        return true;
    }

    if (b == c)
    {
        return true;
    }

    return false;
}

int main()
{
    int a = 0;
    std::cin >> a;

    int b = 0;
    std::cin >> b;

    int c = 0;
    std::cin >> c;

    if (isPoor(a, b, c))
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
// @author: arch_

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

int main(void) {
    int n = 0;
    array<array<int, 2>, 3000> d;
    while (cin >> d[n][0] >> d[n][1], d[n][0] | d[n++][1]);
    int a, b;
    for (int i = 0; i < n - 1; i++) {
        a = d[i][0]; b = d[i][1];
        if (a > b) swap(a, b);
        printf("%d %d\n", a, b);
    }
    return 0;
}

Measured memory_bytes: 3160
n,q = map(int,input().split())
l = [[] for i in range(n+1)]
for i in range(n-1):
	a,b = map(int,input().split())
	#print(l,l[a])
	l[a].append(b)
c = [0 for i in range(n+1)]
for i in range(q):
	a,b = map(int,input().split())
	c[a] += b

for i in range(n+1):
	if(l[i] != []):
		for x in l[i]:
			c[x] += c[i]
for i in range(1,len(c)):
	print(c[i],end = ' ')


Measured memory_bytes: 91468
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i=0,count=0;
    while (i<s.size()-1) {
        if (s.at(i)=='O') {
            if (s.at(i+1)=='X') {
                count++;
                i+=2;
            } else {
                i++;
            }
        } else if (s.at(i)=='X') {
            if (s.at(i+1)=='O') {
                count++;
                i+=2;
            } else {
                i++;
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3348
#include<stdio.h>

#include<algorithm>


using namespace std ;

typedef long long llong ;

struct Data
{
	llong size ;
	llong value ;

} ;

#define N_MAX 500000
Data art[ N_MAX ] ;

bool cmp( const Data& a ,const Data& b )
{
	return a.size == b.size ? a.value < b.value : a.size < b.size ;
}

inline llong Max( llong a ,llong b )
{
	return a > b ? a : b ;
}


int main( void )
{
	int N ;
	scanf( "%d" ,&N ) ;

	int i ;
	for( i = 0 ; i < N ; ++i )
	{
		scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
	}

	sort( art ,art + N ,cmp ) ;

	llong min_size	= art[ 0 ].size		;
	llong sum_value	= art[ 0 ].value	;

	llong ans = art[ 0 ].value ;
	for( i = 1 ; i < N ; ++i )
	{
		llong value	= art[ i ].value	;
		llong size	= art[ i ].size		;

		llong tmp =  sum_value + value  - ( size -  min_size ) ;
		if( tmp < value )
		{
			ans = Max( ans ,value ) ;

			sum_value	= value	;
			min_size	= size	;
		}

		else
		{
			ans = Max( ans ,tmp ) ;

			sum_value += value ;
		}
	}

	printf( "%lld\n" ,ans ) ;

	return 0 ;
}


Measured memory_bytes: 10592
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int answer = 0;
  string s;
  
  cin >> s;

  int n = s.size();
  char base;
  
  //最初が0から始まる集合との差分を数える
  int answer_0 = 0;
  base = '0';
  for (int i=0;i<n;++i) {
    if (s[i] != base) {
      answer_0++;
    }
    base = (base == '0') ? '1' : '0';
  }
  
  //最初が1から始まる集合との差分を数える
  int answer_1 = 0;
  base = '1';
  for (int i=0;i<n;++i) {
    if (s[i] != base) {
      answer_1++;
    }
    base = (base == '0') ? '1' : '0';
  }
  
  answer = min(answer_0, answer_1);  
  
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
vector<int> h;
int dfs(int left, int right)
{
    if(left > right) return 0;
    int minv = INF;
    for(int i = left; i <= right; i++) minv = min(minv, h[i]);
    vector<int> pos;
    for(int i = left; i <= right; i++)
    {
        h[i] -= minv;
        if(h[i] == 0) pos.push_back(i);
    }
    int res = minv;
    for(int i = 0; i < pos.size(); i++)
    {
        res += dfs(left, pos[i] - 1);
        left = pos[i] + 1;
    }
    res += dfs(left, right);
    return res;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    h.resize(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    cout << dfs(0, n - 1) << endl;
    return 0;
}



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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length()>k){
        cout << s.substr(0,k)+"..." << "\n";
    }else{
        cout << s << "\n";
    }
    
}   



Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) D4(D2(a,b),D2(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
#define EPS 1e-10
using namespace std;
typedef pair<double,double> D2;
typedef pair<D2,D2> D4;
typedef pair<int,double> ID;
typedef long long ll;
typedef unsigned long long ull;
int n;
vector<ID> G[200];
double d[200];
double cost[200][200];

double prime(){
  double mincost[200];
  bool used[200];
  rep(i,200)
    mincost[i] = INF,used[i] = false;
  mincost[0] = 0;
  double res = 0;

  while(true){
    int v = -1;
    rep(u,n){
      if(!used[u] && (v == -1 || mincost[u] < mincost[v]))v = u;
    }

    if(v == -1)break;
    used[v] = true;
    res += mincost[v];

    rep(u,n){
      mincost[u] = min(mincost[u],cost[v][u]);
    }
  }
  return res;
}

bool judgement(D4 a, D4 b){
  double len;
  len = sqrt(pow(a.F.F - b.F.F,2)+pow(a.F.S - b.F.S,2)+pow(a.S.F - b.S.F,2));
  if(len-(a.S.S+b.S.S) <= EPS)return false;
  return true;
}


int main(){

  while(true){
    cin >> n;
    if(n == 0)break;
    rep(i,200)G[i].clear();
    vector<D4> vec; 
    rep(i,n){
      double x,y,z,r;
      cin >> x >> y >> z >> r;
      vec.pb(insert(x,y,z,r));
    }

   

    /* --- 座標、コスト作成  --- */
    rep(i,n){
      rep(j,n){
	cost[i][j] = fabs(sqrt(pow(vec[i].F.F-vec[j].F.F,2)+pow(vec[i].F.S-vec[j].F.S,2)+pow(vec[i].S.F-vec[j].S.F,2)) - (vec[i].S.S + vec[j].S.S));
	if(!judgement(vec[i],vec[j])){
	  cost[i][j] = 0;
	}
      }
    }

    cout << setiosflags(ios::fixed) << setprecision(3) << prime() << endl;
  }
  return 0;
}

Measured memory_bytes: 1464
// let coding = begin

#include<bits/stdc++.h>

#define ll long long
#define pb       push_back
#define all(a)   a.begin(), a.end()

using namespace std;
const int MAX = 1e9+9;
const int MIN = -1e9;
const int N= 1e5+9;
const double PI = 3.14159265;
int n;
string tab[N];
set<string> se;
int main(){
  clock_t start;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> tab[i];
  }
  se.insert(tab[0]);
  char last = tab[0][tab[0].length()-1];
  for(int i=1; i<n; i++){
    int si = se.size();
    se.insert(tab[i]);
    if(si != se.size()){
      if(last != tab[i][0]){
        cout << "No" << endl;
        return 0;
      }
    } 
    else{
      cout << "No" << endl;
      return 0;
    }
    last = tab[i][tab[i].length()-1];
  }
  cout << "Yes" << endl;
  cerr << "Time: " << (clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem088b(n, a))
}

fun problem088b(n: Int, a: List<Int>): Int {
    var aSum = 0
    var bSum = 0
    var isAliceTurn = true
    a.sortedDescending().forEach {
        if (isAliceTurn) {
            aSum += it
        } else {
            bSum += it
        }
        isAliceTurn = !isAliceTurn
    }
    return aSum - bSum
}

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

int main() {
  int x;
  int ans;

  cin >> x;

  if(x>=400 && x<600) {ans=8;}
  else if(x>=600 && x<800) {ans=7;}
  else if(x>=800 && x<1000) {ans=6;}
  else if(x>=1000 && x<1200) {ans=5;}
  else if(x>=1200 && x<1400) {ans=4;}
  else if(x>=1400 && x<1600) {ans=3;}
  else if(x>=1600 && x<1800) {ans=2;}
  else if(x>=1800 && x<2000) {ans=1;}

  cout << ans << endl;

  return 0;
}


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

int main() {
	int a, b;
	while (true) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				cout << "#";
			}
			cout << endl;
		}
       cout<<endl;

	}
}


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

using namespace std;

typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1000000000;

int main() {
    int N;

    cin >> N;

    string sn = to_string(N);

    int n = sn.size();
    int one = sn[n-1] - '0';

    if (one == 2 || one == 4 || one == 5 || one == 7 || one == 9) {
        cout << "hon" << endl;
    } else if (one == 0 || one == 1 || one == 6 || one == 8) {
        cout << "pon" << endl;
    } else if (one == 3) {
        cout << "bon" << endl;
    }
}


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

#define ll long long int
#define All(a) (a).begin(),(a).end()

void solve(){
  int n,m;
 
  scanf("%d %d",&n,&m);
  char A[n][m];
  int ans[n][m]={};
  for(int i=0;i<n;i++){
    for (int  j = 0; j < m; j++){
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < n; i++){
    for (int  j = 0; j < m; j++){
      if(A[i][j]=='#'){
        if(i!=0)    ans[i-1][j]+=1;
        if(j!=0)    ans[i][j-1]+=1;
        if(i!=n-1)  ans[i+1][j]+=1;
        if(j!=m-1)  ans[i][j+1]+=1;
        if(i!=0 && j!=0)      ans[i-1][j-1]+=1;
        if(i!=0 && j!=m-1)    ans[i-1][j+1]+=1;
        if(i!=n-1 && j!=0)    ans[i+1][j-1]+=1;
        if(i!=n-1 && j!=m-1)  ans[i+1][j+1]+=1;
      }
    }
  }
  for(int i=0;i<n;i++){
    for (int j = 0; j < m; j++)
    {
       if(A[i][j]=='#'){
         printf("#");
       }else{
          printf("%c",'0'+ans[i][j]);
      }
    }
    printf("\n");
    
  }
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

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

using namespace std;

int main() {
	string str1,str2,str3;
	
	cin >> str1 >> str2 >> str3;

	int a, b;
	
	a = stoi(str1);
	b = stoi(str3);

	if (str2[0] == '+')cout << a + b << endl;
	else cout << a - b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int k, x;
    cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++) {
        if (i < -1000000) {
            i = -1000000;
        }
        if (i > 1000000) {
            return 0;
        }
        cout << i << " ";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

string s;

bool solve(string u, int d){
  if(d == u.size()) return u == s;
// dbg(u,d);
  if(u[d] != 'A') return solve(u, d+1);

  if(solve(u, d+1)) return true;
  else {
    string t = u.substr(0,d) + u.substr(d+1);
    return solve(t,d);
  }
}

int main(){
  cin>>s;

  if(solve("AKIHABARA",0)) cout << "YES" << endl;
  else cout << "NO" << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}
bool bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; }

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

    // solution comes here

    string S, T;
    cin >> S >> T;

    ll t=T.size(), s=S.size();
    for(ll i=s-t; i>=0; i--) {
        string ans="";
        bool ok=true;
        rep(x, i) {
            if(S[x]=='?') ans += 'a';
            else          ans += S[x];
        }
        rep(x, t) {
            if(ok and S[i+x]!='?'){
                ok = (S[i+x]==T[x]);
                ans += T[x];
            }
            else ans += T[x];
        }
        for(ll x=i+t; x<s; x++) {
            if(S[x]=='?') ans += 'a';
            else          ans += S[x];
        }

        if(ok){
            cout << ans << nl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << nl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int i;

    scanf("%d", &n);
    printf("%d:", n);

    while (n % 2 == 0){
        printf(" %d", 2);
        n /= 2;
    }
    
    for (i = 3; i * 2 <= n; i += 2){
        while (n % i == 0){
            printf(" %d", i);
            n /= i;
        }
    }
    if (n > 1){
        printf(" %d", n);
    }
    
    printf("\n");

    return (0);
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  char c; cin >> c;
  c++;
  cout << c;

  

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    ll n,ans=0;
    string s;
    cin>>n;
    vi r,g,b,rgb(n+1);
    cin>>s;
    
    rep(i,n)rgb.at(i+1)=0;
    
    rep(i,n){
        if(s.at(i)=='R')r.push_back(i+1);
        else if(s.at(i)=='G')g.push_back(i+1);
        else b.push_back(i+1);
    }
      
    rep(i,b.size()){
       rgb.at(b.at(i))=1; 
    } 
    
    rep(i,r.size()){
        rep(j,g.size()){
            
            ll min1=min(r.at(i),g.at(j));
            ll max1=max(r.at(i),g.at(j));
            ll abs1=max1-min1;
            //cout<<min1<<" "<<max1<<" "<<abs1<<endl;
            
            if(0<min1-abs1){
               // cout<<min1-abs1<<endl;
                if(rgb.at(min1-abs1)==1)ans++;
                
            }
            
            if(max1+abs1<n+1){
                if(rgb.at(max1+abs1)==1)ans++;
            }
            if((max1+min1)%2==0){
                if(rgb.at((max1+min1)/2)==1)ans++;
            }
        }
    }
    //rep(i,n+1)cout<<i<<" "<<rgb.at(i)<<endl;
    //cout<<ans<<endl;
   //cout<<r.size()+g.size()+b.size()<<endl;
    cout<<r.size()*g.size()*b.size()-ans<<endl;
    //cout<<r.size()*g.size()*b.size();
    
}
   



Measured memory_bytes: 3692
n,k=map(int,input().split())
mod=10**9+7
def inv(x):
    return pow(x,mod-2,mod)
N=2*10**5
Fact=[0 for i in range(N+1)]
Finv=[0 for i in range(N+1)]
Fact[0]=1
for i in range(N):
    Fact[i+1]=(Fact[i]*(i+1))%mod
Finv[N]=inv(Fact[N])
for i in range(N-1,-1,-1):
    Finv[i]=((i+1)*Finv[i+1])%mod
def C(a,b):
    return (Fact[a]*(Finv[b]*Finv[a-b])%mod)%mod
ans=0
for i in range(min(n,k+1)):
    ans+=(C(n,i)*C(n-1,i))%mod
    ans%=mod
print(ans)


Measured memory_bytes: 18968
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        long D = s.nextInt();
        int count = 0;
        for (int i = 0; i < N; i++) {
            long x = Math.abs(s.nextInt());
            long y = Math.abs(s.nextInt());
            if (x * x + y * y <= D * D) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 59224
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[1100];

int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int c,d;
		scanf("%d%d",&c,&d);
		for(int i=c;i<d;i++)p[i]++;
	}
	int ret=a+1;
	for(int i=1;i<=a;i++)if(p[i])ret+=2;
	printf("%d\n",ret);
}

Measured memory_bytes: 1028