akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
long long int mod = 4294967296;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,f,g,h,i,j,k,w,ok,ng,res;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005][3];
char s[500005];
bool flag,dame;

int main(){
    cin >> n >> a >> b >> c;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	num = 1;
	for(i=0;i<n;i++){
		num *= 4;
	}
	ans = INF;
	for(i=0;i<num;i++){
		res = 0;
		d = i;
		for(j=0;j<n;j++){
			y[j] = d % 4;
			//pe(y[j]);
			d /= 4;
		}
		//el;
		for(j=0;j<4;j++)z[j] = 0;
		for(j=0;j<n;j++){
			if(z[y[j]] && y[j] != 0)res += 10;
			z[y[j]] += x[j];
		}
		res += abs(z[1] - a);
		res += abs(z[2] - b);
		res += abs(z[3] - c);
		if(z[1] * z[2] * z[3] == 0)res = INF;
		ans = min(res,ans);
		if(res == 120){
			//for(j=0;j<n;j++)pe(y[j]);
			//el;
		}
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 31104
#include <cstdio>

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

    int no_of_people = 0;
    while(no_of_rows--)
    {
        int left, right;
        scanf("%d %d", &left, &right);

        no_of_people += right - (left - 1);
    }

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


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

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

    char c[3];
    c[0] = a.front();
    c[1] = b.front();
    c[2] = c1.front();

    for(int i = 0; i < 3; i++)
        c[i] =  c[i] - 'a' + 'A';

    printf("%c%c%c\n", c[0], c[1], c[2]);

    return 0;
}


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


int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int ans;
  if(A<=C){
    if(B<=C) ans = 0;
    else if(B>C && B<D) ans = B - C;
    else ans = D - C;
  }else{
    if(D<A) ans = 0;
    else if(D>A && D<B) ans = D - A;
    else ans = B - A;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main()
{
    map<int, int> m;

    int n, l = 0;
    while( cin >> n ) {
        ++m[n];
        l = max( l, m[n] );
    }

    for( auto&& p : m ){
        if ( p.second == l )
            cout << p.first << endl;
    }
}

Measured memory_bytes: 1192
#include <stdio.h>
int main(){
        int n,a,b,i;
        while(1){
                scanf("%d", &n);
                if(n == 0){
                        break;
                }
                b = 0;
                for(i=0;i<n/4;i++){
                                scanf("%d", &a);
                                b += a;
                }
                printf("%d\n",b);
        }
return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n;
cin>>n;
long long int sum=0;
 for(int i=1;i<=n;i++)
 {
   if(i%3!=0 && i%5!=0)
   {
   sum+=i;
   }
 }
  
  cout<<sum<<"\n";
}

Measured memory_bytes: 3584
while True:
    h,w = map(int,input().split())
    if h == 0 and w == 0:
        break
    for x in range(h):
        if x % 2 == 0:
            for y in range(w):
                if y % 2 ==0:
                    print("#",end="")
                else:
                    print(".",end="")
        else:
            for y in range(w):
                if y % 2 == 0:
                    print(".",end="")
                else:
                    print("#",end="")
        print()
    print()


Measured memory_bytes: 7004
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    string a, b; cin >> a >> b;
    int a_len, b_len;
    a_len = a.size(); b_len = b.size();

    if (a_len > b_len) {
        cout << "GREATER" << endl;
    }
    else if (a_len < b_len) {
        cout << "LESS" << endl;
    }
    else {
        rep(i,a_len) {
            if (a[i] - '0' > b[i] - '0') {
                cout << "GREATER" << endl;
                break;
            }
            else if (a[i] - '0' < b[i] - '0') {
                cout << "LESS" << endl;
                break;
            }
            else if (i == a_len - 1) {
                cout << "EQUAL" << endl;
            }
        }
    }

    
    return 0;
}






Measured memory_bytes: 256
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    n,a,b = map(int,input().split())
    x = n // (a + b)
    ans = a * x
    if n-(a+b)*x<=a:
        ans += n - (a + b) * x
    else:
        ans += a
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38384
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

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

  int n;
  int d[n];
  set<int> s;
  cin >> n;
  FOR(i,0,n) cin >> d[i];
  FOR(i,0,n) s.insert(d[i]);

  cout << s.size() << endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
  int x,y;
  cin >> x >> y;
  if (0 <= y - 2*x && (y - 2*x) % 2 == 0 && 0 <= 4*x - y && (4*x - y) % 2 == 0) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0; 
}

Measured memory_bytes: 3636
import collections
n=int(input())
s = []
for _ in range(n):
    s.append(input())
