akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string S, T;
int SA[100001], TA[100001];
int Q;
bool F[3][3][3][3];

signed main() {
  srand(time(NULL));
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S >> T >> Q;
  SA[0] = S[0] == 'A';
  for (int i=1; i<S.length(); i++) {
    SA[i] = SA[i-1] + (S[i] == 'A');
  }
  TA[0] = T[0] == 'A';
  for (int i=1; i<T.length(); i++) {
    TA[i] = TA[i-1] + (T[i] == 'A');
  }

  for (int xa=0; xa<3; xa++) {
    for (int xb=0; xb<3; xb++) {
      int a = xa, b = xb;
      F[xa][xb][a][b] = true;

      rep(i, 10000) {
        a = (2+a) % 3;
        b = (2+b) % 3;
        F[xa][xb][a][b] = true;
      }
    }
  }
  rep(i, Q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--, b--, c--, d--;
    int xa = SA[b]-(a>0?SA[a-1]:0);
    int ya = TA[d]-(c>0?TA[c-1]:0);
    int xb = (b-a+1) - xa;
    int yb = (d-c+1) - ya;
    xa %= 3;
    xb %= 3;
    ya %= 3;
    yb %= 3;
    //cout<<"("<<xa<<","<<xb<<") -> (" <<ya<<","<<yb<<")\n";
    if (F[xa][xb][ya][yb]) cout << "YES\n";
    else cout << "NO\n";
  }
  return 0;
}


Measured memory_bytes: 1744
import sys
from itertools import accumulate

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    R = [0] + list(accumulate(A))
    subs = []
    for left in range(n + 1):
        for right in range(left + 1, n + 1):
            num = R[right] - R[left]
            subs.append(num)

    for i in reversed(range(41)):
        tmp = []
        for num in subs:
            if num & (1 << i):
                tmp.append(num)
        if len(tmp) >= k:
            subs = tmp

    res = subs[0]
    for num in subs:
        res &= num
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 29832
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = A;
    int sum = 0;
    while (B != 0) {
      sum += B % 10;
      B /= 10;
    }
    if (A % sum == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21712
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = BigInt(input[0][0]);

  const name: string[] = [];
  let n = N;

  while (n > 0) {
    const num = n % 26n === 0n ? 26n : n % 26n;

    name.unshift(String.fromCodePoint(96 + Number(num)));

    n = (n - num) / 26n;
  }

  return name.join("");
};

console.log(main(read()));


