akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1<<30)-10;


void solve(long long N, long long A, long long B){
  ll cnt = N/(A+B);
  ll ans = A*cnt;
  ll rest = (N%(A+B));
  ans += min(A, rest);
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
/* ex 7_3 APG4b • AtCoder Beginner Contest 107 B
   nk777 */
 
#include<stdio.h>
// メモリの動的確保
#include<stdlib.h>

int main(void){
    // H行line,W列col,,for文のカウンタi,j,黒がある行と列を記憶する配列lineBlack,colBlack(初期値0)
    int line, col, i, j, *lineBlack, *colBlack;
    // 入力格納2次元配列matrix
    char **matrix;

    // line, colを受け取る
    scanf("%d %d", &line, &col);

    // line分の領域を確保
    lineBlack = (int*)calloc(line, sizeof(int));
    // col分の領域を確保
    colBlack = (int*)calloc(col, sizeof(int));
    if (lineBlack == NULL || colBlack == NULL)
    {
        exit(1);
    }
    
    // 各行の配列へのポインタ分のメモリ領域を確保
    matrix = (char**)calloc(line, sizeof(char*));
    if (matrix == NULL)
    {
        exit(1);
    }
    // 各行の要素分のメモリ領域を確保
    for (i = 0; i < line; i++)
    {
        matrix[i] = (char*)calloc(col, sizeof(char));
        if (matrix[i] == NULL)
        {
            exit(1);
        }
        for (j = 0; j < col; j++)
        {
            // 入力されるマス目の色を受け取る
            scanf(" %c", &matrix[i][j]);
            // もし黒だったら
            if (matrix[i][j] == '#')
            {
                // 黒があることを記録
                lineBlack[i] = 1;
                colBlack[j] = 1;
            } 
        }
    }
   
    // 黒が一つでもある行と列を出力
    for (i = 0; i < line; i++)
    {
        if (lineBlack[i] == 1)
        {
           for (j = 0; j < col; j++)
           {
               if (colBlack[j] == 1)
               {
                    // 行も列も黒があるときだけ表示
                    printf("%c", matrix[i][j]);
               }
           }

            // 1行終わるごとに改行する
            printf("\n");
        }
        // matrixの各行の要素を解放
        free(matrix[i]);
    }
    // メモリ領域の解放
    free(lineBlack);
    free(colBlack);
    // matrix各行の配列へのポインタ解放
    free(matrix);
    
    return 0;
}


Measured memory_bytes: 1624
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,k,f,a[maxn];

int main()
{
	n=read(); k=read();
	if((n-1)%(k-1)==0) cout<<(n-1)/(k-1)<<endl;
	else cout<<(n-1)/(k-1)+1<<endl;
	return 0;
}

Measured memory_bytes: 256
from math import ceil
n = int(input())

lst = []
if n == 0:
    ans = 0
else:
    while n!= 1:
        lst.append(n-(-2)*ceil(n/(-2)))
        n = ceil(n/(-2))
    else:
        lst.append(1)
    lst = [str(c) for c in reversed(lst)]
    ans = "".join(lst)

print(ans)

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

/*
七五数
75=3*5*5

a^74
a^24 * b^2
a^15 * b^4
a^4 * b^4 * c^2
のどれか。
1.a^74
 a=2がギリギリありそう。実際、100なら50+25+12+6+3+1>75。
 74を超えるのは、n=78 39+19+9+4+2+1 以上の場合。
2.a^24 * b^2
 例えばn=100まで行くと、a=2,3,5まで届く。
 a=2はn>=28
 a=3はn>=54
 a=5はn>=100
 bについては大体の素数がそう
 n/2以下の素数の数を数える。ただし、aと同じ数になってはいけない。
3.a^14 * b^4
 n=7もギリギリ届く
 a=2はn>=16
 a=3はn>=30
 a=5はn>=60
 a=7はn>=91
 bについては、n/4以下の素数の数を数えればいい。
4.a^4 * b^4 * c^2
 約数が4つ以上の素数の数をp
 n/2以下の素数をq個とする。
 pC2 * (q-2)が答え。
*/

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

void solve(){
    ll n;
    cin >> n;
    vector<int> v;
    for(int i=2; i<=n/2; i++){
        if(IsPrime(i)) v.emplace_back(i);
    }

    ll ans = 0;

    //1
    if(n>=78) ans++;

    //2
    //a=2
    if(n>=28) ans += v.size()-1;
    //a=3
    if(n>=54) ans += v.size()-1;
    //a=5
    if(n>=100) ans += v.size()-1;

    //3
    //n/4以下の素数の数を数える
    int limit = n/4;
    int count = 0;
    for(int i=11; i<=limit; i++){
        if(IsPrime(i)) count++;
    }
    //2,3,5,7は個別に数える
    if(n>=6) count++;
    if(n>=9) count++;
    if(n>=20) count++;
    if(n>=28) count++;

    //a=2はn>=16
    if(n>=16) ans += count-1;
    //a=3はn>=30
    if(n>=30) ans += count-1;
    //a=5はn>=60
    if(n>=60) ans += count-1;
    //a=7はn>=91
    if(n>=91) ans += count-1;

    //4
    ll p=count;
    ll q=v.size();
    ans += p*(p-1)/2 * (q-2);

    cout << ans << endl;

    
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
int n,k,vi[110]; 
signed main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=k;i++)
	{
		int d;
		scanf("%d",&d);
		for (int j=1;j<=d;j++)
		{
			int x;
			scanf("%d",&x);
			vi[x]=1;
		}
	}
	int cnt=0;
	for (int i=1;i<=n;i++)
	{
		if (vi[i]==0)
		{
			cnt++;
		}
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    if (B - A <= 0) cout << "delicious" << endl;
    else if (B - A <= X) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define pii pair<int,int>
#define INF (int)1e9
#define MOD (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vi dam(n);
	vi mon(n);
	llong sum=0;
	REP(i,n){
		cin>>dam[i];
		sum+=dam[i];
	}
	
	llong tmp=sum;
	for(int i=1;i<n;i+=2){
		tmp-=2*dam[i];
	}
	mon[0]=tmp;
	
	for(int i=1;i<n;++i){
		mon[i]=2*dam[i-1]-mon[i-1];
	}
	
	REP(i,n) cout<<mon[i]<<endl;
}//解説参考.

Measured memory_bytes: 2048
def main():
    S = input()

    S_half_len = int(len(S) / 2 + 0.5)

    S1 = []
    for i in range(S_half_len):
        S1.append(S[i])

    S2 = []
    if len(S) % 2 == 1: S_half_len -= 1
    for i in range(S_half_len, len(S)):
        S2.append(S[i])
        # print(S[i])
    S2.reverse()
    

    ans = 0
    for i in range(len(S1)):
        if S1[i] != S2[i]:
            ans += 1

    print('{}'.format(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n;cin>>n;
  map<string,int> sm;
  vector<string>key;
  for(int i = 0; n > i; i++){
    string s;cin>>s;
    if(sm.count(s)){
      sm[s]++;
    }else{
      sm.insert(make_pair(s,1));
      key.push_back(s);
    }
  }
  int m;cin>>m;
  for(int i = 0; m > i; i++){
    string s;cin>>s;
    if(sm.count(s)){
      sm[s]--;
    }else{
      sm.insert(make_pair(s,-1));
      key.push_back(s);
    }
  }
  int mx = 0;
  for(int i = 0; sm.size() > i; i++){
    mx = max(mx,sm[key[i]]);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c,t;
	cin>>a>>b>>c;
	{
		t=a;
		a=b;
		b=t;
	}
	{
		t=a;
		a=c;
		c=t;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
#define fov(i,x) for(auto &i : x)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> _ii;
i64 sum = 0;
string a;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    cin >> a;
	fov(i,a)
	{
        sum += (i-'0');
        sum %= 9;
	}
	if(sum) cout << "No" << '\n';
	else cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll L, R;

int main(){
  cin >> L >> R;
  if(R - L > 2019) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = INFi;
  for(ll i = L; i < R; i++) {
    for(ll j = i + 1; j <= R; j++) {
      ans = min(ans, i * j % 2019);
    }
  }

  cout << ans << endl;


  return 0;
}


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

#define pb push_back
#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
const int maxn = 100050;

int n, a[maxn], x;
char str[maxn];

int p(int x){int k = x%n; if(!k) return n; return k;}

int main()
{
	scanf("%d",&n);
	scanf("%s",str+1);
	for(a[1] = 0; a[1] <= 1; ++ a[1]) 
		for(a[2] = 0; a[2] <= 1; ++ a[2])
		{
			fo(i,2,n-1)
			{
				if(a[i]==0)
				{
					if(str[i] == 'o') a[i+1] = a[i-1];
					else a[i+1] = a[i-1]^1;
				}
				else
				{
					if(str[i] == 'o') a[i+1] = a[i-1]^1;
					else a[i+1] = a[i-1];
				}
			}
			bool ok = true;
			fo(i,1,n)
			{
			if(a[i]==0)
			{
				if(str[i]=='o') {if(a[p(i+1)]!=a[p(i-1)]) ok = false;}
				else {if(a[p(i+1)]==a[p(i-1)]) ok = false;}
			}
			else
			{
				if(str[i]=='x') {if(a[p(i+1)]!=a[p(i-1)]) ok = false;}
				else {if(a[p(i+1)]==a[p(i-1)]) ok = false;}
			}
			}
			if(!ok) continue;
			fo(i,1,n) if(a[i]) printf("W");else printf("S");
			return 0;
		}
	printf("-1");
	return 0;
}

Measured memory_bytes: 896
n = int(input())
card = []
tc = []
hc = []

taro = 0
hanako = 0
counter = 0

i = 0
j = 0
k = 0
for i in range(n):
    card.append(list(input().split()))
    tc.append(list(card[i][0]))
    hc.append(list(card[i][1]))

    if len(card[i][0]) <= len(card[i][1]):
        counter = len(card[i][0])
    else:
        counter = len(card[i][1])
    
    for j in range(counter):
        if ord(tc[i][j].lower()) < ord(hc[i][j].lower()):
            hanako += 3
            break
        elif ord(tc[i][j].lower()) > ord(hc[i][j].lower()):
            taro += 3
            break
        else:
            if j == counter - 1:
                if len(card[i][0]) < len(card[i][1]):
                    hanako += 3
                elif len(card[i][0]) > len(card[i][1]):
                    taro += 3
                else:
                    taro += 1
                    hanako += 1

                break

print("%d %d" % (taro, hanako))


Measured memory_bytes: 5860
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 998244353;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// ll lpow(ll a, ll b){
//   if(b==0) return 1;
//   else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
//   else return lpow(a,b-1) * a;
// }

// ll kyori()


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

	if(n%2) return cout<<"No"<<endl,0;
	rep(i,n/2){
		cerr << i SP s[i] SP s[i+n/2] << endl;
		if(s[i]!=s[i+n/2]) return cout<<"No"<<endl,0;
	}
	cout << "Yes" << endl;


  return 0;
}


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

int main() {
	int n;
	cin >> n;
	set<string> st;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//s.find(w[i])==string::npos
//findの使い方

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m=1,h,x,y,sum=0;

string s,w;

vector<int> z;

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
     cin >> a >> b;
     x=b;
	while(b!=0){
            b/=10;
            sum++;
        }
        rep(i,sum){
            m*=10;
        }
            a*=m;
           cmp=a+x;
          
           rrep(i,1,350){
               if(i*i==cmp){
                   cout << "Yes" << endl;
                   return 0;
               }
           }
           cout << "No" << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int i;
	string S, T;
	cin >> S >> T;
	int x = S.length();
	int y = T.length();
	int a = 0;
	if (y == x + 1) {
		for (i = 0; i < x; i++) {
			if (S[i] != T[i]) {
				a += 1;
			}
		}
		if (a == 0) {
			cout << "Yes" << "\n";
		}
		else {
			cout << "No" << "\n";
		}
	}
	else {
		cout << "No" << "\n";
	}
}

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

int main(){
    int N,max=0,C=0,Alice=0,Bob=0;
    cin >> N;
    vector<int> card(N);
    vector<int> sort(N);
    for(int i=0;i<N;i++) cin >> card.at(i);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(max<card.at(j)){
                max=card.at(j);
                C=j;
            }
        }
        sort.at(i)=max;
        max=0;
        card.at(C)=0;
    }
    for(int i=0;i<N;i+=2) Alice+=sort.at(i);
    for(int i=1;i<N;i+=2) Bob+=sort.at(i);
    cout << Alice - Bob << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };




int main() {
	fastIO;
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();

		int[] d = new int[N];
		int sum = 0;

		for (int i = 0; i < N; i++) {
			int g = sc.nextInt();
			d[i] = g;
			sum += g;
		}

		Arrays.sort(d);

		int z = X - sum;
		int c = z / d[0];

		System.out.println(N + c);

	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    map<string,int> mp;
    bool f=true;
    int n;cin>>n;
    string pre;cin>>pre;
    mp[pre]++;
    for(int i=1;i<n;i++){
      string s;cin>>s;
      if(mp[s]) f=false;
      if(pre[pre.length()-1]!=s[0]) f=false;
      mp[s]++;
      pre=s;
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define mod 1000000007;

using namespace std;

void test(){
    int N,K,X,Y;
    cin >> N >> K >> X >>Y;
    int total = 0;
    if(N<K){
        total = N * X;
        cout << total;
        return;
    }
    total += K * X;

    total += (N-K) * Y;
    cout << total << endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,q;cin>>n>>k>>q;
  	vector<int >points(n,0);
  for(int i=0,a;i<q;i++){
  	cin>>a;
    points[a-1]+=1;
  }
  for(int i=0;i<n;i++){
  	if((k-(q-points[i]))>0)cout<<"Yes\n";
    else cout<<"No\n";
  }
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
  int N,K = 0;
  scanf("%d""%d",&N,&K);
  int i;
  long a[50];
  for(i=0;i<N;i++) {
    scanf("%ld",&a[i]);
  }

  int tmp = 0;
  int j = 0;
  for(j=0;j<N+1;j++) {
    for(i=0;i<N-1;i++){
      if(a[i] - a[i+1] < 0) {
        tmp = a[i+1];
        a[i+1] = a[i];
        a[i] = tmp;
      }
    }
  }
 
  int sum = 0;
  for(i=0;i<K;i++) {
    sum = sum + a[i];
  }

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define rep(i,n) for(u64 i = 0; i < (u64) n; ++i)

typedef signed int s32;
typedef unsigned int u32;
typedef float f32;
typedef signed long long s64;
typedef unsigned long long u64;
typedef double f64;

using namespace std;
using str = string;
template<typename T>
using vec = vector<T>;
template<typename T>
using uset = unordered_set<T>;
template<typename T, typename S>
using umap = unordered_map<T, S>;

const u64 mod = 1000000007;
const f64 pi = 3.14159265359;

void solve()
{
	u32 a,b;
	cin>>a>>b;
	cout<<a*b;	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cout<<fixed;
	//for(cin>>t; t>0; --t)
	solve();
	return 0;
}

Measured memory_bytes: 3632
N = int(input())

def main():
    s = [int(input()) for _ in range(N)]
    sum_n = sum(s)
    f = list(filter(lambda n: n % 10 != 0, s))
    
    ans = 0
    if sum_n % 10 != 0:
        ans = sum_n
    elif len(f) > 0:
        ans = sum_n - min(f)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
readlines.each do |l|
  puts case l.to_f.ceil
  when 0..48; "light fly"
  when 48..51; "fly"
  when 51..54; "bantam"
  when 54..57; "feather"
  when 57..60; "light"
  when 60..64; "light welter"
  when 64..69; "welter"
  when 69..75; "light middle"
  when 75..81; "middle"
  when 81..91; "light heavy"
  else "heavy"
  end
end

Measured memory_bytes: 6104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int max = m / n;
        for(int kouyakusu = max; kouyakusu > 0; kouyakusu--) {
            if(m % kouyakusu == 0) {
                System.out.println(kouyakusu);
                return;
            }
        }
    }
}

Measured memory_bytes: 21844
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)

ans = p[:X] + q[:Y] + r
ans.sort(reverse = True)
print(sum(ans[:X+Y]))

Measured memory_bytes: 111852
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define int long long
int INF = 1e9+7;;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    int M = N-1;
    int ans = 0;
    for(int i = 2; i*i <= M; i++) {
        if(M%i == 0) {
            ans++;
            if(i*i != M) {
                ans++;
            }
        }
    }
    for(int i = 2; i*i <= N; i++) {
        if (N%i == 0) {
            int X = N;
            int Y = N;
            while (X%i == 0) {
                X/=i;
            }
            if (X%i == 1) {
                ans++;
            }
            int Z = N/i;
            if (Z != i) {
                while (Y%Z == 0) {
                    Y/=Z;
                }
                if (Y%Z == 1) {
                    ans++;
                }
            }
        }
    }
    if(N == 2) {
        cout << 1 << endl;
        return 0;
    }
    cout << ans+2 << endl;
}


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

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

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  vector<int> b(n);
  rep(i, n + 1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll result = 0;
  for (int i = (n - 1); i >= 0; i--) {
    int diff = min(a[i + 1], b[i]);
    a[i + 1] -= diff;
    b[i] -= diff;
    result += diff;

    int diff2 = min(a[i], b[i]);
    a[i] -= diff2;
    b[i] -= diff2;
    result += diff2;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//

//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 1;
//***********//
int main() {
	ll A, B, C;
	cin >> A >> B >> C;
	cout << min(A + B + 1, C) + B;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     ll          long long int
#define     REP(i,x,n)    for(ll i=x;i<n;i++)
#define     SZ(v)       (ll)v.size()
#define     endl        "\n"
#define     ff          first
#define     ss          second
#define     PQ_MIN      priority_queue <ll, vector<ll>, greater<ll> >
#define     PQ          priority_queue <int>
#define     pbds        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define     setbit(x)   __builtin_popcount(x)
#define     prec(n)     fixed<<setprecision(n)
#define     pb(n)       push_back(n)
#define     mp(a,b)     make_pair(a,b)
#define     clr(n)      memset(n,0,sizeof(n))
#define     reset(n)    memset(n,-1,sizeof(n))
#define     ii          pair<ll,ll>
#define     vll         vector<ll>
using namespace std;
using namespace __gnu_pbds;
bool comp(pair<ll,ll> a,pair<ll,ll> b) {       }
const ll MOD=1e9+7;
void print(vector<vector<ll> >&v)
{
    ll n=v.size();
    ll m=v[0].size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }
}
void print(vector<ll>&v)
{
    ll n=v.size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
            cout<<v[i]<<" ";
    }
        cout<<"\n";

}
void print(set<ll>&s)
{

cout<<endl;

set<ll>::iterator it;
for(it=s.begin();it!=s.end();it++)
    cout<<*it<<" ";
cout<<endl;
}
ll __lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
ll power(ll a,ll p)
{
    ll res=1;
    while(p>0)
    {
        if(p&1){
            res=(res*a)%MOD;
            p--;
        }
            a=(a*a)%MOD;
            p/=2;
    }

    return res%MOD;
}
const ll INF=1e16;
const ll nxm=2e5+5;

ll spf[nxm];
void sieve()
{
    memset(spf,-1,sizeof(spf));

    spf[0]=spf[1]=1;

    for(ll i=2;i<nxm;i++)
    {
        if(spf[i]==-1)
            spf[i]=i;
        for(ll j=i*i;j<nxm;j+=i)
        {
            if(spf[j]==-1)
                spf[j]=i;

        }

    }
//    while(x>1)
//    {
//        ll s=spf[x];
//        temp[s]++;
//        x/=s;
//    }


// log n prime factor
}
void solve(){






ll n;

cin>>n;

string s;cin>>s;

ll ans=0;
ll r=0;

for(ll i=0;i<n;i++)
{
        if(s[i]=='R')
            r++;

}

ans=min(r,n-r);

ll cnt=0;

for(ll i=0;i<r;i++)
{
    if(s[i]!='R')
    {
        cnt++;
    }
}

ans=min(ans,cnt);

cout<<ans<<endl;










}
int main(){
//    freopen("timber_input", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
    REP(i,1,t+1)
    {
//    cout<<"Case #"<<i<<": ";
		solve();
    }
	return 0;
}
//  bitset<64>(x).to_ullong() // in my com  _ulong()
//  cout<<bitset<64>(ans).to_string().substr(64-m)<<endl;
/*

char s[100];

fgets(s,100,stdin);

stringstream stram(s);

string abc;

bool ok1=0,ok2=0;

while(stram>>abc)
*/


Measured memory_bytes: 3772
#include <iostream>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

ull div_ceil(ull a, ull b)
{
    return (a + b - 1) / b;
}

int main()
{
    int n; cin >> n;
    ull x, y;
    cin >> x >> y;
    for (int i = 1; i < n; ++i) {
        ull p, q;
        cin >> p >> q;
        ull n = max(div_ceil(x, p), div_ceil(y, q));
        x = n * p;
        y = n * q;
    }
    cout << x + y << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int n;
int a[200000];
int b[200000];
int c[400000];

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) cin >> b[i];
	
	int ans = 0;
	for (i = 0; i < 29; i++) {
		for (j = 0; j < n; j++) c[j] = b[j] % (1 << (i + 1));
		for (j = n; j < 
		2 * n; j++) c[j] = c[j - n] + (1 << (i + 1));
		sort(c, c + 2 * n);
		
		int cnt = 0;
		for (j = 0; j < n; j++) {
			//(a[j] + c[k]) >> i == 1となるkがいくつあるか？
			int low = ((1 << i) - (a[j] % (1 << (i + 1))) + (1 << (i + 1))) % (1 << (i + 1));
			int high = low + (1 << i);
			//[low, high)に含まれるc[k]はいくつあるか
			int lk = lower_bound(c, c + 2 * n, low) - c;
			int hk = lower_bound(c, c + 2 * n, high) - c;
			int kosuu = hk - lk;
			cnt += kosuu;
			//if (i < 5) cout << i << " " << " " << j << " " << kosuu << endl;
		}
		if (cnt % 2 == 1) ans += (1 << i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s == "abc")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
} 

Measured memory_bytes: 3620
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T,class Size=typename vector<T>::size_type>inline auto vector_2d(Size h,Size w,T v){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator,class Pair=typename iterator_traits<RandomAccessIterator>::value_type>inline void sort_pairs_by_second(RandomAccessIterator first,RandomAccessIterator last){sort(first,last,[](const Pair&p1,const Pair&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    string s;cin>>s;
    ll sum=0;
    for(auto c:s){
        sum+=c-'0';
        sum%=9;
    }
    cout<<(sum==0?"Yes":"No")<<endl;
}


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

#define PI 3.14159265358979323846264338327950L

int main(){
  long double hl, ml, h, m;
  long double dis, powdis;
  cin >> hl >> ml >> h >> m;
  
  hl *= 1000.0;
  ml *= 1000.0;
  
  long double time = h * 60 + m;
  long double angle = (m / 60.0) - (time / (60.0 * 12.0));
  
  powdis = pow(hl, 2.0) + pow(ml, 2.0) - (hl * ml * 2 * cos(angle * 2 * PI));
  dis = sqrt(powdis);
  dis /= 1000.0;
  
  cout << fixed << setprecision(16);
  cout << dis << endl;
}

Measured memory_bytes: 4136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;


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

	set<string> c;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		c.insert(s);
	}

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

	return 0;
}

Measured memory_bytes: 19052
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = sc.nextInt();
    System.out.println(a+b > x && a <= x ? "YES" : "NO");
  }
}

Measured memory_bytes: 35596
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    string s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        s += c;
    }
    for (int i = 0; i <= 10000; ++i) {
        string x = to_string(i);
        if(s.find(x) == string::npos){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3292
#include <stdio.h>

int main (){
	
	int a,b;
	scanf ("%d %d", &a, &b);
	int num[a];
	for (int i = 0 ; i < a ; i++){
		scanf ("%d", &num[i]);
	}
	
	for (int i = b ; i < a ; i++){
		if (num[i-b] < num[i]){
			printf ("Yes\n");
		}
		else {
			printf ("No\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 2396
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	string s;
	cin >> s;
	ll n = s.length();
	n--;
	ll ans = 0;
	map<ll, ll>mp;
	for (ll bit = 0;bit < (1 << n);++bit) {
		string target;
		ll res = 0;
		rep(i, n) {
			target.push_back(s[i]);
			if (bit & (1 << i)) {
				res += stoll(target);
				target = "";
			}
		}
		target.push_back(s[n]);
		res += stoll(target);
		mp[res]++;
	}
	for (auto p : mp) {
		ll x = p.first;
		ll y = p.second;
		ans += x * y;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define MAXN 110
#define MAXW 10010
int dp[MAXN][MAXW];
int value[MAXN], weight[MAXN];
using namespace std;
int main(void)
{
	int N, W;

	scanf("%d%d", &N, &W);
	for (int i = 1; i <= N; i++)
		scanf("%d%d", &value[i], &weight[i]);
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= W; j++)
			if (j < weight[i])
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weight[i]] + value[i]);
	printf("%d\n", dp[N][W]);
	//system("pause");

	return 0;
}


Measured memory_bytes: 7108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin>>c;
  if(c == 'a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	ini(n);
	int mortyma = 0;
	int mortymin = INF;
	FOR(i,0,n){
		ini(x);
		mortyma = max(mortyma,x);
		mortymin = min(mortymin,x);
	}
	out(mortyma-mortymin);















	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main(){
  ull h, w;
  cin >> h >> w;
  ull ans;
  if (w == 1 || h == 1) {
      cout << 1 << endl;
      return 0;
  } else if (w % 2) {
      if (h % 2) ans = w * (h - 1) / 2 + (w / 2 + 1);
      else ans = w * h / 2;
  } else ans = w * h / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split(" ")))
    B = list(map(int, input().split(" ")))
    before = sum(A)
    for i in range(N):
        if A[i] >= B[i]:
            A[i] -= B[i]
            B[i] = 0
        else:
            B[i] -= A[i]
            A[i] = 0
            if A[i + 1] >= B[i]:
                A[i + 1] -= B[i]
                B[i] = 0
            else:
                B[i] -= A[i + 1]
                A[i + 1] = 0
    print(before - sum(A))


if __name__ == '__main__':
    main()

Measured memory_bytes: 19004
l = input().split()
n = int(l[0])
k = int(l[1])

l = input().split()
r = int(l[0])
s = int(l[1])
p = int(l[2])

t = list(input())

point = []

for i in range(n):
  if i >= k:
    if t[i] == t[i - k]:
      if point[i - k] != 0:
        point.append(0)
        continue

  if t[i] == "r":
    point.append(p)
  elif t[i] == "s":
    point.append(r)
  elif t[i] == "p":
    point.append(s)

print(sum(point))

Measured memory_bytes: 4792
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  while (cin >> n && n) {
    VI a(n);
    REP(i, 0, n) cin >> a[i];
    int cnt = 0;
    int cur = -1;
    REP(i, 0, n) {
      if (cnt == 0) {
        cur = a[i];
        cnt = 1;
      } else if (cur == a[i]) {
        cnt += 1;
      } else {
        cnt -= 1;
      }
    }
    cnt = 0;
    REP(i, 0, n) cnt += a[i] == cur;
    if (2 * cnt > n) {
      cout << cur << endl;
    } else {
      cout << "NO COLOR" << endl;
    }
  }
}



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

/*define*/
int A,B,C,K;


int main(){
    /*inpus*/
    std::cin >> A >> B >> C >> K;

    /*syori*/
    if(A>=K){
        std::cout << K;
    }else if(A+B>=K){
        std::cout << A;
    }else{
        std::cout << 2*A+B-K;
    }
}    


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long K,A,B;
	long long bis=1;
	long long yen=0;
	long long i;
	cin>>K>>A>>B;
		//cout<<"bis="<<bis<<" yen="<<yen<<endl;
	for(i=0;i<K;i++){
		if(yen){yen--; bis+=B;}
		else if(bis>=A&&K-1!=i&&B-A>1) {bis-=A; yen++;}
		else bis++;
		//cout<<"bis="<<bis<<" yen="<<yen<<endl;
	}
	cout<<bis<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

main(){
  int n, m;
  int ns, ms;
  int d2[100], d1[100];
  while(1){
    cin >> n >> m;
    if(n==0 && m==0) break;
    ns=ms=0;
    for(int i=0;i<n;i++){
      cin >> d1[i];
      ns+=d1[i];
    }
    for(int i=0;i<m;i++){
      cin >> d2[i];
      ms+=d2[i];
    }
    int a1=1000, a2=1000;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	int t1=ns, t2=ms;
	t1-=d1[i];
	t2+=d1[i];
	t1+=d2[j];
	t2-=d2[j];
	if(t1==t2){
	  if(a1+a2>d1[i]+d2[j]){
	    a1=d1[i];
	    a2=d2[j];
	  }
	}
      }
    }
    if(a1==1000 || a2==1000){
      cout << -1 << endl;
    }else{
      cout << a1 << ' ' << a2 << endl;
    }
  }
  return 0;
}

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

int main()
{
    char x[1001];

    while (1) {
        int sum = 0, i = 0;

        cin >> x;
        if (x[0] == '0')
            break;
        while (x[i]) {
            sum += (x[i] - '0');
            i++;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef pair<int, int> P;

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

const int N = 1000010;

int main() {
  int n, m, h[N], ma[N];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    ma[i] = 0;
  }

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    ma[a] = max(ma[a], h[b]);
    ma[b] = max(ma[b], h[a]);
  }

  int ans = 0;
  rep(i, n + 1) ans += h[i] > ma[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4384
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
 
using namespace std;
 
int main() {
	int n;
	long long sum=0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) sum += i;
	}
 
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

ll c[200001];
vector<int> g[200001];
int n,q;
ll ans[200001];
void dfs(int v,int par,ll cur){
    ans[v]+=cur+c[v];
    for(int nx:g[v])if(nx!=par){
        dfs(nx,v,ans[v]);
    }
}
int main(){
    cin>>n>>q;
    int ai,bi;
    rep(i,n-1){
        cin>>ai>>bi;
        --ai,--bi;
        g[ai].pb(bi);
        g[bi].pb(ai);
    }
    int pi,xi;
    rep(i,q){
        cin>>pi>>xi;
        --pi;
        c[pi]+=xi;
    }
    dfs(0,-1,0);
    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 25600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    string S;

    cin >> N;

    for(int i=0; i < N;i++){
        cin >> S;
        if(S == "Y"){
            cout << "Four" << endl;
            break;
        }
        if(i == N-1){
            cout << "Three" << endl;
            break;
        }
    }
}

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

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    ll n, m;
    vector<pair<ll, ll>> ab;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        ll a, b;
        scanf("%lld %lld", &a, &b);
        ab.emplace_back(make_pair(a,b));
    }
    sort(ab.begin(), ab.end());
    ll ans = 0;
    for (ll i = 0; i < n && m > 0; ++i) {
        ll a = ab[i].first, b = ab[i].second;
        ans += a*min(b, m);
        m -= b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3444
import sys
s = input()
flag = 0
s1 = ""
s2 = ""

for i in range(int(input())):
	X = sys.stdin.readline().split()
	if int(X[0]) == 1:
		flag = flag^1	
	elif (int(X[1])-1)^flag == 0:
		s1 += X[2]
	else:
		s2 += X[2]
s3 = s1[::-1]+s+s2
if flag:
	print(s3[::-1])
else:
	print(s3)


Measured memory_bytes: 4540
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>


signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a,b,c; cin >> a >> b >> c;
  cout << min(b/a, c) << endl;
  ret;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <limits.h>
#include <map>
#include <math.h>
#include <cmath>

using namespace std;

int main(){
  int x,a,b;cin>>x>>a>>b;
  string str = "A";
  if(abs(x-a)>abs(x-b)) str = "B";
  cout<<str<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
#include <assert.h>
using namespace std;

const unsigned long long MOD = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

int main()
{
    int n;
    cin >> n;
    int c = 0;
    bool yes = false;
    FROM_0(i, n)
    {
        int x, y;
        cin >> x >> y;
        if (x == y)
        {
            c += 1;
        }
        else
        {
            c = 0;
        }
        if (c >= 3)
        {
            yes = true;
        }
    }
    cout << (yes ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> A[0] >> A[1];
	cin >> B[0] >> B[1];
	if (A[0] != B[0])cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 4352