akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

bool expr(bool a, bool b, bool c, bool d, auto& itr) {
  switch (*itr) {
    case '0': return ++itr, false;
    case '1': return ++itr, true;
    case 'a': return ++itr, a;
    case 'b': return ++itr, b;
    case 'c': return ++itr, c;
    case 'd': return ++itr, d;
    case '-': return !expr(a, b, c, d, ++itr);
    case '(': {
      bool l = expr(a, b, c, d, ++itr);
      bool is_xor = *itr == '^';
      bool r = expr(a, b, c, d, ++itr);
      assert(*itr == ')');
      return ++itr, is_xor ? l ^ r : l & r;
    }
    default: assert(false);
  }
}
int enc(const string& s) {
  int res = 0;
  for (int k = 0; k < 16; ++k) {
    auto itr = begin(s);
    res |= expr(k & 1, k & 2, k & 4, k & 8, itr) << k;
  }
  return res;
}
V<string> gen(int n) {
  if (n < 1) return {};
  if (n == 1) return {"0", "1", "a", "b", "c", "d"};
  V<string> res;
  for (const auto& s : gen(n - 1)) {
    if (s[0] != '-') res.push_back('-' + s);
  }
  for (int i = 1; i < n - 3; ++i) {
    for (const auto& l : gen(i)) for (const auto& r : gen(n - 3 - i)) {
      res.push_back('(' + l + '^' + r + ')');
      res.push_back('(' + l + '*' + r + ')');
    }
  }
  return res;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  V<> res(1 << 16, 1e9);
  for (int n = 1; n <= 16; ++n) {
    for (const auto& s : gen(n)) {
      int x = enc(s);
      res[x] = min(res[x], (int)s.size());
    }
  }
  while (true) {
    string s; cin >> s;
    if (s == ".") break;
    cout << res[enc(s)] << '\n';
  }
}


Measured memory_bytes: 139288
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    int a,b,c;
    cin >> a >> b>>c;

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

Measured memory_bytes: 256
#include<stdio.h>
#include<assert.h>
#include<math.h>
#include<string.h>
int stack[110];
int top = 0;

void push(int v){ stack[top++] = v; }
int  pop(){ return stack[--top]; }
int getInt(char *s)
{
  int i,ret=0;
  int size = strlen(s);
  for(i=0;i<size;i++)
    {
      ret += (s[i]-'0')*pow(10,size-i-1);
    }
  return ret;
}