Measured memory_bytes: 29664
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 100005
#define mod 1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,k,i,x;
    cin>>a>>b>>k;
    x=b/a;
    x=min(x,k);
    cout<<x;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inclass in = new inclass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AMultipleOf2AndN solver = new AMultipleOf2AndN();
        solver.solve(1, in, out);
        out.close();
    }

    static class AMultipleOf2AndN {
        public void solve(int testNumber, inclass in, PrintWriter out) {
            int n = in.nextInt();
            out.print((2) * (n / gcd(2, n)));
        }

        int gcd(int a, int b) {
            if (b == 0) {
                return a;
            }
            return gcd(b, a % b);
        }

    }

    static class inclass {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private inclass.SpaceCharFilter filter;

        public inclass(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(void){
   int X;
   cin>>X;
   if(400<=X&&X<=599) cout<<8<<endl;
   if(600<=X&&X<=799) cout<<7<<endl;
   if(800<=X&&X<=999) cout<<6<<endl;
   if(1000<=X&&X<=1199) cout<<5<<endl;
   if(1200<=X&&X<=1399) cout<<4<<endl;
   if(1400<=X&&X<=1599) cout<<3<<endl;
   if(1600<=X&&X<=1799) cout<<2<<endl;
   if(1800<=X&&X<=1999) cout<<1<<endl;
   return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  uint64_t a;
  double b;
  cin >> a >> b;
  uint64_t b_int = b * 100 + 0.5;

  cout << (a * b_int) / 100 << endl;
  
  return 0;
}


Measured memory_bytes: 3724
n, m = map(int, input().split())
SG = sorted([[int(i) for i in input().split()] for i in range(m)], key = lambda x: x[1])

cnt = 1
b = SG[0][1]
for s, g in SG:
    if s >= b:
        b = g
        cnt += 1
        
print(cnt)

Measured memory_bytes: 23584
#include <stdio.h>

int
main(void)
{
    int n;
    scanf("%d", &n);
    long a[n][n];
    int i, j;
    for (i = 0; i < n; ++i)
        for (j = 0; j < n; ++j)
            scanf("%ld", &a[i][j]);

    int k;
    long sum = 0;
    for (i = 0; i < n; ++i) {
        for (j = i+1; j < n; ++j) {
            int found = 1;
            for (k = 0; k < n; ++k) {
                if (k == i || k == j)
                    continue;
                long compound = a[i][k] + a[j][k];
                if (a[i][j] == compound) {
                    found = 0;
                    continue;
                }
                if (a[i][j] > compound) {
                    printf("-1\n");
                    return 0;
                }
            }
            if (found)
                sum += a[i][j];
        }
    }
    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 896
n,m,x=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
ans=10**18
for i in range(2**n):
  flag=format(i,'b')
  flag='0'*(n-len(flag))+flag
  tmp=0
  check=[0]*(m)
  for j in range(n):
    if flag[j]=='0':
      continue
    tmp+=arr[j][0]
    for k in range(m):
      check[k]+=arr[j][k+1]
  for j in range(m):
    if check[j]<x:
      break
  else:
    ans=min(ans,tmp)
if ans==10**18:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9248
"""everything has a cost!"""

from math import *
import random, functools, collections, sys

__author__ = 'p7x'


# sys.stdin = open('in.txt', 'r')
# sys.stdout = open('out.txt', 'w')
# sys.stderr = open('err.txt', 'w')


if __name__ == '__main__':
    n = int(input())
    print(n + n**2 + n**3)


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

int main() {
    long long A,B,K;
    cin >> A >> B >> K;
    for(int i = 1; i <= K; i++) {
        int X = A;
        int Y = B;
        if(i%2 == 0){
            B/=2;
            A+=Y/2;
        }
        else {
            A/=2;
            B+=X/2;
        }
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut vec: Vec<usize> = (0..n).map(|_| read()).collect();
    vec.sort();
    let mut vec2: Vec<bool> = vec![false; 10_usize.pow(6) + 2];
    for &v in &vec {
        vec2[v] = true;
    }
    let mut ans = vec![];
    // 一番小さな数が1個だけの場合はそう。
    // 二番目に小さな数は1番目の倍数じゃなかったらそう
    // ソートしてエラトステネスの篩でFAです。ただし次が同じ数かどうかは要注意
    for i in 0..vec.len() {
        let v = vec[i];
        if vec2[v] {
            if i == vec.len() - 1 || v != vec[i + 1] {
                ans.push(vec[i]);
            }
            let mut now = v;
            let org = now;
            while now <= 10_usize.pow(6) {
                vec2[now] = false;
                now += org;
            }
        }
    }
    println!("{}", ans.len());
}


Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, std::vector<long long> A)
{
  map<int, int> counter;
  for (auto val : A)
  {
    counter[val] += 1;
  }
  LL base = 0;
  for (auto val : counter)
  {
    LL n = val.second;
    base += n * (n - 1) / 2;
  }
  for (auto val : A)
  {
    LL n = counter[val];
    LL a = n * (n - 1) / 2;
    LL b = (n - 1) * (n - 2) / 2;
    cout << base - a + b << endl;
  }
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#define MOD 10000;
using namespace std;

int yotei[100] = {};
int dp[100][6] = {};

int n,k;

int main() {
    cin >> n >> k;
    for(int i = 0; i < k; i++) {
        int a,b;
        cin >> a >> b;
        a--;
        yotei[a] = b;
    }
    // 0day
    for(int i = 0; i < 3; i++) dp[0][i] += (yotei[0]==i||yotei[0]==0)?1:0;
    // 1day...
    for(int i = 1; i < n; i++) {
        if(yotei[i]==0||(yotei[i]%3==0)) dp[i][0] = dp[i-1][1]+dp[i-1][2]+dp[i-1][4]+dp[i-1][5];
        if(yotei[i]==0||(yotei[i]%3==1)) dp[i][1] = dp[i-1][0]+dp[i-1][2]+dp[i-1][3]+dp[i-1][5];
        if(yotei[i]==0||(yotei[i]%3==2)) dp[i][2] = dp[i-1][0]+dp[i-1][1]+dp[i-1][3]+dp[i-1][4];
        if(yotei[i]==0||(yotei[i]%3==0)) dp[i][3] = dp[i-1][0];
        if(yotei[i]==0||(yotei[i]%3==1)) dp[i][4] = dp[i-1][1];
        if(yotei[i]==0||(yotei[i]%3==2)) dp[i][5] = dp[i-1][2];
        for(int j = 0; j < 6; j++) dp[i][j] %= MOD;
    }
    int ans = 0;
    for(int i = 0; i < 6; i++) {
        ans = (ans+dp[n-1][i])%MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  double a, b, c;
  cin >> a >> b >> c;

  double s = a * b * sin(acos(-1.0) / 180.0 * c) / 2.0;
  double cc = sqrt(a * a + b * b - 2 * a * b * cos(acos(-1.0) / 180.0 * c));
  double h = 2.0 * s / a;
  cout << fixed << setprecision(10) << s << ' ' << a + b + cc << ' ' << h << endl;

  return 0;
}



Measured memory_bytes: 3668
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    x: usize,
    y: usize,
    z: usize,
    k: usize,
    aa: [i64; x],
    bb: [i64; y],
    cc: [i64; z],
  }
  let mut ab = Vec::with_capacity(x * y);
  for &a in &aa {
    for &b in &bb {
      ab.push(a + b);
    }
  }
  ab.sort();
  let mut abc = Vec::with_capacity(k * z);
  for &p in ab.iter().rev().take(k) {
    for &c in &cc {
      abc.push(p + c);
    }
  }
  abc.sort();
  for &q in abc.iter().rev().take(k) {
    puts!("{}\n", q);
  }
}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int K,A,B;

void input() {
	cin>>K>>A>>B;
}

void solve() {
	cout<<(B/K-(A-1)/K>0?"OK":"NG")<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

string str;
int ans;

bool A()
{
	stringstream ss(str);
	
	vector<int> num;
	vector<char> sign;
	
	int t = 0;
	while (!ss.eof()){
		if (!t){
			int s;
			ss >> s;
			
			if (sign.size() && sign.back() == '*'){
				num[num.size() - 1] *= s;
				sign.pop_back();
			}
			else num.push_back(s);
		}
		else {
			char s;
			ss >> s;
			sign.push_back(s);
		}
		t ^= 1;
	}
	
	int res = 0;
	for (int i = 0; i < num.size(); i++){
		res += num[i];
	}
	
	return res == ans;
}

bool B()
{
	stringstream ss(str);
	
	vector<int> num;
	vector<char> sign;
	
	int t = 0;
	while (!ss.eof()){
		if (!t){
			int s;
			ss >> s;
			
			if (sign.size()){
				if (sign.back() == '*') num[num.size() - 1] *= s;
				if (sign.back() == '+') num[num.size() - 1] += s;
				sign.pop_back();
			}
			else num.push_back(s);
		}
		else {
			char s;
			ss >> s;
			sign.push_back(s);
		}
		t ^= 1;
	}
	
	return num.back() == ans;
}

int main()
{
	cin >> str >> ans;
	const char* s = "ILMU";
	int res = (A() << 1) | B();
	printf("%c\n", s[res]);
}

Measured memory_bytes: 1236
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String a = sc.next();
		// スペース区切りの整数の入力
		// 出力
      if(a.contains("a") &&
        a.contains("b") &&
        a.contains("c") ){
		System.out.println("Yes");
    }else{
      System.out.println("No");
    }
	}
}


Measured memory_bytes: 22868
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N = intinput()
datas = lineinputs(func=input)

d = dict()
for data in datas:
    if data in d.keys():
        d[data] += 1
    else:
        d[data] = 0

m = max(d.values())
dd = []
for k, v in d.items():
    if v != m:
        continue
    dd.append(k)

dd.sort()
# 出力
for _ in dd:
    print(_)





Measured memory_bytes: 37540
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,count_individual=0,count=0;
  cin >> A;
  int target[A];
  for(int i=0; i<A; i++){
    cin >> B;
    count_individual=0;
    while(B%2==0){
      B/=2;
      count_individual+=1;
    }
    if(i==0){
      count=count_individual;
    }
    if(count>count_individual){
      count=count_individual;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

max_h = 0
for h in H:
    if h >= max_h:
        max_h = h
    else:
        if max_h - 1 == h:
            continue
        else:
            print("No")
            break
else:
    print("Yes")  

Measured memory_bytes: 14396
#include<cstdio>
#define N 510
using namespace std;

int n,m,h,w;
int a[N][N];

int main(){
  scanf("%d%d%d%d",&n,&m,&h,&w);
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      a[i][j]=4000;
    }
  }
  for(int i=h;i<=n;i+=h){
    for(int j=w;j<=m;j+=w){
      a[i][j]=-h*w*4000+3999;
    }
  }
  long long sum=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      sum+=a[i][j];
    }
  }
  if(sum<=0){
    printf("No\n");
  }else{
    printf("Yes\n");
    for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
        printf("%d ",a[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];

  int negative = 0;
  for (int i = 0; i < N; i++)
    if (A[i] < 0)
      negative++, A[i] *= -1;

  sort(A.begin(), A.end());

  long long ans = 0;
  if (negative % 2 == 0)
    for (int i = 0; i < N; i++)
      ans += A[i];
  else
    for (int i = 0; i < N; i++)
      if (i == 0)
        ans += A[i] * -1;
      else
        ans += A[i];

  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    int cnt = 0;
    rep(i, N) {
        int A;
        cin >> A;
        if (A % 2) cnt++;
    }

    cout << (cnt % 2 ? "NO" : "YES") << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := walk(n)
	fmt.Println(answer)
}

func walk(n int) int {
	minLength := 1000000000000
	for i := 1; i <= n; i++ {
		if i*i > n {
			break
		} else if n%i != 0 {
			continue
		} else {
			if length := i + n/i - 2; length < minLength {
				minLength = length
			}
		}
	}
	return minLength
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++){
    cin >> B[i];
  }
  vector<int> C(N);
  for (int i = 0; i < N; i++){
    cin >> C[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  long long ans = 0;
  for (int i = 0; i < N; i++){
    long long ans1 = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    long long ans2 = C.end() - upper_bound(C.begin(), C.end(), B[i]);
    ans += ans1 * ans2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		String s = sc.next();

		if(a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}


	}

}


Measured memory_bytes: 20948
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	if(n % k == 0) cout << 0 << endl;
	else cout << 1 << endl;
}


Measured memory_bytes: 256
def main():
    import sys
    N = int(input())
    C = [0] * N
    for n in range(N):
        a, b = [int(x) for x in input().strip().split()]
        C[n] = (a+b, a, b)
    C.sort(reverse=True)
    ans = 0
    for n in range(N):
        if n % 2:
            ans -= C[n][2]
        else:
            ans += C[n][1]

    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 20944
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];

	int sum = 0;
	rep(i,n) {
		sum += a[i];
	}

	int max = 0;
	for(int i=1;i*i<=sum;i++) {
		if(sum%i==0) {
			{
				std::vector<int> b(n);
				rep(j,n) b[j] = a[j]%i;
				std::sort(all(b));
				std::vector<int> d(n);
				std::vector<int> p(n);
				{
					int accum = 0;
					rep(j,n) {
						accum += b[j];
						d[j] = accum;
					}
				}
				{
					int accum = 0;
					rep(j,n) {
						accum += i-b[j];
						p[j] = accum;
					}
				}
				{
					rep(j,n) {
						if(d[j] == p[n-1] - p[j]) {
							if(d[j]<=k) max = std::max(max,i);
						}
					}
				}
			}
			int tmp = sum/i;
			{
				int i = tmp;
				std::vector<int> b(n);
				rep(j,n) b[j] = a[j]%i;
				std::sort(all(b));
				std::vector<int> d(n);
				std::vector<int> p(n);
				{
					int accum = 0;
					rep(j,n) {
						accum += b[j];
						d[j] = accum;
					}
				}
				{
					int accum = 0;
					rep(j,n) {
						accum += i-b[j];
						p[j] = accum;
					}
				}
				{
					rep(j,n) {
						if(d[j] == p[n-1] - p[j]) {
							if(d[j]<=k) max = std::max(max,i);
						}
					}
				}
			}
		}
	}
	print(max);

	return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

int main() {

    int a, b;
    cin >> a >> b;

    cout << max(a + b, max(a - b, a * b)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>

using namespace std;

int main()
{
    long L, R;

    cin >> L >> R;

    long L_1 = L % 2019;
    long R_1 = R % 2019;

    long MIN = 2019;

    if (R_1 <= L_1 || R - 2019 > L)
    {
        cout << 0 << endl;
    }
    else
    {
        for (long i = L_1; i < R_1; i++)
        {
            for (long j = i + 1; j <= R_1; j++)
            {
                MIN = min(MIN, (i * j) % 2019);
            }
        }
        cout << MIN << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}
}

Measured memory_bytes: 3592
n,q=[int(i) for i in input().split(" ")]

Q=[[] for i in range(n)]

for _ in range(q):
    query=[int(j) for j in input().split(" ")]
    if query[0]==0:
        Q[query[1]].append(query[2])
    elif query[0]==1:
        if len(Q[query[1]])>0:
            print(Q[query[1]][0])
    else:
        if len(Q[query[1]])>0:
            Q[query[1]].pop(0)



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

int main(){
	string s;
	int n;
	cin >> n >> s;
	int mid, j, c=0;
	for(int i=0; i<s.size(); i++) s[i] += n;
	for(int i=0; i<s.size(); i++) if(s[i]>'Z') s[i] = 'A'+s[i]-'Z'-1;
	cout << s;
	return 0;
}

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

int main(int argc, char charv[])
{
  string S;
  cin >> S;
  
  if (S[2]==S[3] && S[4]==S[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


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

int main(){
  int k;cin >> k;
  string s;cin >> s;
  int len = s.length();
  if(len <= k)cout << s << endl;
  else cout << s.substr(0,k) + "..." << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int ans=0,n,a[105];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=j+1;k<=n;k++){
				if(a[i]==a[j]||a[j]==a[k]||a[i]==a[k])continue;
				int t[5]={0,a[i],a[j],a[k]};
				sort(t+1,t+4);
				if(t[1]+t[2]>t[3])ans++;
			}
		}
	}
	cout<<ans;
} 

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int num = 0;
  int cnt = 0;
  if (n % 2 == 0)
    cout << "-1" << endl;
  else
  {
    int ans = -1;
    for (int i = 1; i <= 100000000; ++i)
    {
      num *= 10;
      num += 7;
      num %= n;
      if (num % n == 0)
      {
        ans = i;
        break;
      }
    }
    cout << ans;
  }

}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

int main(){
	lint a,b;cin>>a>>b;--a;
	lint ans=((a+1)/2%2)^((b+1)/2%2);
	for(lint bi=1;bi<60;++bi){
		ans+=lint(((a%(1LL<<(bi+1))>=(1LL<<bi)&&!(a&1LL))^(b%(1LL<<(bi+1))>=(1LL<<bi)&&!(b&1LL))))<<bi;
	}
	cout<<ans<<endl;
}

//int main(){
//	lint n,m;cin>>n>>m;
//	vector<pair<int,int> > a(n);rep(i,n)cin>>a[i].first>>a[i].second;sort(all(a));
//	lint ans=0,cur=0,pos=0;
//	while(m>0){
//		if(a[pos].second<m){
//			ans+=a[pos].first*a[pos].second;
//			m-=a[pos].second;++pos;
//		} else{
//			cout<<ans+a[pos].first*m<<endl;
//			return 0;
//		}
//	}cout<<ans<<endl;
//}

//sub-EOF


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	if len(a) > len(b) {
		fmt.Println("GREATER")
		return
	}
	if len(a) < len(b) {
		fmt.Println("LESS")
		return
	}
	if a == b {
		fmt.Println("EQUAL")
		return
	}
	if a > b {
		fmt.Println("GREATER")
		return
	}
	fmt.Println("LESS")
}


Measured memory_bytes: 512
#include<iostream>
#include<string>

using namespace std;

int main(){
	int n;
	while(cin>>n &&n){
		int ans=0;
		int l=0,r=0;
		for(int i=0;i<n;i++){
			string str;
			cin>>str;
			if(str[0]=='l'){
				if(l==1)l=0;
				else if(r==1){
					ans++;
					r=l=0;
				}
				else l=1;
			}
			else {
				if(r==1)r=0;
				else if(l==1){
					ans++;
					r=l=0;
				}
				else r=1;
			}
		}
		cout<<ans<<endl;
	}
}

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

int sum_e_ord (int i) {
    int sum;
    int temp;
    
    sum = 0;
    temp = i;
    for (int j = 0; j < 10 ; j++){
        sum += temp%10;
        temp = temp/10;
    } 
    return sum;
}

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

    fx = sum_e_ord(N);

    if (N%fx == 0){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

}

Measured memory_bytes: 256
// use proconio::input;
use std::io;
use std::f64::consts::PI;

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

fn main() {
    let vec = read_vec::<f64>();
    let r = vec[0];

    println!("{:.6} {:.6}", r * r * PI, 2.0 * r * PI);
}



Measured memory_bytes: 5060
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
using namespace std;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char i){
  if(i=='a'){
    return 1;
  }
  if(i=='b'){
    return 2;
  }
  if(i=='c'){
    return 3;
  }
  if(i=='d'){
    return 4;
  }
  if(i=='e'){
    return 5;
  }
  if(i=='f'){
    return 6;
  }
  if(i=='g'){
    return 7;
  }
  if(i=='h'){
    return 8;
  }
  if(i=='i'){
    return 9;
  }
  if(i=='j'){
    return 10;
  }
  if(i=='k'){
    return 11;
  }
  if(i=='l'){
    return 12;
  }
  if(i=='m'){
    return 13;
  }
  if(i=='n'){
    return 14;
  }
  if(i=='o'){
    return 15;
  }
  if(i=='p'){
    return 16;
  }
  if(i=='q'){
    return 17;
  }
  if(i=='r'){
    return 18;
  }
  if(i=='s'){
    return 19;
  }
  if(i=='t'){
    return 20;
  }
  if(i=='u'){
    return 21;
  }
  if(i=='v'){
    return 22;
  }
  if(i=='w'){
    return 23;
  }
  if(i=='x'){
    return 24;
  }
  if(i=='y'){
    return 25;
  }
  if(i=='z'){
    return 26;
  }
  return 100;
  
}




