akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    int main(void){
      int n,i,j,a[1010][1010],t=-1,k[1010]={};
      bool d[1010],pos=true;
      cin >> n;
      for (i=1;i<=n;i++) for (j=0;j<n-1;j++) cin >> a[i][j];
      while (pos){
        t++;
        pos=false;
        for (i=1;i<=n;i++) d[i]=false;
        for (i=1;i<=n;i++) if (k[i]!=n-1){
          j=a[i][k[i]];
          if (!d[i] && !d[j] && a[j][k[j]]==i){
            pos=true;
            k[i]++;
            k[j]++;
            d[i]=true;
            d[j]=true;
          }
        }
      }
      for (i=1;i<=n;i++) if (k[i]!=n-1) break;
      if (i==n+1) cout << t << endl;
      else cout << -1 << endl;
      return 0;
    }

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using ll = long long;
using ld = long double;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
int w[3000];

signed main() {
    accell();
    int n, t;
    cin >> n >> t;
    vector<pair<int, int> >a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(all(a));
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = t - 1; j >= 0; --j) {
            if (w[j] != 0 || j == 0) {
                ans = max(ans, w[j] + a[i].second);
            }
        }
        for(int j = t - 1; j >= 0; --j) {
            if (w[j] != 0 || j == 0) {
                if (j + a[i].first < t) {
                    w[j + a[i].first] = max(w[j + a[i].first], w[j] + a[i].second);
                }
            }
        }
    }
    cout << ans;
    return 0;
}


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

using namespace std;

int h, w;
char G[1010][1010];
int dp[1010][1010]; //dp[i][j] means  the number of roads to (i, j) 
const int MOD = 1e9 + 7;

int add(int x, int y) {
	x += y;
	while (x >= MOD)
		x -= MOD;
	return x;
}

bool vaild(int i, int j) {
	if (G[i][j] == '#')
		return false;
	else 
		return true;
}

void solve() {
	dp[1][1] = 1;
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++) {
			if (G[i][j] == '#') continue;
			else {
				if (vaild(i - 1, j)) dp[i][j] = add(dp[i - 1][j], dp[i][j]);
				if (vaild(i, j - 1)) dp[i][j] = add(dp[i][j - 1], dp[i][j]);
			}
		}
	cout << dp[h][w];
}