c = collections.Counter(s)
a = max(c.values())
b = []
for i in c:
    if c[i] == a:
        b.append(i)
b.sort()
for i in b:
    print(i)

Measured memory_bytes: 35564
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run(){
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(String.valueOf(a+b).length());
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;

int main(){
	int n,w,h;
	cin >> n >> w >> h;
	pair<int,int> temp(0,0);
	vector< pair<int,int> > line(n,temp),column(n,temp);
	vector<pair<int,int> >::iterator it;
	for(int i = 0; i < n; i++){
		int x,y,r;
		cin >> x >> y >> r;
		int xs=x-r,xg=x+r,ys=y-r,yg=y+r;
		column[i].first = xs;
		column[i].second = xg;
		line[i].first = ys;
		line[i].second = yg;
	}

	sort(column.begin(), column.end() );
	sort(line.begin(), line.end() );
	
	bool flagx=true,flagy=true;
	int x=0,y=0;
	for(int i = 0; i < n; i++){
		int xs,xg;
		xs = column[i].first;
		xg = column[i].second;
		if(xs > x){
			flagx = false;
			if(!flagy){
				break;
			}
		}
		else{
			if(xg > x){
				x = xg;
			}
		}
		int ys,yg;
		ys = line[i].first;
		yg = line[i].second;
		if(ys > y){
			flagy = false;
			if(!flagx){
				break;
			}
		}
		else{
			if(yg > y){
				y = yg;
			}
		}
	}
	if(x < w){
		flagx = false;
	}
	if(y < h){
		flagy = false;
	}

	if(flagx || flagy)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 4412
// AOJ 2249: Road Construction
// 2017.11.15 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 16010
typedef struct { int t, node, c; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && (que[l].t < que[i].t ||
		que[l].t == que[i].t && que[l].c < que[i].c)) min = l; else min = i;
	if (r < qsize && (que[r].t < que[min].t ||
		que[r].t == que[min].t && que[r].c < que[min].c)) min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
//	return 1;
}

void enq(int n, int t, int c)
{
	int i, min;

	i = qsize++;
	que[i].node = n, que[i].t = t, que[i].c = c;
	while (i > 0 && (que[min = PARENT(i)].t > que[i].t ||
		   que[min].t == que[i].t && que[min].c > que[i].c)) {
		QUE tt = que[i]; que[i] = que[min]; que[min] = tt;
		i = min;
	}
}

#define INF 0x55555555
typedef struct { int len, to[100], d[100], c[100]; } TBL;
TBL *tbl;
char visited[10003]; int size;

int dijkstra(int start)
{
	int i, s, e, c, d, ans = 0;
	TBL *tp;

	qsize = 0;
	memset(visited, 0, sizeof(visited));
	enq(start, 0, 0);
	while(qsize) {
		s = que[0].node, d = que[0].t, c = que[0].c;
		deq();
		if (visited[s]) continue;
		visited[s] = 1;
		ans += c;
		for (tp = tbl+s, i = 0; i < tp->len; i++) {
			e = tp->to[i];
			if (visited[e]) continue;
			enq(e, d + tp->d[i], tp->c[i]);
		}
	}
	return ans;
}

char buf[40], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, i, k, u, v, d, c;
	TBL *tp;

	while (fgets(p=buf, 40, stdin) && *p != '0') {
		size = n = getint(), p++, m = getint();

		tbl = calloc(size+2, sizeof(TBL));
		memset(tbl, 0, sizeof(TBL)*size);
		for (i = 0; i < m; i++) {
			fgets(p=buf, 40, stdin);
			u = getint()-1, p++, v = getint()-1, p++, d = getint(), p++, c = getint();
			tp = tbl+u,	k = tp->len;
			tp->to[k] = v, tp->d[k] = d, tp->c[k] = c, tp->len++;
			tp = tbl+v, k = tp->len;
			tp->to[k] = u, tp->d[k] = d, tp->c[k] = c, tp->len++;
		}
		printf("%d\n", dijkstra(0));
		free(tbl);
	}
	return 0;
}

Measured memory_bytes: 12296
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
if N >= M:
    print(0)
else:
    tmp = []
    for i in range(M - 1):
        tmp.append(A[i+1] - A[i])
    tmp.sort(reverse=True)
    interval = 0
    for i in range(N - 1):
        if i + 1 == M - 1:
            break
        interval += tmp[i]
    print(sum(tmp) - interval)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int mex(vector<int> a)
{
	sort(a.begin(), a.end());
	for(int i = 0; i < (int)a.size(); i++)
		if(i != a[i]) return i;
	return (int)a.size();
}