int main() {
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<3;i++){
    if(s.at(i)=='1'){
      sum++;
    }
  }
  cout<<sum<<endl;

  

  


  

  




  
  
}

  

  





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


int main(){
  ll N; cin>>N;
  map<ll,ll> mp_count;
  ll a;
  REP(i,N){
    cin >> a;
    mp_count[a]++;
  }
  ll r = 1;
  ll INF = pow(10,9)+7;
  if(N%2==1){
    if(mp_count[0]!=1){ r = 0;}
    else{
      for(int i=1;i<=N-1;i++){
        if(i%2==0 && mp_count[i]!=2){r = 0;break;} 
        if(i%2==1 && mp_count[i]>0){ r = 0; break;}
      }
      if(r>0){
        REP(i,N/2){ r *= 2; r %= INF;}
      }
    }
  }else{
    if(mp_count[0]>0){r = 0;}
    else{
      for(int i=1;i<=N-1;i++){
        if(i%2==1 && mp_count[i]!=2){r = 0;break;}
        if(i%2==0 && mp_count[i]>0){ r = 0;break;}
      }
      if(r>0){
        REP(i,N/2){ r *= 2; r %= INF;}
      }
    }
  }
  cout << r <<"\n";
}

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

namespace b
{
    class Program
    {
        public static int Main()
        {
            new Program().calc();
            return 0;
        }