int main() {
	cin >> h >> w;
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			cin >> G[i][j];
	solve();
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long long ll;

//returns index of first element which has value not less than num.
int BS_lower_bound(vector <ll> &v, ll num, ll l, ll r) {
    if(l == r) {
        if(v[l] >= num) return l;
    }
    else if(r == (l+1)) {
        if(v[l] >= num) return l;
        else if(v[r] >= num) return r;
    }
    else {
        ll mid = (l+r)/2;
        if(v[mid] >= num) return BS_lower_bound(v, num, l, mid);
        else return BS_lower_bound(v, num, mid, r);
    }
    return -1;
}

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

    vector <ll> v;
    v.resize(n);

    map <ll,ll> m1;
    for(int  i = 0; i < n; i++) {
        cin >> v[i];

        if(m1.find(v[i]) == m1.end()) {
            m1[v[i]] = 1;
        }
        else m1[v[i]]++;
    }

    vector <ll> v1;
    map <ll, ll> :: iterator itr;

    for(itr = m1.begin(); itr != m1.end(); itr++) {
        v1.push_back((*itr).first);
    }

    ll n1 = v1.size();
    ll answer = 0;

    for(int i = 0; i < n1-2; i++) {
        for(int j = i+1; j < n1-1; j++) {
            int k;
            if(v1[n1-1] < (v1[i]+v1[j])) k = n1;
            else k = BS_lower_bound(v1, v1[i]+v1[j], j+1,n1-1);

            if(k == -1) {
                cout << "Not working" << endl;
                return 0;
            }

            for(int k1 = j+1; k1 < k; k1++) {
                answer += (m1[v1[i]] * m1[v1[j]] * m1[v1[k1]]);
            }
        }
    }

    cout << answer << endl;



    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n,m,d;
int main() {
    scanf("%lld%lld%lld",&n,&m,&d);
    double d0 = n, d1 = (n-1.0)*2.0;
    if(d==0){
        double ans = 1.0*d0*(m-1.0)/n/n;
        printf("%.8f\n",ans);
    }
    else if(d==1){
        double ans = 1.0*d1*(m-1.0)/n/n;
        printf("%.8f\n",ans);
    }
    else {
        double dd = d1 - 1.0*(d-1.0)*2.0;
        double ans = 1.0*dd*(m-1.0)/n/n;
        printf("%.8f\n",ans);
    }
    return 0;
}

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

using namespace std;

int main(void){
  int N;
  int sum=0;
  cin >> N;
  
  int a[N] = {0};
  
  for(int i=0;i<N;i++){
    cin >> a[i];
    sum ^= a[i];
  }
  
  for(int i=0;i<N;i++){
    int b = 0;
    b = sum ^ a[i];
    cout << b << " ";
  }
  cout << endl;
  return 0;
}
  

Measured memory_bytes: 4412
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

class CardEater
{
private:
	int n;
	vector<int> a;
	unordered_map<int, int> um;

public:
	CardEater() {
		cin >> n;
		a.resize(n);
		for (int i = 0; i < n; ++i)
		{
			cin >> a[i];
			um[a[i]]++;
		}
	}

	void exec() {
		int count = 0;
		int odd_count = 0;
		for(auto itr : um) {
			count++;
			if(itr.second % 2 == 0) {
				odd_count++;
			}
		}
		if(odd_count % 2 == 1) count--;
		cout << count << endl;
	}
	
};

int main() {
	CardEater ce = CardEater();
	ce.exec();
}


Measured memory_bytes: 4772
while True:
    try:
        a = map(int, raw_input().split())
        b = map(int, raw_input().split())
        hit = blow = 0
        for i in range(4):
            if a[i] == b [i]:
                hit+=1
            elif a[i] in b:
                blow+=1
        print hit, blow
    except:
        break



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

int main() {
  int k, a, b, s, golf = 0;
  cin >> k;
  cin >> a >> b;
  for (int i=1 ; i<100 ;i++){
    s = k*i ;
    if ( s>=a && s<=b){
      golf = 1;
      break;
    }
  }
  if (golf ==1 ) cout << "OK" <<endl;
  if (golf ==0 ) cout << "NG" << endl;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

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

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

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

void solve(int N, int L, int R, vector<int> const &seq) {
  int cnt = 0;
  FOR(x, L, R) {
    int i = 0;
    while (i < N && x % seq[i] != 0) { ++i; }
    if ((i < N && i % 2 == 0) || (i == N && N % 2 == 0)) { ++cnt; }
  }
  cout << cnt << endl;
}

int main() {
  // cout << fixed << setprecision(10);
  int N, L, R;
  while (cin >> N >> L >> R && N) {
    vector<int> seq;
    REP(i, N) {
      int A; cin >> A;
      seq.push_back(A);
    }
    solve(N, L, R, seq);
  }
  return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


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

    vector<int> x;
    int tmp = 1;
    for(int i = 1; i < s.length(); i++){
        if(s[i-1] == s[i]){
            tmp++;
        }
        else{
            x.push_back(tmp);
            tmp = 1;
        }
    }
    x.push_back(tmp);
    vector<int> cum;
    cum.push_back(0);
    for(int i = 0; i < x.size(); i++){
        cum.push_back(x[i] + cum[i]);
    }
    for(int k = s.length(); k >= 1; k--){
        auto itr = lower_bound(cum.begin(), cum.end(), k);
        itr--;
        if(s.size() - *itr >= k){
            cout << k << endl;
            return 0;
        }
    }

    return 0;
}




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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string b; cin >> b;
    REP(i, b.length())
    {
        switch (b[i])
        {
            case 'A':
                cout << 'T'; break;
            case 'C':
                cout << 'G'; break;
            case 'G':
                cout << 'C'; break;
            case 'T':
                cout << 'A'; break;
        }
    }
    cout << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int min = Integer.MAX_VALUE;
			int max = Integer.MIN_VALUE;

			for (int i = 0; i < N; i++) {
				int tmp = sc.nextInt();
				if (tmp < min) {
					min = tmp;
				}
				if (max < tmp) {
					max = tmp;
				}
			}

			System.out.println(max - min);
		}
	}
}

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

#define vi vector<int>
#define all(v) v.begin(), v.end()
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pp pop_back
#define forn(i,n) for(int i=0;i<n;i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int main(){
    int t;
    cin>>t;
    if(t==1){
        cout<<0;
    }
    else{
        cout<<1;
    }
}

Measured memory_bytes: 3620
#include <stdio.h>
int iCheckDeck(char chInputMark, int iInputNum, int aiDeck[4][13]);
int iPrintNoneCard(int aiDeck[4][13]);


