akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cctype>
#define sq(a) ((a)*(a))
using namespace std;
int dist(int R, int G, int B, int rR, int rG, int rB){
	return sq(R-rR) + sq(G-rG) + sq(B-rB);
}
string judge(int R, int G, int B ){
	int min_dist = 1<<30;
	string color;

	int r;
	
	r = dist( R, G, B, 0, 0, 0 );
	if( min_dist > r ){
		min_dist = r;
		color = "black";
	}
	r = dist( R, G, B, 0, 0, 0xFF );
	if( min_dist > r ){
		min_dist = r;
		color = "blue";
	}
	r = dist( R, G, B, 0, 0xFF, 0 );
	if( min_dist > r ){
		min_dist = r;
		color = "lime";
	}
	r = dist( R, G, B, 0, 0xFF, 0xFF );
	if( min_dist > r ){
		min_dist = r;
		color = "aqua";
	}
	r = dist( R, G, B, 0xFF, 0, 0 );
	if( min_dist > r ){
		min_dist = r;
		color = "red";
	}
	r = dist( R, G, B, 0xFF, 0, 0xFF );
	if( min_dist > r ){
		min_dist = r;
		color = "fuchsia";
	}
	r = dist( R, G, B, 0xFF, 0xFF, 0 );
	if( min_dist > r ){
		min_dist = r;
		color = "yellow";
	}
	r = dist( R, G, B, 0xFF, 0xFF, 0xFF );
	if( min_dist > r ){
		min_dist = r;
		color = "white";
	}
	return color;
}

