akhauriyash/Code-Regression huggingface dataset:
string = input()
kai = int(input())
data = [input().split(' ') for i in range(kai)]
key = 0  #0 start
former = []
latter = []

for i in range(kai):
    if(data[i][0] == '1'):
        key = (key + 1) % 2
    elif((int(data[i][1]) + key) % 2 == 1):
        former.append(data[i][2])
    else:
        latter.append(data[i][2])

string = ''.join(former[::-1]) + string + ''.join(latter)
if(key == 0):
    print(string)
else:
    print(string[::-1])


Measured memory_bytes: 42396
#include <stdio.h>
//バイナリヒープ
//バイナリヒープ
#define N 10000000
double heap[N];
int last;
unsigned seed=0x12121204;
void push(double n){
    int i=last,j=(i-1)>>1;
    while(i>0&&heap[j]>n){
        heap[i]=heap[j];
        i=j;
        j=(i-1)>>1;
    }
    heap[i]=n;
    last++;
}
double pop(){
    last--;
    double a=heap[0];
    double t=heap[last];
    int i=0,j;
    j=1+(heap[1]>heap[2]);
    while(j<last&&t>heap[j]){
        heap[i]=heap[j];
        i=j;
        if(j*2+1<last&&heap[j*2+1]>heap[j*2+2]){
            j=j*2+2;
        }else{
            j=j*2+1;
        }
    }
    heap[i]=t;
    return a;
}
int main(void){
    int n;
    int v;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&v);
        push(v);
    }
    double t,q;
    for(i=0;i<n-1;i++){
        t=pop();
        q=pop();
        push((t+q)/2);
    }
    printf("%.5f\n",pop());
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int PMAX = 2000000;
const int QMAX = 100000;

const function<int(int, int)> minQ = [](int l, int r) { return min(l, r); };

template <typename T>
struct node {
	T val;
	node *l, *r;
	node() {}
	node(T val) : val(val), l(nullptr), r(nullptr) {}
	void init(T v, node *left, node *right) {
		val = v;
		l = left;
		r = right;
	}
};

node<int> pool[PMAX];
node<int> *root[QMAX];

