akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		WriteLine(new HashSet<int>(G).Count == 1 ? "Yes" : "No");
	}
}


Measured memory_bytes: 13408
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    for(int i = 0;i < S.length();i++){
        if(i % 2)continue;
        cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    vector<vector<int>> a(n,vector<int>(26,0));
    rep(i,n){
        a[i][s[i]-'a']++;
    }
    rep(i,n-1){
        rep(j,26){
            a[i+1][j] += a[i][j];
        }
    }
    ll ans = 0;
    for (int i = n - 1; i >= 1; i--){
        rep(j,26){
            if (s[i]-'a' == j) continue;
            ans += a[i-1][j];
        }
    }
    PRINT(ans+1);
}


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

const int M = 1e9+7;

long long int power(long long int x, long long int n, long long int M)
{
  long long int res = 1;
  if(n > 0){
    res = power(x,n/2,M);
    if(n % 2 == 0) res = (res*res)%M;
    else res = (((res*res)%M)*x)%M;
  }
  return res;
}

int main()
{
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  long long int fact[H+W-1];
  long long int rfact[H+W-1];
  fact[0] = rfact[0] = 1;
  for(int i = 1; i < H+W-1; i++){
    fact[i] = (fact[i-1]*i)%M;
    rfact[i] = power(fact[i],M-2,M);
  }
  long long int ans = 0;
  for(int i = B+1; i <= W; i++){
    long long int x = (((fact[H-A+i-2]*rfact[H-A-1])%M)*rfact[i-1])%M;
    x *= (((fact[A+W-i-1]*rfact[W-i])%M)*rfact[A-1])%M;
    ans += x%M;
  }
  cout << ans%M << endl;
}

Measured memory_bytes: 3328
import re

s = input().replace('?', '.')
t = input()

for i in range(len(s)-len(t), -1, -1):
    if re.match(s[i:i+len(t):], t):
        s = s.replace('.', 'a')
        print(s[:i:]+t+s[i+len(t)::])
        exit()
print('UNRESTORABLE')

Measured memory_bytes: 9720
#include <stdio.h>

void change(char S[64],int K);

int main(void){
    int N,K;
    char S[64];
    
    scanf("%d %d",&N,&K);
    scanf("%s",S);
    //printf("%d %d %s\n",N,K,S);
    
    change(S,K);
    
    printf("%s\n",S);
    
    return 0;
}

void change(char S[64],int K){
    if(S[K - 1] == 'A'){
        S[K - 1] = 'a';
    }else if(S[K - 1] == 'B'){
        S[K - 1] = 'b';
    }else{
        S[K - 1] = 'c';
    }
    
    return;
}


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