int main()
{
  char s[1000];
  while(scanf("%s",s)!=EOF)
    {
      if('0' <= s[0] && s[0] <= '9')
	{
	  int v = getInt(s);
	  push(v);
	  continue;
	}
	  int a,b;
	  b = pop();
	  a = pop();
	  if(s[0] == '+')
	      push(a+b);
	  else if(s[0] == '-')
	    push(a-b);
	  else if(s[0] == '*')
	    push(a*b);
	  else 
	    assert(0);
    }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2020
#include <bits/stdc++.h>
#include <vector>
#include <stack>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <map>
#include <list>
using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> V(N),C(N);
  for(int i = 0; i < N; i++){
    cin >> V.at(i);
  }
 for(int i = 0; i < N; i++){
   cin >> C.at(i);
 }
  
  int ans = 0;
  for(int i = 0; i < N; i++){
    int x = V.at(i) - C.at(i);
    if(x > 0) ans += x; 
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define NEXTP(x) next_permutation(x.begin(),x.end())
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

class comb{
	public:
	vector<ll> f,fr;
	ll MOD;
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	ll ans = 0;
	cin >> n >> k;
	comb co;
	co.init(n+k,MOD);
	cout << co.calc(k,n,MOD) << endl;
}


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

int main() {
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	for(int i=0;i<k;i++)
	{
		if(b<=a)
		{
			b*=2;
		}
		else
		{
			c*=2;
		}
	}
	string ans="No";
	if(a<b&&b<c)
	{
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612
import java.io.*;

class Main {
	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			
			while(true){
			 String buf = br.readLine();

			 String[] line = buf.split(" ");
			 int x = Integer.parseInt(line[0]);
			 int y = Integer.parseInt(line[1]);			
				if( x ==0 && y == 0) break;
				if( x > y){
					System.out.print(y+" "+x);
				} else if( x < y ){
					System.out.print(x+" "+y);
				} else {
					System.out.print(x+" "+y);
				}
				System.out.print("\n");
			
			}
		} catch(Exception e){
		}
	} 
}

Measured memory_bytes: 26648
/*
 * src2.cpp
 *
 *  Created on: 2016/08/21
 *      Author: joi
 */
#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

const int MAX_N=1e5,INF=2e9;

int N;
int A[MAX_N],B[MAX_N];

map<int,int> mp;

int main(){
	scanf("%d",&N);
	REP(i,N){
		scanf("%d",&A[i]);
		B[i]=A[i];
	}
	sort(A,A+N);
	REP(i,N){
		mp[A[i]]=i;
	}
	ll ans=0;
	REP(i,N){
		ans+=abs(mp[B[i]]-i)%2;
	}
	printf("%lld\n",(ans+1)/2);
	return 0;
}








Measured memory_bytes: 5760
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;
long long int N,X,m[200200],res=0,L,R;

string S;
int main(){
    cout << fixed << setprecision(18);
    cin>>S;
    
    for(long long int i = 1; i < S.size(); i++){
        if(S[i]!=S[i-1]){res++;}
    }
    
    cout<<res<<endl;
}



Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define N 200010
#define M 1000010
#define maxn 200010
#define INF 2147483647
using namespace std;
vector<int> node[maxn], pos[maxn];
int res[maxn][2];
int id[2][maxn], s = 1, t = 2, cnt = 2, head[N], nxt[M], a[M], r[M], level[N];
int cur[N], edge, sum, ch[maxn], used[maxn], pre[maxn], dl[N];
void create(int u, int v, int t)
{
	edge++; a[edge] = v; nxt[edge] = head[u]; head[u] = edge; r[edge] = t;
}
void build()
{
	for (int i = 1; i <= cnt; i++)
	{
		level[i] = 0;
		cur[i] = head[i];
	}
	int lef = 1, righ = 1;
	level[s] = 1;
	dl[1] = s;
	while (lef <= righ)
	{
		int u = dl[lef];
		for (int i = head[u]; i; i = nxt[i])
		{
			int v = a[i];
			if (r[i] && level[v] == 0)
			{
				level[v] = level[u] + 1;
				dl[++righ] = v;
			}
		}
		lef++;
	}
}
int dinic(int u, int flow)
{
	if (u == t) return flow;
	int ans = 0;
	for (int i = cur[u]; i; i = nxt[i])
	{
		int v = a[i];
		if (r[i] && level[v] == level[u] + 1)
		{
			int low = dinic(v, min(flow, r[i]));
			ans += low; flow -= low;
			r[i] -= low; if (i % 2) r[i + 1] += low; else r[i - 1] += low;
		}
	}
	if (ans == 0) level[u] = -1;
	return ans;
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		id[1][i] = ++cnt;
		create(cnt, t, 1); create(t, cnt, 0);
	}
	for (int i = 1; i <= n - 1; i++)
	{
		id[0][i] = ++cnt;
		create(s, cnt, 1); create(cnt, s, 0);
		int m;
		scanf("%d", &m);
		for (int j = 1; j <= m; j++)
		{
			int x;
			scanf("%d", &x);
			node[i].push_back(x);
			pos[x].push_back(i);
			if (x != 1)
			{
				create(id[0][i], id[1][x], 1);
				create(id[1][x], id[0][i], 0);
			}
		}
	}
	build();
	while (level[t])
	{
		sum += dinic(s, INF);
		build();
	}
	if (sum != n - 1)
	{
		puts("-1");
		return 0;
	}
	for (int i = 1; i <= n - 1; i++)
	{
		int u = id[0][i];
		for (int j = head[u]; j; j = nxt[j])
		{
			int v = a[j];
			if (v >= id[1][1] && r[j] == 0) {ch[i] = v - id[1][1] + 1; break;}
		}
	}
	int cnt = 1;
	pre[1] = 1;
	for (int i = 1; i <= cnt; i++)
	{
		int u = pre[i], len = pos[u].size();
		for (int j = 0; j <= len - 1; j++)
		{
			int x = pos[u][j];
			if (used[x] == 0)
			{
				used[x] = 1;
				res[x][0] = u; res[x][1] = ch[x];
				pre[++cnt] = ch[x];
			}
		}
	}
	if (cnt != n) puts("-1");
	else
	for (int i = 1; i <= n - 1; i++)
		printf("%d %d\n", res[i][0], res[i][1]);
	return 0;
}

Measured memory_bytes: 41216
#include <stdio.h>
#include <string.h>
#include <set>
#define in(x) insert(x)
using namespace std;
set<char>RB;int main() {
    char T[999];RB.in('y'),RB.in('u'),RB.in('i'),RB.in('o'),RB.in('p'),RB.in('h'),RB.in('j'),RB.in('k'),RB.in('l'),RB.in('n'),RB.in('m');int i,j,k;while (1) {
        scanf("%s",&T);if (T[0]=='#') break;i=strlen(T)-1,j=0;k=RB.find(T[i])!=RB.end();
		while (i--) if (k!=(RB.find(T[i])!=RB.end())) j++,k=1-k;printf("%d\n",j);
    }
    return 0;
}

Measured memory_bytes: 1004
#include <iostream>
using namespace std;
long long gcd (long long a, long long b)
{
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main()
{
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long nod = gcd(c, d);
  long long nok = c * d / nod;
  long long cnta = a / c + a / d - a / nok;
  long long cntb = b / c + b / d - b / nok;
  long long dif = cntb - cnta + (a % c == 0 or a % d == 0);
  cout << b - a + 1 - dif << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> P;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n),b(40,0);
    rep(i,0,n){
        cin>>a[i];
        int j=0;
        int tmp = a[i];
        while(tmp){
            b[j]^=tmp&1;
            tmp>>=1;
            j++;
        }
    }
    rep(i,0,n){
        int tmp = 0;
        rep(j,0,40){
            tmp+=b[j]*(1<<j);
        }
        cout<<(tmp^a[i])<<' ';
    }
}

Measured memory_bytes: 3892
#include <iostream>
using namespace std;
bool exchange(int &A, int &B, int &C)
{
	if (A % 2 || B % 2 || C % 2)
	{
		return false;
	}
	int halfA = A / 2, halfB = B / 2, halfC = C / 2;
	A = halfB + halfC;
	B = halfA + halfC;
	C = halfA + halfB;
	return true;
}

int exchangeCookie(int &A, int &B, int &C)
{
	int counter = 0;
	while (true)
	{
		if (exchange(A, B, C))
		{
			counter++;
			if (A == B && B == C)
			{
				return -1;
			}
		}
		else
		{
			return counter;
		}
	}

}

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << exchangeCookie(A, B, C) << endl;
	return 0;
}

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

