akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    vector<vector<vector<ll>>> dp((n + (k - 1)) / k + 1, vector<vector<ll>>(k, vector<ll>(3, 0)));
    rep(i, n)
    {
        char hand = t[i];
        int idx_offset = i % k;
        int idx_num = i / k + 1;
        if (hand == 'r')
        {
            dp[idx_num][idx_offset][0] += max(dp[idx_num - 1][idx_offset][1], dp[idx_num - 1][idx_offset][2]);
            dp[idx_num][idx_offset][1] += max(dp[idx_num - 1][idx_offset][0], dp[idx_num - 1][idx_offset][2]);
            dp[idx_num][idx_offset][2] += max(dp[idx_num - 1][idx_offset][0], dp[idx_num - 1][idx_offset][1]) + p;
        }
        else if (hand == 's')
        {
            dp[idx_num][idx_offset][0] += max(dp[idx_num - 1][idx_offset][1], dp[idx_num - 1][idx_offset][2]) + r;
            dp[idx_num][idx_offset][1] += max(dp[idx_num - 1][idx_offset][0], dp[idx_num - 1][idx_offset][2]);
            dp[idx_num][idx_offset][2] += max(dp[idx_num - 1][idx_offset][0], dp[idx_num - 1][idx_offset][1]);
        }
        else
        {
            dp[idx_num][idx_offset][0] += max(dp[idx_num - 1][idx_offset][1], dp[idx_num - 1][idx_offset][2]);
            dp[idx_num][idx_offset][1] += max(dp[idx_num - 1][idx_offset][0], dp[idx_num - 1][idx_offset][2]) + s;
            dp[idx_num][idx_offset][2] += max(dp[idx_num - 1][idx_offset][0], dp[idx_num - 1][idx_offset][1]);
        }
    }
    ll r_max, s_max, p_max;

    ll res = 0;
    for (int j = 0; j < k; j++)
    {
        r_max = 0;
        s_max = 0;
        p_max = 0;
        for (int i = (n + (k - 1)) / k; i >= 0; i--)
        {
            r_max = MAX(r_max, dp[i][j][0]);
            s_max = MAX(s_max, dp[i][j][1]);
            p_max = MAX(p_max, dp[i][j][2]);
            if (min({r_max, s_max, p_max}) > 0)
                break;
        }
        res += max({r_max, s_max, p_max});
    }
    cout << res << endl;
    return 0;
}

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

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

  vector<ll> dp(n+1, 0);
  dp[0] = 2; dp[1] = 1;
  for(int i = 2; i <= n; i++){
    dp[i] = dp[i-1] + dp[i-2];
  }

  cout << dp[n] << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

typedef long long ll;

const int N=201000;

int A[N];

int n;