int main(){
	while( true ){
		int R;
		int G;
		int B;
		char c;
		string s;
		scanf("%c", &c);
		if( c=='0')break;
		scanf("%2x%2x%2x", &R, &G, &B);
		getline(cin,s);
		cout << judge(R,G,B) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int N, Q;
	string S;
	cin >> N >> Q;
	cin >> S;

	vector<int> ac(N, 0);
	for (int i = 1; i < N; ++i) {
		ac[i] = ac[i - 1];
		if (S[i - 1] == 'A' && S[i] == 'C') {
			ac[i] += 1;
		}
	}

	for (int i = 0; i < Q; ++i) {
		int l, r;
		cin >> l >> r;
		--l;
		--r;
		int ans = ac[r];
		if (l > 0) {
			ans -= ac[l - 1];
			if (S[l - 1] == 'A' && S[l] == 'C') {
				ans--;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#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(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,c=0,d=0,n,m=0,k,ans=0,y;
    string s,s2;
    cin >> a >> b;
    n=b-a-1;
    while(n){
        m += n;
        n--;
    }
    cout << m-a <<endl;
    return 0;
}


Measured memory_bytes: 256
n, sum = STDIN.gets.split(' ').map(&:to_i)

Otoshidama = Struct.new('Otoshidama', :x, :y, :z)

otoshidama = catch(:break_loop) do
  0.upto(n) do |x|
    0.upto(n) do |y|
      z = n - x - y
      next if z < 0

      if 10000*x + 5000*y + 1000*z == sum
        throw :break_loop, Otoshidama.new(x, y, z)
      end
    end
  end
end

if otoshidama.kind_of?(Otoshidama)
  puts "#{otoshidama.x} #{otoshidama.y} #{otoshidama.z}"
else
  puts "-1 -1 -1"
end


Measured memory_bytes: 1788
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let X = readInt()!
print(X == 3 || X == 5 || X == 7 ? "YES" : "NO")


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

template <typename T>
struct FenwickTree {
  vector<T> v;
  int n;
  FenwickTree(int n) : n(n) {
    v = vector<T>(n);
  }
  void update(int i, T x) {
    for (i++; i <= n; i += i & -i) v[i - 1] += x;
  }
  T query(int i) {
    T r = 0;
    for (; i >= 1; i -= i & -i) r += v[i - 1];
    return r;
  }
};

void solve() {
  int n, k;
  cin >> n >> k;
  vi32 a(n);
  cin >> a;
  vi32 b(n);
  rep(i, n) b[i] = a[i] - k;
  using P = pair<i64, int>;
  vector<P> v;
  i64 sum = 0;
  rep(i, n) {
    sum += b[i];
    v.emplace_back(sum, i);
  }
  sort(all(v), [&](P a, P b) {
    return a.first < b.first;
  });
  map<int, int> mp;
  rep(i, n) mp[v[i].second] = i;
  FenwickTree<int> ft(n);
  rep(i, n) ft.update(i, 1);
  i64 ans = 0;
  i64 tar = 0;
  rep(i, n) {
    int ok = n, ng = -1;
    while (abs(ok - ng) != 1) {
      int md = (ok + ng) / 2;
      (v[md].first >= tar ? ok : ng) = md;
    }
    ans += ft.query(n) - ft.query(ok);
    ft.update(mp[i], -1);
    tar += b[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 16108
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

#define rep(i, j) for(int i= 0; i < j;i++)
#define all(i) i.begin(), i.end()

struct team { int num, ac, time; };

// t0<t1
bool compare(team &t0, team &t1)
{
	if (t0.ac == t1.ac) 
	{
		if (t0.time == t1.time){ return t0.num < t1.num; }
		return t0.time > t1.time; 
	}
	return t0.ac < t1.ac;
}
int main()
{
	int M, T, P, R;
	while (cin >> M >> T >> P >> R && (M != 0 && T != 0))
	{
		vector<int> m(R, 0), t(R, 0), p(R, 0), j(R, 0);
		vector<team> dat(T + 10);
		vector<vector<int>> wa(T + 10, vector<int>(P + 10, 0));
		rep(i, R)
		{
			int tmp[4] = { 0 };
			cin >> tmp[0] >> tmp[1] >> tmp[2] >> tmp[3];
			if (tmp[3] > 0) { wa[tmp[1]][tmp[2]] += 20; }
			else if(tmp[3] == 0)
			{
				dat[tmp[1]].time += tmp[0] + wa[tmp[1]][tmp[2]];
				dat[tmp[1]].ac += 1;
				dat[tmp[1]].num = tmp[1];
			}
		}
		rep(i, T + 1) { dat[i].num = i; }
		sort(dat.rbegin(), dat.rend(), compare);
		rep(i, T)
		{
			if (i == T - 1){ printf("%d\n", dat[i].num); }
			else if(dat[i].time == dat[i+1].time && i != T - 1){ printf("%d=", dat[i].num); }
			else{ printf("%d,", dat[i].num); }
		}
	}
}

Measured memory_bytes: 3264
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <cstdio>

using namespace std;

int main(){

	string str;
	while(1){
		if(cin.eof())
			break;
		getline(cin,str);
		if(str=="")
			break;
		stack<double> s;

		for(int i = 0; i < str.size(); i++){
			if(str[i]=='*'){
				double n1=s.top();s.pop();
				double n2=s.top();s.pop();
				s.push(n1*n2);
			}
			else if(str[i]=='+'){
				double n1=s.top();s.pop();
				double n2=s.top();s.pop();
				s.push(n1+n2);
			}
			else if(str[i]=='/'){
				double n1=s.top();s.pop();
				double n2=s.top();s.pop();
				s.push(n2/n1);
			}
			else if(str[i]=='-'){
				if(i!=str.size()-1&&str[i+1]>='0'&&str[i+1]<='9'){
					for(int j = i+1; j <= str.size(); j++){
						if(j!=str.size()&&(str[j]>='0'&&str[j]<='9')){
							
						}
						else{
							double num=atoi(str.substr(i,j-i).c_str());
							s.push(num);
							i=j;
							break;
						}
					}
				}
				else{
					double n1=s.top();s.pop();
					double n2=s.top();s.pop();
					s.push(-n1+n2);
				}
			}
			else if(str[i]>='0'&&str[i]<='9'){
				for(int j = i+1; j <= str.size(); j++){
					if(j!=str.size()&&(str[j]>='0'&&str[j]<='9')){
						
					}
					else{
						double num=atoi(str.substr(i,j-i).c_str());
						s.push(num);
						i=j;
						break;
					}
				}
			}
		}
		double d = s.top();
		printf("%.7f\n",d);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
int N;
int a[100000];
bool j[100000];
int main() {
	std::cin >> N;
	for (int i = 1; i <= N; i++) {
		std::cin >> a[i];
	}
	int ans = 0;
	int i = 1;
	while (true) {
		j[i] = true;
		i = a[i];
		ans++;
		if (i == 2) {
			std::cout << ans << "\n";
			break;
		}
		else if (j[i] == true) {
			std::cout << -1 << "\n";
			break;
		}
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 1016
// D - Lucky PIN
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define all(x) (x).begin(),(x).end()
#define ubound(x,c) upper_bound(all(x),(c))-(x).begin()

int main(){
	int N; string S; cin>>N>>S; S = "-" + S;
	vector<vi> ix(10, vi());
	rp(i, 1, N+1) ix[S[i]-'0'].push_back(i);
	int ans = 0;
	rp(a, 0, 10){
		int p = ix[a].size()? ubound(ix[a], 0): N; if(p >= ix[a].size()) continue;
		rp(b, 0, 10){
			int q = ix[b].size()? ubound(ix[b], ix[a][p]): N; if(q >= ix[b].size()) continue;
			rp(c, 0, 10) if((ix[c].size()? ubound(ix[c], ix[b][q]): N) < ix[c].size()) ans++;
		}
	}
	cout<< ans <<endl;
}

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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 5e5 + 10;
const int M = (int) 1e6 + 10;
const int K = (int) 500 + 10;
const int mod = (int) 1e9 + 7;
const ll LINF = (ll) 1e18;

int n;
vec v[N];
map<pii, int> e;
int sz[N];

void calc_sizes(int x = 1, int p = -1) {
	sz[x] = 1;
	for (auto it : v[x]) {
		if (it == p)
			continue;
		calc_sizes(it, x);
		sz[x] += sz[it];
	}
}

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> n;
	for (int i = 1, x, y, c; i < n; i++) {
		cin >> x >> y >> c;
		v[x].pb(y);
		v[y].pb(x);
		e[mp(x, y)] = e[mp(y, x)] = c;
	}
	calc_sizes();
	ll ans = 0;
	for (auto it : e) {
		//it.f.f, it.f.s, it.s
		//cout << sz[it.f.f] << ' ' << (n - sz[it.f.f]) << ' ' << it.s << "\n";
		int x = it.f.f, y = it.f.s;
		if (sz[x] < sz[y])
			swap(x, y); 
		//cout << x << ' ' << y << ' ' << sz[y] << '\n';
		ans += 1ll * min(sz[y], (n - sz[y])) * it.s;
	}
	vec centroids;
	for (int i = 1; i <= n; i++) {
		bool centroid = true;
		for (auto it : v[i]) {
			if (sz[it] < sz[i] && sz[it] > n / 2)
				centroid = false;
		}
		if (centroid && n - sz[i] <= n / 2) {
			centroids.pb(i);
		}
	}
	if (sz(centroids) == 1) {
		int cmin = mod;
		for (auto it : e) {
			if (it.f.f == centroids[0]) {
				cmin = min(cmin, it.s);
			}
		}
		ans -= cmin;
	} else {
		assert(sz(centroids) == 2);
		ans -= e[mp(centroids[0], centroids[1])];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 33280
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007

int main() {
    int n;
    cin>>n;
    lli a[n], sum = 0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum += (a[i] * a[j]);
        }
    }
    cout<<sum<<"\n";
    return 0;
}


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

/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
/*ll x=1000000001;
vector<bool>p(x,false);
void prime(){
    p[2]=true;
    for(ll i=3;i<x;i=i+2)
        p[i]=true;
    for(ll i=0;i<x;i=i+2){
        if(p[i]){
            for(ll j=i*i;j<x;j=j+i)
                p[j]=false;
        }
    }
}*/
/*vector<ll> divisor(ll n){
    vector<ll> d;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        d.push_back(i);
        d.push_back(n/i);
        }
    }
    sort(d.begin(),d.end(),greater<ll>());
    return d;
}*/
/*bool bs(ll n,string s){
    ll a[4]={0};
    for(ll i=0;i<n-1;i++){
        a[s[i]-'0']++;
    }
    for(ll i=n-1;i<s.size();i++){
        a[s[i]-'0']++;
        if(a[1]>0 && a[2]>0 && a[3]>0)
        return true;
        a[s[i-n+1]-'0']--;
    }
    return false;
}*/


/*ll binarySearch(ll n,ll a[],ll x){
    ll low=0,high=n-1,mid,ans=-1;
    while(low<=high){
        mid=low+(high-low)/2;
        if(a[mid]>=x){

            high=mid-1;
        }
        else{
                ans=mid;
            low=mid+1;
        }
    }
    return a[ans];
}*/




/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
/*ll x=1000000001;
vector<bool>p(x,false);
void prime(){
    p[2]=true;
    for(ll i=3;i<x;i=i+2)
        p[i]=true;
    for(ll i=0;i<x;i=i+2){
        if(p[i]){
            for(ll j=i*i;j<x;j=j+i)
                p[j]=false;
        }
    }
}*/
/*vector<ll> divisor(ll n){
    vector<ll> d;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        d.push_back(i);
        d.push_back(n/i);
        }
    }
    sort(d.begin(),d.end(),greater<ll>());
    return d;
}*/
/*bool bs(ll n,string s){
    ll a[4]={0};
    for(ll i=0;i<n-1;i++){
        a[s[i]-'0']++;
    }
    for(ll i=n-1;i<s.size();i++){
        a[s[i]-'0']++;
        if(a[1]>0 && a[2]>0 && a[3]>0)
        return true;
        a[s[i-n+1]-'0']--;
    }
    return false;
}*/


/*ll binarySearch(ll n,ll a[],ll x){
    ll low=0,high=n-1,mid,ans=-1;
    while(low<=high){
        mid=low+(high-low)/2;
        if(a[mid]>=x){

            high=mid-1;
        }
        else{
                ans=mid;
            low=mid+1;
        }
    }
    return a[ans];
}*/

string solve(ll n){


}

int main() {
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ll x=a[0];
    for(ll i=1;i<n;i++)
        x=x^a[i];
    for(ll i=0;i<n;i++){
        ll y=x^a[i];
        cout<<y<<" ";
    }
}


Measured memory_bytes: 4740
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,P = MI()
A = LI()

x,y = 0,0
for a in A:
    if a % 2 == 0:
        x += 1
    else:
        y += 1

if y == 0:
    if P == 1:
        print(0)
    else:
        print(2**x)
else:
    print(2**(x+y-1))



Measured memory_bytes: 61844
H, W = map(int, input().split())
list=["."+input()+"." for i in range(H)]
list=["."*(W+2)]+list+["."*(W+2)]
a=0
for h in range(H):
    for w in range(W):
        if list[h][w] == "#":
            if list[h+1][w] == "." and list[h-1][w] == "." and list[h][w-1] == "." and list[h][w+1] == ".":
                a=1
                break
print("Yes" if a==0 else "No")

Measured memory_bytes: 3064
n,m,q=gets.split.map &:to_i
abcds=q.times.map{ gets.split.map &:to_i }
puts [*1..m+n-1].combination(n).map{|as|
  abcds.reduce(0){|s,(a,b,c,d)|
    as[b-1]-as[a-1]-(b-a)==c ? s+d : s
  }
}.max

Measured memory_bytes: 15240
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    string s;
    cin >> s;
    string t="keyence";
    ll n=s.length();
    for(ll l=0;l<n;l++){
        for(ll r=l;r<n;r++){
            string ans=s.substr(0,l)+s.substr(r,n-r);
            if(ans==t){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 3560
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long A,B,AB;
bool check(long long l,long long r,long long mid)
{
	long long x=l,y=mid-l+1;
	for (int i=30; i>=0; i--)
		if (x+(1<<i)<=y-(1<<i)) x+=(1<<i),y-=(1<<i);
	if (x>=A) x++;
	if (y>=B) y++;
	return x*y<AB;
}
int main()
{
	int q;
	scanf("%d",&q);
	while (q--)
	{
		scanf("%lld%lld",&A,&B);
		if (A>B) swap(A,B);
		AB=A*B;
		long long l=0,r=(A+B)*2;
		while (l<r)
		{
			long long mid=(l+r+1)>>1;
			long long a=A,b=mid-B+1;
			bool flag=0;
			if(a>b) swap(a,b);
			if (mid<a) flag=check(1,mid,mid);
			else if(mid<b) flag=check(1,a-1,mid)&&check(a,mid,mid);
			else flag=check(1,a-1,mid)&&check(a,b-1,mid)&&check(b,mid,mid);
			if (flag) l=mid;
			else r=mid-1;
		}
		printf("%lld\n",l);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1, i##_end_ = (n); i <= i##_end_; ++i)
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const int maxn = 10200;
int a[maxn], n, P, p[maxn], vis[maxn], pcnt;
int qpow(int x, int y) {
    int ret = 1;
    for(; y; y >>= 1, x = 1LL * x * x % P)
        if(y & 1) ret = 1LL * ret * x % P;
    return ret;
}
int inv(int x) { return qpow(x, P - 2); }
int mo(int x) {
    if(x >= P) x -= P;
    if(x < 0) x += P;
    return x;
}
set<int> ans;
int pol[maxn];
bool check(int x) {
    // printf("CHK %d\n", x);
    P = x;
    if(x == 2 && (a[0] & 1)) return false;
    memset(pol, 0, sizeof pol);
    for(int i = n ;i >= 0; --i)
        pol[i % (P-1)] = (pol[i%(P-1)] + a[i] + P) % P;
    for(int i = 0; i < P; ++i) if(pol[i] != 0) return false;
    return true;
}

int main() {
    for(int i = 2; i <= 10000; ++i) {
        if(!vis[i]) p[++pcnt] = i, vis[i] = i;
        for(int j = 1; j <= pcnt && i * p[j] <= 10000 ; ++j) {
            vis[i * p[j]] = p[j];
            if(i % p[j] == 0) break;
        }
    }
    scanf("%d", &n);
    for(int i = n; i >= 0; --i) scanf("%d", &a[i]);
    int gg = abs(a[1]);
    for(int i = n; i >= 0; --i) gg = __gcd(gg, abs(a[i]));

    for(int i = 2; i * i <= gg; ++i) if(gg % i == 0) {
        while(gg % i == 0) gg /= i;
        ans.insert(i);
    }
    if(gg != 1) ans.insert(gg);

    for(int i = 1; i <= pcnt ; ++i) if(a[0] % p[i] == 0 && check(p[i]))
        ans.insert(p[i]);
    for(auto g : ans) printf("%d ", g);

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int N, Q;
		cin>>N>>Q;
		if(N == 0 && Q == 0) break;
		vector<int> ds;
		multiset<int> m;
		REP(i, N) {
			int M;
			cin>>M;
			REP(j, M) {
				int d;
				cin>>d;
				if(m.count(d) == 0) ds.pb(d);					ds.pb(d);
				m.insert(d);
			}
		}
		ll max = 0;
		ll ans = -1;
		sort(ALL(ds));
		REP(i, ds.size()) {
			ll hoge = m.count(ds[i]);
			if(hoge > max) {
				max = hoge;
				ans = ds[i];
			}
		}
		if(ans == -1 || max < Q) cout<<0<<endl;
		else cout<<ans<<endl;
	}
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int h, w, n;
int sr, sc;

void add(vector<int> &cnt, char c) {
  switch(c) {
    case 'L':
      cnt[0]++;
      break;
    case 'R':
      cnt[1]++;
      break;
    case 'U':
      cnt[2]++;
      break;
    default:
      cnt[3]++;
      break;
  }
}

bool rid(vector<int> &taka, vector<int> &aoki, vector<int> &mi) {
  if(max(0, taka[1] - aoki[0]) >= w - sc + 1 ||
      max(0, taka[0] - aoki[1]) >= sc ||
      max(0, taka[2] - aoki[3]) >= sr ||
      max(0, taka[3] - aoki[2]) >= h - sr + 1) {
    return true;
  } else {
    return false;
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  cin >> h >> w >> n;
  cin >> sr >> sc;
  sr--; sc--;
  string s, t; cin >> s >> t;
  bool lose = false;
  // l
  int pos = sc;
  for(int i=0;i<n;++i) {
    if(s[i] == 'L') {
      pos--;
    }
    if(pos == -1) {
      lose = true;
      break;
    }
    if(t[i] == 'R') {
      if(pos != w-1) pos ++;
    }
  }
  // r
  pos = sc;
  for(int i=0;i<n;++i) {
    if(s[i] == 'R') {
      pos++;
    }
    if(pos == w) {
      lose = true;
      break;
    }
    if(t[i] == 'L') {
      if(pos != 0) pos--;
    }
  }
  // u
  pos = sr;
  for(int i=0;i<n;++i) {
    if(s[i] == 'U') {
      pos--;
    }
    if(pos == -1) {
      lose = true;
      break;
    }
    if(t[i] == 'D') {
      if(pos != h-1) pos++;
    }
  }
  // d
  pos = sr;
  for(int i=0;i<n;++i) {
    if(s[i] == 'D') {
      pos++;
    }
    if(pos == h) {
      lose = true;
      break;
    }
    if(t[i] == 'U') {
      if(pos != 0) pos--;
    }
  }

  cout << (lose ? "NO" : "YES") << endl;
}


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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007

void solve()
{	
	ll n,m,cnt=0;
	cin>>n>>m;
	ll a[n+1];
	set<ll> v[n+1];
	for(ll i=1;i<=n;i++) cin>>a[i];
	for(ll i=1;i<=m;i++)
	{
		ll x,y;
		cin>>x>>y;
		v[x].insert(a[y]);
		v[y].insert(a[x]);
	}
	for(ll i=1;i<=n;i++)
	{
		if(v[i].size()==0)
		{
			cnt++;
			continue;
		}
		ll t=*(--v[i].end());
		if(t<a[i]) cnt++;
	}
	cout<<cnt;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}


Measured memory_bytes: 18468
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().execute(System.in);
	}

	private static class Room {
		int next = -1;
		List<Integer> roads;
	}

	private void addRoad(Room r, int i) {
		if (r.roads == null) {
			r.roads = new ArrayList<Integer>();
		}
		r.roads.add(i);
	}

	Room[] rooms;

	int links[];

	private void linkRooms() {
		int len = rooms.length;
		int idx = 0;
		links[0] = 0;
		int cnt = 1;
		while (idx < len) {
			int i = links[idx++];
			Room r = rooms[i];
			if (r.roads != null) {
				for (int k : r.roads) {
					Room c = rooms[k];
					if (c.next < 0) {
						c.next = i;
						links[cnt++] = k;
					}
				}
			}
		}
	}

	public void execute(InputStream in) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		links = new int[n];
		rooms = new Room[n];
		for (int i = 0; i < n; i++) {
			rooms[i] = new Room();
		}
		
		int a, b;
		for (int i = 0; i < m; i++) {
			a = sc.nextInt() - 1;
			b = sc.nextInt() - 1;
			
			addRoad(rooms[a], b);
			addRoad(rooms[b], a);
		}
		sc.close();
		
		rooms[0].next = 0;
		linkRooms();

		for (Room r : rooms) {
			if (r.next < 0) {
				System.out.println("No");
				return;
			}
		}
		
		System.out.println("Yes");
		for (int i = 1; i < rooms.length; i++) {
			Room r = rooms[i];
			System.out.println(r.next + 1);
		}
	}
}


Measured memory_bytes: 80040
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5+7;
typedef long long LL;
LL a[N];
vector<int>p[N];
int vis[N];
int h, s1, s2, n;
int flag;
void dfs(int u,int sum)
{
    if(flag==1) return ;
    if(u==n)
    {
        h=sum-1;
        flag=1;
        return ;
    }
    for(int i=0;i<p[u].size();i++)
    {
        int v=p[u][i];
        if(vis[v]) continue;
        vis[v]=1;
        dfs(v,sum+1);
        if(flag==1) return ;
        else vis[v]=0;
    }
    return ;
}
int k;
void dfs3(int u,int sum,int pre)
{
    if(sum>k) return ;
    for(int i=0;i<p[u].size();i++)
    {
        int v=p[u][i];
        if(v==pre) continue;
        if(vis[v]) dfs3(v,sum+1,u);
        else
        {
            s1++;
            dfs3(v,sum,u);
        }
    }
    return ;
}




int main()
{
    scanf("%d", &n);
    for(int i=0;i<=n;i++) p[i].clear();
    for(int i=1;i<n;i++)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        p[x].push_back(y);
        p[y].push_back(x);
    }
    memset(vis,0,sizeof(vis));
    h=0,s1=0,s2=0;
    flag=0;
    vis[1]=1;
    dfs(1,0);
    if(h&1) k=h/2+1;
    else k=h/2;
    dfs3(1,0,-1);
    s2=n-2-s1-h;
    if(h&1)
    {
        if(s1>=s2) printf("Fennec\n");
        else printf("Snuke\n");
    }
    else
    {
        if(s1>s2) printf("Fennec\n");
        else printf("Snuke\n");
    }
    return 0;
}


Measured memory_bytes: 22400
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define pp push_back
#define ep emplace_back
#define all(v) (v).begin(),(v).end()
#define szz(v) ((int)(v).size())
#define bi_pc __builtin_popcount
#define bi_pcll __builtin_popcountll
#define bi_tz __builtin_ctz
#define bi_tzll __builtin_ctzll
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long; using lf = long double; 
using pii = pair<int,int>; using ppi = pair<int,pii>;
using pll = pair<ll,ll>; using pff = pair<lf,lf>;
using ti = tuple<int,int,int>;
const lf PI = 3.14159265358979323846264338L;
template <typename T>
inline T umax(T& u, T v){return u = max(u, v);}
template <typename T>
inline T umin(T& u, T v){return u = min(u, v);}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

pll a[200005], b[200005];
int n;

int cnt[120][40];
const int o1 = 60, o2 = 20;

inline ll p2(ll X){
    int r = 0;
    for(;~X & 1;r++) X >>= 1;
    return r;
}
inline ll p5(ll X){
    int r = 0;
    for(;X % 5 == 0;r++) X /= 5;
    return r;    
}
int main(){
    fio;
    cin >> n;
    string S;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        cin >> S;
        auto t = S.find('.');
        if(t == string::npos){
            ll X = stoll(S);
            //cout << "X = " << X << '\n';
            b[i] = pll(p2(X), p5(X));
        }else{
            ll X = stoll(S.substr(0, t) + S.substr(t+1));
            //cout << "X = " << X << '\n';
            int u = szz(S) - int(t) - 1;
            //cout << "u = " << u << '\n';
            b[i] = pll(p2(X) - u, p5(X) - u);
        }
        //cout << S << endl;
        //cout << b[i].va << ' ' << b[i].vb << '\n';
        for(int x = -b[i].va + o1; x < o1 + o1; x++) 
            for(int y = -b[i].vb + o2; y < o2 + o2; y++) ans += cnt[x][y];
        //cout << ans << '\n';
        cnt[b[i].va + o1][b[i].vb + o2]++;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 6728
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
double pi = 3.1415926535;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    double a,b,x;
    cin >> a >> b >> x;
    double t = (x*2)/a;
    t /= b;
    //printD(t);
    if(t>a){
        x = a*a*b-x;
        t = (x*2)/a;
        t /= a;

        printD(atan2(t,a)/pi*180);
    }
    else{
        printD(atan2(b,t)/pi*180);
    }
    
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 384
#include <iostream>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m;
map<int,int> mp;
int a[101010];
int main(){
	string s;
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j,k,l,r,x,y; 
	cin>>n>>m;
	for(i=0;i<n;++i) 
	   cin>>a[i];
	sort(a,a+n);
	for(i=0;i<m;++i) {
		cin>>x>>y;
		mp[y]+=x;
	}
	long long ans=0;
	for(i=0;i<n;++i) {    
		if(mp.size()&&mp.rbegin()->first>a[i]) {
			a[i]=mp.rbegin()->first;
			mp.rbegin()->second--;   
			if(mp.rbegin()->second==0) {
				mp.erase(mp.rbegin()->first);
			}
		}
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5376
l = input().split()
L = [int(x) for x in l]
N = L[0]
M = L[1]

if N == 0:
    result = (M * (M-1))/2
elif M == 0:
    result = (N * (N-1))/2
else:
    result = (N * (N-1) + M * (M-1))/2

print(int(result))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


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

    long double c = (long double)log(h) / (long double)log(2);
    int count = (int)c;

    ll ans = ((ll)2 << count) - 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		boolean[] in_ball = new boolean[3];
		in_ball[0] = true;
		in_ball[1] = false;
		in_ball[2] = false;
		for(; scanner.hasNext();)
		{
			String in = scanner.next();
			String[] w = in.split(",");
			
			int[] n = new int[2];
			for(int i=0; i<2; i++)
			{
				switch (w[i])
				{
					case "A":
						n[i] = 0;
						break;
					case "B":
						n[i] = 1;
						break;
					case "C":
						n[i] = 2;
						break;
				}
			}
			
			boolean buf = in_ball[n[0]];
			in_ball[n[0]] = in_ball[n[1]];
			in_ball[n[1]] = buf;
		}
		
		String[] out = {"A", "B", "C"};
		for(int i=0; i<3; i++)
		{
			if(in_ball[i])
			{
				System.out.println(out[i]);
				break;
			}
		}
	}
}

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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        char[] S = in.s(N);

        int[] r = new int[26];
        for (int i = 0; i < N; i++) {
            r[S[i] - 'a']++;
        }

        int ans = 0;
        int[] l = new int[26];
        for (int i = 1, j = 0; i < N; i++) {
            int k = S[i - 1] - 'a';
            r[k]--;
            l[k]++;
            if (r[k] == 0 && l[k] > 1) {
                j--;
            } else if (l[k] == 1 && r[k] > 0 && ans < ++j) {
                ans = j;
            }
        }

        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 32412
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> h(N+1);
  int maxh = 0;
  int minh = 100;
  for (int i = 0; i < N; i++){
    cin >> h.at(i);
    maxh = max(maxh, h.at(i));
    minh = min(minh, h.at(i));
  }
  h.at(N) = 0;
  int ans = minh;
  for (int i = maxh; i > minh; i--){
    for (int j = 0; j < N; j++){
      if (i == h.at(j) && h.at(j) != h.at(j+1)){
        h.at(j)--;
        ans++;
      } else if (i == h.at(j) && h.at(j) == h.at(j+1)){
        h.at(j)--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int t,n;
    for(int i=0; i<4; i++){
        cin >> t >> n;
        if(t==1)        cout << 6000 * n << endl;
        else if(t==2)   cout << 4000 * n << endl;
        else if(t==3)   cout << 3000 * n << endl;
        else if(t==4)   cout << 2000 * n << endl;
    }
}


Measured memory_bytes: 3084
#include<stdio.h>
#include<stdlib.h>

int compar (const void *a, const void *b) {
  return *(int *)a- *(int *)b;
}
  
int main(void)
{
	int i,f[3],d[2];
	
	for(i=0;i<=2;i++)
	{
		scanf("%d",&f[i]);
	}
	for(i=0;i<=1;i++)
	{
		scanf("%d",&d[i]);
	}
	qsort(f,3,sizeof(int),compar);
	qsort(d,2,sizeof(int),compar);
	printf("%d\n",f[0]+d[0]-50);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  bool f=true;
  char c='a';
  REP(i,4){
    char d;
    cin>>d;
    if(c==d)f=false;
    c=d;
  }
  cout<<(f?"Good":"Bad")<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var N int
var A int
var B int
var C int
var INF int = 100000000
var L []int

func main() {
	N = nextInt()
	A = nextInt()
	B = nextInt()
	C = nextInt()
	L = nextInts(N)
	fmt.Printf("%v", dfs(0, 0, 0, 0))
}

// 100, 70, 20
func dfs(a, b, c, d int) int {
	if d == N {
		if a == 0 || b == 0 || c == 0 {
			return INF
		}
		return Abs(A-a) + Abs(B-b) + Abs(C-c) - 30
	}
	d0 := dfs(a, b, c, d+1)
	d1 := dfs(a+L[d], b, c, d+1) + 10
	d2 := dfs(a, b+L[d], c, d+1) + 10
	d3 := dfs(a, b, c+L[d], d+1) + 10
	return MinIn4Values(d0, d1, d2, d3)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func MinIn4Values(a int, b int, c int, d int) int {
	e := MinIn2Values(a, b)
	f := MinIn2Values(c, d)
	return MinIn2Values(e, f)
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


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

int main()
{
    int y,m,d;
    char c1,c2;
    cin>>y>>c1>>m>>c2>>d;
    if(m<=4)cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    int counter = 700;
    if (s[0] == 'o') counter += 100;
    if (s[1] == 'o') counter += 100;
    if (s[2] == 'o') counter += 100;
    cout << counter << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

vint v;
void foo(int n,int m){
	// cout<<n<<" "<<m<<endl;
	if(n<-10) return;
	if(n==0){
		rep(i,v.size()){
			if(i) cout<<" ";
			cout<<v[i];
		}
		cout<<endl;
		return;
	}
	for(int i=min(m,n);i>0;i--){
		v.PB(i);
		foo(n-i,i);
		v.pop_back();
	}
	return;
}

void mainmain(){
	int n;
	while(cin>>n,n){
		while(v.size()) v.pop_back();
		foo(n,n);
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1220
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Queue;
import java.util.Scanner;

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

        int[] cnt = new int[26];
        while (scanner.hasNext()) {
            String str = scanner.nextLine().toLowerCase();

            for (int i = 0; i < str.length(); ++i) {
                if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z') {
                    ++cnt[str.charAt(i) - 'a'];
                }
            }
        }
        for (int i = 0; i < 26; ++i) {
            System.out.printf("%s : %d\n", (char) ('a' + i), cnt[i]);
        }
    }
}


Measured memory_bytes: 26304
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        System.out.println(N==0?1:0);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35788
import string

if __name__ == '__main__':
    A = list(input())
    hist = {}
    for c in string.ascii_lowercase:
        hist[c] = A.count(c)

    # print(hist)

    same_when_reverse = 0
    for v in hist.values():
        same_when_reverse += v * (v - 1) // 2

    num_len = len(A)
    print((num_len * (num_len - 1) // 2 + 1) - same_when_reverse)


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

int n;
string s;
long long mc_acc[1000001], m_acc[1000001], c_acc[1000001];

long long solve(int len) {
  long long ans = 0;
  for (int i=0; i<n; i++) {
    if (s[i] == 'D') {
      ans += mc_acc[min(i+len, n)] - mc_acc[i] - m_acc[i] * (c_acc[min(i+len, n)] - c_acc[i]);
    }
  }
  return ans;
}
int main() {
  cin>>n;
  cin>>s;
  m_acc[0] = 0;
  for (int i=0; i<n; i++) {
    m_acc[i+1]= m_acc[i];
    if (s[i] == 'M') {
      ++m_acc[i+1];
    }
  }
  c_acc[0] = 0;
  mc_acc[0] = 0;
  for (int i=0; i<n; i++) {
    c_acc[i+1] = c_acc[i];
    mc_acc[i+1] = mc_acc[i];
    if (s[i] == 'C') {
      mc_acc[i+1] += m_acc[i];
      ++c_acc[i+1];
    }
  }

  int q;
  cin>>q;
  for (int i=0; i<q; i++) {
    int k;
    cin>>k;
    cout<<solve(k)<<endl;
  }
}

Measured memory_bytes: 24836
n = int(input())
A = [0] + list(map(int, input().split())) + [0]
diff = [abs(A[i]-A[i+1]) for i in range(n+1)]

#普通に総和を出す
sum = sum(diff)
  
#引いて足す
for i in range(1, n+1, 1): #1～Nを省いたとき
  nowsum = sum
  nowsum -= diff[i-1]
  nowsum -= diff[i]
  nowsum += abs(A[i-1]-A[i+1])
  print(nowsum)


Measured memory_bytes: 14176
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		long[]A = new long[N];
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str[i]);
		}
		long ans = Gcd(A[0],A[1]);
		for(var i=2;i<N;i++){
			ans = Gcd(ans,A[i]);
		}
		Console.WriteLine(ans);
	}
	
	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
}

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

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int N, M, K; cin >> N >> M >> K;
    UnionFind U = UnionFind(N);
    vector<int> friends(N);
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        U.merge(a, b);
        friends[a]++;
        friends[b]++;
    }
    ll ans[N];
    rep(i, N){
        ans[i] = U.size(i) - friends[i] - 1;
    }
    rep(i, K){
        int c, d; cin >> c >> d;
        c--; d--;
        if(U.issame(c, d)){
            ans[c]--;
            ans[d]--;
        }
    }

    rep(i, N){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;

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

    if (s.at(3 - 1) != s.at(4 - 1))
    {
        cout << "No" << endl;
        return 0;
    }
    if (s.at(6 - 1) != s.at(5 - 1))
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x;
  while(1){
    scanf("%d%d",&n,&x);
    if(n==0 && x==0){break;}
    int i,j,k,count=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	k=x-i-j;
	if(k<=j){break;}
	if(k<=n){
	  count++;
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
}



Measured memory_bytes: 2696
int main()
{
    int a[101][101], b[101], c[101];
    int i, j;
    int n, m;
    
    scanf("%d%d", &n ,&m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    
    for (j = 0; j < m; j++) {
        scanf("%d", &b[j]);
    }
    
    for (i = 0; i < n; i++) {
        c[i] = 0;
        for (j = 0; j < m; j++) {
            c[i] += a[i][j] * b[j];
        }
    }
    
    for (i = 0; i < n; i++) {
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2100
#include<iostream>

using namespace std;

int main() {
	int h,w;
while(1){
	std::string line = "";
	cin >> h >> w;
if (h!=0 || w!=0){
	for (int i=0;i<w;i++){ line += "#"; }
	for (int j=0;j<h;j++){
		cout << line << endl;
	}
	cout << "" << endl;
}else{ break; }
}
	return 0;
}


Measured memory_bytes: 3196