int main()
{
   long long int i,j,k,l,m,n,p;
  string s;
  cin>>s;
  n=s.size();
  p=0;
  for(i=0;i<n;i++)
  {
    if(s[i]=='L' && i%2==0)
    {
      p=1;
    } 
    if(s[i]=='R' && i%2!=0)
    {
      p=1;
    }
  }
  if(p==0)
  {
    cout<<"Yes\n";
  }
  if(p==1)
  {
    cout<<"No\n";
  }
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

a = 0 # (
b = 0 # )
for i in range(N):
  if S[i] == '(':
    a += 1
  else:
    if a > 0:
      a -= 1
    else:
      b += 1

ans = "".join(S)
if b > 0:
  ans = "("*b + ans
if a > 0:
  ans = ans + ")"*a
print(ans)


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

int main() {
  cout << fixed << setprecision(0);
  long long n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  cout << ceil((n-1) / min(a,min(b,min(c,min(d,e))))) + 5 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0){
    cout<<(b-a)/2<<endl;
  }else{
    long long t=min(a-1,n-b);
    if(a-1<=n-b){
      cout<<t+1+((b-(t+1))-1)/2<<endl;
    }else{
      cout<<t+1+(n-(a+(t+1)))/2<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#import numpy as np
#import collections
#import math

#f = open('./input_C.txt')

#f.readline()
#int(f.readline())
#map(int, f.readline().split())
#list(map(int, f.readline().split()))

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

highest = A[0]
dai = 0

for Ai in A[1:]:
    if Ai <= highest:
        dai += highest-Ai
    else:
        highest = Ai

ans = dai
print(ans)

Measured memory_bytes: 94144
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int area = Integer.parseInt(s[0]) * Integer.parseInt(s[1]) / 2;
    System.out.println(area);
  }
}

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

map<string, int> mapeo;

int main()
{	
	int n;
	cin>>n;
	bool res=true;
	string s;
	string sl;
	bool last= false;
	while(n--)
	{
		cin>>s;
		if(last)
		{
			if(mapeo[s] == 0)
			{
				mapeo[s] = 1;
				if(sl[sl.length()-1] != s[0])
				{
					res =false;
				}
			}
			else
			{
				res = false;
			}
			sl = s;
		}else
		{
			sl = s;
			last = true;
			mapeo[s] = 1;
		}
		//cout<<mapeo[s]<<endl;
	}
	if(res)
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

using namespace std;

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

	int ans = 0;

	for (int i = '0'; i <= '9'; i++)
	{
		for (int j = '0'; j <= '9'; j++)
		{
			for (int k = '0'; k <= '9'; k++)
			{

				int pointer_b = 0;

				for (char &val : s)
				{
					if (pointer_b == 0 && val == i)
					{
						pointer_b++;
					}
					else if (pointer_b == 1 && val == j)
					{
						pointer_b++;
					}
					else if (pointer_b == 2 && val == k)
					{
						pointer_b++;
					}

					if (pointer_b == 3)
					{
						ans++;
						break;
					}
				}
			}
		}
	}

	cout << ans << endl;
}
//g++ -std=c++17 -g main.cpp -o mai	n


Measured memory_bytes: 3220
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	string a, b, c;
	cin >> a >> b >> c;
	int t = 'a' - 'A';
	printf("%c%c%c\n", a[0] - t, b[0] - t, c[0] - t);

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication21
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                int n = int.Parse(Console.ReadLine());
 
                if (n == 0)
                {
                    break;
                }
 
                string[] str = Console.ReadLine().Split(' ');
 
                int[] S = new int[n];
                int sum1 = 0;
 
                for (int i = 0; i < n; ++i)
                {
                    S[i] = int.Parse(str[i]);
                    sum1 += S[i];
                }
 
                double m = (double)sum1 / n;
 
                double sum2 = 0;
 
                for (int i = 0; i < n; ++i)
                {
                    sum2 += Math.Pow((S[i] - m), 2);
                }
 
                double a = Math.Sqrt(sum2 / n);
 
                Console.WriteLine("{0:f8}",a);
 
            }
        }
    }
}

Measured memory_bytes: 5744
n = int(input())

list1 = input().split()
list2 = []
for i in range(0,len(list1)):
    list2.append(int(list1[i]))
count = 0
if(n<=2):
    count = 0
for i in range(n):
    if(i+2==len(list2)):
        continue
    for j in range(i+1,n):
        if(i+1==len(list2)):
            continue
        for k in range(j+1,n):
            if(list2[i] != list2[j] and list2[i] != list2[k] and list2[j] != list2[k]):
                ma = max(list2[i],list2[j],list2[k])
                mi = min(list2[i],list2[j],list2[k])
                tyuukann = list2[i]+list2[j]+list2[k]-ma-mi
                if(ma<mi+tyuukann):
                    count = count + 1

print(count)


Measured memory_bytes: 9168
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}
		int zahyo = 0;
		int num = 0;
		for (int i = 0; i < n; i++) {
			zahyo += list.get(i);
			if (zahyo > x) {
				break;
			} else {
				num++;
			}
		}
		System.out.println(num + 1);
	}
}

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


using namespace std;

template <typename T>
class arr {
  int n;
  T *a;
  void raise(int x) {
    T *b=a;
    a=new T[x];
    copy(b,b+n,a);
    delete b;
  }
  T& operator << (T x) {
    if ((n&-n)==n) {
      raise(n<<1);
    }
    a[n++]=x;
  }
  void resize(int x) {
    if (n<x) {
      raise(1<<(32-__builtin_clz(x)));
    }
    n=x;
  }
  arr() {
    n=0;
    a=NULL;
  }
  arr(int x) {
    n=0;
    a=NULL;
    resize(x);
  }
  T& operator << (int x) {
    return a[x];
  }
};