bool judge()
{
	for(int i=1;i<=n;i++)
		if(A[i]>=i || A[i]-A[i-1]>1)return 0;
	return 1;
}
ll calc()
{
	ll ret=0;
	for(int i=1;i<=n;i++)
		if(A[i]+1==A[i+1])continue;
		else ret+=A[i];
	return ret;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",A+i);
	if(!judge())printf("-1\n");
	else printf("%lld\n",calc());

	return 0;
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);

    string s;
    cin >> s;
    int m = s[s.size()-1] - '0';
    if(m == 3){
        cout << "bon" << endl;
    }else if(m == 0 || m == 1 || m== 6 || m == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }

    return 0;
}


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

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

    map<char,int> m;

    for(auto x:  s){
        if(m.find(x)==m.end()){
            m[x]=0;
        }else{
            m[x]++;
        }
    }
    int c = 0;
    for(auto i:m){
        c = max(c,i.second+1);
    }
    if(c == 2 && m.size() == 2){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
N_str = input()
N=int(N_str)

length = len ( N_str )

num = 0

for i in range(length-1):
    if (i%2!=0):
        continue
    num = num + 9 * 10 ** i

if (length%2!=0):    
    num = num + ( N - 10**(length-1) + 1 )

print ( num )    

Measured memory_bytes: 3060
N,A,B,C = map(int,input().strip().split())
ls = [int(input()) for i in range(0,N)]
INF = 10 ** 9

def dfs(cur,a,b,c):
    if cur == N:
        return abs(A - a) + abs(B - b) + abs(C- c) - 30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur + 1,a,b,c)
    ret1 = dfs(cur + 1,a + ls[cur],b,c) + 10
    ret2 = dfs(cur + 1,a,b + ls[cur],c) + 10
    ret3 = dfs(cur + 1,a,b,c + ls[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int thp,tat,ahp,aat;
    cin >> thp >> tat >> ahp >> aat;
    
    int tatnum = (ahp+tat-1)/tat;
    int aatnum = (thp+aat-1)/aat;
    
    if(tatnum <= aatnum) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	long long r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

	ll ans=0;
	for(int i=59; i>=0; i--){
		vector<ll> tmp;
		for(int j=0; j<v.size(); j++){
			if(v[j]&(((ll)1)<<i)) tmp.push_back(v[j]);
		}

		if(tmp.size()>=k){
			ans+=(((ll)1)<<i);
			v=tmp;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second

int n, a[100010];

int main() {
  scanf("%d", &n);
  REPE(i, 1, n) scanf("%d", &a[i]);
  int cnt = 0;
  REPE(i, 1, n) {
    if (a[i] == i) {
      if (i < n) swap(a[i], a[i + 1]);
      else swap(a[i], a[i - 1]);
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 640
#include<stdio.h>

int search(int*,int,int);

int main(){
  int i,n,A[10000+1],q,key,sum=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
    scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key))
    sum++;}
printf("%d\n",sum);
return 0;
}
int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key)
    i++;
  if(i!=n)
  return 1;

  else
    return 0;
}



Measured memory_bytes: 2768
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<vector>
#include<cstdlib>
using namespace std;
#define c 'C'
#define f 'F'
#define yes printf("Yes")
#define no printf("No")
string a;
bool b=false;
int main(){
	cin>>a;
	int i;
	for(i=0;i<a.size();i++){
		if(a[i]==c) b=true;
		if((a[i]==f)&&(b)){
			yes;
			return 0;
		}
	}
	no;
    return 0;
}

Measured memory_bytes: 256
//                     ?????? ???????? ???????????? ??????????
//                   ?? ?????? ????? ?????? ????????? ??????? ??????




#include <bits/stdc++.h>

using namespace std;
#define endl "\n"

int main()
{

    string x;
    cin >> x;
    long long sum = 0;
    for(int i = 0 ; i < x.size() ; i++) sum += x[i] - '0';
	if(sum % 9 ==0) cout << "Yes" << endl;
	else cout << "No" << endl;
    
    
    
	return 0;
}


Measured memory_bytes: 3628
n = int(input())
A=list(map(int,input().split()))

endflag=False
for i in range(10**9):
    for j in range(n):
        if A[j]%2==1:
            print(i)
            endflag=True
            break
        else:
            A[j]//=2
    if endflag:
        break

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (h, w, n) = readLine()!!.split(' ').map(String::toLong)
    val abMap = mutableMapOf<Pair<Long, Long>, Boolean>()
    val abList = (1..n).map {
        val (a, b) = readLine()!!.split(' ').map(String::toLong)
//        abMap[Pair(a, b)] = false
        Pair(a, b)
    }


    val total = (h - 2) * (w - 2)
    val ansArray = LongArray(10) { 0 }
    ansArray[0] = total

    for (ab in abList) {
        val (a, b) = ab
        for (dw in -1..1) {
            for (dh in -1..1) {
                if (a + dh - 1 < 1) continue
                if (a + dh + 1 > h) continue
                if (b + dw - 1 < 1) continue
                if (b + dw + 1 > w) continue

                var count = 0
                for (dw2 in -1..1) {
                    for (dh2 in -1..1) {
                        val th = a + dh + dh2
                        val tw = b + dw + dw2
                        if (th == a && tw == b) continue
                        if (abMap[Pair(th, tw)] != null) {
                            count++
                        }

                    }
                }
                ansArray[count]--
                ansArray[count + 1]++
            }
        }
        abMap[Pair(a, b)] = false
    }

    (0..9).forEach { println(ansArray[it]) }
}


Measured memory_bytes: 138168
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main() {
  int a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2;
  
  return 0;
}

Measured memory_bytes: 3600
t = int(input())
a = list(map(int, input().split()))

if t == 1:
    print(0)
elif t == 2:
    print(abs(a[0] - a[1]))

else:
    dp = [-1] * (t)
    dp[0] = 0
    dp[1] = abs(a[0] - a[1])
    for i in range(2, t):
        dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1],
                    abs(a[i] - a[i - 2]) + dp[i - 2])

    print(dp[t - 1])


Measured memory_bytes: 13980
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v = {a, b, c};
    sort(v.begin(), v.end());
    cout << v[2] * 10 + v[1] + v[0];
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#define INF 0x3f3f3f3f
#define MAX_N 1001000
using namespace std;
void optimize_cpp_stdio()
{
    std::ios::sync_with_stdio(false);
    std::cout.tie(NULL);
    std::cin.tie(NULL);
}
long long n, k;

long long quickpow(long long X, long long N)
{
    long long x = X, n = N;
    long long ans = 1;
    while(n > 0)
    {
        if(n & 1)
            ans = ans * x;
        x = x * x;
        n >>= 1;
    }
    return ans;
}