int n;
int A[MAXN], K[MAXN]; 

void read()
{
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i] >> K[i];
}

int solve(int a, int k)
{
	if(a % k == 0) return a / k;
	if(a < k) return 0;

	int v = a / k + 1;
	if(v == 0) return 0;

	int bg = v * k;
	if(bg + v <= a) return solve(a % v + bg, k);
	return solve(a - v, k);
}

void solve()
{
	int answer = 0;
	for(int i = 0; i < n; i++)
		answer ^= solve(A[i], K[i]);

	if(answer == 0) cout << "Aoki" << endl;
	else cout << "Takahashi" << endl;
}

int tmp_sg[MAXN];

void prepare()
{
	for(int k = 1; k <= 20; k++)
	{
		cout << k << ": ";
		tmp_sg[0] = 0;
		for(int v = 1; v <= 60; v++)
		{
			vector<int> li;
			int mx = v / k;

			for(int i = v - 1; i >= v - mx; i--)
				li.push_back(tmp_sg[i]);

			tmp_sg[v] = mex(li);
			cout << tmp_sg[v] << " ";
		}

		cout << endl;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//prepare();
	read();
	solve();
	return 0;
}



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

using namespace std;

int main(){
    int a;
    int l;
    cin >> a >> l;
    if(a == 1 && (l==2||l==4)){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = 0;i <= a;i++){
        int t = a - i;
        if((4*i + 2*t)==l){
            cout << "Yes" << endl;
            return 0;
        }
    }
    /*for(int i = 1;i*4 < l;i++){
        int bird = l - i * 4;
        if(bird % 2 == 0 && (bird/2+i)==a){
            cout << "Yes" << endl;
            return 0;
        }
    }*/
    cout <<"No"<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
	int n, m;cin >> n >> m;
	vector<int> x(m);for (int i = 0;i < m;i++) { cin >> x[i]; } 

	if (m < n) { cout << 0 << endl; }
	else 
	{
		sort(x.begin(), x.end());
		vector<int> diff;
		for (int i = 1;i < m;i++) { diff.push_back(x[i] - x[i - 1]); }
		sort(diff.begin(), diff.end(), greater<int>());
		int ans = *(x.end()-1) - *(x.begin());
		for (int i = 0;i < n - 1;i++) { ans -= diff[i]; }
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1276
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
const int P=1000000007;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
	int n, k, kk;
	cin>>n>>k>>kk;


	if((k-1)/n<kk/n      )puts("OK");


	else puts("NG");


}


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 2019;
int main(){
ll l,r;
cin >> l >> r;
if(r-l>=2018) cout << 0;
else{
        ll mini = INT_MAX;
    for(ll i = l;i<r;i++){
        for(ll j = i+1;j<=r;j++){
            mini = min(mini,i*j%2019);
        }
    }
cout << mini;
}
return 0;
}

Measured memory_bytes: 3624
// Minimization

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

using namespace std;

int main(){
	int N,K;
	cin >> N >> K;
	int A[N];
	for (int i = 0; i < N; ++i)
		cin >> A[i];

	if ((N-K) % (K-1))
		cout << 1 + (N-K) / (K-1) + 1 << endl;
	else
		cout << 1 + (N-K) / (K-1) << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

    int r = 0;
    rep(i, n) {
        if (s[i]=='R') r++;
    }

    // 左からr番目以内のwの数(a)
    int a = 0;
    rep(i, r) {
        if (s[i]=='W') a++;
    }
    debug(a, r, n-r);
    cout << min(a, min(r, n-r)) << endl;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define printV(v) for(int i=0;i<v.size();i++){cout << v[i]<< " ";} cout << endl
#define printRev(v) for(int i=v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
#define sortV(v) sort(v.begin(),v.end())
#define revV(v) reverse(v.begin(),v.end())
#define FOR(i,from,n) for(int i=from;i<n;i++)
#define FOL(i,from,n) for(int i=from;i >= n;i--)
    
    ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,q;
    ll mod = 1000000007;
    
    void solve(){
        cin >> n;
        string str; cin >> str;
        int R[n+1];
        int G[n+1];
        int B[n+1];
        for(int i=0;i<=n;i++){
            R[i] = G[i] = B[i] = 0;
        }
        for(int i=n-1;i >= 0;i--){
            R[i] = R[i+1];
            G[i] = G[i+1];
            B[i] = B[i+1];
            if(str[i] == 'R') R[i]++;
            else if(str[i] == 'G') G[i]++;
            else if(str[i] == 'B') B[i]++;
        }
        ll cnt = 0;
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                if(str[i] == 'G' && str[j] == 'B'){
                    cnt += R[j+1];
                    if(2*j - i < n && str[2*j-i] == 'R') cnt--;
                }
            }
        }


        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                if(str[i] == 'G' && str[j] == 'R'){
                    cnt += B[j+1];
                    if(2*j - i < n && str[2*j-i] == 'B') cnt--;
                }
            }
        }



        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                if(str[i] == 'B' && str[j] == 'G'){
                    cnt += R[j+1];
                    if(2*j - i < n && str[2*j-i] == 'R') cnt--;
                }
            }
        }



        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                if(str[i] == 'B' && str[j] == 'R'){
                    cnt += G[j+1];
                    if(2*j - i < n && str[2*j-i] == 'G') cnt--;
                }
            }
        }



        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                if(str[i] == 'R' && str[j] == 'B'){
                    cnt += G[j+1];
                    if(2*j - i < n && str[2*j-i] == 'G') cnt--;
                }
            }
        }
        for(int i=0;i<n-2;i++){
            for(int j=i+1;j<n-1;j++){
                if(str[i] == 'R' && str[j] == 'G'){
                    cnt += B[j+1];
                    if(2*j - i < n && str[2*j-i] == 'B') cnt--;
                }
            }
        }
        cout << cnt;
    }
        

  
   
    int main(){
    ios_base::sync_with_stdio(false);
    
    int cases = 1;
    //cin >> cases;
  
    while(cases--){ 
        solve();
    }

    return 0;

    }