int main(){
    int H, W; cin >> H >> W;
    vector<vector<char>> A(100, vector<char>(100));

    rep(i, H) rep(j, W) cin >> A[i][j];

    vector<bool> rows(H,true), columns(W,true);

    rep(i,H) rep(j,W) {
        if(A[i][j] == '#'){
            rows[i] = false;
            columns[j] = false;
        }
    }

    rep(i,H){
        bool flag = false;
        rep(j,W){
            if(!rows[i] && !columns[j]){
                cout << A[i][j];
                flag = true;
            }
        }
        if(flag) cout << endl;
    }
}

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

#define go(i,a,b) for(int i=a;i<=b;++i)
#define com(i,a,b) for(int i=a;i>=b;--i)
#define mem(a,b) memset(a,b,sizeof(a))
#define fo(i,a) for(int i=0;i<a;++i)
#define il inline
#define int long long

const int inf=0x3f3f3f3f,N=2010,mod=1e9+7;

int n,m,dp[N];

il void read(int &x){
	x=0;char c=getchar(),f=1;
	while(!isdigit(c)){ if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)){ x=x*10+c-'0'; c=getchar(); }
	x*=f;
}

signed main(){
	//freopen("input.txt","r",stdin);
	read(n),read(m);
	dp[n+1]=1;
	go(i,1,m){
		com(j,n,1){
			if(n-j+1<i) dp[j]=0;
			else (dp[j]+=dp[j+1])%=mod;
		}
	}
	int ans=1;
	go(i,1,n-m-1) ans=ans*2%mod;
	printf("%lld",ans*dp[1]%mod);
	return 0;
}