int main()
{
    scanf("%d%d", &n, &k);
    long long l = 0, r = 30;
    long long ans = 0;
    while(l + 1< r)
    {
        long long mid = (l + r) / 2;
        if(quickpow(k, mid) <= n)
        {
            ans = mid;
            l = mid;
        }
        else
            r = mid;
    }
    printf("%d\n", ++ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
   double x1,y1,x2,y2,d,d1,d2;
   scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    
   d1=pow(x2-x1,2.0);
   d2=pow(y2-y1,2.0);
   d=sqrt(d1+d2);
   printf("%f\n",d);
    
   return 0;
    
}


Measured memory_bytes: 2048
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#define ll long long
#include<bits/stdc++.h>

using namespace std;
int main(){
    vector<vector<int>> a(3,vector<int>(3));
    vector<vector<bool>> ch(3,vector<bool>(3,false));
    int ans=0;
    int n;
    lp(i,3){
        lp(j,3){
            cin>>a[i][j];
        }
    }
    cin>>n;
    int b;    
    lp(i,n){
        cin>>b;
        lp(j,3){
            lp(k,3){
                if(a[j][k]==b){
                    ch[j][k]=true;
                }
            }
        }
    }
    lp(i,3){
        lp(j,3){
            if(ch[i][j]!=false){
                ans++;
            }
            else{
                ans=0;
                break;
            }
        }
        if(ans==3)
            break;
    }
    if(ans!=3){
        ans=0;
        lp(i,3){
            lp(j,3){
                if(ch[j][i]!=false){
                    ans++;
                }
                else{
                    ans=0;
                    break;
                }
            }
            if(ans==3)
            break;
        }
    }
    if(ans!=3){
        ans=0;
        lp(i,3){
            if(ch[i][i]!=false){
                ans++;
            }
            else{
                ans=0;
                break;
            }
        }
    }
    if(ans!=3){
        ans=0;
        lp(i,3){
            if(ch[i][2-i]!=false){
                ans++;
            }
            else{
                ans=0;
                break;
            }
        }
    }
    ans==3?cout<<"Yes"<<endl:cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    string s;
    cin >> s;
    deque<char> deq;
    rep(i,s.size()){
        deq.push_back(s[i]);
    }
    int q;
    cin >> q;
    bool flag = 1;
    rep(i,q){
        int a;
        cin >> a;
        if(a==1){
            flag = !flag;
        }else{
            int b;
            char c;
            cin >> b >> c;
            b--;
            if(flag^b){
                deq.push_front(c);
            }else{
                deq.push_back(c);
            }
        }
    }
    int n = deq.size();
    if(flag){
        rep(i,n){
            cout << deq[i];
        }
    }else{
        rep(i,n){
            cout << deq[n-1-i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 960
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long

int N;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  vector<int> h;
  cin >> N;
  h.resize(N);

  REP(i, N){
  	cin >> h[i];
  }
  vector<int> dp;
  dp.resize(N + 10, llINF);
  dp[0] = 0;
  for(int i = 0 ; i < N; i++){
  	dp[i + 1] = min(dp[i+1],dp[i] + abs(h[i + 1] - h[i]));
  	dp[i + 2] = min(dp[i+2],dp[i] + abs(h[i + 2] - h[i]));
  }

  cout << dp[N - 1] << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 1792
l =[int(i) for i in list(str(input()))]
ans = 0
num =0
n = 0

if l[0] == 1:
    l=[abs(i-1) for i in l]

for i in l:
    if num%2 ==0:
        if i == 1:
            ans = ans +1
    else:
        if i == 0:
            ans =ans +1
    num = num +1
print(ans)

Measured memory_bytes: 4776
def gcd(a,b):
    while a%b != 0:
        a = a%b
        (a,b) = (b,a)
    return min(a,b)

nm = input().split()
n = int(nm[0])
m = int(nm[1])
s = input()
t = input()
g = gcd(m,n)

ans = int(n*m / g)
for i in range(g):
    if s[(n//g)*i] != t[(m//g)*i]:
        ans = -1
            
print(ans)

Measured memory_bytes: 3316
from bisect import bisect_left

N = int(input())
L = [int(x) for x in input().split()]
L.sort()

ans = 0
for i in range(N-2):
	for j in range(i+1,N-1):
		ans += bisect_left(L, L[i]+L[j])-j-1
print(ans)

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

int dig(int x){
	if( x < 10 ) return x;
	return x / 10 + x % 10;
}

int m;
int a[10];
int c[2];
int ans;

void count(int r){
	if( !c[0] && !c[1] ){
		if( r % 10 == 0 ) ++ans;
	}
	else if( c[0] ){
		--c[0];
		for(int i = 0; i < m; ++i){
			count(r + a[i]);
		}
		++c[0];
	}
	else{
		--c[1];
		for(int i = 0; i < m; ++i){
			count(r + dig(2 * a[i]));
		}
		++c[1];
	}
}

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

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

	for(int i = 0; i < m; ++i){
		cin >> a[i];
	}

	int s = 0;
	for(int i = 0; i < id.size(); ++i){
		if( id[i] == '*' ){
			++c[i & 1];
		}
		else{
			if( i & 1 ){
				s += dig((id[i] - '0') * 2);
			}
			else{
				s += id[i] - '0';
			}
		}
	}

	count(s);
	cout << ans << endl;
}

Measured memory_bytes: 1332
//Candies
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int n;
    vector<vector<int>> a(2,vector<int>(110));
    cin >> n;
    rep(i,2){
        rep(j,n) cin >> a.at(i)[j];
    }
    // rep(i,2){
    //     rep(j,n) cout << a.at(i)[j] << endl;
    // }

    //行ごとの累積和を計算
    vector<vector<int>> cumulative_sum_a(2,vector<int>(n));
    rep(i,2){
        rep(j,n){
            if(j==0) cumulative_sum_a.at(i)[j] = a.at(i)[j];
            else{
                cumulative_sum_a.at(i)[j] = cumulative_sum_a.at(i)[j-1];
                cumulative_sum_a.at(i)[j] +=  a.at(i)[j];
            }
        }
    }
    // rep(i,2){
    //     rep(j,n) cout<< cumulative_sum_a.at(i)[j] << " ";
    //     cout<<endl;
    // }

    //処理
    int ame=0;
    int ame_max=0;
    rep(s,n){
        if(s==0){
            ame = cumulative_sum_a.at(0)[s] 
                + cumulative_sum_a.at(1)[n-1];
        }
        else{
            ame = cumulative_sum_a.at(0)[s] 
                + cumulative_sum_a.at(1)[n-1] 
                - cumulative_sum_a.at(1)[s-1];
        }

        if(ame_max<ame){
            ame_max = ame;
        }
    }
    cout<<ame_max<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		String s = scanner.next();
		int result = n;
		for (int i = 1; i < n; i++) {
			if (s.charAt(i) == s.charAt(i - 1))
				result--;

		}
		System.out.println(result);
	}

}


Measured memory_bytes: 24148
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	double x,y;
} xy_t;

int qsort_comp(const void* x,const void* y) {
	const xy_t* a=(const xy_t*)x;
	const xy_t* b=(const xy_t*)y;
	if((a->x)>(b->x))return 1;
	if((a->x)<(b->x))return -1;
	if((a->y)>(b->y))return 1;
	if((a->y)<(b->y))return -1;
	return 0;
}

int zahyou_num;
xy_t zahyou[100];

int th_up_n;
int th_down_n;
xy_t th_up[100];
xy_t th_down[100];

int main(void) {
	int i;
	while(1) {
		scanf("%d",&zahyou_num);
		if(zahyou_num==0)break;
		for(i=0;i<zahyou_num;i++) {
			scanf("%lf,%lf",&zahyou[i].x,&zahyou[i].y);
		}
		qsort(zahyou,zahyou_num,sizeof(xy_t),qsort_comp);
		//sita no totu-ho
		th_down_n=1;
		th_down[0].x=zahyou[0].x;
		th_down[0].y=zahyou[0].y;
		for(i=1;i<zahyou_num;i++) {
			//if(zahyou[i].y<th_down[th_down_n-1].y) {
				while(th_down_n>1) {
					double k1,k2;
					if(zahyou[i].x==th_down[th_down_n-1].x) {
						//INF
						if(zahyou[i].y<th_down[th_down_n-1].y) {
							k1=-1e+200;
						} else if(zahyou[i].y>th_down[th_down_n-1].y) {
							k1=1e+200;
						} else k1=0;
					} else {
						k1=(zahyou[i].y-th_down[th_down_n-1].y)/
						   (zahyou[i].x-th_down[th_down_n-1].x);
					}
					if(th_down[th_down_n-1].x==th_down[th_down_n-2].x) {
						//INF
						if(th_down[th_down_n-1].y<th_down[th_down_n-2].y) {
							k2=-1e+200;
						} else if(th_down[th_down_n-1].y>th_down[th_down_n-2].y) {
							k2=1e+200;
						} else k2=0;
					} else {
						k2=(th_down[th_down_n-1].y-th_down[th_down_n-2].y)/
						   (th_down[th_down_n-1].x-th_down[th_down_n-2].x);
					}
					if(k1>=k2)break;
					th_down_n--;
				}
			//}
			th_down[th_down_n].x=zahyou[i].x;
			th_down[th_down_n].y=zahyou[i].y;
			th_down_n++;
		}
		//ue no totu-ho
		th_up_n=1;
		th_up[0].x=zahyou[zahyou_num-1].x;
		th_up[0].y=zahyou[zahyou_num-1].y;
		for(i=zahyou_num-2;i>=0;i--) {
			//if(zahyou[i].y>th_up[th_up_n-1].y) {
				while(th_up_n>1) {
					double k1,k2;
					if(zahyou[i].x==th_up[th_up_n-1].x) {
						//INF
						if(zahyou[i].y<th_up[th_up_n-1].y) {
							k1=1e+200;
						} else if(zahyou[i].y>th_up[th_up_n-1].y) {
							k1=-1e+200;
						} else k1=0;
					} else {
						k1=(zahyou[i].y-th_up[th_up_n-1].y)/
						   (zahyou[i].x-th_up[th_up_n-1].x);
					}
					if(th_up[th_up_n-1].x==th_up[th_up_n-2].x) {
						//INF
						if(th_up[th_up_n-1].y<th_up[th_up_n-2].y) {
							k2=1e+200;
						} else if(th_up[th_up_n-1].y>th_up[th_up_n-2].y) {
							k2=-1e+200;
						} else k2=0;
					} else {
						k2=(th_up[th_up_n-1].y-th_up[th_up_n-2].y)/
						   (th_up[th_up_n-1].x-th_up[th_up_n-2].x);
					}
					if(k1>=k2)break;
					th_up_n--;
				}
			//}
			th_up[th_up_n].x=zahyou[i].x;
			th_up[th_up_n].y=zahyou[i].y;
			th_up_n++;
		}
		printf("%d\n",zahyou_num-(th_down_n+th_up_n-2));
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	ll val = min(a, k);
	a -= val;
	k -= val;
	val = min(b, k);
	b -= val;
	k -= val;
	cout << a <<  ' ' << b << endl;
	return 0;
}


Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
char x;
cin>>x;
cout<<++x<<endl;
return 0;
}


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

int main() {
	int A, B, C;
  	cin >> A >> B >> C;
  	vector<int> vec(3);
    vec = { A, B, C };
  	sort(vec.begin(), vec.end());
  	reverse(vec.begin(), vec.end());
  	
  	int count = 0;
  	if( (vec.at(1) - vec.at(2)) % 2 == 1 ){
      vec.at(0) += 1; vec.at(1) += 1;
      count += 1;
    }
      count += (vec.at(1) - vec.at(2)) /2;
      count += (vec.at(0) - vec.at(1));
      
      cout << count << endl;
}

Measured memory_bytes: 256
from fractions import gcd
n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
flag = False
for i in range(1,n):
    if gcd(a[i],a[0])==1:
        flag = True
mn = 10**9
if not flag:
    for i in range(1,n):
        mn = min(mn,gcd(a[0],a[i]))
print(1 if flag else mn)

Measured memory_bytes: 88428
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<ll,ll>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):0;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    inline ll qpower(ll x,ll e)
    {
        ll ans=1;
        while(e){if(e&1)ans=ans*x%MOD;x=x*x%MOD;e>>=1;}
        return ans;
    }
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

	int op;
	struct SGT
	{
		pr mx[N*4];
		pr merg(pr x,pr y)
		{
			int a[5];a[0]=x.FR,a[1]=x.SE,a[2]=y.FR,a[3]=y.SE;
			sort(a,a+4);if(op==1)return MP(a[0],a[1]); else return MP(a[3],a[2]);
		}
		void insert(int x,int l,int r,int pos,int num)
		{
			if(l==r){mx[x].FR=num;return;}
			if(pos<=(l+r)/2) insert(2*x,l,(l+r)/2,pos,num);
			else insert(2*x+1,(l+r)/2+1,r,pos,num);
			mx[x]=merg(mx[2*x],mx[2*x+1]);
		}
		pr ask(int x,int l,int r,int fl,int fr)
		{
			if(fl>fr) return mx[0];
			if(l==fl and r==fr) return mx[x];
			if(fr<=(l+r)/2) return ask(2*x,l,(l+r)/2,fl,fr);
			else if(fl>(l+r)/2) return ask(2*x+1,(l+r)/2+1,r,fl,fr);
			return merg(ask(2*x,l,(l+r)/2,fl,(l+r)/2),ask(2*x+1,(l+r)/2+1,r,(l+r)/2+1,fr));
		}
	}sgt[2]; 
	pr x[N],y[N];int a[N];
	void main()
	{
		int n=qread();for(int i=1;i<=n;i++) a[i]=qread();
		op=0;for(int i=1;i<=n;i++) x[i]=sgt[0].ask(1,1,n,a[i]+1,n),sgt[0].insert(1,1,n,a[i],i);
		op=1;for(int i=0;i<N*4;i++) sgt[1].mx[i]=MP(n+1,n+1);
		for(int i=n;i>=1;i--) y[i]=sgt[1].ask(1,1,n,a[i]+1,n),sgt[1].insert(1,1,n,a[i],i);
		ll ans=0;
		for(int i=1;i<=n;i++)
		{
			ll cnt=0;
			if(x[i].FR>0) cnt+=1ll*((x[i].FR-x[i].SE)*(y[i].FR-i));
			if(y[i].FR<=n) cnt+=1ll*((i-x[i].FR)*(y[i].SE-y[i].FR));
			ans+=cnt*a[i];
		}
		write(ans);
	}
};
int main()
{
	mine::main();
}

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

int main(int argc, char const *argv[])
{
    int r, d, x;
    cin >> r >> d >> x;

    int output;

    for(int i = 0; i < 10; i++){
        output = r * x - d;
        cout << output << endl;
        x = output;        
    }
    
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
全証言 = N.times.map{
	gets.to_i.times.inject([0,0]){|(正直,不正直),| # 自己矛盾はなし
		x, y = gets.split.map(&:to_i)
		next [正直|(y<<(x-1)), 不正直|((1-y)<<(x-1))]
	}
}
F = lambda{|_| b, c = _
	正直, 不正直 = (0...N).select{|i| b[i]==1 }.map{|i| 全証言[i] }.inject([0,0]){|(a,b),(c,d)| [a|c, b|d] }
	next 正直|b, 不正直|c if (正直|b)^b==0
	next F.call [正直|b, 不正直|c]
}
全証言 = 全証言.map(&F)
p (2**N).times.map{|b| F.call [b,0] }.select{|正直,不正直| 正直&不正直==0 }.map{|正直,| (0...N).count{|i| 正直[i]==1 } }.max


Measured memory_bytes: 6396
import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(N-1)]
Query=[list(map(int,input().split())) for i in range(Q)]
mod=10**9+7

EDGELIST=[dict() for i in range(N+1)]
for x,y,c,l in EDGE:
    EDGELIST[x][y]=(c,l)
    EDGELIST[y][x]=(c,l)
    
# LCA(オイラーツアー＋Segment tree)

DEPTH=[-1]*(N+1)
DEPTH[1]=0

from collections import deque
QUE = deque([1])
QUE2 = deque()
EULER=[]#(i,j)で,(1からツアーで辿った点の深さ,そのindex)

USED=[0]*(N+1)
while QUE:
    x=QUE.pop()
    EULER.append((DEPTH[x],x))
    if USED[x]==1:
        continue
    for to in EDGELIST[x]:
        
        if USED[to]==0:
            DEPTH[to]=DEPTH[x]+1
            QUE2.append(to)
        else:
            QUE.append(to)
    QUE.extend(QUE2)
    QUE2=deque()
 
    USED[x]=1

MINP=[1<<30]*(N+1)
MAXP=[-1]*(N+1)

for ind,(depth,p) in enumerate(EULER):
    MINP[p]=min(MINP[p],ind)
    MAXP[p]=max(MAXP[p],ind)

LEN=len(EULER)

seg_el=1<<(LEN.bit_length())#Segment treeの台の要素数
SEG=[(1<<30,0)]*(2*seg_el)#1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

for i in range(LEN):#Dを対応する箇所へupdate
    SEG[i+seg_el]=EULER[i]

for i in range(seg_el-1,0,-1):#親の部分もupdate
    SEG[i]=min(SEG[i*2],SEG[i*2+1])

def update(n,x,seg_el):#A[n]をxへ更新（反映）
    i=n+seg_el
    SEG[i]=x
    i>>=1#子ノードへ
    
    while i!=0:
        SEG[i]=min(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r):#区間[l,r)に関するminを調べる
    L=l+seg_el
    R=r+seg_el
    ANS=(1<<30,0)

    while L<R:
        if L & 1:
            ANS=min(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=min(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

def LCA(l,r):
    return getvalues(min(MINP[l],MINP[r]),max(MAXP[l],MAXP[r])+1)

N_q=[[] for i in range(N+1)]
for ind,(c,pl,x,y) in enumerate(Query):
    N_q[x].append([ind,c,pl,1])
    N_q[y].append([ind,c,pl,1])
    N_q[LCA(x,y)[1]].append([ind,c,pl,0])

ANS=[0]*Q

LENG=0
C_LENGTH=[0]*N
C_SUM=[0]*N

for i in range(1,len(EULER)):
    ind=EULER[i][1]
    c,l=EDGELIST[EULER[i-1][1]][ind]
    if EULER[i][0]>EULER[i-1][0]:
        LENG+=l
        C_LENGTH[c]+=l
        C_SUM[c]+=1

        for que,c,pl,boo in N_q[ind]:
            if boo==1:
                ANS[que]+=LENG+C_SUM[c]*pl-C_LENGTH[c]

            else:
                ANS[que]-=(LENG+C_SUM[c]*pl-C_LENGTH[c])*2
            
    else:
        LENG-=l
        C_LENGTH[c]-=l
        C_SUM[c]-=1

for ans in ANS:
    print(ans)


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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> sunuke(N, 0);

  int tmp;
  int tmp2;
  for(int i=0; i<K; i++){
    cin >> tmp;
    for(int j=0; j<tmp; j++){
      cin >> tmp2;
      sunuke[tmp2-1] += 1;
    }
  }

  int sum = 0;
  for(int i=0; i<N; i++){
    if(sunuke[i] == 0) sum += 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    
    
    double N, M;
    long long sum = 0;
    
    
    cin >> N >> M;
    vector<double> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }
    
    
    
    double miman = sum / (4 * M);
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(A[i] >= miman){
            ans++;
        }
    }
    
    if(ans >= M){
        cout << "Yes" << endl;
        return 0;
    }

    else cout << "No" << endl;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
double kitaiti(double n){
    double sum = 0;
    for(int i = 1; i <= n; i++){
        sum += i;
    }
    return sum / n;
}
int main(){
    int n, k;
    cin >> n >> k;
    vector<double> p(n);
    for(int i = 0; i < n; i++){
        double v;
        cin >> v;
        p[i] = kitaiti(v); 
    }
    vector<double> v(n+1, 0);
    for(int i = 0; i < n; i++){
        v[i+1] = v[i] + p[i];
    }
    double ans = -INF;
    for(int i = 0; i <= n-k; i++){
        double val = v[i+k] - v[i];
        if(ans < val) ans = val;
    }
    printf("%lf\n", ans);
}


Measured memory_bytes: 3328
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
b = []
for i in range(N):
  a = 0
  for j in range(i+1):
    a += A1[j]
  for k in range(i,N):
    a += A2[k]
  b.append(a)
print(max(b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
char s[40];
int main () {
	scanf("%s", s);
	for (int i=0; i<4; i++) printf("%c", s[i]);
	printf(" ");
	for (int i=4; i<12; i++) printf("%c", s[i]);
	printf("\n");
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



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

    ll n; cin >> n;
    vll a(n); 
    REP(i,n) cin >> a[i];
    map<ll,ll>m;
    REP(i,n){
        if (m[a[i]]){
            cout << "NO";
            return 0;
        }
        m[a[i]]++;
    }
    cout << "YES";
    return 0;
}



Measured memory_bytes: 14336
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r,t){"use strict";function n(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=e[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){for(var r=n(e[0].split(" ").map(function(e){return Number(e)}),2),t=r[0],o=r[1],u=e[1].split(" ").map(function(e){return Number(e)}),i=0,f=0;f<t;f++)u[f]>=o&&i++;console.log(i)}},function(e,r){e.exports=require("fs")}]);

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

int main(){
int W,H,x,y,r;
cin >> W >> H >> x >> y >> r;

if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int n;
    string s;
    cin >> n >> s;
    int w = 0, cw = 0, cr = 0;
    for (char c : s)
        if (c == 'W') ++w;
    if (w == 0 || w == n) {
        cout << 0;
        return 0;
    }
    for (int i = 0; i < n - w; ++i) {
        if (s[i] == 'W') ++cw;
    }
    for (int i = n - w; i < n; ++i)
        if (s[i] == 'R') ++cr;
    cout << min({cw, cr, w, n - w});
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n,m,qr;
    scanf("%d%d%d",&n,&m,&qr);
    int t[n][n];
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            t[i][j]=0;
        }
    }
    for (int i=0; i<m; i++){
        int l,r;
        scanf("%d%d",&l,&r);
        l--;
        r--;
        t[l][r]++;
    }
    for (int i=0; i<n; i++){
        for (int j=i; j<n; j++){
            t[i][j]+=t[i][j-1];
        }
    }
    
    
    
    for (int i=0; i<qr; i++){
        int p,q,ans=0;
        scanf("%d%d",&p,&q);
        p--;
        q--;
        for (int j=p; j<=q; j++){
                ans+=t[j][q];
        }
        printf("%d\n",ans);
    }
	return 0 ;
}

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