int main() {
  int n;
  int m;
  int d;
  cin>>n>>m>>d;
  if (n-d<0) {
    puts("0");
  } else if (d==0) {
    printf("%.9f\n",(((double)(m-1)*(double)(n-d))/(double)((double)n*n)));
  } else {
    printf("%.9f\n",(((double)(m-1)*(double)(n-d)*2)/(double)((double)n*n)));
  }
  return 0;
}


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

int main() {

	int N, A, B;
	cin >> N >> A >> B;

	int S = 0;

	for (int i = 1; i <= N; i++) {

		int sum = 0;
		int t = i;

		while (t) {
			sum += t % 10;
			t = t/10;
		}


		if (sum >= A && sum <= B) {
			S += i;
		}
	}

	cout << S << endl;

	return 0;
	
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

int main(){
	ll n;
	ll maxnum = 0,now=-1,nowpoint=1000000000000,a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (nowpoint>=a) {
			nowpoint = a;
			now++;
		}
		else {
			maxnum = max(maxnum, now);
			now = 0;
			nowpoint = a;
		}
	}
	cout<<max(maxnum,now)<<endl;
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] line = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int A = Math.Abs(line[1] - line[0]);
            int B = Math.Abs(line[2] - line[0]);
            Console.WriteLine(A < B ? "A" : "B");
        }
    }
}

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

// A - A?C
int main() {
    int N, K;
    cin >> N >> K;

    vector<bool> havePersons(N);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int person;
            cin >> person;
            havePersons.at(person - 1) = true;
        }
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (havePersons.at(i) == false) {
            count++;
        }
    }
    cout << count;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  vector<string> kws({"dream", "dreamer", "erase", "eraser"});

  string S; cin >> S;
  while (S.size() > 0) {
    bool progress = false;
    for (string kw: kws) {
      if (S.size() < kw.size()) continue;
      if (S.substr(S.size() - kw.size(), kw.size()) == kw) {
	progress = true;
	S.resize(S.size() - kw.size());
	break;
      }
    }
    if (!progress) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m; cin>>n>>m;
    ll arr[n],ans=1;
    bool flag=1;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        arr[i]/=2;
        ans=(ans*arr[i])/__gcd(ans,arr[i]);
        if(ans>m){
            flag=0;
            break;
        }
    }
    
    if(flag==0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if((ans/arr[i])%2==0) flag=0;
    }
    if(flag==0){
        cout<<0<<endl;
        return 0;
    }
    ans=m/ans;
    if(ans%2==0) ans=ans/2;
    else ans=(ans/2)+1;
    cout<<ans<<endl;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int INF = INT_MAX/3;
const double EPS = 1e-14;

template<typename U, typename T>
void chmin(U &x, T y) { x = min(x, y); }