template <typename T>
class PersistentSegmentTree {
	using func_t = function<T(T, T)>;
	const int n;
	const T id;
	func_t merge;
	int it, rit;
	int size(int n) {
		int res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node(int val = 0, node<T> *l = nullptr, node<T> *r = nullptr) {
		pool[it].init(val, l, r);
		return &pool[it++];
	}
	node<T> *fix(node<T> *x, int p, T val, int lb, int ub) {
		if (p < lb || ub <= p) return x;
		if (lb + 1 == ub) return new_node(val);
		int c = (lb + ub) / 2;
		auto nl = fix(x->l, p, val, lb, c);
		auto nr = fix(x->r, p, val, c, ub);
		return new_node(merge(nl->val, nr->val), nl, nr);
	}
	T sub(node<T> *x, int l, int r, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return x->val;
		int c = (lb + ub) / 2;
		return merge(sub(x->l, l, r, lb, c), sub(x->r, l, r, c, ub));
	}
public:
	PersistentSegmentTree(int n_, T id_, func_t merge_) : n(size(n_)), id(id_), merge(merge_), rit(0) {
		for (int i = 1; i < n * 2; i++) {
			pool[i - 1].init(id,i < n ? &(pool[i * 2 - 1]) : nullptr, i < n ? &(pool[i * 2]) : nullptr);
		}
		it = n * 2 - 1;
		root[rit++] = &pool[0];
	}
	void update(int p, T val, int rt = -1) {
		if (rt == -1) rt = rit - 1;
		assert(0 <= rt && rt < rit);
		root[rit++] = fix(root[rt], p, val, 0, n);
	}
	T find(int l, int r, int rt = -1) {
		if (rt == -1) rt = rit - 1;
		assert(0 <= rt && rt < rit);
		return sub(root[rt], l, r + 1, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	int n, q, com, x, y;
	cin >> n >> q;
	PersistentSegmentTree<int> ps(n, INT_MAX, minQ);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", ps.find(x, y));
		}
		else {
			ps.update(x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 30928
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

class UnionFind {
 public:
  UnionFind(int n) : n_(n) { Initialize(); }
  int GetRoot(int x);
  bool IsSame(int x, int y);
  void Unite(int x, int y);

 private:
  const int n_;
  std::vector<int> parent_;
  std::vector<int> rank_;
  void Initialize();
};

void UnionFind::Initialize() {
  parent_.assign(n_, -1);
  rank_.assign(n_, 0);
}

int UnionFind::GetRoot(int x) {
  if (parent_[x] == -1)
    return x;
  else
    return parent_[x] = GetRoot(parent_[x]);
}

bool UnionFind::IsSame(int x, int y) { return GetRoot(x) == GetRoot(y); }

void UnionFind::Unite(int x, int y) {
  x = GetRoot(x);
  y = GetRoot(y);
  if (x == y) return;
  if (rank_[x] < rank_[y]) std::swap(x, y);
  if (rank_[x] == rank_[y]) ++rank_[x];
  parent_[y] = x;
  return;
}

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

  int n, m; cin >> n >> m;
  UnionFind uf(n + m);

  for (int i = 0; i < n; ++i) {
    int k; cin >> k;
    for (int j = 0; j < k; ++j) {
      int l; cin >> l; --l;
      uf.Unite(i, n + l);
    }
  }

  for (int i = 0; i < n - 1; ++i) {
    if (!uf.IsSame(i, i + 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int ans[1024][1024];

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<(1<<n)-1;i++){
		for(int j=0;j<(1<<m)-1;j++){
			if((__builtin_ffs(i+1)+__builtin_ffs(j+1))==(max(n,m)+1)){
				ans[i][j]=1;
			}
		}
	}
	for(int i=0;i<(1<<n)-1;i++){
		for(int j=0;j<(1<<m)-1;j++){
			printf("%d",ans[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>

int main(){
  int sumvac,homework;
  int allhlong=0;
  int i;
  
  scanf("%d %d",&sumvac,&homework);
  int hlong[homework];
  for(i=0;i<homework;i++)
    scanf("%d",&hlong[i]);

  for(i=0;i<homework;i++)
    allhlong=allhlong+hlong[i];

  if(allhlong<=sumvac)
    printf("%d",sumvac-allhlong);
  else
    printf("-1");
}

Measured memory_bytes: 1744
# C - Tax Increase
A,B = map(int,input().split())
a = (A*100+8-1)//8
b = (B*100+10-1)//10

aa = a*8//100
ab = a*10//100
ba = b*8//100
bb = b*10//100

if aa==A and ab==B:
    if ba==A and bb==B:
        print(min(a,b))
    else:
        print(a)
else:
    if ba==A and bb==B:
        print(b)
    else:
        print(-1)


Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    int n,m,x,i,broken[100010]={0},dp[100010]={0};
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&x);
        broken[x]=1;
    }
    dp[n]=1;
    for(i=n-1;i>=0;i--){
        if(broken[i]==1) continue;
        dp[i] = (dp[i+1]+dp[i+2])%1000000007;
    }
    printf("%d",dp[0]);
}

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

#define ll long long int
#define tinput int t; cin>>t; while(t--)
#define rep(i,n,s) for((i)=(s); (i)<(n); (i)++)

template <typename T>
T mini(T x, T y) { return (x<y)?x:y; }
template <typename T>
T maxi(T x, T y) { return (x>y)?x:y; }
ll M = 1e9+7;

int main(){
 //   freopen("input.txt", "r", stdin);
 //   freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin>>s;
	int n = s.length();
	if(s[n-1]=='s') s=s+"es";
	else s=s+"s";
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        if(str.matches("A[a-z](?=[a-zC]{1,7})[a-z]*C[a-z]*[a-z]$")){
            System.out.println("AC");
        }
        else{
            System.out.println("WA");
        }
    }
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;
 
int main(){
   int n;
   cin >> n;
   int n_100 = n / 100;
   int n_10 = (n - n_100 * 100) / 10;
   int n_1 = n % 10;

   if(n_10 < n_100) cout << n_100 * 100 + n_100 * 10 + n_100 << endl;
   else if(n_10 == n_100){
      if(n_1 <= n_100) cout << n_100 * 100 + n_100 * 10 + n_100 << endl;
      else cout << (n_100 + 1) * 100 + (n_100 + 1) * 10 + (n_100 +1) << endl;
   }else{
      cout << (n_100 + 1) * 100 + (n_100 + 1) * 10 + (n_100 +1) << endl;
   }
}


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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

// typedef pair<int, int> P;
int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    int i = 0;
    while (i < n - 2) {
        if (s.at(i) == 'A' && s.at(i + 1) == 'B' && s.at(i + 2) == 'C') {
            ans++;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,rep[3],s[1001000],cnt[3],t[1001000];
char S[1001000];
void WORK(){
	int top=0;
	for(int i=1;i<=n;++i)s[i]=rep[s[i]];
	for(int i=0;i<3;++i)if(rep[i]<i)swap(cnt[i],cnt[rep[i]]);
	if(cnt[1]==cnt[2]){
		for(int i=1;i<=n;)if(cnt[1]^cnt[0]&&i<n&&s[i]&&s[i+1]&&(i+2>n||s[i+2]||!top))i+=2,--cnt[1];else t[++top]=s[i++];
	}else{
		array<int,3> rp={0,1,2};
		if(cnt[1]>cnt[2])swap(rp[1],rp[2]);
		for(int i=1;i<=n;++i)s[i]=rp[s[i]];
		int b1=0,b2=0,c1=0,c2=0;
		for(int i=1,ls=0;i<=n+1;++i)if(!s[i]){
			if(i-ls==2)s[i-1]-1?(c2++,c1++):(b2++,b1++);
			if(i-ls>2)++c1,++b1;
			ls=i;
		}
		if(c2>b1&&s[n]==2&&!s[n-1])--n,--c2;
		for(int i=1,_=n;i<=_;++i){
			if(i==1)n=0;
			if(s[i]==2&&(i==n||!s[i+1])&&(i==1||!s[i-1])&&c2>b1)--c2;else t[++n]=s[i];
		}
		for(int i=1,_=n;i<=_;++i)if(i==1)s[n=1]=t[i];else if(s[n]^t[i])s[++n]=t[i];s[n+1]=0;
		memset(cnt,0,sizeof cnt);
		for(int i=1;i<=n;++i)++cnt[s[i]];
		for(int i=1,_=n;i<=_;++i){
			if(i==1)n=0;
			if(s[i]==2&&(s[i-1]==0)+(s[i+1]==0)==1&&cnt[2]^cnt[1])--cnt[2];else t[++n]=s[i];
		}
		memset(cnt,0,sizeof cnt);
		for(int i=1;i<=n;++i)++cnt[s[i]=t[i]];
		for(int i=1;i<=n;)if(cnt[1]^cnt[0]&&i<n&&s[i]&&s[i+1]&&(i+2>n||s[i+2]||!top))i+=2,--cnt[1];else t[++top]=rp[s[i++]];
	}
	for(int i=1;i<=top;++i)putchar(rep[t[i]]+65);
}
int main(){
	scanf("%s",S+1);n=strlen(S+1);
	rep[0]=0;rep[1]=1;rep[2]=2;
	for(int i=1,_=n;i<=_;++i)if(i==1)n=1;else if(S[i]^S[n])S[++n]=S[i];
	for(int i=1;i<=n;++i)++cnt[s[i]=S[i]-65];
	if(!cnt[0]||!cnt[1]||!cnt[2]){printf("\n");return 0;}
	if(cnt[0]<=cnt[1]&&cnt[0]<=cnt[2])WORK();else
	if(cnt[1]<=cnt[0]&&cnt[1]<=cnt[2])rep[0]=1,rep[1]=0,WORK();
	else rep[0]=2,rep[2]=0,WORK();
}

Measured memory_bytes: 9984
#include <map>
#include <vector>
#include <algorithm>
typedef long long ll;
//#define scanf(a) scanf(a)+1
using namespace std;
int mod = 1e9+7;

bool comparator(pair<int, int> lh, pair<int, int> rh) {
	return (lh.second < rh.second);
}

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

	vector<pair<int, int>> vpii;
	vpii.reserve(N);

	int tmp1, tmp2;
	for (int i = 0; i < N; i++) {
		scanf("%d%d", &tmp1, &tmp2);
		vpii.push_back(make_pair(tmp1, tmp2));
	}

	sort(vpii.begin(), vpii.end(), comparator);

	ll sum = 0;
	bool ans = true;
	auto end = vpii.end();
	for (auto itr = vpii.begin(); itr != end; itr++) {
		sum += itr->first;
		if (sum > itr->second) {
			ans = false;
			break;
		}
	}

	printf(ans ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
  int a,b,c,result;
  scanf("%d %d %d",&a,&b,&c);
  int a_=a,b_=b,c_=c;
  if (a<b) ;
  else a=b_,b=a_;
  a_=a,b_=b,c_=c;
  if (b<c) ;
  else b=c_,c=b_;
  a_=a,b_=b,c_=c;
  if (a<b) ;
  else a=b_,b=a_;
  a_=a,b_=b,c_=c;
//  printf("%d %d %d",a,b,c);
  if (((b-a)%2==0)&&((c-b)%2==0)) result=(((c-a)/2)+((c-b)/2));
  else if (((b-a)%2==0)&&((c-b)%2==1))
  {
    a++;
    b++;
    result++;
    result+=((c-a)/2+(c-b)/2);
  }
  else if (((b-a)%2==1)&&((c-b)%2==0))
  {
    c++;
    b++;
    result++;
    result+=((c-a)/2+(c-b)/2);
  }
  else if (((b-a)%2==1)&&((c-b)%2==1))
  {
    c++;
    a++;
    result++;
    result+=((c-a)/2+(c-b)/2);
  }
  printf("%d",result);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
   string str;cin>>str;
   bool c1=true,c2=true;
   for(int i=0;i<str.size();i++)
   {
       if(i%2==0)//ODD
       {
            if(str[i]!='R'&& str[i]!='U'&& str[i]!='D')
            {
                c1=false;
                break;
            }
       }
       else if(i%2==1)
       {
            if(str[i]!='L'&& str[i]!='U'&&str[i]!='D')
            {
                c1=false;
                break;
            }
       }
   }
   if(c1&&c2)
   {
       cout<<"Yes\n";
   }
   else cout<<"No\n";
   
   return 0;
}

Measured memory_bytes: 3576
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N;
    cin >> N;

    vll h(N);
    rep(i, N) cin >> h[i];

    vll dp(N, INF);
    dp[0] = 0;

    repl(i, 1, N)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i >= 2) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N - 1] << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

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

int N, A, B, C;
int l[10];

int rec(int i, int a, int b, int c){
    if(i == N){
        if(!a || !b || !c) return INF;
        return abs(a - A) + abs(b - B) + abs(c -C);
    }

    int res =rec(i+1, a, b, c);

    res = min(res, rec(i+1, a + l[i], b, c) + (a ? 10 : 0));
    res = min(res, rec(i+1, a, b + l[i], c) + (b ? 10 : 0));
    res = min(res, rec(i+1, a, b, c + l[i]) + (c ? 10 : 0));

    return res;
}

int main(){
    int ans;

    cin >> N >> A >> B >> C;
    rep(i,N) cin >> l[i];

    ans = rec(0, 0, 0, 0);

    cout << ans << endl;
} 

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;
    
class Main{
    
static final PrintWriter out=new PrintWriter(System.out);
 
static class binarySearchTree{
 
static class Node{
int id;
Node p;
Node l;
Node r;
int deg;
Node(int id){
this.id=id; this.p=null; this.l=null; this.r=null; this.deg=0;
}
}
 
private static Node root;
 
binarySearchTree(){
root=null;
}
 
public static void insert(int v){
if(root==null) root=new Node(v);
else __insert(new Node(v));
}
 
private static void __insert(Node z){
Node x=root;
Node y=null;
while(x!=null){
y=x;
if(z.id<x.id) x=x.l;
else x=x.r;
}
z.p=y;
if(z.id<y.id) y.l=z;
else y.r=z;
y.deg++;
}
 
public static boolean find(int v){
Node x=root;
while(x!=null){
if(x.id==v) return true;
else if(x.id>v) x=x.l;
else x=x.r;
}
return false;
}
 
public static void print(){
inorder(root);
out.println();
preorder(root);
out.println();
}
 
private static void preorder(Node now){
if(now==null) return;
out.print(" "+now.id);
preorder(now.l);
preorder(now.r);
}
  
private static void inorder(Node now){
if(now==null) return;
inorder(now.l);
out.print(" "+now.id);
inorder(now.r);
}
  
private static void postorder(Node now){
if(now==null) return;
postorder(now.l);
postorder(now.r);
out.print(" "+now.id);
}
}
 
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
binarySearchTree tree=new binarySearchTree();
int num=Integer.parseInt(br.readLine());
for(int i=0;i<num;i++){
st=new StringTokenizer(br.readLine());
String command=st.nextToken();
int n;
if("insert".equals(command)){
n=Integer.parseInt(st.nextToken());
tree.insert(n);
}
else if("find".equals(command)) {
n=Integer.parseInt(st.nextToken());
out.println((tree.find(n))?"yes":"no");
}
else tree.print();
}
out.flush();
}
}

Measured memory_bytes: 152576
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    int ma=0,ans=0;
    while(n--){
        int h; cin>>h;
        if(ma<=h) ans++;
        ma=max(ma,h);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    cin >> s;
    ll ans = 0, cnt = 0;
    int i = 0;
    while(i < s.size()){
        if(s[i] == 'A'){
            cnt++;
            i++;
        }else if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C'){
            ans += cnt;
            i += 2;
        }else{
            cnt = 0;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int tot = 0;
		foreach(var c in S) tot += c - '0';
		Console.WriteLine(tot % 9 == 0 ? "Yes" : "No");
		
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 26588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    int n,m; cin>>n>>m;
    vector<int> v(n,0);
    rep(i,0,m){
        int x,y; cin>>x>>y;
        x--; y--;
        v[x]++; v[y]++;
    }
    rep(i,0,n){
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 256
package main
import "fmt"

func check(num,num2 int)(bool){
    if num<num2{
        return true
    }else{
        return false
    }
}

func main(){
    nums:=[3]int{}
    fmt.Scan(&nums[0],&nums[1],&nums[2])
    
    var checkBool bool
    for i:=0;i<2;i++{
        checkBool=check(nums[i],nums[i+1])
        if checkBool==false{
            break
        }
    }
    
    if checkBool==true{
        fmt.Println("Yes")
    }else{
        fmt.Println("No")
    }
}



Measured memory_bytes: 1120
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if(n > k)cout << x * k + y * (n - k);
	else cout << x * n;
	cout << endl;
	return 0;
}


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


int n, q;

class RangeMinimumQuery {
private:
  int* tree;
public:
  int size;
  RangeMinimumQuery(int n) {
    size = 1; while(size < n) size *= 2;
    tree = new int[2*size - 1];
    for (int i=0; i < 2*size - 1; i++) tree[i] = INT_MAX;
  }
  void update(int i, int x);
  int find(int s, int t, int i, int l, int r);
};

void RangeMinimumQuery::update(int i, int x) {
  i += size - 1;

  tree[i] = x;
  while (i > 0) {
    i = (i - 1) / 2;
    tree[i] = min(tree[2*i+1], tree[2*i+2]);
  }

  // for (int i=0; i < 2*i - 1; i++) {
    // cout << tree[i] << ", ";
  // }
  // cout << '\n';
}

int RangeMinimumQuery::find(int s, int t, int i, int l, int r) {
  // cout << i <<": (" << s << ", " << t << ")" << '\n';
  // cout << "[" << l << ", " << r << "]" << '\n';
  if (r < s || t < l) return INT_MAX;
  if (s <= l && r <= t) return tree[i];

  int vl = find(s, t, 2*i+1, l, (l+r)/2);
  int vr = find(s, t, 2*i+2, (l+r)/2+1, r);
  return min(vl, vr);
}

int main () {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> n >> q;

  RangeMinimumQuery* RmQ = new RangeMinimumQuery(n);
  
  int com, x, y;
  for (int i=0; i < q; i++) {
    cin >> com >> x >> y;
    if (com == 0) {
      RmQ -> update(x ,y);
    } else {
      cout << RmQ -> find(x, y, 0, 0, RmQ -> size - 1) << '\n';
    }
  }
  return 0;
} 

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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

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


int main(int argc, char **argv)
{
	ll a; cin >> a;
	string b; cin >> b;
	ll b100 = (b[0]-'0')*100 + (b[2]-'0')*10 + b[3]-'0';
	std::cout << a*b100/100<< std::endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

////////////////*My library*////////////////////////
#define rep_to(a,i,n) for(i=a;i<n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define rep_r(i,n) for(i=n-1;i>=0;i--)
#define debug_i(x) printf("x:%d\n",x)
#define debug_f(x) printf("x:%f\n",x)
#define debug_s(str) printf("str:%s\n",str)
#define debug_c(c) printf("c:%c\n",c)
#define s_i1(x) scanf("%d",&x)
#define s_i2(x,y) scanf("%d %d",&x,&y)
#define s_i3(x,y,z) scanf("%d %d %d",&x,&y,&z)
////////////////////////////////////////////////////

////////////////////////
/*prime()*/
/*primecount()*/
/*sort()*/
///////////////////////

int main()
{
	int N,i,num,ans=0;
	while(1)
	{
		s_i1(N);
		if(N==0)break;
		ans=0;
		rep(i,N/4)
		{
			s_i1(num);
			ans+=num;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1028
import math
def primes(x):# エラトステネス
    if x < 2: return []
    primes = [i for i in range(x)]
    primes[1] = 0 
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0
    return [prime for prime in primes if prime != 0]

p = primes(55556)
p = [i for i in p if i%5 == 4]
p = p[:int(input())]
print(" ".join(map(str,p)))


Measured memory_bytes: 5272
#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;

int main(){
    int n;
    cin>>n;
    string s,t;
    while(n--){
        cin>>s>>t;
        int si=0;
        rep(i,s.size()){
            if(isdigit(s[i])){
                if(s[i+1]=='m') si+=1000*(s[i]-'0');
                if(s[i+1]=='c') si+=100*(s[i]-'0');
                if(s[i+1]=='x') si+=10*(s[i]-'0');
                if(s[i+1]=='i') si+=1*(s[i]-'0');
                ++i;
            }
            else{
                if(s[i]=='m') si+=1000;
                if(s[i]=='c') si+=100;
                if(s[i]=='x') si+=10;
                if(s[i]=='i') si+=1;
            }
        }
        int ti=0;
        rep(i,t.size()){
            if(isdigit(t[i])){
                if(t[i+1]=='m') ti+=1000*(t[i]-'0');
                if(t[i+1]=='c') ti+=100*(t[i]-'0');
                if(t[i+1]=='x') ti+=10*(t[i]-'0');
                if(t[i+1]=='i') ti+=1*(t[i]-'0');
                ++i;
            }
            else{
                if(t[i]=='m') ti+=1000;
                if(t[i]=='c') ti+=100;
                if(t[i]=='x') ti+=10;
                if(t[i]=='i') ti+=1;
            }
        }
        int sum=si+ti;
        string ans;
        if(sum/1000>1) ans+=(char)('0'+sum/1000),ans+='m';
        if(sum/1000==1) ans+='m';
        sum%=1000;
        if(sum/100>1) ans+=(char)('0'+sum/100),ans+='c';
        if(sum/100==1) ans+='c';
        sum%=100;
        if(sum/10>1) ans+=(char)('0'+sum/10),ans+='x';
        if(sum/10==1) ans+='x';
        sum%=10;
        if(sum>1) ans+=(char)('0'+sum),ans+='i';
        if(sum==1) ans+='i';
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;
public class Main {

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

// 標準入力を1行ずつ読み出す。
while (stdin.hasNextLine()) {
    int line1 = Integer.parseInt(stdin.nextLine());
    String line2 = stdin.nextLine();
  System.out.println(line1 >= 3200 ? line2 : "red"); 
}
  }
}

Measured memory_bytes: 23124
//逆数の総和の逆数
#include <bits/stdc++.h>
using namespace std;

void solve(int N, vector<double> A){
  double sum = 0.0;
  for (int i = 0; i < N; i++){
    sum += 1 / A[i];
  }
  printf("%lf\n", 1 / sum);
}

int main(){
  int N;
  scanf("%d",&N);
  vector<double> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lf",&A[i]);
  }
  solve(N, move(A));
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n,k,s;scanf ("%d%d%d",&n,&k,&s);
	for (int i=1;i<=k;i++) printf ("%d ",s);
	for (int i=k+1;i<=n;i++) printf ("%d ",(s==1000000000)?1:1000000000);
	return 0;
}


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

const int MOD = 1e9+7;
const int MAXN = 1010;

typedef struct def{
	int a,b,c;

	def(){}
	def(int a2, int b2, int c2){
		a = a2; b = b2; c = c2;
	}
	bool operator < (def comp) const{
		if(a!=comp.a) return a < comp.a;
		else return b < comp.b;
	}
} generico;

typedef pair<int,int> pii;
typedef long long int ll;

#define INF 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define x first
#define y second

int n , m;
char g[MAXN][MAXN];
int memo[MAXN][MAXN];

long long  solve(int r , int c){
	
	if(r == n && c == m) return 1;
	if(r > n || c > m) return 0;
	if(g[r][c] == '#') return 0;
	if(memo[r][c] != -1) return memo[r][c];
	
	return memo[r][c] = (solve(r + 1 , c) % MOD + solve(r , c + 1) % MOD) % MOD;
}

int main(){
	
	memset(memo, -1 , sizeof memo);
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n>>m;
	
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= m ; j ++)
			cin>>g[i][j];
	
	cout<<solve(1,1)<<"\n";
	
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cstdlib>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <sstream>

using namespace std;

int sort[100];

class qs{
	private:
	
	public:
	void QuickSort(int bottom,int top,int *data);
};

void qs::QuickSort(int bottom,int top,int *data){
	int lower, upper, div, temp;
	if (bottom >= top){
		return;
	}
	div = data[bottom];
	for (lower = bottom, upper = top; lower < upper;){
		while(lower <= upper && data[lower] <= div){
			lower++;
		}
		while(lower <= upper && data[upper] > div){
			upper--;
		}
		if(lower < upper){
			temp = data[lower];
			data[lower] = data[upper];
			data[upper] = temp;
		}
	}
	temp = data[bottom];
	data[bottom] = data[upper];
	data[upper] = temp;
	
	QuickSort(bottom, upper-1, data);
	QuickSort(upper+1,top,data);
}

int main(){
	int n;
	int i;
	
    n = 10;
	//cin >> n;
	for(i=0; i<n; ++i){
		cin >> sort[i];
	}
	
	qs qs01;
	qs01.QuickSort(0,n-1,sort);
	
	for ( i=n-1; i>n-4; --i){
		cout << sort[i] <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3100
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	string s, m;
	int cnt = 0, k, n;
	cin >> s >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> m;
		m = m + m;
		n = m.find(s);
		if (n>=0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3100
#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() {
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	rep(i, n) {
		for (int j = 1; i+j <= n; j++) {
			string t = s.substr(i, j);
			int k = 0;
			while (true)
			{
				if (k >= t.size()) break;
				bool ok = t[k]=='A'||t[k]=='T'||t[k]=='G'||t[k]=='C';
				if (!ok) break;
				k++;
			}
			ans = max(ans, k);
		}	
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vector<ll> S(N);
	for (auto& v : S) cin >> v;

	ll ans = 0;
	for (ll d = 1; d < N-1; d++) {
		ll cnd = 0;
		for (int i = 0; d * (i+1) < N-1; i++) {
			if ((N-1) % d == 0 && d * i >= (N-1) - d * i) {
				break;
			}
			cnd += S[d*i];
			cnd += S[(N-1) - d*i];
			ans = max(ans, cnd);
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1024
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

bool cmp(const string& s1, const string& s2) {
  if (s1.size() != s2.size())
    return s1.size() < s2.size();
  return s1 < s2;
}
int n, m;
string dp[(int)1e4 + 5];
bool jest[10], git[(int)1e4 + 5];
int bla[] = {2,5,5,4,5,6,3,7,6};

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x;
    cin >> x;
    jest[x] = true;
  }
  git[0] = true;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 9; ++j)
      if (jest[j] && i >= bla[j-1] && git[i-bla[j-1]]) {
        string dru = (char)(j+'0') + dp[i-bla[j-1]];
        if (cmp(dp[i], dru)) {
          git[i] = true;
          dp[i] = dru;
        }
      }
  }
  cout<<dp[n]<<"\n";
}

Measured memory_bytes: 32512
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll Q,M,K,P,A,B,N,X;

    long double x;

    string S;
    char aaa;
    ll ans=0;
    ll count=0;
    ll flag=0;
    ll temp=0;

    vector<ll> aa, bb, hh, ff;
    ll a,b;
    
    ll d;


    cin >>N>>K;
    
    rep(i,N){
        cin>>Q;
        aa.push_back(Q);
    }
    sort(aa.begin(),aa.end());

    rep(i,K){
        ans += aa[i];
    }
   
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3176
//39
#include<iostream>
#include<map>
#include<set>
#include<sstream>
#include<string>
#include<cstdio>

using namespace std;

int b,l;
map<string,int> m;
map<string,map<int,int> > me;

void dec(string s){
  for(int i=0;i<s.size();i++){
    if(s[i]==']'||s[i]=='['){
      s[i]=' ';
    }
  }
  stringstream ss(s);
  string n;
  int c;
  ss>>n>>c;
  m[n]=c;
}

int exp(const char **p){
  int n,r;
  if(sscanf(*p,"%d%n",&n,&r)==1){
    (*p)+=r;
    return n;
  }else{
    char an[99];
    sscanf(*p,"%[^[]%n",an,&r);
    string ans=an;
    *p+=r+1;
    int x=exp(p);
    (*p)++;
    if((!me[ans].count(x)||m[ans]<=x)&&b==0){
      b=l;
    }
    return me[ans][x];
  }
}

void asn(const char *p){
  int r;
  char an[99];
  sscanf(p,"%[^[]%n",an,&r);
  string ans=an;
  p+=r+1;
  int x=exp(&p);
  p+=2;
  if(m[ans]<=x&&b==0){
    b=l;
  }
  int v=exp(&p);
  me[ans][x]=v;
}

int main(){
  for(string s;cin>>s,s!=".";){
    m.clear();
    me.clear();
    b=l=0;
    for(;s!=".";cin>>s){
      l++;
      if(s.find('=')!=string::npos){
	asn(s.c_str());
      }else{
	dec(s);
      }
    }
    cout<<b<<endl;
  }
  return 0;
}

Measured memory_bytes: 1344
using System;

namespace ABC109_B_Shiritori
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] words = new string[n];

			string ans = "Yes";

			for (int i = 0; i < n; i++)
			{
				words[i] = Console.ReadLine();
				if (i >= 1)
				{
					string firstWord = words[i].Substring(0, 1);
					string lastWord = words[i - 1].Substring(words[i - 1].Length - 1, 1);

					if (firstWord != lastWord)
					{
						ans = "No";
					}
				}
			}

			for (int i = 0; i < n - 1; i++) {
				for (int j = i + 1; j < n; j++) {
					if (words[i] == words[j])
					{
						ans = "No";
					}
				}
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String ABC = "ABC";
		String ARC = "ARC";
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (ABC.equals(s)) {
			System.out.println(ARC);
		} else {
			System.out.println(ABC);
		}
	}
}

Measured memory_bytes: 35600
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = 2 * 1000 * 1000 * 1000;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
using namespace std;

void file_put() {
	freopen("filename.in", "r", stdin);
	freopen("filename.out", "w", stdout);
}

ll x;

int main() {
	//file_put();

	scanf("%I64d", &x);
	cout << (ceil)((-1 + (long double)sqrt(8 * x + 1)) / 2) << endl;

	return 0;
}

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

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


int main(int argc, char const *argv[])
{
	int n; ll h; cin >> n >> h;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];

	int max = 0, index;
	rep(i, n) {
		if (max < a[i]) max = a[i], index = i;
	}

	vector<int> b1;
	rep(i, n) if (b[i] > max)  b1.push_back(b[i]);
	sort(b1.begin(), b1.end());
	reverse(b1.begin(), b1.end());


	int ans = 0;
	rep(i, b1.size()) {
		h -= b1[i];
		ans++;
		if (h <= 0ll) break;
	}

	if (h <= 0ll) {
		printf("%d\n", ans);
		return 0;
	}

/*
	while(1) {
		h -= max;
		ans++;
		if (h <= 0ll) break;
	}
*/

	ans += h / max + ((h % max) ? 1 : 0);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2428
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function(input) {
  var lines = input.split('\n');
  var ab = lines[0].split(' ');
  var a = +ab[0];
  var b = +ab[1];
  console.log(a*b + ' ' + (a+b)*2);
});

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a, b, c;
    cin >> a >> b >> c;
    char card = 'a';
    string winner = "X";
    while(1){
        if(card=='a'){
            if(a.empty()){
                winner = "A";
                break;
            }else{
                card=a[0];
                a = a.substr(1, a.size()-1);
            }
        }else if(card=='b'){
            if(b.empty()){
                winner = "B";
                break;
            }else{
                card=b[0];
                b = b.substr(1, b.size()-1);
            }
        }else if(card=='c'){
            if(c.empty()){
                winner = "C";
                break;
            }else{
                card=c[0];
                c = c.substr(1, c.size()-1);
            }
        }
    }
    cout << winner << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool sox=false;
  int jj=0;
  int pp=0;
  vector<int64_t> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());

  int ans = 0;
  for (int i = 0; i < n - 2; ++i) {
    for (int j = i + 1; j < n - 1; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (l[i] != l[j] && l[j] != l[k] && l[i] + l[j] > l[k]) {
          ++ans;
          sox=true;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define vi vector<int>
#define pb push_back

int main(){
int n,ans;
cin >> n;
int i;
for(i=1;i<=n;i*=2){}

cout << i/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b"<<endl;
        return 0;
    }
    if(a == b){
        cout<<"a == b"<<endl;
        return 0;
    }
    cout<<"a < b"<<endl;
    return 0;
}


Measured memory_bytes: 1160
#include<stdio.h>
int main(void)
{
	int i;
	char s[100];
	char a1, a2;
	int flag = 0, co = 0, co2 = 0;

	scanf("%s", s);
	a1 = s[0];
	a2 = '0';
	for (i = 0; s[i] != '\0'; i++) {
		if (a1 == s[i]) {
			co++;
			if (co >= 3) {
				flag = 1;
			}
		}
		else if (a2 == s[i]) {
			co2++;
			if (co2 >= 3) {
				flag = 1;
			}
		}
		else if (a1 != s[i]) {
			if (a2 == '0') {
				a2 = s[i];
			}
			else {
				flag = 1;
			}
		}
	}
	if (flag == 0) {
		printf("Yes\n");
	}
	else if (flag == 1) {
		printf("No\n");
	}
	return 0;
}

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

using namespace std;
int main(){
    int n;
    int AC=0,TLE=0,WA=0,RE=0;
    cin >> n;
    string s;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s =="AC")          AC++;
        else  if(s == "WA")   WA++;
        else  if(s == "TLE")  TLE++;
        else                  RE++;
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
    return 0;
}

Measured memory_bytes: 3608
k,n=map(int, input().split())
a = list(map(int, input().split()))
dist = []#家間の距離
for i in range(len(a)-1):
    dist.append(a[i+1] - a[i] )
dist.append(k - a[-1] + a[0])
print(sum(dist) - max(dist))

Measured memory_bytes: 26444
#include<stdio.h>
int main()
{
	int W,H,r,x,y;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                while (true) {
                        int N = sc.nextInt(), count = 0;
                        if (N == 0) {
                                break;
                        }
                        long A[] = new long[4001];
                        for (int i = 0; i < N; i++) {
                                int e = sc.nextInt();
                                long p = sc.nextLong(), q = sc.nextLong();
                                A[e] += p * q;
                                if (A[e] >= 1000000) {
                                        System.out.println(e);
                                        count++;
                                        A[e] = Long.MIN_VALUE;
                                }
                        }
                        if (count == 0) {
                                System.out.println("NA");
                        }
                }
        }
}

Measured memory_bytes: 36148
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
   int a = sc.nextInt();
   int b = sc.nextInt();
   if(a<b){
    System.out.println("a < b");
   }else if(a>b){
    System.out.println("a > b");
   }else{
    System.out.println("a == b");
   }
 }
}

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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define V vector
#define endl "\n"
#define CLEAR(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ios_tie() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(nullptr)
#define trace1(a)             cout <<#a<<":"<<a<< endl;
#define trace2(a,b)           cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<< endl;
#define trace3(a,b,c)         cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<endl;
#define trace4(a,b,c,d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll maxn = 1e5+10;
const ldb PI = acos(-1);

void lol(ll s) {cerr<<"check........................................... "<<s<<endl;}
ll power(ll x,ll y) {ll res=1; x%=mod; while(y) {if(y&1) res=(res*x)%mod; y>>=1LL; x=(x*x)%mod; }return res;}
ll inv(ll x) {return power(x,mod-2);}//(1/x)%y = x^(y-2) % y;   // pow(x,y)%m = pow(x,y%(m-1))%m
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// I can solve mirror cube in 2 mins but can't solve div2 C in 1hr.
void solve()
{
    ll x, n;
    cin>>x>>n;
    ll a[n];
    ll freq[102];
    rep0(i,102) {
        freq[i] = 1;
    }
    ll d = inf;
    ll res;
    rep0(i,n) {
        cin>>a[i];
        freq[a[i]] = 0;
    }
    rep0(i,102) {
        if(freq[i]) {
            ll tmp = abs(i-x);
            if(tmp<d) {
                res = i;
                d = tmp;
            }
        }
    }
    cout<<res<<endl;
}
int main()
{
    ios_tie();
    // freopen("input.txt", "r", stdin);
    // freopen("myOut.txt", "w", stdout);
    ll _ = 1;
    // cin>>_;
    rep1(i,_)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

using Graph = V<V<int>>;
int n, m, k;
int id = 0;
V<int> seen;

void dfs(const Graph &g, int v, int &cnt){
    seen[v] = id;
    cnt++;
    for(auto next_v : g[v]){
        if(seen[next_v] != -1) continue;
        dfs(g, next_v, cnt);
    }
}

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

    Graph g(n);
    V<int> a(m), b(m);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    V<int> c(k), d(k);
    for(int i = 0; i < k; i++){
        cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
    }

    seen.assign(n, -1);
    V<int> nums;
    for(int i = 0; i < n; i++){
        if(seen[i] == -1){
            int cnt = 0;
            dfs(g, i, cnt);
            nums.push_back(cnt);
            id++;
        }
    }

    V<int> ans(n);
    for(int i = 0; i < n; i++){
        ans[i] = nums[seen[i]] - 1 - (int)g[i].size();
    }
    for(int i = 0; i < k; i++){
        if(seen[c[i]] == seen[d[i]]){
            ans[c[i]]--;
            ans[d[i]]--;
        }
    }

    for(int i = 0; i < (int)ans.size(); i++){
        cout << ans[i];
        if(i != (int)ans.size() - 1) cout << " ";
    }
    cout << endl;

}


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

using vi = vector<int>;
using vvll = vector<vector<long long>>;
using vll = vector<long long>;
constexpr long long INF = 1e9;

void WarshallFloyd(vvll & Es){
    for (int k = 0; k != Es.size(); ++k){
        for (int i = 0; i != Es.size(); ++i){
            for (int j = 0; j != Es.size(); ++j){
                Es[i][j] = min(Es[i][j], Es[i][k] + Es[k][j]);
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, R;
    cin >> N >> M >> R;
    vi Rs(R);
    for (auto &r : Rs) cin >> r;
    for (auto &r : Rs) --r;
    vvll Es(N, vll(N, INF));
    while (M--){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        --a;
        --b;
        Es[a][b] = c;
        Es[b][a] = c;
    }
    WarshallFloyd(Es);
    vvll dp(1 << R, vll(R, INF));
    for (int r = 0; r != R; ++r){
        dp[1 << r][r] = 0;
    }
    for (int mask = 1; mask != (1 << R); ++mask){
        for (int r = 0; r != R; ++r){
            if (mask & (1 << r)){
                for (int s = 0; s != R; ++s){
                    if (mask & (1 << s)) continue;
                    int new_mask = mask | (1 << s);
                    dp[new_mask][s] = min(dp[new_mask][s], dp[mask][r] + Es[Rs[r]][Rs[s]]);
                }
            }
        }
    }
    int full_mask = (1 << R) - 1;
    cout << *min_element(dp[full_mask].begin(), dp[full_mask].end()) << endl;
    return 0;
}

Measured memory_bytes: 640