akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,x;
    cin >> N >> x;
    if(x == 1 || x == 2 * N - 1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    queue<ll> q1 = queue<ll>();
    queue<ll> q2 = queue<ll>();
    if(x == 2 * N - 2){
        q2.push(x-1);
        q2.push(x+1);
        q2.push(x);
        q2.push(x-2);
        int i = 1;
        while(i <= 2 * N - 1) {
            if(i < x - 2 || x + 1 < i){
                q1.push(i);
            }
            i++;
        }
    }else{
        q2.push(x+1);
        q2.push(x-1);
        q2.push(x);
        q2.push(x+2);
        int i = 1;
        while(i <= 2 * N - 1) {
            if(i < x - 1 || x + 2 < i){
                q1.push(i);
            }
            i++;
        }
    }
    for (int i = 1; i <= 2 * N - 1; ++i) {
           if( N - 2  <= i && i <= N + 1){
                cout << q2.front() << " ";
                q2.pop();
            }else{
                cout << q1.front() << " ";
                q1.pop();
            }
    }

}


Measured memory_bytes: 3200
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int H=in(),W=in();
	vector<vector<int>> M(H,vector<int>(W));
	vector<int> V(W),A(H,0);
	REP(i,H){
		REP(j,W){
			M[i][j] = in();
		}
	}
	REP(i,W){
		V[i] = in();
	}

	REP(j,H){
		REP(k,W){
			A[j] += M[j][k]*V[k];
		}
	}

	for(auto& x:A){
		out(x);
	}

	return 0;
}



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

#define mp make_pair

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef pair<i64,int> pli;
typedef pair<int,i64> pil;
typedef pair<i64,i64> pll;
typedef vector<int> vi;
typedef vector<i64> vl;

template <typename T>
T id(T b) {return b;};
template <class It>
bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It>
bool any(It f,It l){return std::any_of(f,l,id<bool>);}

const int MAX_N = 100;
int n, a, b;

int main()
{
  cin >> n >> a >> b;
  int ac = 0, bc = 0, cc = 0, p;
  for (int i = 0; i < n; ++i) {
    cin >> p;
    if (p <= a) ac++;
    else if (p <= b) bc++;
    else cc++;
  }

  cout << min(ac, min(bc, cc)) << endl;


  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
 
using namespace std;
 
typedef long long ll;
 
#define MP make_pair
#define F first
#define S second
 
int main(){
	int n,m;
    cin >> n >> m;
    vector<string> g(n);
    vector<string> t(m);
    for(int i=0;i<n;i++){
    	cin >> g.at(i);
    }
    for(int i=0;i<m;i++){
    	cin >> t.at(i);
    }
    for(int i=0;i<n-m+1;i++){
    	int tmp = (int)g.at(i).find(t.at(0));
        if(tmp==-1){
        	continue;
        }else if(tmp>n-m){
        	continue;
        }else{
        	for(int j=0;j<m;j++){
            	if(g.at(i+j).substr(tmp,m)!=t.at(j)){
                	break;
                }
                if(j==m-1){cout<<"Yes"<<  endl; return 0;}
            }
        }
    }
    cout << "No" << endl;
}

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

int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}