Measured memory_bytes: 256
from itertools import*
s,k=open(0)
k=int(k)
g=[len(list(v))for _,v in groupby(s)]
print(sum(c//2for c in g)*k+((s[0]==s[-2])*g[0]%2&g[-2]%2)*(k//2*(-len(s)==~g[0])or k-1))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;


//int main(){
//  set<string> str;
//  string s;
//  cin>>s;
//  int x;
//  cin>>x;
//  str.insert(s);
//
//  for(int i=0; i<s.size(); i++){
//    for(int j=0; i+j<s.size(); j++){
//      string st;
//      int y=0;
//      cout<<"i = "<<i<< "  J = "<<j<<en
//      for(int k=i; k<=i+j; k++){
//        st[y++]=s[k];
//        cout<<"st["<<y-1<<"] = "<<s[k]<<en
//      }
//      string sst=st.substr(i,j);
//      str.insert(sst);
//    }
//  }
//
//  int i=0;
//  for(set<string>::iterator it=str.begin(); it!=str.end(); it++){
//    i++;
//    string ss=*it;
//    cout<<"ss = "<<ss<<en
//    if(i==x) {
//      cout<<ss<<en
//      break;
//    }
//  }
//}



char ch[105];


int main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>ch[i];
  }
  int ans=0;
  for(int i=1; i<n; i++){
    map<char,bool> mp;
    for(int j=0; j<n; j++) mp[ch[j]]=0;
    int cnt=0;
    for(int j=0; j<i; j++){
      for(int k=i; k<n; k++){
        if(mp[ch[k]]==1||mp[ch[j]]==1) continue;
        if(ch[j]==ch[k]){
          cnt++;
          mp[ch[j]]=1;
          break;
        }
      }
    }
    ans=max(ans,cnt);
  }
  
  cout<<ans<<en
}


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