        Scanner sc;

        public void calc()
        {
            sc = new Scanner();
            int n = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            string s = sc.next();
            int kokunai = 0;
            int kaigai = 0;
            for (int i = 0; i < n; i++)
            {
                if(s[i]=='a')
                {
                    if(kokunai < a + b)
                    {
                        Console.WriteLine("Yes");
                        kokunai++;
                    }
                    else Console.WriteLine("No");
                }
                else if(s[i] == 'b')
                {
                    if (kokunai < a + b && kaigai < b)
                    {
                        Console.WriteLine("Yes");
                        kokunai++;
                        kaigai++;
                    }
                    else Console.WriteLine("No");
                }
                else Console.WriteLine("No");

            }

        }

    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            while (i >= s.Length)
            {
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
            }
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

    }
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
const lli mod = 1000000007;


void precal() {

	return;
}

bool solve() {
	lli a, p;
	if ( cin >> a >> p );
	else return false;
	
	cout << (a*3+p)/2 << '\n';
	
	return true;
}

int main() {
	precal();
	int t = INT_MAX;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		if ( !solve() ) break;
	}
	return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < n; i++)
#define REP(n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using INT64 = long long;
using UINT64 = unsigned long long;
constexpr int MOD = 1000000007;

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

    int l = s.size();

    vector<INT64> dp1(l,0);
    vector<INT64> dp2(l,0);

    REP(l){
        if (i == 0) {
            dp1[0] = 1;
            dp2[0] = 2;
        } else {
            if (s[i] == '1') {
                dp1[i] = (dp1[i-1] * 3 + dp2[i-1]) % MOD;
                dp2[i] = dp2[i-1] * 2 % MOD;
            } else {
                dp1[i] = (dp1[i-1] * 3) % MOD;
                dp2[i] = dp2[i-1];
            }
        }
    }

    cout << (dp1[l-1] + dp2[l-1]) % MOD << endl;


    return 0;
}


