akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;
static const int SIZE = 100005;

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

    string s;
    cin >> s;
    vector< string > v;
    bool flg = true;
    int pos = s.size() - 1;
    while( pos >= 4 && flg ) {
        if( s[pos] == 'r' && s[pos - 1] == 'e' ) {
            if( pos >= 6 && s[pos - 2] == 'm' && s[pos - 3] == 'a' && s[pos - 4] == 'e' && s[pos - 5] == 'r' && s[pos - 6] == 'd' ) {
                pos -= 7;

            } else if( pos >= 5 && s[pos - 2] == 's' && s[pos - 3] == 'a' && s[pos - 4] == 'r' && s[pos - 5] == 'e' ) {                pos -= 6;


            } else {
                flg = false;

            }
        } else {
            if( s[pos] == 'm' && s[pos - 1] == 'a' && s[pos - 2] == 'e' && s[pos - 3] == 'r' && s[pos - 4] == 'd' ) {
                pos -= 5;

            } else if( s[pos] == 'e' && s[pos - 1] == 's' && s[pos - 2] == 'a' && s[pos - 3] == 'r' && s[pos - 4] == 'e' ) {
                pos -= 5;

            } else {
                flg = false;
            }
        }
    }

    if( flg && pos == -1 ) cout << "YES";
    else cout << "NO";
    cout << endl;

    return 0;
}



Measured memory_bytes: 512
from itertools import accumulate

def chk(samp):
    for i in samp:
        print(samp)

N,W = map(int,input().split())

w = [0 for i in range(N)]
v = [0 for i in range(N)]

for i in range(N):
    w[i],v[i]=map(int,input().split())



#価値毎に置き換える
wl = [[] for i in range(4)]

#価値ごとのりすとに入れていく
for i in range(N):
    wl[w[i]-w[0]].append(v[i])


#ソートして最初に0を追加する。0は選択しない場合
for i in range(4):
    wl[i].sort(reverse = 1)
    wl[i].insert(0,0)
    

#累積和を作る
for i in range(4):
    wl[i] = list(accumulate(wl[i]))
    
#出力用変数
out = 0


for i,wl0 in enumerate(wl[0]):
   for j,wl1 in enumerate(wl[1]):
       for k,wl2 in enumerate(wl[2]):
           for l,wl3 in enumerate(wl[3]):
               if i*(w[0])+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3) > W:
                   pass
               else:
                   out = max(out,wl0+wl1+wl2+wl3)
                   
print(out)

Measured memory_bytes: 3064
//include
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
//マクロとか
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n) + 1; i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//自前の関数たち
//最大公約数
ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

//最小公倍数
ll LCM(ll a, ll b)
{
    return (a * b) / GCD(a, b);
}

//namespace my
namespace my {
    //配列の最大値or最小値を数値で返す関数
    int max_element(std::vector<int> vec){
        std::sort(vec.begin(), vec.end());
        return vec.at(vec.size() - 1);
    }
    int min_element(std::vector<int> vec){
        std::sort(vec.begin(), vec.end());
        return vec.at(0);
    }
}