int main(void){
    int n;
    scanf("%d",&n);
    int d[n];
    for (int i=0; i<n; i++){
        scanf("%d",&d[i]);
    }
    int m;
    scanf("%d",&m);
    int t[m];
    for (int i=0; i<n; i++){
        scanf("%d",&t[i]);
    }
    qsort (d,n,sizeof(int),sort); 
    qsort (t,m,sizeof(int),sort);
    int count=0;
    for (int i=0; i<n; i++){
        if (d[i]==t[count]){
            count++;
        }
    }
    if (count==m){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
	return 0 ;
}

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

// 累積和
struct cumulative_sum {
    using lint = long long;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz = 0) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint &operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int n, w;

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

int main() {
    cin >> n >> w;
    vector<vector<lint>> goods(4);
    lint w_0, v_0;
    cin >> w_0 >> v_0;
    goods[0].push_back(v_0);
    for (int i = 1; i < n; i++) {
        int s, t;
        cin >> s >> t;
        goods[s - w_0].push_back(t);
    }
    for (int i = 0; i < 4; i++) {
        sort(goods[i].begin(), goods[i].end(), greater<lint>());
    }
    vector<cumulative_sum> cum(4);
    for (int i = 0; i < 4; i++) {
        cum[i] = cumulative_sum(goods[i].size());
        for (int j = 0; j < goods[i].size(); j++) {
            cum[i][j] = goods[i][j];
        }
        cum[i].build();
    }
    lint ans = 0;
    for (int i = 0; i <= cum[0].sz; i++) {
        for (int j = 0; j <= cum[1].sz; j++) {
            for (int k = 0; k <= cum[2].sz; k++) {
                for (int l = 0; l <= cum[3].sz; l++) {
                    if (i * w_0 + j * (w_0 + 1) + k * (w_0 + 2) + l * (w_0 + 3) <= w) {
                        lint cand = cum[0].query(0, i) + cum[1].query(0, j) + cum[2].query(0, k) +
                                    cum[3].query(0, l);
                        chmax(ans, cand);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
area :: Int->Int->Int
area a b= a*b

perimeter ::Int->Int->Int
perimeter a b= 2*(a+b)


main ::IO()
main = do
  s<-getLine
  let a:b:_=map (\x -> read x ::Int) (words s)
  putStrLn ((show (area a b))++" "++(show (perimeter a b)))


Measured memory_bytes: 3588
// ABC067_A.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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



Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define mp make_pair
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
    char c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

const int MAX_N = 305;
const int MAX_M = 14005;
const int INF = 0x3f3f3f3f;

int a, b, k;

int main()
{
#ifdef ANONYM
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    Read(a) , Read(b), Read(k);
    int kk = k >> 1;
    for(int i=0; i<kk; i++) {
        if(a%2) a -= 1;
        a >>= 1;
        b += a;
        if(b%2) b -= 1;
        b >>= 1;
        a += b;
    }
    if(k%2) {
        if(a%2) a -= 1;
        a >>= 1;
        b += a;
    }
    printf("%d %d\n", a, b);
    return 0;
}


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

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

  return gcd(b, a%b);
}

int main(){
  while(true){
    int a, b;
    cin >> a >> b;

    if(cin.eof())
      break;

    int g = gcd(a, b);
    cout << g << ' ' << a/g*b << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort(reverse=True)  # 0(NlogN)
    F.sort()  # O(NlogN)

    def train(X, Y, T):  # O(N)    ans: 回数
        ans = 0
        for i in range(len(X)):
            ans += max(0, X[i] - T // Y[i])
        return ans

    ok = 10**18+1 #時間
    ng = -1

    while ok - ng > 1:
        mid = (ok + ng) // 2 #時間
        ans = train(A,F,mid)  #kaisuu
        if ans >K:
            ng =mid
        else:
            ok =mid

    print(ok)


if __name__ == "__main__":
    main()


Measured memory_bytes: 113692
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<j; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef pair<int, int> 		pii;

int main()
{
//	freopen("t.in","r",stdin);
//	freopen("t.out","w",stdout);
	IOS;
	int x, a, b;
	cin >> x >> a >> b;
	if(b<=a)
		puts("delicious");
	else if(b <= a+x)
		puts("safe");
	else
		puts("dangerous");
    return 0;
}

Measured memory_bytes: 256
N,M,C=map(int,input().split())
b_list=list(map(int,input().split()))
a_list=[]
for _ in range(N):
    a=list(map(int,input().split()))
    a_list.append(a)
cnt=0    
for i in a_list:
    ab=[j*k for j,k in zip(i,b_list)]
    hantei=sum(ab)+C
    if hantei>0:
        cnt+=1
print(cnt)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MXN = 50;

int main(){
    int n, m;
    int cnt[MXN] = {};
    cin >> n >> m;
    for(int i = 0, k, a; i != n; ++i)
    {
        cin >> k;
        while(k--)
        {
            cin >> a;
            ++cnt[a];
        }
    }
    int ans = 0;
    for(int i = 0; i <= m; ++i)
    {
        if(cnt[i] == n)
        {
            ++ans;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int p[n];for(int i=0;i<n;i++){cin>>p[i];p[i]--;}
  int a[n],b[n];
  a[p[0]]=30000*(p[0])+1;
  b[p[0]]=30000*(n-1-p[0])+1;
  for(int i=1;i<n;i++){
    int y=p[i-1],now=p[i];
    if(now>y){
      a[now]=a[y]+(now-y)*30000+1;
      b[now]=b[y]-(now-y)*30000;
    }
    else{
      a[now]=a[y]-(y-now)*30000;
      b[now]=b[y]+(y-now)*30000+1;
    }
  }
  for(int i=0;i<n;i++)cout<<a[i]<<" ";
  cout<<endl;
  for(int i=0;i<n;i++)cout<<b[i]<<" ";
  cout<<endl;
}
    

Measured memory_bytes: 896
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

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

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}
const int N = 2e5+5;
int n;
int dp[N];
int a[N],h[N];
int bit[N];


inline int lowbit(int x){
	return x & (-x);
}
int query(int x){
	int res = 0;
	for(;x;x -= lowbit(x)){
		res = max(res,bit[x]);
	}
	return res;
}

void add(int x,int y){
	for(;x <= n;x += lowbit(x)){
		bit[x] = max(bit[x],y);
	}
}

signed main(){
	IOS
	cin >> n;
	rep(i,n)	cin >> h[i];
	rep(i,n)	cin >> a[i];

	rep(i,n){
		dp[i] = query(h[i]) + a[i];
		add(h[i],dp[i]);
	}
	cout << query(n) << endl;

}


Measured memory_bytes: 6528
#include <iostream>
#include <cstring>

using namespace std;

int main() {
	
	char sentence;
	int count[26];
	int index, val;
	//cout << (int)'a' << " " << (int)'b' << " " <<(int)'z' <<" "<< (int)'A' <<" "<< (int)'B' <<" "<< (int)'Z' << endl;
	//cout << (char)65 << endl;
	//a->97 z->122
	//A->65 Z->90

	/*

	cin >> sentence;

	//cout << "len = " << strlen(sentence) << endl;

	//????????????????????????
	for (int i = 0; i < 26; i++) {
		count[i] = 0;
	}
		
	for (int i = 0; i < strlen(sentence); i++) {

		//65~90 97~122?????¨???????????????
		val = (int)sentence[i];
		//??§???????????¨???
		if (val >= 65 && val <= 90) {
			index = val - (int)'A';
			count[index]++;
		}
		//?°????????????¨???
		else if (val >= 97 && val <= 122) {
			index = val - (int)'a';
			count[index]++;
		}

		cout << "char=" << sentence[i] << " index=" << index << " count=" << count[index] << endl;

	}

	//??¨???
	for (int i = 0; i < 26; i++) {
	cout << (char)(i + 97) << " : " << count[i] << endl;
	}

	*/

	//????????????????????????
	for (int i = 0; i < 26; i++) {
		count[i] = 0;
	}

	while (cin >> sentence) {

			//65~90 97~122?????¨???????????????
			val = (int)sentence;
			//??§???????????¨???
			if (val >= 65 && val <= 90) {
				index = val - (int)'A';
				count[index]++;
			}
			//?°????????????¨???
			else if (val >= 97 && val <= 122) {
				index = val - (int)'a';
				count[index]++;
			}
			//????????\????????¨???????????????????????????
			/*
			else {
				break;
			}
			*/

			//cout << "char=" << sentence << " index=" << index << " count=" << count[index] << endl;

	}

	//??¨???
	for (int i = 0; i < 26; i++) {
		cout << (char)(i + 97) << " : " << count[i] << endl;
	}

	return 0;
}

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


int main() {
	ios_base::sync_with_stdio(0);
	
	long long A, B, C;
	cin >> A >> B >> C;
	
	long long ans = 0;
	if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) ans = 0;
	else ans = min(A * B, min(B * C, A * C));
	
	cout << ans;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
        int a, b, x;
        cin >> a >> b >> x;

        double d;
        if(2*x > a*a*b){
                double v = 2 * (a*a*b - x);
                v = v/(a*a*a);
                d = atan(v);
                d = (180*d)/M_PI;
        }
        else{
                double v = a*b*b;
                v = v/(2*x);
                d = atan(v);
                d = (180*d)/M_PI;
        }

        printf("%3.10lf\n", d);
        return 0;
}

Measured memory_bytes: 4000
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    vector<int> cnt(4);
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        cnt[a]++;
        cnt[b]++;
    }
    sort(cnt.rbegin(), cnt.rend());
    cout << (cnt[0] != 3 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>

int main(){
	int N;
	scanf("%d",&N);
	while(N != 0){
		int x[N],y[N],r[N],m[N];
		for(int i=0;i<N;i++){
			scanf("%d %d %d %d",&x[i],&y[i],&r[i],&m[i]);
		}
		int max = 0;
		for(int i=0;i<N;i++){
			for(double j=0; j< 2*M_PI; j=j+0.001){
				double a,b,c,ab;
				if(j == 0 || j == M_PI){
					a = 1.0;
					b = 0.0;
					c = -x[i]-r[i]*cos(j);
					ab = sqrt(pow(a,2.0)+pow(b,2.0));
				}else{
					a = 1 / tan(j);
					if(a < 0.01 && a > -0.01){
						a = 0.0;
					}
					b = 1.0;
					c = (-x[i]-r[i]*cos(j)) / tan(j) - y[i] - r[i] * sin(j);
					if(a == 0){
						c = (int)(c*1000)/1000;
					}
					ab = sqrt(pow(a,2.0)+pow(b,2.0));
				}
				int tempmax = 0;
				for(int k=0;k<N;k++){
					if(i==k){
						tempmax++;
					}else{
						double d = fabs(a*x[k] + b*y[k] + c) / ab;
						if(m[k] == 0){
							if((int)(d+0.5) == r[k]){
								tempmax++;
							}
						}else{
							if(d >= r[k] && d <= r[k] + m[k]){
								tempmax++;
							}
						}
					}
				}
				if(max < tempmax){
					max = tempmax;
				}
			}
		}
		printf("%d\n",max);
		scanf("%d",&N);
	}

}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<ll> l(n);
  rep(i,n)cin>>l[i];
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  ll rest=accumulate(l.begin()+1,l.end(),0LL);
  if(rest>l[0]) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

d = {}
for a in A:
  if a in d:
    d[a] += 1
  else:
    d[a] = 1

s = 0
for k in d:
    s += d[k] * (d[k] - 1) // 2

for i in range(N):
    t = d[A[i]]
    print(s - t * (t - 1) // 2 + (t - 1) * (t - 2) // 2)

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

int main() {
    int x, y;
    cin >> x >> y;
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; ++i) cin >> p[i];
    for (int i = 0; i < b; ++i) cin >> q[i];
    for (int i = 0; i < c; ++i) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vector<int> d;
    for (int i = 0; i < x; ++i) d.push_back(p[i]);
    for (int i = 0; i < y; ++i) d.push_back(q[i]);
    for (int i = 0; i < c; ++i) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    for (int j = 0; j < x + y; ++j) ans += d[j];
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    long long int sum = 0;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    map<long long int,long long int> num;
    for(int i = 0; i < N; i++) {
        num[A[i]] += 1;
    }
    long long res = 0;
    for(auto it : num) res += it.second * (it.second - 1) / 2;
    for(int i = 0; i < N; i++) {
        long long val = num[A[i]];
        long long before = val * (val - 1) / 2;
        long long after = (val - 1) * (val - 2) / 2;
        cout << res + after - before << endl;  
    }

    return 0;
}

Measured memory_bytes: 10240
! 2019.12.29
!
      program answer
      implicit none
      integer :: N,K
      integer :: R,S,P
      character(len=100000) :: T
      integer :: i
      integer :: score,scJ
      integer :: ans
!
      read(*,*) N,K
      read(*,*) R,S,P
      read(*,*) T
!
      ans = 0
      do i=1,N
        if(T(i:i) == 'r') then
          score = P
        else if(T(i:i) == 's') then
          score = R
        else
          score = S
        end if
!
        scJ = 0
        if( i > K) then
          if( T(i:i) == T((i-K):(i-K))) then
            scJ=1
            T(i:i) = 'u'
          end if
        end if
        if(scJ == 0) then 
          ans = ans + score
        end if
      end do
      write(*,*) ans
      end program answer

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

const int MAX_N = 100;
char yard[MAX_N][MAX_N];
int h,w;
int dx[4]={-1,0,1,0}, dy[4]={0, 1, 0, -1};

void dfs(int, int, char);

int main(){
    while((scanf("%d%d",&h,&w))&& h!=0 && w!=0 ){
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            scanf(" %c", &yard[i][j]);
        }
    }
    int cnt=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(yard[i][j]!='.') {dfs(i, j, yard[i][j]); cnt++;}
        }
    }
    printf("%d\n", cnt);
    }
}

void dfs(int x, int y, char ch){
    yard[x][y]='.';
    for(int i=0; i<4; i++){
        int nx = x+dx[i], ny = y+dy[i];
        if(nx>=0&& nx<h && ny>=0 && ny<w && yard[nx][ny]==ch)
            dfs(nx, ny, ch);
    }
    
}


Measured memory_bytes: 3560
#include<stdio.h>

int main(){
  char a[11],b[11],c[11];
  int numa=0,bnum=0,numb=0,cnum=0;
  int i;
  
  scanf("%s %s %s",a,b,c);
  
  for(i=0;a[i]!='\0';i++)
    numa++; //aの最後の文字の番目
  for(i=0;b[i]!='\0';i++)
    numb++; //bの最後の文字の番目
  
  if(a[numa-1]==b[0] && b[numb-1]==c[0])
    printf("YES");
  else
    printf("NO");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  cout<<"A"<<s2[0]<<"C"<<endl;
  return 0;
}


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

X=[[0 for i in range(a)] for j in range(b)]

d=[input().split() for i in range(c)]

for i in range(c):
    if d[i][2]=="1":
        for j in range(b):
            for k in range(int(d[i][0])):
                X[j][k]=1
    elif d[i][2]=="2":
        for j in range(b):
            for k in range(a-1,int(d[i][0])-1,-1):
                X[j][k]=1
    elif d[i][2]=="3":
        for j in range(int(d[i][1])):
            for k in range(a):
                X[j][k]=1
    else:
        for j in range(b-1,int(d[i][1])-1,-1):
            for k in range(a):
                X[j][k]=1


c=0
for i in range(b):
    for j in range(a):
        if X[i][j]==0:
            c+=1

print(c)

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

using namespace std;
typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> sn(n + 1);
    for (int i = 1; i <= k; i++) {
        int d;
        cin >> d;
        while (d--) {
            int ai;
            cin >> ai;
            sn[ai] = 1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += !sn[i];
    cout << ans << "\n";
}


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

void change( int kingaku, int a[] )
{
	a[0] = kingaku / 1000;
	kingaku -= a[0] * 1000;
	a[1] = kingaku / 500;
	kingaku -= a[1] * 500;
	a[2] = kingaku;
}

int main(void)
{
	while ( true ) {
		int n;
		std::cin >> n;
		if ( n == 0 ) break;

		std::vector<int> omiyage(n);

		for ( int i = 0; i < n; ++i ) {
			std::cin >> omiyage[i];
		}

		const int NC = 5000;
		int now = 0;
		static int kingaku[2][NC];
		static unsigned char m[2][NC];
		for ( int j = 0; j < NC; ++j ) {
			m[1-now][j] = 0;
			kingaku[1-now][j] = 0;
		}

		for ( int i = 1; i <= n; ++i ) {
			for ( int j = 0; j < NC; ++j ) {
				int a[3];
				m[now][j] = m[1-now][j];
				kingaku[now][j] = kingaku[1-now][j];
				for ( int v = j%100 - 100; v <= j; v += 100 ) {
					int u = v;
					if ( u < 0 ) u = 0;
					int l = ((omiyage[n-i] - u) + 999) / 1000;
					if ( l < 0 ) continue;
					change( l * 1000 + u - omiyage[n-i], a);
					if ( a[2] + j - u >= NC ) continue;
					if ( m[now][j] == a[1] + m[1-now][a[2] + j - u] && kingaku[now][j] > omiyage[n-i] + kingaku[1-now][a[2] + j - u] ) {
						m[now][j] = a[1] + m[1-now][a[2] + j - u];
						kingaku[now][j] = omiyage[n-i] + kingaku[1-now][a[2] + j - u];
					} else if ( m[now][j] < a[1] + m[1-now][a[2] + j - u]) {
						m[now][j] = a[1] + m[1-now][a[2] + j - u];
						kingaku[now][j] = omiyage[n-i] + kingaku[1-now][a[2] + j - u];
					}
				}
			}
			now = 1 - now;
		}
		now = 1 - now;
		std::cout << (int)m[now][0] << " " << kingaku[now][0] << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3108
n, m = map(int, input().split())
ans = [i for i in range(1, n + 1)]

l_max = 0
r_min = n

for _ in range(m):
    x, y = map(int, input().split())
    l_max = max(l_max, x)
    r_min = min(r_min, y)

print(len([i for i in range(l_max, r_min + 1)]))


Measured memory_bytes: 16852
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {

	int A;
	int B;
	cin >> A;
	cin >> B;

	int del = A - 2 * B;

	if (del >= 0) {
		cout << del << endl;
	}
	else {
		del = 0;
		cout << del << endl;
	}

	return  0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

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

    ll ans = 0;
    multiset<int, std::greater<int>> s;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans += a;
        s.insert(a);
    }

    for (int i = 0; i < m; ++i) {
        int t = *s.begin();
        int n = t/2;
        ans -= t - n;
        s.erase(s.begin());
        s.insert(n);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
CD = [list(map(int,input().split())) for _ in range(M)]

for ab in AB:
    man = [(abs(ab[0]-CD[i][0]) + abs(ab[1]-CD[i][1])) for i in range(len(CD))]
    print(man.index(min(man))+1)

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

bool IsEasyDance(string s){
    bool flg=false;
    for(int i=0;i<s.size();i++){
        if(i%2!=0){
            if(s.at(i)=='L'||s.at(i)=='U'||s.at(i)=='D'){
                flg=true;
            }
            else{
                flg=false;
                break;
            }
        }
        else{
            if(s.at(i)=='R'||s.at(i)=='U'||s.at(i)=='D'){
                flg=true;
            }
            else{
                flg=false;
                break;
            }
        }
    }
    return flg;
}

int main(){
    string s; cin >> s;
    if(IsEasyDance(s)==true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

int main(){
  string s;
  cin >> s;
  cout << s.substr(0,4) << " " << s.substr(4,8) << endl;
}

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    Yes(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d));

    return 0;
}


Measured memory_bytes: 256
import math

# Check


def main():
    N = 5
    dishes = [0] * N
    m = 10 ** 9
    m_index = -1

    for i in range(N):
        dishes[i] = int(input())

    for i in range(len(dishes)):
        if m > dishes[i] % 10 and dishes[i] % 10 != 0:
            m = dishes[i] % 10
            m_index = i

    if m_index == -1:
        print(sum(dishes))
    else:
        print(sum([d // 10 * 10 + 10 if d % 10 != 0 else d for i, d in enumerate(dishes) if i != m_index]) + dishes[m_index])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main() {
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++) {
		 map<string,int> days = {{"SUN",1},{"MON",2},{"TUE",3},{"WED",4},{"THU",5},{"FRI",6},{"SAT",7}};
		 string s;
		 cin >> s;
		 if(days[s] == 1){
			 cout << 7 << "\n";
		 }else{
			 cout << 7 - days[s] + 1 << "\n";
		 }
	 }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int MAX = 100;
static const int INFTY = (1 << 30);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n, M[MAX][MAX]; //nは要素数、Mは隣接行列
int prim()
{
    int u, minv;                    //uは最短距離の相手、minvは最短距離
    int d[MAX], p[MAX], color[MAX]; //dは始点からの距離、pは親,colorは訪問状態
    rep(i, 0, n)                    //初期設定
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE; //未訪問
    }
    d[0] = 0; //始点のdは0
    while (1)
    {
        minv = INFTY;
        u = -1;
        rep(i, 0, n) //未完了の点のうち始点からの最短距離は？
        {
            if (minv > d[i] && color[i] != BLACK) //未完了の点がある
            {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1)
            break;
        color[u] = BLACK;
        rep(i, 0, n)
        {
            if (color[i] != BLACK && M[u][i] != INFTY)
            {
                if (d[i] > M[u][i])
                {
                    d[i] = M[u][i];
                    p[i] = u;
                    color[i] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    rep(i, 0, n)
    {
        if (p[i] != -1)
            sum += M[i][p[i]];
    }
    return sum;
}
int main()
{
    cin >> n;
    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }
    cout << prim() << endl;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsinged long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
string str[3];
int shift[3][3][16005];

void calc(int i1,int i2)
{
	string &x=str[i1];
	string &y=str[i2];
	int a=x.size(),b=y.size();
	int j;
	for(int shift=0;shift<=16000;shift++)
	{
		::shift[i1][i2][shift]=true;
		for(int i=b;i<b+a;i++)
		{
			j=i-shift;
			if(j<0 || j>=b) continue;
			if(x[i-b]=='?') continue;
			if(y[j]=='?') continue;
			if(x[i-b]==y[j]) continue;
			::shift[i1][i2][shift]=false;
		}
	}
}

bool check(int i,int j,int p1,int p2)
{
	int shift=p2-p1+(int)str[j].size();
	if(shift<0) return false;
	return (!::shift[i][j][shift]);
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>str[0]>>str[1]>>str[2];
	for(int i=0;i<3;i++)
	{
		for(int j=i+1;j<3;j++)
		{
			calc(i,j);
		}
	}
	int res=inf;
	for(int p1=0;p1<8000;p1++)
	{
		for(int p3=0;p3<8000;p3++)
		{
			if(check(0,1,p1,4000)) continue;
			if(check(1,2,4000,p3)) continue;
			if(check(0,2,p1,p3)) continue;
			int l=min({p1,4000,p3});
			int r=max({p1+str[0].size(),4000+str[1].size(),p3+str[2].size()});
			chmin(res,r-l);
		}
	}
	cout<<res<<endl;
	return 0;
}

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


void solve(string s){
    int c1 = 0,c2 = 0;
    char num1 = '0' ,num2 = '1';
    for(int i=0;i<s.size();i++){
        if(s.at(i) != num1) c1++;
        if(num1 == '0'){
            num1 = '1';
        }else{
            num1 = '0';
        }
    }

    for(int i=0;i<s.size();i++){
        if(s.at(i) != num2) c2++;
        if(num2 == '0'){
            num2 = '1';
        }else{
            num2 = '0';
        }
    }

    cout << min(c1,c2) << endl;
}

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

Measured memory_bytes: 3856
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int a = 0, b = 0;
  REP(i, 3){
    if(s[i] == 'A') a = 1;
    if(s[i] == 'B') b = 1;
  }

  if(a && b) Yes;
  else No;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    string S;
    cin >> S;
    int ans = 0;
    char now = S[0];
    for (int i = 1; i < S.size(); i++) {
        if (S[i] != now) {
            ans++;
            now = S[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	if(n%m==0) printf("%d",n/m);
	else printf("%d",n/m+1);
	return 0;
}

Measured memory_bytes: 256
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)
#define cio ios::sync_with_stdio(false);

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


inline bool jd(char *str,int n)
{
    int ok = 1;
    for (int i = 0;i < n / 2;i ++)
    {
        if (str[i] != str[n - i - 1])
        {
            ok = 0;
            break;
        }
    }
    return ok;
}

int main()
{
    char str[110];
    scanf("%s",str);
    int n = (int) strlen(str);
    if (jd(str,n) && jd(str,(n - 1) / 2) && jd(str + (n + 3) / 2 - 1,n - (n + 3) / 2) + 1) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define llu unsigned long long int
#define scll(x) scanf("%lld",&x)
#define scld(x) scanf("%lf",&x)
#define scull(x) scanf("%llu",&x)
#define scch(x) scanf(" %c",&x)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define ppb() pop_back()
#define ppf() pop_front()
#define Pi acos(-1.0)
#define INF 1e18
#define ff first
#define ss second
#define mpr make_pair
ll  _xor(ll a,ll b){return a^b;}
ll _and(ll a,ll b){return a&b;}
ll _or(ll a,ll b){return a|b;}
ll _not(ll a){ return ~a;}
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
           #ifndef ONLINE_JUDGE 
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
         #endif
    ll b,c,d,e,f,g,h,i,j,k,l1,l2,l3,t,a,m,n,p,q,r,s,u,v,x,y,c1,c2,c3;

        string str;
              cin>>str;
              if(str[str.length()-1]=='2'||str[str.length()-1]=='4'||str[str.length()-1]=='5'||str[str.length()-1]=='7'||str[str.length()-1]=='9')
              	cout<<"hon";
              else if(str[str.length()-1]=='0'||str[str.length()-1]=='1'||str[str.length()-1]=='6'||str[str.length()-1]=='8')
              	cout<<"pon";
              else
              	cout<<"bon";
return 0;
}

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

int main(void) {
    int N;cin>>N;
    vector<int> A(N + 2);
    // departure
    A.push_back(0);
    for (int i = 1; i <= N; i++) cin>>A[i];
    // goal
    A.push_back(0);

    int SUM[N + 1];
    int sum = 0;
    for (int i = 0; i <= N; i++) {
        SUM[i] = abs(A[i + 1] - A[i]);
        sum += SUM[i];
    }
    // 結果出力
    for (int i = 1; i <= N; i++) {
        cout << sum - SUM[i - 1] - SUM[i] + abs(A[i + 1] - A[i - 1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll gcd(ll a,ll b)
{

   return b==0?a:gcd(b,a%b);
}
int main()
{
    ll a,b;
    while(cin>>a>>b)
    {
        ll t = gcd(a,b);
        cout << t << " " << a*b/t << endl;
    }

}



Measured memory_bytes: 3036
#include <iostream>

using namespace std;

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

 int t = s.size();

 if(t<=k){
	 cout << s << endl;
 }else{
	 for(int i=0;i<k;i++){
		 cout << s[i];
	 }
	 cout << "..." << endl;
 }

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int H, W, K; cin>> H >> W >> K;
VS s(H); rep(i, 0, H) cin >> s[i];

string dotsline(W, '.');
VVI ans(H, VI(W, -1));
int n = 1;
rep(i, 0, H){
    if (s[i] != dotsline){
        rep(j, 0, W){
            if (s[i][j] == '#'){
                ans[i][j] = n;
                ++n;
            }
            else {
                ans[i][j] = n;
            }
        }
        if (s[i][W-1] == '.'){
            --n;
            for (int j = W-1; s[i][j] == '.'; --j)
                ans[i][j] = n;
            ++n;
        }
    }
}
rep(i, 0, H-1){
    if (s[i] == dotsline){
        int k = i;
        while (k < H && ans[k][0] == -1)  ++k;
        if (k >= H) continue;
        rep(j, 0, W) cout <<  ans[k][j] << ' ';
        cout << "\n";
    }
    else {
        rep(j, 0, W) cout << ans[i][j] << ' ';
        cout << "\n";
    }
}
if (s[H-1] == dotsline){
    int k = H-1;
    while (ans[k][0] == -1) --k;
    rep(i, k+1, H)
        rep(j, 0, W) cout << ans[k][j] << ' ';
}
else 
    rep(i, 0, W) cout << ans[H-1][i] << ' ';

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 1664
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K, H, W, L, R, l, r, u, d, sum, Q;
LL ans;
LL no;
bool b, bb[100001];
string s, t;

int main() {

	cin >> N >> K;
	vector<double> v(N),vv(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		v[i] = (v[i] + 1) / 2;
	}
	vv[0] = v[0];
	for (int i = 1; i < N; i++) {
		vv[i] = v[i] + vv[i - 1];
	}
	double dans = vv[K-1];
	for (int i = K; i < N; i++) {
		dans = max(dans, vv[i] - vv[i - K]);
	}
	cout << std::setprecision(10)<<dans<<endl;
	return 0;
}



Measured memory_bytes: 3328