int main(){
    long N,K;
    cin >> N >> K;

    vector<long> H(N);
    for(long i=0; i<N; ++i) cin >> H.at(i);

    sort(H.rbegin(),H.rend());

    long total = 0;

    for(long i=K; i<N; ++i) total += H.at(i);
    cout << total << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S, T; std::cin >> S >> T;

  bool flag = false;
  for(char c='a'; c<='z'; c++) {
    auto s = S;
    s.push_back(c);
    if ( s == T ) flag = true;
  }
  
  if ( flag ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}



Measured memory_bytes: 3612
use std::io;


fn main() {
    let abcd = read_one::<String>().chars()
        .map(|c| c as isize - '0' as isize)
        .collect::<Vec<isize>>();

    // 0: +, 1: -
    for j in 0..1 << (abcd.len() - 1) {
        let mut sum = abcd[0];
        let mut ans = abcd[0].to_string();
        let mut vec = Vec::new();
        for k in 0..(abcd.len() - 1) {
            vec.push(j & (1 << k));
            if (j & 1 << k) != 0 {
                sum -= abcd[k + 1];
                ans.push_str(format!("-{}", abcd[k + 1]).as_str());
            } else {
                sum += abcd[k + 1];
                ans.push_str(format!("+{}", abcd[k + 1]).as_str());
            }
        }
        if sum == 7 {
            println!("{}=7", ans);
            break;
        }
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vl a(3);
  rep(i, 3) cin >> a[i];
  ll k;
  cin >> k;
  sort(ALL(a));
  reverse(ALL(a));
  rep(i, k) a[0] *= 2;
  ll ans = 0;
  rep(i, 3) ans += a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define set setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
#include<numeric>
using namespace std;
int gcd(int a, int b)//最大公約数
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)//最小公倍数
{
	return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;;
	return(j);
}
int main(){
	ll a, b, n;
cin >> a >> b >> n;
if (n / b > 100000000) {
	ll p = n / b;
	cout << ((floor(a * n / b)) - a * (floor(n / b))) << endl;
}
else {
	ll k = n / b;
	ll s;
	ll maxx = 0;
	for (int i = 0; i <= k; i++) {
		s = (i + 1) * b - 1;
		if (i == k)s = n;
		if (maxx < ((floor(a * s / b)) - a * (floor(s / b)))) {
			maxx = ((floor(a * s / b)) - a * (floor(s / b)));
		}
	}
	cout << maxx << endl;
}
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <cstdio>
#include <complex>
using namespace std;

int main() {
  int N , W;
  cin >> N >> W;
  vector<vector<int> > vs(N+1, vector<int>(W+1, 0));
  for (int i = 1; i <= N; i++) {
    int v, w;
    cin >> v >> w;
    for (int j = 0; j <= W; j++) {
      vs[i][j] = vs[i-1][j];
      if (j < w) continue;
      vs[i][j] = max(vs[i][j], vs[i][j-w] + v);
    }
  }
  
  cout << vs[N][W] << endl;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int a;
  cin>>a;
  cout<<"ABC"<<a<<endl;
}


Measured memory_bytes: 14080
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
using namespace std;
typedef long long int ll;

int main() {
    string N; cin >> N;
    ll ans=0;
    for (ll i=0; i<N.size();i++){
        if (N[i] == '2') ans += 1;
    }
    cout << ans << endl;
    
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b;
  c = a * b % 2;
  if ( c == 0 ) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;

int main() {
    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << endl;
    return 0;
}


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

const int N=2e5+5;
const int mod=1e9+7;

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n,k;cin>>n>>k;
    ll l=1LL*k*(k-1)/2,r=1LL*k*n-1LL*k*(k-1)/2;
    ll ans=(r-l+1)%mod;
    for(int i=k;i<=n;i++){
        l+=i,r+=n-i;
        (ans+=r-l+1)%=mod;
    }
    cout<<ans;
}


Measured memory_bytes: 3624
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str = sc.next();
        System.out.print(change(str,n));
        
    }
    static String change(String str,int n){
        char[] strary = str.toCharArray();
        for(int i = 0;i < strary.length;i++){
            for(int j = 0;j < n;j++){
                if(strary[i] == 'A'){
                    strary[i] = 'B';
                } else if(strary[i] == 'B'){
                    strary[i] = 'C';
                } else if(strary[i] == 'C'){
                    strary[i]  = 'D';
                } else if(strary[i] == 'D'){
                    strary[i] = 'E';
                } else if(strary[i] == 'E'){
                    strary[i]  = 'F';
                }else if(strary[i] == 'F'){
                    strary[i] = 'G';
                } else if(strary[i] == 'G'){
                    strary[i]  = 'H';
                }else if(strary[i] == 'H'){
                    strary[i] = 'I';
                } else if(strary[i] == 'I'){
                    strary[i]  = 'J';
                }else if(strary[i] == 'J'){
                    strary[i] = 'K';
                } else if(strary[i] == 'K'){
                    strary[i]  = 'L';
                }else if(strary[i] == 'L'){
                    strary[i] = 'M';
                } else if(strary[i] == 'M'){
                    strary[i]  = 'N';
                }else if(strary[i] == 'N'){
                    strary[i] = 'O';
                } else if(strary[i] == 'O'){
                    strary[i]  = 'P';
                }else if(strary[i] == 'P'){
                    strary[i] = 'Q';
                } else if(strary[i] == 'Q'){
                    strary[i]  = 'R';
                }else if(strary[i] == 'R'){
                    strary[i] = 'S';
                } else if(strary[i] == 'S'){
                    strary[i]  = 'T';
                }else if(strary[i] == 'T'){
                    strary[i] = 'U';
                } else if(strary[i] == 'U'){
                    strary[i]  = 'V';
                }else if(strary[i] == 'V'){
                    strary[i] = 'W';
                } else if(strary[i] == 'W'){
                    strary[i]  = 'X';
                }else if(strary[i] == 'X'){
                    strary[i] = 'Y';
                } else if(strary[i] == 'Y'){
                    strary[i]  = 'Z';
                }else if(strary[i] == 'Z'){
                    strary[i] = 'A';
                } 
            }
        }   
        String ans="";
        for(int i = 0;i < strary.length;i++)ans += strary[i];
        return ans;
    }
    
}


Measured memory_bytes: 145992
#include <stdio.h>
#include <string.h>

void iSortAscend( char *, int );
void iSortDescend( char *, int );

int main( void ) {
	char aStr[ 20 ][ 7 ], min[ 7 ], max[ 7 ];
	int i, j, a0, L;

	for ( ; scanf( "%d %d", &a0, &L ), L; printf( "%d %d %d\n", j, atoi( aStr[ i ] ), i - j ) ) {
		sprintf( aStr[ 0 ], "%0*d", L, a0 );

		for ( i = 1; ; i++ ) {
			strcpy( min, aStr[ i - 1 ] );
			iSortAscend( min, L );

			strcpy( max, aStr[ i - 1 ] );
			iSortDescend( max, L );

			sprintf( aStr[ i ], "%0*d", L, atoi( max ) - atoi( min ) );

			for ( j = 0; j < i; j++ )
				if ( !strcmp( aStr[ j ], aStr[ i ] ) )
					break;
			if ( j != i )
				break;
		}
	}

	return 0;
}


void iSortAscend( char *data, int n ) {
	char tmp;
	int i, j;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		if ( data[ i - 1 ] > tmp ) {
			j = i;
			do {
				data[ j ] = data[ j - 1 ];
				j--;
			} while ( j > 0 && data[ j - 1 ] > tmp );
			data[ j ] = tmp;
		}
	}
}