Measured memory_bytes: 3652
import numpy as np

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

A = np.array(A)

A.sort()

d = {}

for a in A:
    d.setdefault(a,0)
    d[a] += 1

sieve = [True] * (A[-1] + 1)

for a in A:
    if sieve[a] == False:
        continue
    if d[a] > 1:
        sieve[a] = False
    for i in range(a + a, A[-1] + 1, a):
        sieve[i] = False

print(sum(1 for a in A if sieve[a]))

Measured memory_bytes: 55184
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    char s[100];
    scanf("%s", s);

    if (s[0] != 'A') {
        printf("WA\n");
        return 0;
    }

    int Ccount= 0;
    for (int i = 2; i < strlen(s) - 1; i++) {
        if (s[i] == 'C') {
            Ccount++;
        }
    }
    if (Ccount != 1) {
        printf("WA\n");
        return 0;
    }

    int upper_count= 0;
    for (int i = 0; i < strlen(s); i++) {
        if (s[i] <= 'Z' && s[i] >= 'A') {
            upper_count++;
        }
    }
    if (upper_count != 2) {
        printf("WA\n");
    } else {
        printf("AC\n");
    }

}


Measured memory_bytes: 128
# リファクタ
from collections import defaultdict
import itertools
n, c = map(int, input().split())
D = [list(map(int, input().split()))for _ in range(c)]

# 集計
diago = [defaultdict(int)for _ in range(3)]
for i in range(n):
    for j, color in enumerate(map(int, input().split())):
        diago[(i+j) % 3][color-1] += 1

# 0列目をcにするときのcにするときの最小コスト
costs = [[0]*c for _ in range(3)]
for i in range(3):
    for j in range(c):
        for k, v in diago[i].items():
            costs[i][j] += D[k][j]*v

INF = 10**18
ans = INF
for trio in itertools.combinations(range(c), 3):
    for color in itertools.permutations(trio, 3):
        cost = sum(costs[i][j] for i, j in enumerate(color))
        if cost < ans:
            ans = cost
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std; 

struct city {
	int p;
	int y;
	int ind;
	string ID;
	bool operator<(const city& right) const {
		if (p == right.p) {
			if (y == right.y) {
				return (ind < right.ind);
			}
			else {
				return (y < right.y);
			}
		}
		else {
			return (p < right.p);
		}
	}
};