//yes,noを出力するやつ
void ans(bool qus)
{
    if (qus == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool qust)
{
    if (qust == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

//std::を省略するやつ
using namespace std;

////////////////////////////////////////////////////////////////////////////////
//スタート


int main(){
    int n, d;
    cin >> n >> d;
    vector<vector<int>> dem(n, vector<int>(d));
    rep(i,n){
        rep(j,d){
            cin >> dem.at(i).at(j);
        }
    }
    int count = 0;
    rep(i, n){
        for (int j = i + 1; j < n; j++){
            double a = 0;
            rep(k,d){
                a += pow((dem.at(i).at(k) - dem.at(j).at(k)), 2);
            }
            double b = sqrt(a);
            if (floor(b) == b){
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#! /usr/bin/env python3

n, k = map(int, input().split())
a = [int(i) for i in input().split()]

max_idx = a.index(min(a))

left = a.index(min(a))
right = n - left - 1

res = 0

left_mod = left % (k - 1)
res += left // (k - 1)

right_mod = right % (k - 1)
res += right // (k - 1)

if left_mod == 0 and right_mod == 0:
    res += 0
elif k >= left_mod + right_mod + 1:
    res += 1
else:
    res += 2

print(res)


Measured memory_bytes: 13880
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> height(N);
    int count = 0;
    for(int i=0;i<N;i++){
        cin >> height.at(i);
    }

    for(int i=0;i<N;i++){
        if(K <= height.at(i)) ++count;
    }

    cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> y[i];
  }
  long long s1, s2, s3, s0, tmp;
  s1 = s2 = s3 = s0 = 0;
  for (int i = 0; i < n; ++i) {
    tmp = abs(y[i] - x[i]);
    s1 += tmp;
    s2 += tmp * tmp;
    s3 += tmp * tmp * tmp;
    if (s0 < tmp) s0 = tmp;
  }
  double d1 = static_cast<double>(s1);
  double d2 = sqrt(s2);
  double d3 = cbrt(s3);
  double d0 = static_cast<double>(s0);

  printf("%.8f\n%.8f\n%.8f\n%.8f\n", d1, d2, d3, d0);
  fflush(stdout);
  return 0;
}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define en           "\n" 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(int i = (int)(a); i <= (int)(b); i++)
#define rf(i,a,b)    for(int i = (int)(a); i >= (int)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***

const int maxn = 1e6;
int a[maxn+5];



void solve()
{
    
    ll n,m;;
    rd(n,m);
    read(a,m);
    ll s = 0;
    fo(i,0,m-1)s+=a[i];
    if(s>n){
        pp(-1);
    }
    else{
        pp(n-s);
    }
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio;

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	string s;
	int n,sa,sb,ea,eb,end;
	cin>>n>>sa>>sb>>ea>>eb;
	cin>>s;
	s=s+"aaaa";
	eb--;
	ea--;
	sa--;
	sb--;
	bool check=false;
	for(int i=sa;i<max(ea,eb);i++)
	{
		if(s[i]=='#'&&s[i+1]=='#') {cout<<"No"; return 0;}
	}
	if(eb>ea) cout<<"Yes";
	else if(eb<ea)
	{
		bool check=false;
		for(int i=sb-1;i<=eb-1;i++)
		{
			if(s[i]==s[i+1]&&s[i+2]==s[i+1]&&s[i+1]=='.')
			check=true;
		}	
		if(check==true) cout<<"Yes";
		else cout<<"No";
	}
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int k;

int main(){
  cin >> k;
  cout << a[k-1];
  return 0;
}


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

int main()
{
    iostream::sync_with_stdio(0);
    set<int>s;
    int T,num=0;
    cin>>T;
    while(T--)
    {
        int flag,x;
        cin>>flag>>x;
        if(flag==0)
        {
            auto it=s.insert(x);
            if(it.second==1)
                num++;
            cout<<num<<endl;
        }
        else if(flag==1)
        {
            auto it=s.find(x);
            if(it==s.end())
            {
                cout<<0<<endl;
            }
            else cout<<1<<endl;
        }
        else if(flag==2)
        {
            int n=s.erase(x);
            num-=n;
        }
        else
        {
            int R;
            cin>>R;
            for(auto it=s.lower_bound(x);it!=s.end()&&*it<=R;it++)
            {

                    cout<<*it<<endl;

            }
        }
    }
  //  cout << "Hello world!" << endl;
    return 0;
}



Measured memory_bytes: 12488
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>


using namespace std;

int gcd(int a,int b,int c);
int gcd(int a,int b);

int main(){
    int k;
    cin>>k;
    long long sum=0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                //cout<<sum<<endl;
                sum+=gcd(a,b,c);
            }
        }
    }
    cout<<sum;
}

int gcd(int a,int b,int c){
    //cout<<"1";
    return gcd(gcd(a,b),c);
}

int gcd(int a,int b){
    //cout<<"2";
    if(a<b){
        int tmp=a;
        a=b;
        b=tmp;
    }
    if (b == 0)return a;
    return gcd(b,a%b);
}



Measured memory_bytes: 3612
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc049/tasks/arc065_a

s = input()[::-1]
collector = ''
t = ''
words = ['remaerd', 'maerd', 'resare', 'esare']

for c in s:
    collector += c
    if collector in words:
        t += collector
        collector = ''

if s == t:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
nums = input().split(" ")
N = int(nums[0])
A = int(nums[1])
B = int(nums[2])

time = int(N / (A + B))

if time == 0 or (time == 1 and N / (A + B) == 1):
  if N - A <= 0:
    print(N)
  else:
    print(A)
else:
  N -= (A + B) * time
  if N - A <= 0:
    print(N + A*time)
  else:
    print(A + A*time)

Measured memory_bytes: 3064
import sys
n, a, b, c, d = map(int, input().split())
s = input()
if any(s[i]==s[i+1]=="#" for i in range(a-1, c-2)) or any(s[i]==s[i+1]=="#" for i in range(b-1, d-2)):
    print("No")
elif c<d:
    print("Yes")
else:
    for i in range(b-1, d):
        if s[i-1]==s[i]==s[i+1]==".":
            print("Yes")
            sys.exit()
    print("No")

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
typedef tuple<ll, ll, ll> tp;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  
  if (c >= (a - b)) cout << c - (a - b) << endl;
  else cout << 0 << endl;
}

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

#define FASTIO1 ios_base::sync_with_stdio(false)
#define FASTIO2 cin.tie(NULL),cout.tie(NULL)
#define count_1(p) __builtin_popcountll(p)
#define count_0(p) __builtin_ctzll(p)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll power(ll x,ll y,ll p);
const ll inf=999999999;
const ll mod=1e9+7;
bool tc=false;

void solve()
{
    ll n; cin>>n;
    ll ct=0;
    for(ll i=1;i<=n;i++)
        for(ll j=i;j<=(n/i);j++)
        {
            if(i*j<n)
            {
                if(i==j) ct++;
                else ct+=2;
            }
        }
    cout<<ct;
}

int main() 
{
    FASTIO1;
    FASTIO2;
    clock_t start=clock();
    ll t=1; 
    if(tc) cin>>t;
    while(t--)
        solve();
    cerr<<fixed<<setprecision(6);
    cerr<<(double)(clock()-start)/CLOCKS_PER_SEC<<endl;
    return 0;
}

ll power(ll x,ll y,ll p)  
{  
    ll res=1; x=x%p;
    if(x==0) return 0;
    while(y>0)  
    {
        if(y&1) res=(res*x)%p;
        y=y>>1; x=(x*x)%p;  
    }
    return res;  
}  


Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int a,b,c; cin >>a>>b>>c;

    if (a == b) {
        cout << c << endl;
    } else if (b == c) {
        cout << a << endl;
    } else {
        cout << b << endl;
    } 
    return 0;
}


Measured memory_bytes: 256
while True:
  n = int(input())
  if n == 0:break
  a = [list(map(int, input().split())) for _ in range(n)]
  p, q, r, c = map(int, input().split())
  b = [x[0] for x in a if x[1] <= p and x[2] <= q and x[3] <= r and 4 * (x[1]+x[3])+9*x[2] <= c]
  if len(b):print(*b, sep='\n')
  else:print('NA')


Measured memory_bytes: 5980
import qualified Data.ByteString.Char8 as C
import Data.Maybe (fromJust)
import Data.Ratio
import Data.List 

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  as <- getParms
  let (sw,s) = select as
  putStrLn $ show sw ++ " " ++ show s

type SW = Int -- SugarWater
type S  = Int -- Sugar

ratio :: (SW, S) -> Maybe (Ratio Int)
ratio (a,b) = if a==0 then Nothing 
                      else Just (b % a) 

combinations :: [Int] -> [(SW,S)]
combinations [a,b,c,d,_e,f] 
  = [(w + s,s)
      | let fa = f `div` (100*a)
      , na <- [0 .. fa]
      , let fb = (f-100*a*na) `div` (100*b)
      , nb <- [0 .. fb]
      , let w = 100*(a*na + b*nb)
      , let fc = (f-w) `div` c
      , nc <- [0 .. fc]
      , let fd = (f-w-c*nc) `div` d
      , nd <- [0 .. fd]
      , let s = c*nc + d*nd
      , na + nb > 0
--      , nc + nd > 0
      ]

select :: [Int] -> (SW,S)
select as@[a,b,c,d,e,f] = h e ls l
  where
    (l:ls) = combinations as

    h :: Int -> [(SW,S)] -> (SW,S) -> (SW,S)
    h _ []     best     = best
    h e (m:ms) best
      | rmax < ratio best = h e ms m
      | rmax == rm      = m
      | rmax <  rm      = h e ms best
      | ratio best < rm
          && rm < rmax  = h e ms m
      | otherwise       = h e ms best
      where
        rm = ratio m
        rmax = ratio (e+100, e)


Measured memory_bytes: 1916
N, M = map(int, input().split())
A = [int(a) for a in input().split()]    
L = [2, 5, 5, 4, 5, 6, 3, 7, 6]
B = [[A[i], L[A[i]-1]] for i in range(M)]
best = sorted(B, key = lambda x: x[1]*10-x[0])[0]
adj = max((N - 200),0)//best[1]
N -= best[1] * adj

X = [0] + [-10**9] * N
for i in range(1, N+1):
    if i > 50 and i < N-50:
        X[i] = X[i-best[1]]*10 + best[0]
    else:
        for b in B:
            if b[1] <= i:
                X[i] = max(X[i], X[i-b[1]]*10 + b[0])

ans = str(X[N])
ans = ans[:10] + str(best[0]) * adj + ans[10:]

print(ans)

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

using namespace std;

int qtd[4];

int main() {
	string s;
	cin >> s;
	for(int x : s){
		qtd[x-'a']++;
	}
	sort(qtd, qtd+3);
	if(qtd[2]-qtd[0]<=1){
		puts("YES");
	}
	else{
		puts("NO");
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <map>
using namespace std;
int main()
{
	int N,T,A;
	double H[1005],tmp,mn = 1000000;
	double d[1005];
	int ans;
	cin >> N >> T >> A;
	for(int i = 1; i <= N; i++){
		cin >> H[i];
	}
	for(int i = 1;i <= N;i++){
		tmp = 1.0 * T - H[i] * 0.006;
		if(abs(tmp - A) < mn){
			ans = i;
			mn = abs(tmp - A);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<P> items(N);
    rep(i, N) cin >> items[i].second >> items[i].first;
    sort(items.begin(), items.end());
    bool ok = true;
    ll time = 0;
    rep(i, N) {
        P p = items[i];
        time += p.second;
        if (p.first >= time) continue;
        ok = false;
    }
    cout << (ok ? "Yes" : "No") << '\n';

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<int>())
#define pb push_back
#define ll long long

int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
}
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
}
int cel(int a,int b){return((a-1)/b+1);} 
int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a,int b){
    return (a*b)/gcd(a,b);
}
void dfs(int u,vi &visited,vi adj[]) {
    visited[u] = 1; 
	for (int i=0; i<adj[u].size(); i++) 
		if (visited[adj[u][i]] == 0) 
			dfs(adj[u][i],visited,adj); 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,t,c=0,ans=0;string s;
    cin>>n;
    cin>>s;
    rep(i,0,n){
        if(s[i]=='R')c++;
    }
    rep(i,0,c){
        if(s[i]!='R')ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int N, A;
  cin >> N >> A;
  if(N%500 <= A) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<Pi>> data(N);
  FOR(i, N) {
    int A;
    cin >> A;
    data[i].resize(A);
    FOR(j, A) {
      int x, y;
      cin >> x >> y;
      data[i][j] = Pi(x - 1, y);
    }
  }
  int ans = 0;
  FOR(i, (1 << N)) {
    bool f = 1;
    int nowans = 0;
    FOR(j, N) {
      if ((i >> j) & 1) {
        nowans++;
        for (Pi p : data[j]) {
          if (p.second == 1 && ((i >> p.first) & 1) == 0) {
            f = 0;
          } else if (p.second == 0 && ((i >> p.first) & 1) == 1) {
            f = 0;
          }
        }
      }
    }
    if (f) {
      ans = max(ans, nowans);
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = len(str(n))
if a==1:
    print(n)
elif a==2:
    print(9)
elif a==3:
    print(n-99+9)
elif a==4:
    print(999-99+9)
elif a==5:
    print(n-9999+999-99+9)
elif a==6:
    print(90909)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c;
    
    for(int i = 0; i < 4; i++){
        cin >>a>>b;
        
        if(a == 1){
            c = 6000 * b;
        }else if(a == 2){
            c = 4000*b;
        }else if(a == 3){
            c = 3000*b;
        }else if(a == 4){
            c = 2000*b;
        }
        
        cout<<c<<endl;
    }
    
}



Measured memory_bytes: 3096
<?php

while(fscanf(STDIN, "%d%d", $h, $w)){
    if($h == 0 && $w == 0){
        return 1;
    }
$count = 0;
for($i = 0; $i < $h; $i++){

$a = substr(str_repeat("#.", ceil($w/2)), 0, $w);
$b = substr(str_repeat(".#", ceil($w/2)), 0, $w);

if($count % 2 == 0){
    echo $a.PHP_EOL;
    $count++;
}else {
    echo $b.PHP_EOL;
    $count++;
}
}echo PHP_EOL; //for
} //while
?>

Measured memory_bytes: 14992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll w,h,p,c[2]={},ans=0;
  pair<ll,bool> lb[200010];
  cin>>w>>h;
  fr(i,w){cin>>p;lb[i]=mp(p,0);}
  fr(i,h){cin>>p;lb[w+i]=mp(p,1);}
  sort(lb,lb+h+w);
  fr(i,h+w){
    if(lb[i].sd){
      c[1]++;
      ans+=(w+1-c[0])*lb[i].ft;
    }
    else{
      c[0]++;
      ans+=(h+1-c[1])*lb[i].ft;
    }
  }
  cout<<ans<<endl;
}

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

int main(){
    vector<int> vec(3);
    cin >> vec[0] >> vec[1] >> vec[2];
    sort(begin(vec),end(vec),greater<int>());
    int ans = vec[0] * 10 + vec[1];
    ans = ans + vec[2];
    cout <<  ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,y,z,ans;
int main(){
	scanf("%d%d%d",&x,&y,&z);
	if (x<y) swap(x,y);
	if (x<z) swap(x,z);
	if (y<z) swap(y,z);
	for (;y<x;++y,++z,++ans);
	for (;z+2<=y;z+=2,++ans);
	if (z<y) ans+=2;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
using P = pair<ld,ld>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=998244353;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> C(N-1,0);
    vector<ll> S(N-1,0);
    vector<ll> F(N-1,0);
    for(ll i=0;i<N-1;++i)cin>>C[i]>>S[i]>>F[i];
    for(ll i=0;i<N;++i){
        ll time=0;
        for(ll j=i;j<N-1;++j){
            //timeをS[j]以上で最小のF[i]の倍数にする
            time=max(F[j]*((time+F[j]-1)/F[j]),S[j]);
            time+=C[j];
        }
        prt(time)
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
string s;
int p, var;
bool f;

int parse();

int unit()
{
	int res;
	if (s[p] == '-'&&s[p + 1] != '>')
	{
		p++;
		int a = unit();
		res = 1 - a;
	}
	else if (s[p] == '(')
	{
		p++;
		res = parse();
		p++;
	}
	else
	{
		if (s[p] == 'T') res = 1;
		else if (s[p] == 'F') res = 0;
		else
		{
			int t = s[p] - 'a';
			res = (var >> t) & 1;
		}
		p++;
	}
	return res;
}

int parse()
{
	int a = unit();
	if (s[p] == '+')
	{
		p++;
		int b = unit();
		a = max(a, b);
	}
	else if (s[p] == '*')
	{
		p++;
		int b = unit();
		a = min(a, b);
	}
	else if(s[p] == '-' && s[p+1] == '>')
	{
		p += 2;
		int b = unit();
		if (a == 1 && b == 0) a = 0;
		else a = 1;
	}
	return a;
}

void solve()
{
	p = 0;
	int l = parse();
	p++;
	int r = parse();
	if (l != r) f = false;
}

int main()
{
	while (cin >> s&&s != "#")
	{
		f = true;
		for (var = 0; var < 1 << 11;var++)
		{
			solve();
		}
		puts(f ? "YES" : "NO");
	}
	return 0;
}

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

int main(){
  
  int n,m;
  int s[51][2];
  int p[51][2];
  int ans;
  int point;
  
  scanf(" %d %d",&n,&m);
  
  for(int i=0;i<n;i++){
    scanf(" %d %d",&s[i][0],&s[i][1]);
  }
  
  for(int i=0;i<m;i++){
    scanf(" %d %d",&p[i][0],&p[i][1]);
  }
  
  for(int i=0;i<n;i++){
    ans=abs(s[i][0]-p[0][0])+abs(s[i][1]-p[0][1]);
    point=0;
    for(int j=1;j<m;j++){
      int a=ans;
      ans=min(ans,abs(s[i][0]-p[j][0])+abs(s[i][1]-p[j][1]));
      if(a!=ans)point=j;
    }
    printf("%d\n",point+1);
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  long long n,ans=0;
  cin >> n;
  map<string,int> m;
  string s;
  for(int i=0; i<n; i++) {
    cin >> s;
    sort(s.begin(),s.end());
    ans+=m[s];
    m[s]++;
  }
  cout << ans << endl;
}


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

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

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n;
	lint k; scanf("%d%lld",&n,&k);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	auto b=a;
	rep(i,n) b[i]*=-1;

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());

	lint lo=-INF,hi=INF;
	while(hi-lo>1){
		lint mi=(lo+hi)/2;

		lint cnt=0;
		rep(i,n){
			if(a[i]==0){
				if(mi>=0) cnt+=n;
			}
			else if(a[i]>0){
				lint num;
				if(mi>=0) num=mi/a[i];
				else      num=-((-mi+a[i]-1)/a[i]);
				cnt+=upper_bound(a.begin(),a.end(),num)-a.begin();
			}
			else{
				lint num;
				if(mi>=0) num=mi/-a[i];
				else      num=-((-mi-a[i]-1)/-a[i]);
				cnt+=upper_bound(b.begin(),b.end(),num)-b.begin();
			}
			if(a[i]*a[i]<=mi) cnt--;
		}
		cnt/=2;

		if(cnt<k) lo=mi;
		else      hi=mi;
	}
	printf("%lld\n",lo+1);

	return 0;
}


Measured memory_bytes: 3328
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

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

  if (n == 0) {
    writeln(0);
    return;
  }

  int[] r;
  while (n != 0) {
    auto ri = n.abs%2;
    r ~= ri;
    n = (ri-n)/2;
  }

  writeln(r.map!(to!string).retro.joiner(""));
}


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

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      vector<int>card[2];
      for(int i=1;i<=2*n;i++)
	{
	  card[1].push_back(i);
	}
      for(int i=0;i<n;i++)
	{
	  int tmp;
	  cin>>tmp;
	  card[1].erase(remove(card[1].begin(),card[1].end(),tmp),card[1].end());
	  card[0].push_back(tmp);
	}
      sort(card[0].begin(),card[0].end());
      int cnt=0;
      int fi=0;
      while(card[0].size()!=0&&card[1].size()!=0)
	{
	  int tmp_fi=0;
	  for(int i=0;i<card[cnt].size();i++)
	    {
	      if(card[cnt][i]>fi)
		{
		  tmp_fi=card[cnt][i];
		  card[cnt].erase(card[cnt].begin()+i);
		  break;
		}
	    }
	  fi=tmp_fi;	    
	  if(cnt==0)
	    cnt=1;
	  else
	    cnt=0;
	}
      cout<<card[1].size()<<endl;
      cout<<card[0].size()<<endl;

    }
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

map<P,vector<P>> g;
map<P,int> m; set<P> used;
int dfs(P u){
  if(used.count(u)>0) return -1;
  if(m[u]!=0) return m[u];

  int res = 0;
  used.insert(u);
  for(P v:g[u]) {
    int temp = dfs(v);
    if(temp<0) return m[u] = -1;
    res = max(res,temp);
  }
  used.erase(u);
  return m[u] = res + 1;
}

int main() {
  int n;
  cin >> n;
  vector<P> v;
  rep(a,n){
    P p;
    rep(i,n-1){
      int b;
      cin >> b;
      --b;
      P np = a<b ? P(a,b) : P(b,a);
      if(i>0) g[p].emplace_back(np);
      else v.emplace_back(np);
      p = np;
    }
  }
  int ans = 0;
  rep(i,v.size()){
    int temp = dfs(v[i]);
    if(temp<0){
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans,temp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 86272
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] times = new int[n];
    
        boolean isOdd = (n & 1) == 1;
        int num = 0;
        for(int i = 0; i < n; i++) {
            num = sc.nextInt();

            if(isOdd && ((num & 1) == 1)) {
                System.out.println(0);
                return;
            } else if(!isOdd && ((num & 1) == 0)) {
                System.out.println(0);
                return;
            }
            
            times[num]++;
            if(times[num] > 2 || times[0] == 2) {
                System.out.println(0);
                return;
            }
        }
    
        long ans = 1;
		for(int i = 0; i < n/2; i++)
		    ans = 2 * ans % 1000000007;
		System.out.println(ans);
    }
}


Measured memory_bytes: 50292
import java.util.*;
public class Main {

    static int N;


    private  static int count753num(long currentNumber, boolean isThree, boolean isFive, boolean isSeven ){

        int ret = 0;

        //現在の値が入力された値をこえた
        if(N < currentNumber) return 0;

        //現在の値の下一桁を取得
        int length = String.valueOf(currentNumber).length();
        int lastDigit = Integer.parseInt( Long.toString(currentNumber).substring(length -1));

        //現在の値の下一桁の値が3,5,7のいずれかであるか調べる
        if(lastDigit == 3) isThree = true;
        if(lastDigit == 5) isFive  = true;
        if(lastDigit == 7) isSeven = true;

        //すべてtrueになったら、753数としてカウント
        if(isThree && isFive && isSeven) ret++;

        //現在の値を　xx3にして再帰
        ret += count753num(currentNumber*10 + 3 ,isThree, isFive, isSeven);
        //現在の値を　xx5にして再帰
        ret += count753num(currentNumber*10 + 5, isThree, isFive, isSeven);
        //現在の値を　xx7にして再帰
        ret += count753num(currentNumber*10 + 7, isThree, isFive, isSeven);

        return ret;
    }

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        N = Integer .parseInt(scan.next());

        //0から(7,5,3)の値のみで構成される数だけを調べ、その中で753数となったものをカウントする
        int num = count753num(0, false, false, false);

        System.out.println(num);
    }
}

Measured memory_bytes: 29268
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
 
const int N=1e6+5;

int n;
int a[N];

int32_t main()
{
	IOS;
	map<int, int> m;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	m[0]=1;
	int pref=0, ans=0;
	for(int i=1;i<=n;i++)
	{	
		pref+=a[i];
		ans+=m[pref];
		m[pref]++;
	}
	cout<<ans;
}

Measured memory_bytes: 14336
K = int(input())

runrun = [[1]*10]
s = sum(runrun[0][1:])
i = 1
while K > s:
  K -= s
  r = [sum(runrun[-1][max(0,i-1):min(10, i+2)]) for i in range(10)]
  runrun.append(r)
  s = sum(r[1:])
  i += 1

j = 1
while runrun[-1][j] < K:
  K -= runrun[-1][j]
  j += 1

ans = [j]
k = -2
while K and len(runrun) >= -k:
  j = max(0, j-1)
  while runrun[k][j] < K:
    K -= runrun[k][j]
    j += 1
  k -= 1
  ans.append(j)

print("".join(map(str, ans)))


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

#define ll long long

int main() {
    int N, K;
    cin >> N >> K;
    int g[N + 1][N + 1];
    for(int i = 0;i < N + 1;i++) {
        fill(g[i], g[i] + N + 1, 1);
    }
    if((N - 1)*(N - 2)/2 < K) {
        cout << -1 << endl;
        return 0;
    }
    int count = 0;
    for(int i = 1;i < N;i++) {
        for(int j = i + 1;j < N && count < K;j++, count++) {
            g[i][j] = 0;
        }
    }

    cout << N*(N - 1)/2 - K << endl;
    for(int i = 1;i <= N;i++) {
        for(int j = i + 1;j <= N;j++) {
            if(g[i][j] != 0) {
                cout << i << " " << j << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);
const int MOD = 1000000007;

int main(){
    int n; cin >> n;
    if(n) cout << 0 << endl;
    else cout << 1 << endl;
}

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

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

    int n, m; cin >> n >> m;
    map<int, int> price_cans;

    for (int i = 0; i < n; ++i) {
        int a, b; cin >> a >> b;
        if (price_cans.count(a)) {
            price_cans[a] += b;
        } else {
            price_cans[a] = b;
        }
    }

    long long ans = 0;

    for (auto it : price_cans) {
        int p = it.first, c = it.second;
        if (m >= c) {
            ans += (long long)p*c;
            m -= c;
        } else {
            ans += (long long)p*m;
            break;
        }
    }

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

Measured memory_bytes: 4992
while True:
    n, m = map(int, input().split())
    if n+m==0 : break
    a = [list(map(int,input().split())) for i in range(m)]
    for i in range(1, m):
        for j in range(n):
            a[i][j] += a[i-1][j]
    print(max(a[m-1]))


Measured memory_bytes: 7672
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    String s;

    for(;sc.hasNext();){
      s = sc.next();
      if(s.charAt(0) != 's' && s.charAt(0) == s.charAt(1) && s.charAt(0) == s.charAt(2))
        out.println(s.charAt(0));
      else if(s.charAt(3) != 's' && s.charAt(3) == s.charAt(4) && s.charAt(3) == s.charAt(5))
        out.println(s.charAt(3));
      else if(s.charAt(6) != 's' && s.charAt(6) == s.charAt(7) && s.charAt(6) == s.charAt(8))
        out.println(s.charAt(6));
      else if(s.charAt(0) != 's' && s.charAt(0) == s.charAt(3) && s.charAt(0) == s.charAt(6))
        out.println(s.charAt(0));
      else if(s.charAt(1) != 's' && s.charAt(1) == s.charAt(4) && s.charAt(1) == s.charAt(7))
        out.println(s.charAt(1));
      else if(s.charAt(2) != 's' && s.charAt(2) == s.charAt(5) && s.charAt(2) == s.charAt(8))
        out.println(s.charAt(2));
      else if(s.charAt(0) != 's' && s.charAt(0) == s.charAt(4) && s.charAt(0) == s.charAt(8))
        out.println(s.charAt(0));
      else if(s.charAt(2) != 's' && s.charAt(2) == s.charAt(4) && s.charAt(2) == s.charAt(6))
        out.println(s.charAt(2));
      else out.println("d");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 26124
<?php


$input = readline();

$parts = explode(" ", $input);

$low = $parts[0];
$high = $parts[1];

$div = $parts[2];


//first find the lowest

$low_div = $low % $div;
if ($low_div == 0)
{
	$low_min = $low;
}
else
{
	$low_min = $low + ($div - $low_div);
}


//then find the highest
$high_div = $high % $div;
$high_max = $high - $high_div;


//then see how many are in between
$result = ( $high_max - $low_min ) / $div + 1;

echo $result ."\n";

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	vector<ll> B(50, 0);
	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j < 50; j++) {
			if (A[i] & (1LL << j))B[j]++;
		}
	}
	ll K_ = 0, ans = 0;
	for (ll i = 49; (i >= 0); i--) {
		if ((K - K_) >= (1LL << i) && (N - B[i]) >= B[i]) {
			K_ += 1LL << i;
			ans += (N - B[i]) * (1LL << i);
		}
		else {
			ans += B[i] * (1LL << i);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		Dice dice = new Dice(stdIn.nextInt(), stdIn.nextInt(), stdIn.nextInt(), stdIn.nextInt(), stdIn.nextInt(),
				stdIn.nextInt());
		String a = stdIn.next();
		for (int i = 0; i < a.length(); i++) {
			if (a.charAt(i) == 'N') {
				dice.TurnN();
			} else if (a.charAt(i) == 'W') {
				dice.TurnW();
			} else if (a.charAt(i) == 'E') {
				dice.TurnE();
			} else {
				dice.TurnS();
			}
		}
		System.out.println(dice.Top);
	}
}

class Dice {
	int Top;
	int Bottom;
	int N;
	int S;
	int W;
	int E;

	Dice(int a, int b, int c, int d, int e, int f) {
		Top = a;
		S = b;
		E = c;
		W = d;
		N = e;
		Bottom = f;
	}

	public void TurnN() {
		int tmp = Top;
		Top = S;
		S = Bottom;
		Bottom = N;
		N = tmp;
	}

	public void TurnW() {
		int tmp = Top;
		Top = E;
		E = Bottom;
		Bottom = W;
		W = tmp;
	}

	public void TurnE() {
		int tmp = Top;
		Top = W;
		W = Bottom;
		Bottom = E;
		E = tmp;
	}

	public void TurnS() {
		int tmp = Top;
		Top = N;
		N = Bottom;
		Bottom = S;
		S = tmp;
	}
}



Measured memory_bytes: 26260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll N, C;
ll x[100010], v[100010];
ll cumv[100010];

ll calc() {
  for (int i = 0; i < N; i++) {
    if (i == 0) cumv[i] = v[i];
    else cumv[i] = cumv[i-1] + v[i];
  }
  ll res = 0;
  for (int i = 0; i < N; i++) {
    res = max(res, cumv[i] - x[i]);
  }
  priority_queue<ll> que;
  que.emplace(0);
  ll cumv2 = 0;
  for (int i = N-1; i >= 0; i--) {
    ll tmp = cumv[i] - 2*x[i] + que.top(); 
    res = max(res, tmp);
    cumv2 += v[i];
    que.emplace(cumv2-(C-x[i]));
  }
  res = max(res, que.top());
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> C;
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> v[i];
  }
  ll ans = 0;
  ans = max(ans, calc());
  reverse(x, x+N);
  reverse(v, v+N);
  for (int i = 0; i < N; i++) {
    x[i] = C - x[i];
  }
  ans = max(ans, calc());
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<ll> a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> b[i];
    }   
    ll ca = 0; ll cb = 0;
    ll ma = 0;
    for (int i = 0; i < N; i++) {
        ma += b[i]; ma -= a[i];
    }
    for (int i = 0; i < N; i++) {
        if(a[i] > b[i]){
            cb += a[i] - b[i];
        }
        else if(a[i] < b[i]){
            if((b[i] - a[i]) % 2 == 0){
                ca += (b[i] - a[i]) / 2;
            }
            else{
                ca += (b[i] + 1- a[i]) / 2;
                cb += 1;
            }
        }
    }
    if(ca <= ma && cb <= ma){
        Yes();
    }
    else{
        No();
    }

}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a;
    cin>>b>>c;
    for(int i=b;i<=c;i++)
    {
        if(i%a==0)
        {
            cout<<"OK\n";
  return 0;
        }
    }
    cout<<"NG\n";
}


Measured memory_bytes: 3596
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String[] cup={"A","B","C"};
		boolean[] ball={true,false,false};
		while(sc.hasNext()){
			String[] change=sc.next().split(",");
			for(int i=0;i<3;i++){
				if(cup[i].equals(change[0])){
					for(int j=0;j<3;j++){
						if(cup[j].equals(change[1])){
							if(ball[i]){
								ball[i]=false;
								ball[j]=true;
							}else if(ball[j]){
								ball[j]=false;
								ball[i]=true;
							}
							break;
						}
					}
					break;
				}
			}
		}
		for(int i=0;i<3;i++){
			if(ball[i]){
				System.out.println(cup[i]);
				break;
			}
		}
	}
}

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