// カードの情報を受け取り、不足しているカードを出力する
int main()
{
	// deck管理　添え字 0:S, 1: H, 2:C, 3: D
	int aiDeck[4][13] = { 0 }; 

	int iInputN;
	char chInputMark[2];
	int iInputNum;

	scanf("%d", &iInputN);


	while (iInputN > 0)
	{
		//printf("iInputN: %d\n", iInputN);
		scanf("%s %d", chInputMark, &iInputNum);
		iCheckDeck(chInputMark[0], iInputNum, aiDeck);
		
		iInputN--;
	}
	iPrintNoneCard(aiDeck);

	return 0;
}

// 入力されたカードをデッキに追加
int iCheckDeck(char chInputMark, int iInputNum, int aiDeck[4][13])
{
	switch (chInputMark)
	{
	case 'S':
		aiDeck[0][iInputNum - 1]++;
		break;
	case 'H':
		aiDeck[1][iInputNum - 1]++;
		break;
	case 'C':
		aiDeck[2][iInputNum - 1]++;
		break;
	case 'D':
		aiDeck[3][iInputNum - 1]++;
		break;
	default:
		break;
	}

	return 0;
}

// デッキで不足しているカードを出力
int iPrintNoneCard(int aiDeck[4][13])
{
	int iCnt1,iCnt2;

	for (iCnt1 = 0; iCnt1 < 4; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < 13; iCnt2++)
		{
			//printf("%d", aiDeck[iCnt1][iCnt2]);
			if (aiDeck[iCnt1][iCnt2] == 0)
			{
				switch (iCnt1)
				{
				case 0:
					printf("S %d\n", iCnt2+1);
					break;
				case 1:
					printf("H %d\n", iCnt2+1);
					break;
				case 2:
					printf("C %d\n", iCnt2+1);
					break;
				case 3:
					printf("D %d\n", iCnt2+1);
					break;
				default:
					break;
				}
			}
		}
	}

	return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>

#define MEMZERO(x) memset(x, 0, sizeof(x));

using namespace std;

int main ( void )
{
	const int dx[] = { 0, 0, 0, -1, 1, -1, 1, -1, 1, 0, 0, -2, 2 };
	const int dy[] = { 0, -1, 1, 0, 0, -1, -1, 1, 1, -2, 2, 0, 0 };
	int p[10][10];
	int x, y, s;
	
	MEMZERO(p);
	
	while(~scanf("%d,%d,%d", &x, &y, &s))
	{
		s *= 4;
		for ( int i = 0; i <= s; ++i )
		{
			int mx = x + dx[i];
			int my = y + dy[i];
			if ( 0 <= mx && mx < 10 && 0 <= my && my < 10 )
			{
				++p[my][mx];
			}
		}
	}
	
	int cnt = 0, val = 0;
	
	for ( int i = 0; i < 10; ++i )
		for ( int j = 0; j < 10; ++j )
			if(!p[i][j])
				++cnt;
			else
				val = max(val, p[i][j]);
	cout << cnt << endl << val << endl;
	
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
			cout<<"Yes"<<endl;
	}
	
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

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

	int r(0);
	for (int i(0); i < (int)s.size(); ++i) {
		if (s[i] == 'R') r++;
	}
	if (r > (n - r)) cout << "Yes";
	else cout << "No";
	return 0;
}

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