int main(){
	int n, i, j;
	int cards[4][13] = {0};
	char suit; //?????????
	int num;
	
	cin >> n;
	
	for(i = 0; i < n; i++){
		cin >> suit >> num;
		
	if(suit == 'S'){
		cards[0][num - 1]++;
	}else if(suit == 'H'){
		cards[1][num -1]++;
	}else if(suit == 'C'){
		cards[2][num - 1]++;
	}else{
		cards[3][num - 1]++;
	}

}
	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			if(cards[i][j] == 0){
				if(i == 0){
					cout << 'S' << " " << j + 1 << endl;
				}else if(i == 1){
					cout << 'H' << " " << j + 1 << endl;
				}else if(i == 2){
					cout << 'C' << " " << j + 1 << endl;
				}else{
					cout << 'D' << " " << j + 1 << endl;
				}
			}
		}
	}
	
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> x(n);
  for(int i = 0; i < n; i++) cin >> x.at(i);
  
  int ans = 1e9;
  for(int i = 1; i <= 100; i++){
    int keep = 0;
    for(int j = 0; j < n; j++){
      keep += (x.at(j) - i) * (x.at(j) - i);
    }
    ans = min(ans, keep);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
from heapq import *

n, m = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapify(A)

for _ in range(m):
    max_a = heappop(A)*(-1)
    max_a //= 2
    heappush(A, -max_a)
print(-sum(A))

Measured memory_bytes: 20360
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var A = long.Parse(inputs[0]);
        var B = long.Parse(inputs[1]);
        var K = long.Parse(inputs[2]);

        for (int i = 0; i < K; i++)
        {
            if (i % 2 == 0)
            {
                SetNextValue(ref A, ref B);
            }
            else
            {
                SetNextValue(ref B, ref A);
            }
        }

        Console.WriteLine(A + " " + B);
    }

    static void SetNextValue(ref long target1, ref long target2)
    {
        if (target1 % 2 == 1)
        {
            target1--;
        }

        long give = target1 / 2;
        target1 -= give;
        target2 += give;
    }


}



Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <climits>
#include <map>
#include <unordered_map>
#include <string>
#include <ctime>
#include <unistd.h>