int N, M;
int l[100005], r[100005];

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

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

    int ans = 0;
    sort(l, l+M); sort(r, r+M);
    if (l[M-1] <= r[0]) ans = r[0]-l[M-1]+1;

    cout << ans << endl;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())

A = set({})
B = set({})
for j in range(M):
    tmp = []
    tmp = [int(i) for i in input().split()]
    if tmp[0] == 1:
        A.add(tmp[1])
    elif tmp[1] == N:
        B.add(tmp[0])

if len(A.intersection(B)) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 19008
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	cin>>s;
 	int n,i,k,j;
  	n=s.size();
      
    for(i=0;i<n;i++){
		if(s[i]=='A'){
			k=i;
          	break;
        }
    }
	
  	for(i=n-1;i>=0;i--){
		if(s[i]=='Z'){
			j=i;
        	break;
        }
    }

  	cout<<j-k+1<<endl;
}
  	
  	

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 1000006;
const long long M = 1000000007;

int x, y;

int a[102][102];
int solv0()
{
    for (int i = 0; i <= x; ++i)
    {
        for (int j = 0; j <= y; ++j)
        {
            if (i == 0 && j == 0)
                a[i][j] = 1;
            else
            {
                if (i - 1 >= 0 && j - 2 >= 0)
                    a[i][j] = a[i][j] + a[i - 1][j - 2];
                if (i - 2 >= 0 && j - 1 >= 0)
                    a[i][j] = a[i][j] + a[i - 2][j - 1];
            }
        }
    }
    cout << a[x][y] << endl;
}