int main(void) {
	int N,M;
	cin >> N >> M;
	vector<city> data(M);
	for (int i = 0; i < M; ++i) {
		cin >> data[i].p >> data[i].y;
		data[i].ind = i;
	}
	sort(data.begin(),data.end());
	int np = data[0].p;
	int ni = 0;
	vector<string> res(M);
	for (int i = 0; i < M; ++i) {
		if (np != data[i].p) {
			np = data[i].p;
			ni = 0;
		}
		++ni;
		string pre = to_string(np);
		string suf = to_string(ni);
		while (pre.length() < 6) {
			pre = "0" + pre;
		}
		while (suf.length() < 6) {
			suf = "0" + suf;
		}
		res[data[i].ind] = pre + suf;
	}

	for (int i = 0; i < M; ++i) {
		cout << res[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}


int main() {
	ll N;
	cin >> N;
	vector<ll>A(N);
	rep(N)
		cin >> A[i];
	vector<ll>WA(N, 0);
	vector<ll>SA(N, 0);
	map<ll, ll>M,K;
	ll ans=0;
	ll mi = 1000000000000;
	ll ma = 0;
	for (int i = 0; i < N; i++) {
		WA[i] = A[i] + i+1;
		SA[i] = -A[i] + i+1;
		M[WA[i]]++;
		K[SA[i]]++;
		ma = max(SA[i], ma);
		mi = min(SA[i], mi);
	}
	for (auto it=M.begin();it!=M.end();it++)
		ans += it->second * K[it->first];
	cout << ans;
}

Measured memory_bytes: 42176
#include <bits/stdc++.h>
  
using namespace std;
  
#define MAX 35
#define INF 1e9
#define F first
#define S second
typedef pair<double,int> pdi;
typedef pair<int,int> pii;
typedef pair<pdi,pii> State;
  
struct Edge{
    int to,d,c;
    Edge(int to,int d,int c) : to(to),d(d),c(c) {}
};
  
int N,M,s,g;
vector<Edge> G[MAX];
  
double dijkstra(){
    priority_queue<State,vector<State>,greater<State> > Q;
    Q.push(State(pdi(0,s),pii(1,N)));
    double Time[MAX][MAX][MAX];
    fill(Time[0][0],Time[0][0]+MAX*MAX*MAX,INF);   
    Time[s][1][N] = 0;
  
    while(!Q.empty()){
	State p = Q.top(); Q.pop();
	int v = p.F.S, vel = p.S.F;
	if(Time[v][vel][p.S.S] < p.F.F) continue;
 
	if(v == g && vel == 1){
	    return Time[g][1][p.S.S];
	}
  
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    for(int j = -1 ; j <= 1 ; j++){
		if(vel+j <= 0) continue;
		if(Time[v][vel][p.S.S] == 0 && j){
		    continue;
		}
		Edge e = G[v][i];
		if(e.to == p.S.S) continue;
		double t = (double)e.d/(vel+j);
		if(vel+j <= e.c && 
		   Time[v][vel][p.S.S] + t < Time[e.to][vel+j][v]){
		    Time[e.to][vel+j][v] = Time[v][vel][p.S.S] + t;
		    Q.push(State(pdi(Time[e.to][vel+j][v],e.to),pii(vel+j,v)));
		}
	    }
	}
    }
    return INF;
}
  
int main(){
    int x,y,d,c;
    while(cin >> N >> M, N){
	for(int i = 0 ; i < MAX ; i++){
	    G[i].clear();
	}
	cin >> s >> g; s--; g--;
	for(int i = 0 ; i < M ; i++){
	    cin >> x >> y >> d >> c;
	    x--; y--;
	    G[x].push_back(Edge(y,d,c));
	    G[y].push_back(Edge(x,d,c));
	}
	double res = dijkstra();
	if(res == INF){
	    cout << "unreachable" << endl;
	}else{
	    printf("%.8f\n",res);
	}
    }
    return 0;
}

Measured memory_bytes: 3816
h,w,k = gets.chomp.split.map(&:to_i)
cs = h.times.map{gets.chomp.chars}
black_num = cs.inject(0){|res,c| res += c.count("#")}
ans = 0
flag = black_num - k

(2**h).times do |i|
  (2**w).times do |k|
    cnt = 0

    h.times do |j|
      w.times do |l|
        cnt += 1 if cs[j][l] == "#" && i[j] == 1
        cnt += 1 if cs[j][l] == "#" && k[l] == 1
        cnt -= 1 if cs[j][l] == "#" && i[j] == 1 && k[l] == 1
      end
    end
    ans += 1 if cnt == flag
  end
end

puts ans


Measured memory_bytes: 14220
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
using namespace std;

int main()
{
    int x;
    scanf("%d",&x);
    if(x>999)
        printf("ABD\n");
    else
        printf("ABC\n");
    return 0;
}


Measured memory_bytes: 256
az = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
dic = {}
for i, s in enumerate(az):
  dic[s] = i
N = int(input())
S = input()

az2 = az+az
ans = ""
for s in S:
  ind = dic[s]+N
  ans += az2[ind]
  
print(ans)  

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <numeric>

using namespace std;

int main() {
    size_t N, x;
    scanf("%zu %zu", &N, &x);

    if (x == 1 || x == 2*N-1)
        return !printf("No\n");

    vector<int> A(2*N-1), B(3);
    iota(A.begin(), A.end(), 1);
    iota(B.begin(), B.end(), x-1);

    A.erase(A.begin()+x-2, A.begin()+x+1);
    A.insert(A.begin()+N-2, B.begin(), B.end());

    printf("Yes\n");
    for (int a: A) printf("%d\n", a);

    return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <string.h>
int main(){
  char x[11];
  char y[11];
  int i,j=0;
  scanf("%s", x);
  for(i=0;i<strlen(x);i++){
    if(x[i]>='A'&&x[i]<='Z'){
      y[j]=x[i];
      j++;
    }
  }
  y[j]='\0';
  if(x[0]=='A'&&strlen(y)==2&&y[1]=='C'&&x[strlen(x)-1]!='C'&&x[1]!='C'){
    printf("AC\n");
  }
  else{
    printf("WA\n");
  }
  //printf("x[0]=%c strlen(y)=%d y[1]=%c x[strlen(x)-1]=%c x[1]=%c\n",x[0],strlen(y),y[1],x[strlen(x)-1],x[1]);
  return 0;
}


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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

const int MX = 100005;

int a, b;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> a >> b;

	if (a + b == 15) cout << '+';
	else if (a * b == 15) cout << '*';
	else cout << 'x';
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int m;

vector<int> edges[10];
int vis[10];

int rec(int s,int cou = 1)
{
    int ans = 0;
    vis[s] = 1;

    if(cou == n) ans += 1;

    for(int to : edges[s])
    {
        if(vis[to] == 0)
        {
           ans += rec(to,cou + 1); 
        }
    }


    vis[s] = 0;
    return ans;    
}

int main()
{
    cin >> n >> m;
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        edges[a].push_back(b);   
        edges[b].push_back(a);
    }

    cout << rec(1) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	stack<int> s;
	int a;
	while (cin >> a) {
		if (a != 0)s.push(a);
		else {
			cout << s.top() << endl;
			s.pop();
		}
	}
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	long double L;
	cin >> L;

	long double a = L / (long double)3;
	long double ans = a * a * a;
	cout.precision(15);
	cout << fixed << ans << endl;

	return 0;
}


Measured memory_bytes: 256
/*ex3_3
series2*/
 
# include <stdio.h>
int main(void){
      //各文字の箱を作って読み取り
    int N,K;
    scanf("%d %d", &N,&K);
    int i=0;//桁数
    int j=1;//現在の調べている位を十進法で表した時の値
    while(j<=N){
        //現在の調べている位を十進法で表した時の値が調べている数字Nを超えたとき、その時のiは桁数になる。
        j=j*K;
        i ++;
    }
    printf("%d\n",i);
    return 0;
}


Measured memory_bytes: 128
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


N, M = map(int, input().split())
H = [int(i) for i in input().split()]
AB = [list(map(int, input().split())) for i in range(M)]
#s={AB[0][0]}
A = [0]*N
ans = 0
#print(H)
for i in range(M):
    #s.add(AB[i][0])
    #s.add(AB[i][1])
    #print(AB[i][0]-1, AB[i][1]-1)
    #print(H[AB[i][0]-1], H[AB[i][1]-1])
    if(H[AB[i][0]-1]==H[AB[i][1]-1]):
        A[AB[i][0]-1] =1
        A[AB[i][1]-1] =1
    elif(H[AB[i][0]-1]<H[AB[i][1]-1]):
        A[AB[i][0]-1] =1
    else:
        A[AB[i][1]-1] =1

#print(A)
#print(s)
ans = A.count(0)
#ans += N-len(s)


print(ans)


Measured memory_bytes: 95336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  cout << 800*n-200*(n/15) << endl;
}

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