Measured memory_bytes: 2000
#include <iostream>

int main()
{
    const int REF_NUM = 753;
    int ans = 753;
    std::string s;
    std::cin >> s;

    for (int i = 0; i < s.length() - 2; i++)
    {
        int target_num = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
        ans = std::min(ans, std::abs(target_num - REF_NUM));
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int ans = 0;
char c[100][100];
void judge(int i, int j) {
	char tmp = c[i][j];
	c[i][j] = 'X';
	if (i > 0&&c[i-1][j]==tmp)judge(i - 1, j);
	if (j > 0&&c[i][j-1]==tmp)judge(i, j - 1);
	if (i < 99&&c[i+1][j]==tmp)judge(i + 1, j);
	if (j < 99&&c[i][j+1]==tmp)judge(i, j + 1);
}
int main() {
	int h, w;
	do {
		ans = 0;
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++)
				c[i][j] = 'X';
		}
		cin >> h >> w;
		if (h == 0)break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++)
				cin >> c[i][j];
		}
		for (int i = 0; i < 100; i++) {
			for (int j = 0; j < 100; j++)
				if (c[i][j] != 'X') { judge(i, j); ans++; }
		}
		cout << ans << endl;
} while (1);
return 0;
	}

Measured memory_bytes: 1936
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    string x;
    cin >> x;
    if (x == "AAA" || x == "BBB") {
        cout << "No";
    } else {
        cout << "Yes";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    bool a[52];
    int n,temp;
    char c;
    for(int i=0;i<52;i++)
        a[i]=true;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        c='\0';
        while(c!='S'&&c!='H'&&c!='D'&&c!='C')scanf("%c",&c);
        scanf("%d",&temp);
        temp--;
        if(c=='D'){
            temp+=39;
        }
        if(c=='C'){
            temp+=26;
        }
        if(c=='H'){
            temp+=13;
        }
        a[temp]=false;
    }
    for(int i=0;i<52;i++){
        if(a[i]){
            c='S';
            if(i>=13)c='H';
            if(i>=26)c='C';
            if(i>=39)c='D';
            printf("%c %d\n",c,i%13+1);
        }
    }
}