struct ban
{
    long long x;
    ban()
    {
        x = 0;
    }
    ban(long long x)
    {
        this->x = x % M;
    }
};
ban operator+(const ban& a, const ban& b)
{
    return ban(a.x + b.x);
}
ban operator-(const ban& a, const ban& b)
{
    return ban(a.x - b.x + M);
}
ban operator*(const ban& a, const ban& b)
{
    return ban(a.x * b.x);
}
ban ast(ban x, long long n)
{
    ban ans(1);
    while (n)
    {
        if (n % 2 == 1)
            ans = ans * x;
        x = x * x;
        n /= 2;
    }
    return ans;
}
ban operator/(const ban& a, const ban& b)
{
    return a * ast(b, M - 2);
}

ban f[N];
void pre()
{
    f[0] = ban(1);
    for (int i = 1; i < N; ++i)
        f[i] = f[i - 1] * ban(i);
}
ban C(int n, int k)
{
    return f[n] / (f[k] * f[n - k]);
}

int main()
{
    pre();
    cin >> x >> y;
    ban ans;
    for (int z = 0; ; ++z)
    {
        if (z > x || 2 * z > y)
            break;
        x -= z;
        y -= 2 * z;
        if (y * 2 == x)
        {
            ans = ans + C(y + z, z);
        }
        x += z;
        y += 2 * z;
    }
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 8192
#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

int main(){
	lint a,b,c;cin>>a>>b>>c;
	c=min(c,a+b+1);
	cout<<b+c<<endl;
}

//sub-EOF


Measured memory_bytes: 256