signed main(void)
{
	int h, w, k, cnt;
	cin >> h >> w >> k;
	int sum[h], ans[h][w];
	string s[h];

	rep(i, h)
	{
		cin >> s[i];
		sum[i] = 0;
	}
	rep(i, h) rep(j, w)
	{
		if (s[i][j] == '#') sum[i]++;
	}
	
	vector<int> vec;
	// ���ɐ؂�
	rep(i, h)
	{
		if (sum[i] >= 1)
			vec.push_back(i);
	}
	// �c�ɐ؂�
	int tmp_l, tmp_r;
	cnt = 0;
	tmp_l = 0;
	rep(i, vec.size())
	{
		tmp_r = 0;
		rep(j, w)
		{
			if (s[vec[i]][j] == '#' || j == w - 1)
			{
				if (s[vec[i]][j] == '#')
					cnt++;
				for(int m = tmp_l; m <= vec[i]; m++)
				for(int l = tmp_r; l <= j; l++)
					ans[m][l] = cnt; 
				if (i == vec.size() - 1 && vec[i] != h - 1)
				{
					for(int m = vec[i]; m < h; m++)
					for(int l = tmp_r; l <= j; l++)
						ans[m][l] = cnt; 
				}
				tmp_r = j + 1;
			}
		}
		tmp_l = vec[i] + 1;
	}
	rep(i, h) rep(j, w)
		printf("%d%c", ans[i][j], j==w-1?'\n':' ');
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define pi 3.1415926535897932
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    int t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

int main(){
    int a,b;cin >> a >> b;
    int h,m;cin >> h >> m;
    double th=abs(pi*((h+m/60.0)/(6.0))-(pi*(m/(30.0))));
    double ans=a*a+b*b-2*a*b*cos(th);
    cout << fixed << setprecision(15);
    cout << sqrt(ans) << endl;
}

Measured memory_bytes: 4196
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
	int H,W;
	cin >> H >> W;
	char C[201][201];
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> C[i][j];
		}
	}
	char ans[201][201];
	for(int i=1;i<=2*H;i++){
		for(int j=1;j<=W;j++){
			ans[i][j]=C[(i+1)/2][j];
		}
	}
	for(int i=1;i<=2*H;i++){
		for(int j=1;j<=W;j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
	}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
bool check(vector<int>& x, int &y){
    for(int i = 0; i < x.size(); i++)
        if(x[i] < y) return false;
    return true;
}


int main() {
    IO;
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int> > a(n, vector<int>(m + 1));
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= m; j++)
            cin >> a[i][j];
    }
    int mask = 1 << n;
    int ans = 1e9;
    for(int i = 0; i <= mask; i++){
        int money_needed = 0;
        vector<int> levels(m);
        for(int j = 0; j < n; j++){
            if((1 << j) & i){
                money_needed += a[j][0];
                for(int k = 1; k <= m; k++)
                    levels[k - 1] += a[j][k];
            }
        }
        if(check(levels, x)) ans = min(ans, money_needed);
    }
    if(ans == 1e9) cout << -1 << '\n';
    else cout << ans << '\n';
    return 0;
}