int main()
{
	int x[4], y[4], xh, yh;
	for (int i = 0; i < 2; ++i)
	{
		cin >> x[i] >> y[i];
	}
	xh = x[1] - x[0];
	yh = y[1] - y[0];
	y[2] = y[1] + xh;
	x[2] = x[1] - yh;
	y[3] = y[2] - yh;
	x[3] = x[2] - xh;
	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		int n  =sc.nextInt();
		long[]a = new long[n];
		for(int i=0; i<n; i++) {
			a[i] = sc.nextLong();
		}
		long[]acc = new long[n];
		acc[0] = a[0];
		for(int i=1; i<n; i++) {
			acc[i] = acc[i-1]+a[i];
		}
		HashMap<Long, Long> m = new HashMap<>();
		m.put(0L, 1L);
		for(int i=0; i<n; i++) {
			if(m.containsKey(acc[i])) {
				m.put(acc[i], m.get(acc[i])+1);
			} else {
				m.put(acc[i], 1L);
			}
		}
		long ans = 0;
		for(Map.Entry<Long, Long> e : m.entrySet()) {
			long num = e.getValue();
			ans += (num-1)*num/2;
		}
		System.out.println(ans);
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


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

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

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

//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t;
	cin>>t;
	auto no=[](){cout<<"No"<<endl;};
	auto yes=[](){cout<<"Yes"<<endl;};
	while(t--){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		if(b>a){//初日から在庫が足りない
			no();
			continue;
		}
		if(d<b){//在庫の追加が追いつかない
			no();
			continue;
		}
		if(b==d){//cが適切なら無限ループに落とし込める
			if(a%b<=c){
				yes();
			}else{
				no();
			}
			continue;
		}
		//以下, a>=b,d>bのケースを考える
		if(b<=c){//残りがbより少なくなったら追加可能なので常にok
			yes();
			continue;
		}
		//c<bのケース
		ll g=gcd(b,d);
		ll k=(b-a%g+g-1)/g-1;
		if(a%g+g*k<=c) yes();
		else no();
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl a(n);cin>>a;
	double ans=0, val=0;
	rep(i,n){
		val+=(a[i]+1)/2.;
		chmax(ans,val);
		if(i+1<k)continue;
		else val-=(a[i-k+1]+1)/2.;
		// puta(val);
	}
	fcout(10)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int ans = 0;
		if(N>=2000){
			ans = 1;
		} else {
			for(var i=0;i<=19;i++){
				for(var j=0;j<=19;j++){
					for(var k=0;k<=19;k++){
						for(var l=0;l<=19;l++){
							for(var m=0;m<=19;m++){
								for(var n=0;n<=19;n++){
									if(100*i+101*j+102*k+103*l+104*m+105*n==N){
										ans = 1;
									}
								}
							}
						}
					}
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
N,M,K=gets.split.map(&:to_i)
MOD=1000000007
def xsum
  sum=0
  (N-1).times do |i|
    i+=1
    sum+=(i*(N-i)*M*M) % MOD
  end
  return sum
end

def ysum
  sum=0
  (M-1).times do |i|
    i+=1
    sum+=(i*(M-i)*N*N) % MOD
  end
  return sum
end

def comb(n, k)
  def mpow(x, n)
    ret = 1
    while n > 0
      if n.even?
        x = x * x % MOD
        n >>= 1
      else
        ret = ret * x % MOD
        n -= 1
      end
    end
    return ret
  end
  k = k < n-k ? k : n-k
  return (n-k+1..n).inject(1){|p, q| p*q % MOD} * mpow((1 .. k).inject(1){|p, q| p*q % MOD}, MOD - 2)
end
puts ((xsum+ysum)*comb(N*M-2,K-2)) % MOD










Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>d(n);
    for(int i=0;i<n;i++)cin >> d[i];
    sort(d.begin(),d.end());
    cout << d[n/2]-d[n/2-1];    
}


Measured memory_bytes: 640
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>
#include <fstream>
#include <sstream>
#include <time.h>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define x first
#define y second
#define pi acos(-1.0)
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
//#define dprintf(...) 
#define hash _hash
#define next _next
//#define dprintf(...) fprintf(outFile,__VA_ARGS__)
 
#define FOREACH(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define ull unsigned long long
#define ll long long
#define N 200005
 
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}
 
//FILE* outFile;
inline void add(int &a,int b){a+=b;while(a>=mod)a-=mod;}


int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=ans*(ll)a%mod;
        a=(ll)a*a%mod;b>>=1;
    }
    return ans;
}

int a[N],l[N],r[N];
int main(){
    //freopen("1.txt","w",stdout);
    //cout<<setprecision(3)<<fixed;
    int T,i,j,k,n,m=0;
    scanf("%d",&n);
    rep(i,0,n)scanf("%d",&a[i]);
    l[0]=0;
    rep(i,1,n){
        j=i-1;
        while(j>=0&&a[j]>a[i])j=l[j]-1;
        l[i]=j+1;
    }
    r[n-1]=n-1;
    per(i,0,n-1){
        j=i+1;
        while(j<n&&a[j]>a[i])j=r[j]+1;
        r[i]=j-1;
    }
    ll ans=0;
    rep(i,0,n){
        ans+=1LL*(i-l[i]+1)*(r[i]-i+1)*a[i];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3068
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();
        int rlnum = 0;
        for (int pos = s.indexOf("RL"); 0 <= pos; pos = s.indexOf("RL", pos + 2)) {
            rlnum++;
        }
        int rltobehappy = Integer.min(k, rlnum);
        k -= rltobehappy;
        int unhappy = 2 * (rlnum - rltobehappy);
        if (s.charAt(0) == 'L') {
            if (0 < k) {
                k--;
            } else {
                unhappy++;
            }
        }
        if (s.charAt(n - 1) == 'R') {
            if (k <= 0) {
                unhappy++;
            }
        }
        if (unhappy == 0) {
            unhappy++;
        }
        System.out.println(n - unhappy);
    }
}


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

int main(){
    int q;
    cin >> q;
    while(q-- > 0){
        string s, t;
        cin >> s >> t;
        s = " " + s; // padding
        t = " " + t; // padding
        int h = s.length(), w = t.length();
        vector<vector<int>> dp(h, vector<int>(w,0));
        for(int i = 1; i < h; i++){
            for(int j = 1; j < w; j++){
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                if(s[i] == t[j])    dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
            }
        }
        cout << dp[h-1][w-1] << endl;
    }
    return 0;
}


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

int main(){
    int value[55], cost[55];
    int num, p;
    cin >> num;
    for (int i = 0; i < num; i++){
        scanf("%d", &value[i]);
    }
    for (int j = 0; j < num; j++){
        scanf("%d", &cost[j]);
    }
    p = 0;

    for (int k = 0; k < num; k++){
        if (value[k] > cost[k]){
            p += value[k] - cost[k]; 
        }else {
            continue;
        }
    }

    cout << p << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<list>
#include<stack>
#define ll  long long
#define lll __int128
#define fi first
#define ld long double
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<vector<int>>
using namespace std;
string s;
vector<int> a = {2, 4, 5, 7, 9};
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
    cin >> s;
    int b = s.back() - '0';
    for(int i  =0;  i< a.size();i++)
        if(a[i] == b){
            cout <<"hon";
            return 0;
        }
    if(b == 3)
        cout <<"bon";
    else
        cout <<"pon";
  return  0;    
}


Measured memory_bytes: 3084
package main

import (
  "fmt"
)

func main() {
  var a, b int

  fmt.Scanf("%d %d", &a, &b)
  if a % 2 == 1 && b % 2 == 1 {
    fmt.Print("Odd\n")
  } else {
    fmt.Print("Even\n")
  }
}

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

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int len = S.Length;
            string ans = "";
            for (int i = 0; i < len; i++)
                ans += "x";
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
int a=rr,b=rr;
printf("%d",max({(a+a-1),(b+b-1),(a+b)})); 
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    long h[]=new long[n];
    for (int i=0;i<n;i++) {
      h[i]=sc.nextInt();
    }

    Arrays.sort(h);

    if (n<=k) {
      System.out.println(0);
    }else{
      long total=0;
      for (int i=0;i<n-k;i++) {
        total=total+h[i];
      }
      System.out.println(total);
    }
  }
}