using namespace std;
#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define mp make_pair
#define pb push_back
#define fi first
#define sd second
#define fu(A, B, C) for(ll (A) = (B); (A) < (C); (A)++)
#define fu0(A, B) fu((A), 0, (B))
#define fd(A, B, C) for(ll (A) = (B); (A) >= (C); (A)--)
#define mem(A, B) memset((A), (B), sizeof((A)))
#define vd(A, B, C) vector<ll> (A)((B), (C))
#define v2d(A, B, C) vector<vector<int>> (A)((B), vector<int> (C));
#define all(x) (x.begin(), x.end())
#define endl "\n"
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;

ll gcd(int a, int b){if(!a)return b;return gcd(b%a,a);}

void perform() {
  int k; string s; cin >> k >> s;
  if (s.size() <= k) cout << s << endl;
  else cout << s.substr(0, k) << "..." << endl;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  ll t = 1; //cin >> t;
  while(t--) {perform();}
}


Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 * 
 * https://atcoder.jp/contests/abc177/submissions/16388865 にも参考
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			int[] a = new int[h], b = new int[h];
			IntStream.range(0, h).forEach(i -> {
				a[i] = scanner.nextInt() - 1;
				b[i] = scanner.nextInt();
			});
			SortedMap<Integer, Integer> currToOrigin = new TreeMap<>();
			IntStream.range(0, w).forEach(j -> currToOrigin.put(j, j));
			int[] gaps = new int[w], results = new int[h];
			gaps[0] = w;
			Arrays.fill(results, -1);
			int minGapIndex = 0, maxGapIndex = 0;
			for (int i = 0; (i < h) && !currToOrigin.isEmpty(); i++) {
				int left = a[i], right = b[i];
				SortedMap<Integer, Integer> subMap = currToOrigin.subMap(left, right);
				if (!subMap.isEmpty()) {
					int maxOrigin = subMap.get(subMap.lastKey());
					subMap.forEach((key, value) -> gaps[key - value]--);
					subMap.clear();
					if ((right < w) && !currToOrigin.containsKey(right)) {
						currToOrigin.put(right, maxOrigin);
						gaps[right - maxOrigin]++;
						maxGapIndex = Math.max(maxGapIndex, right - maxOrigin);
					}
					while ((minGapIndex <= maxGapIndex) && (0 == gaps[minGapIndex])) {
						minGapIndex++;
					}
				}
				results[i] = (minGapIndex <= maxGapIndex) ? minGapIndex + i + 1 : -1;
			}
			Arrays.stream(results).forEach(System.out::println);
		}
	}
}


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