void iSortDescend( char *data, int n ) {
	char tmp;
	int i, j;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		if ( data[ i - 1 ] < tmp ) {
			j = i;
			do {
				data[ j ] = data[ j - 1 ];
				j--;
			} while ( j > 0 && data[ j - 1 ] < tmp );
			data[ j ] = tmp;
		}
	}
}

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(string, a, b, c);
	printf("%c%c%c\n", a[0] - 'a' + 'A', b[0] + -'a' + 'A', c[0] + -'a' + 'A');
}

Measured memory_bytes: 256
X=int(input())
flagp=False
flagm=False
flage=True
for A in range(-10**3,10**3):
    B5=A**5-X
    for B in range(10**3):
        if B5==B**5:
            flagp=True
            flage=False
            break
        elif B5==-B**5:
            flagm=True
            flage=False
            break
    else:
        continue
    break
if flagp:
    print(A,B)
elif flage:
    raise Exception
else:
    print(A,-B)

Measured memory_bytes: 9180
N,K=map(int,input().split())
P=list(map(int,input().split()))
E=[0]*N

for i in range (N):
	E[i]=((P[i]+1)/2)

L=[0]*(N+1)
L[0]=0

for i in range (N):
	L[i+1]=L[i]+E[i]

ans=0

for i in range (K,N+1):
	ans=max(ans,L[i]-L[i-K])

print(ans)

Measured memory_bytes: 24804
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int n,d;
vector<int> nums;

int getDigit(int num) {
  int digit = 0;
  while(num!=0) { num/=10; digit++; }
  return digit;
}

void dfs(vector<int> v) {
  if (v.size() == d) return;

  for(int i: {3,5,7}) {
    vector<int> nv = v;
    nv.push_back(i);

    int x = 0;
    REP(j,nv.size()) x += nv[j] * pow(10,j);
    nums.push_back(x);

    dfs(nv);
  }
}