Measured memory_bytes: 91924
import sys,math,copy,queue,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(-1,0),(0,1),(0,-1))

A,B,N = LI()

x = 0
if N < B:
    x = N
else:
    x = B - 1
ans = math.floor(A*x/B) - A * math.floor(x/B)
print (ans)

Measured memory_bytes: 74908
import math
x, y, a = 0, 0, math.radians(90)
while True:
    p, q = map(int, raw_input().split(','))
    if p == 0 and q == 0:
        break
    x += math.cos(a) * p
    y += math.sin(a) * p
    a -= math.radians(q)
print int(x)
print int(y)

Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n; cin>>n; ll a[n]; 
	unordered_map<ll,ll> m;
	ll s=0;
	for(int i=0;i<n;i++) cin>>a[i],m[a[i]]++,s+=a[i];
	ll q; cin>>q;
	while(q--){
		ll x,y; cin>>x>>y;
		s+=(y-x)*m[x];
		m[y]+=m[x];
		m[x]=0;
		cout<<s<<endl;
	}


}


Measured memory_bytes: 7880
n , m = map(int, input().split())

arr = list(map(int, input().split()))
arr = sorted(arr, reverse=True)
ans = 0
s = sum(arr)/m/4

for i in range(n):
  if arr[i] >= s:
    ans += 1
  