Measured memory_bytes: 2664
#include <stdio.h>
#include <string.h>
#include <math.h>


/*
 * *A int type array
 * left head index of array *A
 * right tail index of array *A
 */
int partition(int *A, int left, int right){
    
    int x = A[right];
    int i = left - 1;
    int j,tmp;
    
    for (j=left; j<right; j++) {
        if (A[j] <= x) {
            i = i+1;
            /* A[i] ??¨ A[j] ????????? */
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    
    /* A[i+1] ??¨ A[r] ????????? */
    tmp = A[i+1];
    A[i+1] = A[right];
    A[right] = tmp;
    
    return i+1;   
}

int main( ){
    
    int i, n,axis;
    
    scanf("%d", &n);
    int A[n];
    
    
    for (i=0; i<n; i++) {
        scanf("%d", &A[i]);
    }
    
    axis = partition(A, 0, n-1);
    
    for (i=0; i<n; i++) {
        if (i == axis) {
            printf("[%d]", A[i]);
        }
        else{
            printf("%d", A[i]);
        }
        if (i != n-1) {
            printf(" ");
        }
    }
    printf("\n");
    
    
    return 0;
}

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

int gcd(int a, int b) {
  int r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

int main() {
  int k;
  int64_t ans = 0;
  cin >> k;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        ans += gcd(a,(gcd(b, c)));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder(sc.next());
		sb.reverse();
		if(sc.next().equals(sb.toString())) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844