int main() {
  cin >> n; d = getDigit(n);
  dfs(vector<int>());

  int ans = 0;
  for(int num: nums) {
    if (num > n) continue;
    M m;
    while(num>0) {
      m[num % 10]++;
      num/=10;
    }
    if (m[3] > 0 && m[5] > 0 && m[7] > 0) ans++;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 512
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static HashMap<String,Integer>dp;
    public static void main(String []args){
        Scanner in=new Scanner(System.in);
        String str=in.nextLine();
        StringBuilder sb=new StringBuilder(str);
        System.out.println(sb.replace(0,4,"2018"));
    }
}






Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
using namespace std;

int N,M,Cap;

struct Edge{
public:
	int to,cost;
	Edge(int a,int b){to=a;cost=b;}
	Edge(){to=0;cost=0;}
};

typedef vector<vector<Edge> > Graph;

const int INF=1000000007;

class Info{
public: 
	int now,total,rem;
	Info(int a,int b,int c){now=a;total=b;rem=c;}
	bool operator < (const Info &a) const {return total>a.total;}
};

vector<int> get_cost(Graph g,int s){
	vector<int> res(N*2,INF);
	vector<bool> visit(N*2,false);
	priority_queue<Info> Q;
	Q.push(Info(s,0,0));
	while(!Q.empty()){
		Info top=Q.top();
		Q.pop();
		int pos=top.now;
		if(visit[pos]) continue;
		visit[pos]=true;
		res[pos]=top.total;
		for(int i=0;i<g[pos].size();i++)
			Q.push(Info(g[pos][i].to,top.total+g[pos][i].cost,0));
	}
	return res;
}

int calc(Graph g,int s,int t){
	vector<bool> visit(N*2,false);
	priority_queue<Info> Q;
	Q.push(Info(s,0,0));
	while(!Q.empty()){
		Info top=Q.top();
		Q.pop();
		if(top.now==t) return top.total;
		int pos=top.now;
		if(visit[pos]) continue;
		visit[pos]=true;
		for(int i=0;i<g[pos].size();i++)
			Q.push(Info(g[pos][i].to,top.total+g[pos][i].cost,0));
	}
	return -1;
}

void solve()
{
	Cap*=10;
	map<string,int> Idx;
	Graph V(N*2,vector<Edge>(0));
	int size=0;
	string start,goal;
	cin>>start>>goal;
	Idx[start]=size++; Idx[goal]=size++;
	for(int i=0;i<N;i++){
		string s1,s2; int d;
		cin>>s1>>s2>>d;
		if(!Idx.count(s1)) Idx[s1]=size++;
		if(!Idx.count(s2)) Idx[s2]=size++;
		V[Idx[s1]].push_back(Edge(Idx[s2],d));
		V[Idx[s2]].push_back(Edge(Idx[s1],d));
	}

	vector<int> Sta(M+2);
	for(int i=0;i<M;i++){
		string s;
		cin>>s;
		Sta[i]=Idx[s];
	}
	Sta[M]=Idx[start];Sta[M+1]=Idx[goal];

	Graph g(N*2);
	for(int i=0;i<M+2;i++){
		vector<int> temp=get_cost(V,Sta[i]);
		for(int j=0;j<M+2;j++){
			if(temp[Sta[j]]<=Cap)
				g[Sta[i]].push_back(Edge(Sta[j],temp[Sta[j]]));
		}
	}

	cout<<calc(g,Idx[start],Idx[goal])<<endl;

}


int main()
{
	while(cin>>N>>M>>Cap){
		if(N==0) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)




int main() {
	int N, K; cin >> N >> K;
	uint64_t ans = 0;
	int length = 0;
	char bef = 'A';
	rep(i, N) {
		char c; cin >> c;
		if (c != bef) {
			length++;
			bef = c;
		}
		else {
			ans++;
		}
	}
	if (length > 2) {
		int tmp = min(K, (length - 1) / 2);
		length -= 2 * tmp;
		ans += 2 * tmp;
		K -= tmp;
	}
	if (K > 0 && 1 < length && length < 3) {
		ans++;
		length--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
spades = []
hearts = []
clubs = []
diamonds = []

mspades = []
mhearts = []
mclubs = []
mdiamonds = []

n = int(input())

i = 0

while i < n:
    card = input()
    if 'S' in card:
        spades.append(card)
    elif 'H' in card:
        hearts.append(card)
    elif 'C' in card:
        clubs.append(card)
    else:
        diamonds.append(card)
    i += 1


deck = [spades, hearts, clubs, diamonds]
mdeck = [mspades, mhearts, mclubs, mdiamonds]
symbols = ['S ', 'H ', 'C ', 'D ']

onDeck = 0

while onDeck < 4:
    rank = 1
    while rank <= 13:    
        if symbols[onDeck] + str(rank) in deck[onDeck]:
            pass
        else:
            mdeck[onDeck].append(symbols[onDeck] + str(rank))
        rank += 1
    onDeck += 1

onmDeck = 0

while onmDeck < 4:
    if mdeck[onmDeck] != []:
        print("\n".join(mdeck[onmDeck]))
    onmDeck += 1

Measured memory_bytes: 7684
/*
 * 組み合わせ
 */
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (auto &e : {a, b, c}) {
        for (long i = 0; i < n; ++i) {
            cin >> e[i];
        }
    }
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    long long total = 0;
    for (auto be: b) {
      total += (lower_bound(a, a + n, be) - a) * (c + n - upper_bound(c, c + n, be));
    }

    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 1408
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#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 Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

int W, H;
vector<vector<int>> field;

void dfs(int h, int w) {
    field[h][w] = 0;

    for(int dh = -1; dh <= 1; ++dh) {
        for(int dw = -1; dw <= 1; dw++) {
            int nh = h + dh, nw = w + dw;

            if(nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if(field[nh][nw] == 0) continue;

            dfs(nh, nw);
        }
    }
}

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

    while(cin >> W >> H) {
        if(H == 0 || W == 0) break;
        field.assign(H, vector<int>(W, 0));
        rep(h, H) rep(w, W) cin >> field[h][w];

        int count = 0;
        rep(h, H) {
            rep(w, W) {
                if(field[h][w] == 0) continue;
                dfs(h, w);
                ++count;
            }
        }
        cout << count << endl;
    }
}



Measured memory_bytes: 3300
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


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

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 146 B - ROT N
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/08
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstring>
using namespace std;

int n;
char s[10000];

void solve() {

    for (int i=0;s[i]!='\0';i++) {
        s[i] = s[i] + n;
        if (s[i] > 'Z')
            s[i] -= 26;
    }
    printf("%s\n", s);

}

int main() {

    scanf("%d", &n);
    scanf("%s", s);

    solve();

}

Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Competition
{
    public class Program
    {
        
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var res = 0;
            if (S == "SUN") res = 7;
            if (S == "MON") res = 6;
            if (S == "TUE") res = 5;
            if (S == "WED") res = 4;
            if (S == "THU") res = 3;
            if (S == "FRI") res = 2;
            if (S == "SAT") res = 1;
            Console.WriteLine(res);
        }

    }
}


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

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

  int w = 0;
  int b = 0;

  for(int i=0;i<n;i++) {
    if(s[i] == '.') w++;
    else b++;
  }

  int ans = w;

  int now = w;

  for(int i=0;i<n;i++) {
    if(s[i] == '.') {
      now--;
      if(now < ans) ans = now;
    }
    else {
      now++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int ans = x/(z+y);
  int q = x%(z+y);
  if(q>=z) cout << ans << endl;
  else cout << ans-1 << endl; 
  return 0;
}

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

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

    int T[N];

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

    int M;
    cin >> M;

    int P[M],X[M];
    int sum = 0;

    for(int i = 0;i<M;i++){
        cin >> P[i] >> X[i];
    }

    for(int i = 0;i<M;i++){
        sum = 0;
        for(int j = 0;j<N;j++){
            if(P[i] == j+1){
                sum += X[i];
            }
            else{
                sum += T[j];
            }
        }
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int conpute( int y,int m, int d ){

  int day = 0;

  for( int i = 1 ; i < y ; i++ ){
    day += 365;
    if( i % 100 == 0 ){
      if( i % 400 == 0 ) day++;
    }
    else if( i % 4 == 0 ) day++;
  }
  
for( int i = 1 ; i <  m ; i++ ){

    switch(i){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      day += 31;
      break;
    case 2:
      day += 28;
      if( y % 100 == 0 ){
	if( y % 400 == 0 ) day++;
      }
      else if( y % 4 == 0 ) day++;
      break;
    case 4:
    case 6:
    case 9:
    case 11:
      day += 30;
      break;
    }
 }
 day += d;
 return day;
}
int main(void){
  
  int y1,y2;
  int m1,m2;
  int d1,d2;
  
  while( cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2 ){
    if( y1 == m1 && m1 == d1 && d1 == y2 && y2 == m2 && m2 == d2 && d2 == -1 ){
      break;
    }
    int ans = 0;
    ans = conpute( y2, m2, d2 ) - conpute( y1, m1, d1 );
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

void solve()
{
    
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a; cin >> a;
    cout << a+a*a+a*a*a;
    return 0;
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// https://siongui.github.io/2017/05/07/go-sort-string-slice-of-rune/
type ByRune []rune

func (r ByRune) Len() int           { return len(r) }
func (r ByRune) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r ByRune) Less(i, j int) bool { return r[i] < r[j] }

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func SortStringByCharacter(s string) string {
	var r ByRune = StringToRuneSlice(s)
	sort.Sort(r)
	return string(r)
}

// main is ...
func main() {
	var n int

	var sc = bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		n, _ = strconv.Atoi(sc.Text())
	}
	var list = make([]string, n)
	for i := 0; i < n; i++ {
		if sc.Scan() {
			list[i] = sc.Text()
		}
	}

	m := map[string]int{}
	for _, s := range list {
		m[string(SortStringByCharacter(s))]++
	}

	ret := 0
	for _, v := range m {
		ret += v * (v - 1) / 2
	}

	fmt.Println(ret)
}


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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        long x=sc.nextLong();
        long y=sc.nextLong();
        out.println(Math.abs(x-y)<=1?"Brown":"Alice");
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int x, y, z;
	scanf("%d %d %d", &x,&y,&z);
if(x<=z&&z<=y)printf("Yes\n");
else printf("No\n");

	return 0;
}


Measured memory_bytes: 128