int main(void) {
    int n, m;
    scanf("%d%d", &n, &m);
    vector<pair<int, int>> ab;

    for (int i = 0; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        ab.emplace_back(a, b);
    }
    sort(ab.begin(), ab.end());

    multiset<int> st;
    int i = 0;
    long long ans = 0;
    for (int d = 1; d <= m; d++) {
        while (i < ab.size() && ab[i].first == d) st.insert(ab[i++].second);

        if (st.size() > 0) {
            auto it = st.end();
            it--;
            ans += *it;
            st.erase(it);
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5748
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "stack"

using namespace std;
typedef long long ll;

int main()
{
  string x;
  cin >> x;
  int size = x.size();
  stack<char> s;
  for (int i = 0; i < size; i++)
  {
    if (x[i] == 'S')
    {
      s.push('S');
    }
    else
    {
      if (s.empty() == true || s.top() == 'T')
      {
        s.push('T');
      }
      else
      {
        s.pop();
      }
    }
  }
  cout << s.size() << "\n";
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  for (int _ = 0; _ < n; ++_) {
    V<> a(10); for (int i = 0; i < 10; ++i) cin >> a[i];
    bool ok = false;
    for (int bit = 0; bit < 1 << 10; ++bit) {
      V<> b, c;
      for (int i = 0; i < 10; ++i) if (bit & 1 << i) {
        b.push_back(a[i]);
      } else {
        c.push_back(a[i]);
      }
      if (is_sorted(begin(b), end(b)) and is_sorted(begin(c), end(c))) {
        ok = true;
        break;
      }
    }
    cout << (ok ? "YES" : "NO") << '\n';
  }
}


Measured memory_bytes: 3176