template<typename U, typename T>
void chmax(U &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> P;

int W, H;
const int HMAX = 58, WMAX = 58;
char field[HMAX][WMAX];
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ostringstream debug;

bool outof_range(int y, int x) {
  return y < 0 || H <= y || x < 0 || W <= x;
}

void dfs(int y, int x, char c, char target) {
  stack<P> st;
  st.push(P(y, x));
  while (!st.empty()) {
    P top = st.top(); st.pop();
    int y = top.first, x = top.second;
    if (outof_range(y, x) || field[y][x] != target) continue;
    field[y][x] = c;
    REP(i, 4) {
      st.push(P(y + dy[i], x + dx[i]));
    }
  }
}

int main() {
  cout << fixed << setprecision(10);
  while (cin >> W >> H and W) {
    REP(y, HMAX) REP(x, WMAX) {
      field[y][x] = '#';
    }
    REP(y, H) {
      string row; cin >> row;
      REP(x, W) {
        field[y][x] = row[x];
      }
    }
    REP(y, H) REP(x, W) {
      if (field[y][x] == 'W') {
        REP(i, 4) {
          dfs(y + dy[i], x + dx[i], 'w', '.');
        }
      }
      if (field[y][x] == 'B') {
        REP(i, 4) {
          dfs(y + dy[i], x + dx[i], 'b', '.');
        }
      }
    }
    REP(y, H) REP(x, W) {
      if (field[y][x] == 'W') {
        REP(i, 4) {
          dfs(y + dy[i], x + dx[i], 'x', 'b');
        }
      }
      if (field[y][x] == 'B') {
        REP(i, 4) {
          dfs(y + dy[i], x + dx[i], 'x', 'w');
        }
      }
      if (field[y][x] == 'x') {
        REP(i, 4) {
          dfs(y + dy[i], x + dx[i], 'x', 'w');
          dfs(y + dy[i], x + dx[i], 'x', 'b');
        }
      }
    }
    int white = 0, black = 0;
    REP(y, H) REP(x, W) {
      char c = field[y][x];
      if (c == 'w') { white++; }
      if (c == 'b') { black++; }
    }
    cout << black << " " << white << endl;
  }
  return 0;
}

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

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int pass = 0;
    int rankb = 0;
    rep(i, n) {
        if(s.at(i) == 'a') {
            if(pass < a + b) {
                pass++;
                cout << "Yes" << endl;
            } else cout << "No" << endl;
        }
        if(s.at(i) == 'b') {
            if(pass < a + b && rankb < b) {
                pass++;
                cout << "Yes" << endl;
            } else cout << "No" << endl;
            rankb++;
        }
        if(s.at(i) == 'c') {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

    int dy[]={0, 0, 1, -1, 0};
    int dx[]={1, -1, 0, 0, 0};


    int main()
    {
    int n;
    cin>>n;
    vector<int> h(n,0);
    vector<int> c(n,0);
    REP(i,n) cin>>h[i]; //高さ
    int ans=0;
    for(int i=0; i<n; i++)
    {
        int d= h[i] -c[i];
        ans+=d;
        for(int j=i; j<n; j++)
        {
            d =min(d, h[j]-c[j]); //減らしている
            c[j]+=d;
        }

    }
        cout<<ans<<endl;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
// priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
priority_queue<ll> PQ;

int main(){
  int l,r,d;
  int t;
  scanf("%d %d %d", &l, &r, &d);

  int ans = 0;
  int i;
  for(i = l;i <= r;i++){
    if(i % d == 0) ans++;
  }

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

  return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  rep(i,n) cin >> m[i];
  
  int count = 0;
  
  rep(i,n){
    x -= m[i];
    count++;
  }
  
  sort(m.begin(),m.end());
  
  count += x/m[0];
  
  cout << count;
  
  return 0;
}

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


int main()
{
  string s;
  cin >> s;
  int first,last;
  for(int i=0;i<s.length();i++){
    if(s[i]=='A'){
      first = i;
      break;
    }
  }
  for(int i=s.length()-1;i>=0;i--){
    if(s[i]=='Z'){
      last = i;
      break;
    }
  }
  cout << last - first +1 << endl;
}




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

int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << ' ' << (w / 2 == x && h / 2 == y ? 1 : 0) << '\n';
    return 0;
}

Measured memory_bytes: 256
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N = inp()
count = dict()
while N:
    s = input()
    if s in count:
        count[s] += 1
    else:
        count[s] = 1
    N -= 1
m = max(count.values())
res = []
for key, value in count.items():
    if value == m:
        res.append(key)
res = sorted(res)
for i in res:
    print(i)


Measured memory_bytes: 32984
n = int(input())
s = input()
t = input()
same = []
for i in range(n):
  if t[0:i+1] == s[len(s)-1-i:len(s)]:
    same.append(t[0:i+1])
if len(same) == 0:
  m = 0
else:
  m = len(same[len(same)-1])
print(len(s)+len(t)- m)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll tnum = (C + B - 1) / B;
    ll anum = (A + D - 1) / D;
    bool ok = true;
    if (anum < tnum) { 
        ok = false;
    }
    yesno(ok);
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

void solve();
int main() {
	solve();
#ifdef DBG
	while (true);
#endif
}
template<int _size>
class Union_tree
{
public:
	Union_tree() {
		for (int i = 0; i < _size; i++)
			root[i] = i;
		for (int i = 0; i < _size; i++)
			branchs[i] = 1;
	}
	int find(int node) {
		if (root[node] == node)
			return node;
		return root[node] = find(root[node]);
	}
	void merge(int node1, int node2) {
		int root1 = find(node1), root2 = find(node2);
		if (root1 == root2)
			return;
		if (root1 < root2) {
			int temp = root2;
			root2 = root1;
			root1 = temp;
		}
		branchs[root1] = branchs[root2];
		branchs[root2] = 0;
		root[root2] = root1;
	}
	bool same(int node1, int node2) {
		return find(node1) == find(node2);
	}
	int size(int node) {
		return branchs[find(node)];
	}
private:
	int root[_size], branchs[_size];
};
void solve() {
	int n, m, p[100000];
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", p + i);
	Union_tree<100000> tree;
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		tree.merge(x - 1, y - 1);
	}

	int count = 0;
	for (int i = 0; i < n; i++)
		if (tree.same(i, p[i] - 1))
			count++;
	printf("%d\n", count);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, c;
  ll k;
  cin >> a >> b >> c >> k;
  ll max_val = max(a, max(b, c)) * (pow(2, k) - 1);
  cout << a + b + c + max_val << endl;

  return 0;
}


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

int main() {
  int n;
  string s = "No";
  cin >> n;
  for (int i = 1; i <= 9; i ++) {
    if (n % i == 0 && n / i >= 1 && n / i <= 9) {
      s = "Yes";
      break;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M =1e9+ 7;
const int N = 2*1e5 + 1;
int mod(int m){
    m%=M;
    return (m+M)%M;
}


int okk(int n,int k){
	int a = n*(n+1)/2;
	int b = (n-k)*(n-k+1)/2;
	k--;
	int c = k*(k+1)/2;
	a = mod( a - c - b +1);
	return a;
}

int32_t main() { 
	int n,k;
	cin>>n>>k;
	int ans=0;
	for(int i=k;i<=n+1;i++){
		ans = mod(ans+okk(n,i));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct edge{
	ll to,cost,t;
};

struct state{
	ll d,city,ag;
};

bool operator>(const state& a,const state& b){
    return a.d>b.d;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,m,s;
	cin>>n>>m>>s;
	vector<vector<edge>> g(n);
	rep(i,m){
		ll u,v,a,b;
		cin>>u>>v>>a>>b;
		u--,v--;
		g[u].push_back({v,a,b});
		g[v].push_back({u,a,b});
	}
	vector<ll> c(n),d(n);
	rep(i,n){
		cin>>c[i]>>d[i];
	}
	ll ma=3000;
	chmin(s,ll(ma));
	vector<vector<ll>> dist(n,vector<ll>(10001,inf));//j==maは銀貨無限枚
	priority_queue<state,vector<state>,greater<state>> que;
	dist[0][s]=0;
	que.push({0,0,s});
	while(!que.empty()){
		auto now=que.top();
		que.pop();
		ll v=now.city,ag=now.ag;
		if(dist[v][ag]<now.d) continue;
		ll nag=min(ag+c[v],ma);
		if(chmin(dist[v][nag],dist[v][ag]+d[v])){
			que.push({dist[v][nag],v,nag});
		}
		for(auto to:g[v]){
			if(ag>=to.cost){
				if(chmin(dist[to.to][ag-to.cost],dist[v][ag]+to.t)){
					que.push({dist[to.to][ag-to.cost],to.to,ag-to.cost});
				}
			}
		}
	}
	FOR(i,1,n){
		ll ans=inf;
		rep(j,ma+1) chmin(ans,dist[i][j]);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 10336
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<double>(1e9+7);

inline long long mod_multiple(long long a,long long b){
	long long res=0;
	long long mir=a%mod;
	while(b) {
		if(b&1) {
			res+=mir;
			if(res>mod) {
				res-=mod;
			}
		}
		mir<<=1;
		if(mir>mod) {
			mir-=mod;
		}
		b>>=1;
	}
	return res;
}

int main() {
	int N,C;
	cin>>N>>C;
	vector<pair<int,int>> arr(N);
	for(auto& val:arr)
		cin>>val.first;
	for(auto& val:arr)
		cin>>val.second;

	vector<vector<long long>> sums(N+1,vector<long long>(C+1,0));
	for(int i=0;i<C+1;++i)
		sums[0][i]=0;
	for(int i=1;i<N+1;++i){
		vector<long long> tmp(arr[i-1].second-arr[i-1].first+1,1);
		sums[i][0]=tmp.size();

		for(int j=1;j<C+1;++j){
			for(int k=0;k<tmp.size();++k){
				//tmp[k]=mod_multiple(tmp[k],arr[i-1].first+k);
				tmp[k]=(tmp[k]*(arr[i-1].first+k))%mod;
				sums[i][j]=(sums[i][j]+tmp[k])%mod;
			}
		}
	}

	vector<vector<long long>> dp(N+1,vector<long long>(C+1,0));
	dp[0][0]=1;
	for(int i=1;i<C+1;++i)
		dp[0][i]=0;
	for(int i=0;i<C+1;++i)
		dp[1][i]=sums[1][i];

	for(int i=2;i<N+1;++i){
		for(int j=0;j<C+1;++j){
			for(int k=0;k<j+1;++k){
				dp[i][j]+=sums[i][k]*dp[i-1][j-k];//mod_multiple(sums[i][k],dp[i-1][j-k]);
				dp[i][j]%=mod;
			}
		}
	}

	cout<<dp[N][C]<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
#include <string.h>
int main()
{
    char weather1[1100];
    scanf("%s",weather1);
    if(strcmp(weather1,"Sunny")==0){
        printf("Cloudy");
    }else if(strcmp(weather1,"Cloudy")==0){
        printf("Rainy");
    }else{
        printf("Sunny");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
using namespace std;
int main() {
	int x,y ;
	int xg, yg;
	int group1[] = { 1,3,5,7,8,10,12 };
	int group2[] = { 4,6,9,11 };
	int group3[] = { 2 };
	cin >> x >> y;
	for (int i = 0; i <= 6; i++) {
		if (x == group1[i])  xg = 1;
		if (y == group1[i])  yg = 1;
	}
	for (int i = 0; i <= 3; i++) {
		if (x == group2[i])  xg = 2;
		if (y == group2[i])  yg = 2;
	}
	for (int i = 0; i <= 0; i++) {
		if (x == group3[i])  xg = 3;
		if (y == group3[i])  yg = 3;
	}
	if (xg == yg) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string t;
    cin >> t;
    int n = t.size();

    rep(i, n) {
        char c = t[i];
        if (i > 0 && t[i-1] == 'P' && t[i] == '?') t[i] = 'D';
        else if (i+1 < n && t[i+1] == 'D' && t[i] == '?') t[i] = 'P';
        else if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}

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

void fnInput(int& rnTrgSu, int& rnTrgKin)
{
  cin >> rnTrgSu >> rnTrgKin;
}

int fnRcsSch(int nPos, int nTrgSu, int nTrgKin, vector<int>& rvnNumMoney)
{
  vector<int> vnMoney{10000, 5000, 1000};

  if (nTrgKin < 0)  return -1;
  if (nPos == rvnNumMoney.size())
    if (nTrgKin)
      return 0;
    else
      return 1;

  if (nPos == 2)
  {
    rvnNumMoney[nPos] = nTrgSu;
    return fnRcsSch(nPos + 1, nTrgSu - nTrgSu, nTrgKin - vnMoney[nPos] * nTrgSu, rvnNumMoney);
  }
  else
    for (int i = 0; i <= nTrgSu; i++)
    {
      rvnNumMoney[nPos] = i;
      int nRtn = fnRcsSch(nPos + 1, nTrgSu - i, nTrgKin - vnMoney[nPos] * i, rvnNumMoney);
      if (nRtn == -1)  return 0;
      else if (nRtn)   return 1;
    }

  return 0;
}

int fnExhSch(int nTrgSu, int nTrgKin)
{
  vector<int> vnNumMoney(3);

  if (fnRcsSch(0, nTrgSu, nTrgKin, vnNumMoney))
    cout << vnNumMoney[0] << " " << vnNumMoney[1] << " " << vnNumMoney[2] << endl;
  else
    cout << -1 << " " << -1 << " " << -1 << endl;
}

int main()
{
  int nTrgSu, nTrgKin;
  
  fnInput(nTrgSu, nTrgKin);
  fnExhSch(nTrgSu, nTrgKin);

  return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

string keyword[2] = {"dream", "erase"};

int main(){
	string S;
	cin >> S;
	int n = S.length();
	int memo[n];
	for(int i = 0; i < n; i++){
		int flag = -1;
		if(n-i >= 5){
			if(S[i] == 'd'){
				flag = 0;
			}
			else if(S[i] == 'e'){
				flag = 1;
			}
		}
		if(flag != -1){
			for(int j = 1; j < 5; j++){
				if(S[i+j] != keyword[flag][j]){
					flag = -1;
					break;
				}
			}
		}
		if(flag == 0 && n-i >= 7){
			if(S[i+5] == 'e' && S[i+6] == 'r'){
				flag = 2;
			}
		}
		if(flag == 1 && n-i >= 6){
			if(S[i+5] == 'r'){
				flag = 3;
			}
		}
		memo[i] = flag;
	}
	int indexlist[n];
	for(int i = 0; i < n; i++){
		indexlist[i] = -1;
	}
	indexlist[0] = 0;
	int now = 0;
	int saveindex = 1;
	int flag = 0;
	while(indexlist[now] <= n){
		int index = indexlist[now];
		if(index == -1){
			break;
		}
		if(index == n){
			flag = 1;
			break;
		}
		if(memo[index] != -1){
			indexlist[saveindex] = index + 5;
			saveindex++;
		}
		if(memo[index] > 1){
			indexlist[saveindex] = index + 9 - memo[index];
			saveindex++;
		}
		now++;
	}
	if(flag == 1){
		cout << "YES\n";
	}
	else{
		cout << "NO\n";
	}
}

Measured memory_bytes: 1280
import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = []
b = []
for i in range(n):
    if i % 2 == 0:
        a.append(v[i])
    else:
        b.append(v[i])

a = Counter(a)
amc = a.most_common()
b = Counter(b)
bmc = b.most_common()
amc.append((0,0))
bmc.append((0,0))
rewrite = 0

if amc[0][0] == bmc[0][0]:
    rewrite = max(amc[0][1]+bmc[1][1],amc[1][1]+bmc[0][1])
else:
    rewrite = amc[0][1]+bmc[0][1]
print(n-rewrite)




Measured memory_bytes: 21172
#include <iostream>
#include <vector>
#include <cstdlib>
#include <climits>

using namespace std;
using ll = long long int;

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

    ll ans = LLONG_MAX;
    ll stmp = 0LL;
    for (int i = 0; i < n-1; ++i) {
        stmp += (long)a[i];
        ll tmp = abs(X - (2 * stmp));
        if (tmp < ans) ans = tmp;
    }

    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class DStringFormation {
public:
    static void solve(std::istream &cin, std::ostream &cout) {
        string s;
        cin >> s;
        deque<char> dq;
        for (int i = 0; i < s.size(); ++i) dq.push_back(s[i]);
        int q;
        cin >> q;
        vector<pair<int, pair<int, string>>> query;
        int direction = 1;
        for (int i = 0; i < q; ++i) {
            int t, f;
            char ss;
            cin >> t;
            if (t == 1) {
                direction *= -1;
            } else {
                cin >> f;
                cin >> ss;

                if (f * direction == 1 || f * direction == -2) {
                    dq.push_front(ss);
                } else {
                    dq.push_back(ss);
                }
            }
        }
        if (direction == -1) {
            while (!dq.empty()) {
                cout << dq.back();
                dq.pop_back();
            }
            cout << endl;
        } else {
            while (!dq.empty()) {
                cout << dq.front();
                dq.pop_front();
            }
            cout << endl;
        }
    }
};


int main() {
    DStringFormation solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 896
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let w: i32 = read();
    let a: i32 = read();
    let b: i32 = read();
    println!(
        "{}",
        if (a - b).abs() <= w {
            0
        } else {
            (a - b).abs() - w
        }
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    s = S()
    if s == ['R', 'S', 'R']:
        print(1)
    else:
        print(s.count('R'))
    return


if __name__ == "__main__":
    solve()


Measured memory_bytes: 65456
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())


for i in range(1,n):
    a[i] += a[i-1]

aa = a[:]

sgn = 1
r1 = 0
v = 0
for i in range(n):
    a[i] += v
    if sgn:
        if a[i] <= 0:
            r1 += -a[i]+1
            v += -a[i]+1
    else:    
        if a[i] >= 0:
            r1 += a[i]+1
            v -= a[i]+1
    sgn ^= 1
    

a = aa
sgn = 0
r2 = 0
v = 0
for i in range(n):
    a[i] += v
    if sgn:
        if a[i] <= 0:
            r2 += -a[i]+1
            v += -a[i]+1
    else:    
        if a[i] >= 0:
            r2 += a[i]+1
            v -= a[i]+1
    sgn ^= 1

#print(r1,r2)
print(min(r1,r2))

Measured memory_bytes: 20148
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	double M, m;
	double a; cin >> a; M = m = a;
	while (cin >> a) {
		M = max(M, a);
		m = min(m, a);
	}
	cout << fixed << setprecision(1);
	cout << M - m << endl;
	return 0;
}

Measured memory_bytes: 1280
object Main {
    def main(args : Array[String]) : Unit = {
        val input = io.StdIn.readLine().split(" ").map(_.toInt)
        println("%d %d %.8f".format(input(0) / input(1), input(0) % input(1), input(0).toDouble / input(1).toDouble))
    }
}

Measured memory_bytes: 43864
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	vi arr(n);
	unordered_map<int,int> m;
	REP(i,0,n-1){
		cin>>arr[i];
		m[arr[i]]++;
	}
	ll ans  = 0;
	for(auto i:m) ans+=i.S*(ll)(i.S-1)/2;
	for(int i:arr) {
		ll am = m[i];
		ll nans = ans;
		nans-=am*(am-1)/2;
		am--;
		nans+=am*(am-1)/2;
		cout<<nans<<"\n";
	}
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 11052
#include <iostream>
#include <locale>
#include <string>

int main()
{
    std::string s1, s2, s3;
    std::cin >> s1 >> s2 >> s3;

    const auto l = std::locale();
    std::cout << std::toupper(s1[0], l) << std::toupper(s2[0], l)
              << std::toupper(s3[0], l) << std::endl;
    return 0;
}


Measured memory_bytes: 3596
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int k = in.nextInt();
    int[] arr = new int[n];
    int i = 0;
    for(i = 0 ; i < n ; i++ ){
      arr[i] = in.nextInt();
    }
    Arrays.sort(arr);
    int sum = 0;
    for(i = 0 ; i < k ; i++)
      sum += arr[i];
    System.out.println(sum);
  }
}

Measured memory_bytes: 38884
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H;
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    H.push_back(h);
  }
  sort(H.rbegin(), H.rend());
  int start = min(K, N);
  ll ans = 0;
  for (int i = start; i < N; i++) {
    ans += H[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1400
import java.util.*;

public class Main {
    public static void main(String[] args) {

        solve_152_C();

        return;
    }

    private static void solve_152_C() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int P[] = new int[N];
        int count = 0;
        Boolean judge = false;

        for(int i=0; i<N; i++){
            P[i] = sc.nextInt();
        }
        int max = P[0];

        for(int i=0; i<N; i++) {
            int value = P[i];
            if(value <= max) count++;
            max = Math.min(max,value);
        }
        System.out.println(count);
    }
}

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

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

  map<ll, ll> a;

  ll tmp;
  for (ll i = 0; i < n; i++) {
    cin >> tmp;
    if (a[tmp] != 0) {
      cout << "NO" << endl;
      return 0;
    } else {
      a[tmp] += 1;
    }
  }
  cout << "YES" << endl;
}


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

#define abs(N) ((N>0)?N:-1*N)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

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

  if (N>999)
  {
    println("ABD");
  }else{println("ABC");}

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int gcd(int x, int y){
    if(y == 0) return x;
    return gcd(y, x%y);
}
 
int main(){
    int n;
    cin >> n;

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

    vector<int> left(n), right(n);
    left[0] = a[0];
    for(i=1; i < n; i++){
        left[i] = gcd(left[i-1], a[i]);
    }

    right[n-1] = a[n-1];
    for(i = n-2; i >= 0; i--){
        right[i] = gcd(right[i+1], a[i]);
    }
 
    int ans = 0;
    for(i = 0; i < n; i++){
        if(i == 0){
            ans = right[1];
        }else if(i == n-1){
            ans = max(ans, left[n-2]);
        }else{
            ans = max(ans, gcd(left[i-1], right[i+1]));
        }
    }
    cout << ans << endl;
    
    return 0;
}
	


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

int isprime(int);

int main() {
  int i,n,num[10000];
  int count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
    if(isprime(num[i]) == 1) count++;
  }
  printf("%d\n",count);
  return 0;
}

int isprime(int num){
  if(num < 2) return 0;
  else if(num == 2) return 1;
  else if(num % 2 == 0) return 0;

  int i,j,k,l;
  l = (int)sqrt(num);
  for(i=3;i<=l;i+=2){
    if(num%i == 0) return 0;
  }
  return 1;
}



Measured memory_bytes: 2064