if ans >= m:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);

	if(a == 2 && b == 2) printf("Yes");
	else if((a==4 || a==6 || a==9 || a==11) && (b==4 || b==6 || b==9 || b==11)) printf("Yes");
	else if((a==1 || a==3 || a==5 || a==7 || a==8 || a==10 || a==12) && (b==1 || b==3 || b==5 || b==7 || b==8 || b==10 || b==12)) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int k;
  cin >> k;
  ll ans = 0;
  FOR(a,1,k+1) FOR(b,1,k+1){ 
    int g1 = gcd(a,b);
    FOR(c,1,k+1){
      ans += (ll)gcd(g1,c);
    }
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, P; cin >> A >> P;
    cout << (3 * A + P) / 2 << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main()
{
	char c;
	int t = 3;
	int cnt = 0;
	while(t--){
		cin >> c;
		if(c == 'o') cnt++;
	}
	cout << 700+100*cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int K = scan.nextInt();
		int P[] = new int[n];
		int a = 0;
		for(int i=0; i<n; i++) {
			P[i] = scan.nextInt();
		}
		Arrays.sort(P);
		for(int i=0; i<K; i++) {
			a = a + P[i];
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 39108
s = input()
q = int(input())
for i in range(0, q):
    args = input().split()
    if args[0] == "print":
        print(s[int(args[1]): int(args[2]) + 1])
    elif args[0] == "reverse":
        tmp = s[0: int(args[1])]
        tmp += s[int(args[1]): int(args[2]) + 1][::-1]
        tmp += s[int(args[2]) + 1:]
        s = tmp
    elif args[0] == "replace":
        s = s[0:int(args[1])] + args[3] + s[int(args[2]) + 1:]



Measured memory_bytes: 5620
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

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

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  vi v(3); input(v);
  cout << (v[0]+v[1]+v[2] >= 22 ? "bust" : "win" ) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>

using namespace std;

class cTop3Hills
{
	vector<int> m_vh;
public:
	cTop3Hills(vector<int> &v)
	{
		m_vh = v;
	}
	void compare();
};

bool comp(int i, int j) { return i > j; }

void cTop3Hills::compare()
{
	sort(m_vh.begin(), m_vh.end(), comp);
	for (int i = 0; i < 3; ++i)
		cout << m_vh[i] << endl;
}

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

	vector<int> vh;
	int th;
	for (int i = 0; i < 10; ++i)
	{
		cin >> th;
		vh.push_back(th);
	}

	cTop3Hills ct(vh);
	ct.compare();

	return 0;
}

Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    char S[3];
    int i;
    
    for (i = 0; cin >> S[i]; i++) {
    }
    if (i == 2) {
        cout << S[0] << S[1] << endl;
    }   else {
        cout << S[2] << S[1] << S[0] << endl;
        
    }
    return 0;
}


Measured memory_bytes: 256
//============================
// ABC135c City Savers
//
// 2019/08/13
//============================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

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

//  long A[100000], B[100000];
  vector<long> A(N+1), B(N);
  for(int i=0; i<N+1; i++) cin >> A[i];
  for(int i=0; i<N; i++)   cin >> B[i];

  long long cnt=0;
  for(int i=0; i<N; i++)
  {
    cnt    += min(A[i], B[i]);
    B[i]   -= min(A[i], B[i]);
    cnt    += min(A[i+1], B[i]);
    A[i+1] -= min(A[i+1], B[i]);
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1792
x = int(input())
p = 2
list_prob = []
ind = 0
i = 1
while p < 11:
    ind = i ** p
    while ind < 1001:
        list_prob.append(int(i ** p))
        i += 1
        ind = i ** p
    i = 1
    p += 1
list_prob.append(1001)
list_prob.sort()
while i < len(list_prob):
    if list_prob[i] <= x and list_prob[i+1] > x:
        print(list_prob[i])
        break
    i += 1


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
    ll m, n, c1, c2, c3, c4, c5, c6, km, kn;
    cin >> m >> n;
    c1 = (m % 3 > 0) * n;
    c2 = (n % 3 > 0) * m;
    km = m / 3;
    kn = n / 3;
    c3 = max(km * n, (m - km) * (n / 2 + n % 2)) - min(km * n, (m - km) * (n / 2));
    c4 = max(kn * m, (n - kn) * (m / 2 + m % 2)) - min(kn * m, (n - kn) * (m / 2));
    km += (m % 3 > 0);
    kn += (n % 3 > 0);
    c5 = max(km * n, (m - km) * (n / 2 + n % 2)) - min(km * n, (m - km) * (n / 2));
    c6 = max(kn * m, (n - kn) * (m / 2 + m % 2)) - min(kn * m, (n - kn) * (m / 2));
    cout << min(c1, min(c2, min(c3, min(c4, min(c5, c6)))));
    return 0;
}

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

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    ll n, m, ans = 1;
    cin >> n >> m;
    for(ll i=1;i*i<=m;i++)
    {
		if (m%i) continue;
		if(i*n<=m)
			ans = max(ans,i);
		if((m/i)*n<=m)
			ans = max(ans,m/i);
	}
	cout << ans;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

string cs[] = {
	"black", "blue", "lime", "aqua",
	"red", "fuchsia", "yellow", "white"
};

int rs[] = {
	0, 0, 0, 0, 255, 255, 255, 255
};

int gs[] = {
	0, 0, 255, 255, 0, 0, 255, 255
};

int bs[] = {
	0, 255, 0, 255, 0, 255, 0, 255,
};

int get_num(char c1, char c2){
	int res = 0;
	if(isdigit(c1)) res += c1 - '0';
	else res += c1 - 'a' + 10;
	res *= 16;
	if(isdigit(c2)) res += c2 - '0';
	else res += c2 - 'a' + 10;
	return res;
}

int pow(int n){ return n * n;}

int get_d(int id, int r, int g, int b){
	return pow(rs[id] - r) + pow(gs[id] - g) + pow(bs[id] - b);
}

int main(){
	string s;
	int r, g, b;
	while(cin >> s && s != "0"){
		int best;
		int p = INF;
		r = get_num(s[1], s[2]);
		g = get_num(s[3], s[4]);
		b = get_num(s[5], s[6]);
		rep(i, 8){
			int c = get_d(i, r, g, b);
			if(c < p){
				best = i;
				p = c;
			}
		}
		cout << cs[best] << endl;
	}
	return 0;
}

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

inline int read() {
	int x = 0, p = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') p = -1; c = getchar(); }
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return x *= p;
}

inline void File() {
#ifndef ONLINE_JUDGE
	freopen("magic.in", "r", stdin);
	freopen("magic.out", "w", stdout);
#endif
}

const int N = 2e2 + 10, M = 1e7 + 10;
int prime[M], isnot[M], cnt, S[M], x;
int n, A[N], B[N], cnt1, cnt2, G[N][N];
int match[N], vis[N];

inline void Init(int n) {
	isnot[1] = 1;
	For(i, 2, n) {
		if(!isnot[i]) prime[++cnt] = i;
		For(j, 1, cnt) {
			if(1ll * i * prime[j] > n) break;
			isnot[i * prime[j]] = 1;
			if(i % prime[j] == 0) break;
		}
	}
}

inline bool dfs(int x) {
	For(i, 1, cnt2)	{
		if(G[x][i] && !vis[i]) {
			vis[i] = 1;
			if(match[i] == -1 || dfs(match[i])) {
				match[i] = x;
				return true;
			}
		}
	}
	return false;
}

int main() {
	Init(M - 5);
	n = read();
	For(i, 1, n) S[(x = read())] ^= 1;
	
	For(i, 1, M - 5) if(S[i] != S[i - 1]) {
		if(i & 1) A[++cnt1] = i;
		else B[++cnt2] = i;
	}
	For(i, 1, cnt1) For(j, 1, cnt2) 
		if(!isnot[abs(A[i] - B[j])] && abs(A[i] - B[j]) != 2) G[i][j] = 1;	

	memset(match, -1, sizeof match);
	int res = 0, ans;
	For(i, 1, cnt1) {
		memset(vis, 0, sizeof vis);
		if(dfs(i)) ++ res;
	}

	ans = res + (cnt1 - res >> 1) * 2 + (cnt2 - res >> 1) * 2;
	if(cnt1 - res & 1) ans += 3;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>

int main(){
    int a,b,c,d,i;
    int count;
    int max_data = 200;
    
    for(i=1;i<=max_data;i++){
        a=-1;
        b=-1;
        count=0;
        scanf("%d %d",&a,&b);
        
        if(a<0||b<0){
            break;
        }
        c=a+b;
        d=(int)log10((double)c) + 1;
        printf("%d\n",d);
    }
    return 0;
}

Measured memory_bytes: 644
#include <iostream>
using namespace std;
int h[1500001] = {},w[1500001] = {};

int main() {
  
  while(1) {
    
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0) break;
  
    int th[1500],tw[1500];
    int sum = 0;
    int L = 0;
  
    for(int i=0;i<n;i++) cin >> th[i] ,sum+= th[i];
    for(int j=0;j<m;j++) cin >> tw[j], L += tw[j];
    if(L < sum) L = sum;
  
    for(int i=0;i<n;i++) {
      int haba=0;
      for(int j=i;j<n;j++) {
	h[haba+th[j]]++;
	//cout << haba+th[j] << endl;
	haba+=th[j];
      }
    }
  
    for(int i=0;i<m;i++) {
      int haba=0;
      for(int j=i;j<m;j++) {
	w[haba+tw[j]]++;
	//cout << haba+tw[j] << endl;
	haba+=tw[j];
      }
    }

    int ans = 0;
    for(int i=1;i<=L;i++) ans += h[i]*w[i];
  
    cout << ans << endl;

    for(int i=1;i<=L;i++) h[i] = 0, w[i] =0;

  }
  
  return 0;
  
}

Measured memory_bytes: 7252
#include <cstdio>
#include <iostream>
#include <sstream>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

const string SP = " ";
i64 B[2][63];

int main() { 
  const i64 mod = 1e9+7LL;
  int n;
  cin >> n;
  vl a(n);
  for(auto&& x:a)cin >> x;
  for(auto&& x:a){
    for(int i=0;i<62;i++){
      i64 mask = (1LL<<i);
      if(x&mask)B[1][i]++;
      else B[0][i]++;
    }
  }

  i64 ans = 0LL;
  for(int i=0;i<62;i++){
    ans += (1LL << i) % mod * B[0][i] % mod * B[1][i] % mod;
    ans %= mod;
    cerr << i << SP << B[0][i] << SP << B[1][i] << SP << B[0][i] % mod * B[1][i] % mod * (1LL << i) % mod << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int Ai[n];
  for( int i=0; i<n; i++ ) cin >> Ai[i];

  double dominiator = 0;
  for(int i=0; i<n; i++ ) dominiator += 1 / double( Ai[i] );
  printf("%lf\n", 1/dominiator );
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b, c, d;
  string A, B, C, D;
  cin >> A >> B;

  int ans = 0;
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  int cnt = 0;
  rep(i, 3) if (A.at(i) == B.at(i)) ans++;

  cout << ans << endl;
}

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

using namespace std;

vector<int> h, st;

int dp(int c)
{
   if (st[c] != -1) return st[c];
   if (c == 1)
   {
      st[c] = abs(h[0] - h[1]);
      return st[c];
   }
   else if (c == 0)
   {
      st[c] = 0;
      return 0;
   }
   else
   {
      st[c] = min(dp(c - 2) + abs(h[c - 2] - h[c]), dp(c - 1) + abs(h[c - 1] - h[c]));
      return st[c];
   }
}

int main()
{
   int n;
   cin >> n;
   h = vector<int>(n);
   st = vector<int>(n, -1);
   for (int i = 0; i < n; i++)
   {
      cin >> h[i];
   }
   int res = dp(n - 1);
   cout << res;
   return 0;
}

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

int main() {
    int sum = 0;
    REP(i,10){
        int a;
        cin >> a;
        sum += a;
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if ((count(s.cbegin(), s.cend(), 'a')==0) 
	|| (count(s.cbegin(), s.cend(), 'b')==0)
	|| (count(s.cbegin(), s.cend(), 'c')==0)){
		cout << "No" << endl;
	} else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define db double
#define ld long double
#define pii pair<int,int> 
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define fore(i,a) for(int i=0;i<a.size();++i) 
const int N=3005;
int n,cc,a[N],f[N],hd[N];
struct E{int v,nxt;}e[N*2];
inline void add(int u,int v){e[++cc]=(E){v,hd[u]};hd[u]=cc;}
void dfs(int x,int p)
{
	f[x]=0;
	for(int i=hd[x],y;i;i=e[i].nxt)if((y=e[i].v)!=p&&a[x]>a[y])
	{
		dfs(y,x);
		if(!f[y]){f[x]=1;return;}
	}
}
int main()
{
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",&a[i]);
	for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	rep(i,1,n){dfs(i,0);if(f[i])printf("%d ",i);}
	return 0;
}


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

int main() {
  int A, B, count = 0;
  cin >> A >> B;

  for (int i = A; i <= B; i++) {
      string str = to_string(i);
      int size = str.size();
      if (str[0] == str[size - 1]
        && str[1] == str[size - 2]) {
        count++;
      }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;

int digsum(int n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    if(n%digsum(n) == 0)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256