/*
7 1 1 1
AB
AC
BC
AB
AB
BC
BC

*/

Measured memory_bytes: 3652
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//ガウスの消去法
#define BIT_N 333
typedef bitset<BIT_N> Bit;
	vector<Bit> gauss(vector<Bit> &v, ll &ran){
	ran = 0;
	rep(i,BIT_N) {
		int pla = -1;
		for(int j = ran;j < v.size();j++){
			if(v[j][i] == 1){
				pla = j;
				break;
			}
		}

		if(pla != -1){
			swap(v[ran], v[pla]);
			for(int j = 0;j < v.size();j++){
				if(j != ran && v[j][i] == 1)v[j] ^= v[ran];
			}
			ran++;
		}
	}
	return v;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin>>n>>m;
	vector<Bit>in(n);
	rep(i,n)rep(j,m){
		int a;cin>>a;
		if(a)in[i][j]=1;
	}
	int rank;
	vector<Bit>out=gauss(in,rank);
	int MOD=998244353;
	vi po(633,1);
	loop(i,1,633)po[i]=po[i-1]*2%MOD;
	cout<<(MOD+po[n+m-1]-po[n+m-rank-1])%MOD<<endl;
}


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

int main (){
  int N,S=0,a=0,b=0,c=0,d=0;
  cin >>N;
  a=1;
  for (int i=0;i<10;i++){
    b=N/a;
    a=a*10;
    c=N/a;
    d=b-c*10;
    S+=d;
  }
  
  if (N%S==0){
    cout <<"Yes"<<endl;
  }
  else {
    cout <<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node{
  int value;
  node *next;
  node(int value,node *next):value(value),next(next){}
};
int INF=1LL<<55LL;
string lcs(string x,string y){
  int n=x.size(),m=y.size();
  map<char,vector<int> > M;
  for(int j=m-1;j>=0;j--) M[y[j]].push_back(j);
  vector<int> xs(n+1,INF);
  xs[0]=-INF;
  vector<node* > link(n+1);
  for(int i=0;i<n;i++){
    if(M.count(x[i])){
      vector<int> ys=M[x[i]];
      for(int j=0;j<(int)ys.size();j++){
	int k=distance(xs.begin(),lower_bound(xs.begin(),xs.end(),ys[j]));
	xs[k]=ys[j];
	link[k]=new node(y[ys[j]],link[k-1]);
      }
    }
  }
  string res;
  int l=distance(xs.begin(),lower_bound(xs.begin(),xs.end(),INF-1))-1;
  for(node *p=link[l];p!=NULL;p=p->next)
    res.push_back(p->value);
  return res;
}
signed main(){
  int q;
  cin>>q;
  while(q--){
    string x,y;
    cin>>x>>y;
    cout<<lcs(x,y).size()<<endl;
  }
  return 0;
}
/*
verified on 2017/06/22
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C
*/

Measured memory_bytes: 51280
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
    // Here your code !
    int h,w;
    cin>>h>>w;
    int i=0,j=0,k=0;
    for(;i<w+2;i++){
        cout<<"#";
    }
    cout<<endl;
    string a[h];
    for(;j<h;j++){
        cin>>a[j];
        cout<<"#"<<a[j]<<"#"<<endl;
    }
    for(;k<w+2;k++){
        cout<<"#";
    }
    cout<<endl;
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    char n;
    cin >> n;
    if(0 <= n-'a' && n-'a' < 26) cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int main(void){
    int n;cin>>n;vector<ll>v(n),x(n);rep(i,n){cin>>v[i];x[i]=v[i];}
    sort(all(v));
    ll a=v[n/2-1],b=v[n/2];
    rep(i,n){
        if(x[i]<=a)cout<<b<<endl;
        else cout<<a<<endl;
    }
}

Measured memory_bytes: 5376
using System;
using System.Linq;

class E
{
	static void Main()
	{
		var N = int.Parse(Console.ReadLine());
		var S = Console.ReadLine();
		var s = new bool[N];
		for (var i = 0; i < N; i++) s[i] = S[i] == 'o';
		var b = new bool[N];
		for (var x = 0; x < 2; x++)
			for (var y = 0; y < 2; y++)
			{
				b[0] = x == 1;
				b[1] = y == 1;
				for (var i = 1; i + 1 < N; i++) b[i + 1] = b[i - 1] == (b[i] == s[i]);
				if ((s[0] == b[0]) == (b[1] == b[N - 1]) && (s[N - 1] == b[N - 1]) == (b[N - 2] == b[0]))
				{
					Console.WriteLine(string.Join("", b.Select(z => z ? "S" : "W")));
					return;
				}
			}
		Console.WriteLine(-1);
	}
}

Measured memory_bytes: 12256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N;
  cin >> N;
  int a[N];

  rep(i, N) {
    cin >> a[i];
  }
  
  int ans = 0;
  rep(i, N){
    for(int j = i + 1; j < N; j++) {
      ans = max(ans, abs(a[i] - a[j]));
    }
  }
  cout << ans << endl;

}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string S;
    cin >> S;

    ll ans;
    S.pop_back();
    while (true) {
        ll len = (ll)S.size();
        if ((len & 1) == 0) {
            if (S.substr(0, len / 2) == S.substr(len / 2, len / 2)) {
                ans = len;
                break;
            }
        }
        S.pop_back();
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main() {
    long N;
    cin>>N;
    vector<long> A(N);
    for (auto& a : A) cin>>a;
    const long MOD = 1e9+7;
    
    vector<long> ca(N), cz(N);
    ca[0] = A[0];
    cz[0] = A[0] == 0;
    map<long, vector<long>> nx;
    nx[A[0]].push_back(0);
    for (size_t i = 1; i < N; i++) {
        ca[i] = ca[i-1] ^ A[i];
        cz[i] = cz[i-1]+(ca[i] == 0);
        nx[ca[i]].push_back(i);
    }
    auto zeros = [&](long a, long b) {return cz[b] - (a>=0?cz[a]:0);};
    
    long ans = 0;
    if (ca.back() == 0) {
        ans = 1;
        for (size_t i = 0; i < cz.back()-1; i++) ans = (ans*2)%MOD;
    }
    for (auto xn : nx) {
        auto x = xn.first;
        if (x == 0) continue;
        if (ca.back() != 0 and x != ca.back()) continue;
        long bef = -1;
        long dp[2] = {1, 0};
        for (auto nx : xn.second) {
            dp[0] += dp[1]*zeros(bef, nx);
            dp[0] %= MOD;
            dp[1] += dp[0];
            dp[1] %= MOD;
            bef = nx;
        }
        if (ca.back() == 0) {
            ans += dp[1];
        } else {
            ans += dp[0];
        }
        ans %= MOD;
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 46064
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int d = a / b;
		int r = a % b;
		double f = (double)a / b;
		System.out.println(d + " " + r + " " + String.format("%1$.5f", f));

	}

}

Measured memory_bytes: 26404