akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
using namespace std;
int main() {
    string s; cin >> s;
    string d[3] = {"dream", "eraser", "erase"};
    //eraseより先にeraserを見るのも大事
    //eraseraser
    for (int i = 0; i < s.size(); ) {
        for (int j = 0; j < 3; ++j) {
            if (s.substr(i, d[j].size()) == d[j]) {
                i += d[j].size();
                if (j == 0) { //dreamerが危険
                    if (i == s.size()) {
                        break;
                    }
                    //継続条件
                    //ere : dreamererase, dreamserase
                    //erd : dreamerdream, dreamerdreamer
                    //(s.size() - i == 2 && ... : dreamer and finish
                    if (s.substr(i, 3) == "ere" || s.substr(i, 3) == "erd"
                        || (s.size() - i == 2 && s.substr(i, 2) == "er")) {
                        i += 2;
                    }
                }
                break;
            }
            if (j == 2) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

ll siz;
ll ofst;
vll seg;
ll sget(ll i) {
  ll ret = 0;
  i += ofst;
  while (true) {
    ret += seg[i];
    i /= 2;
    if (i == 0) break;
  }
  return ret;
}

void sadd(ll l, ll r, ll x) {
  l += ofst, r += ofst + 1;
  while (l < r) {
    if (l % 2 == 1) {
      seg[l] += x;
      l++;
    }
    l /= 2;
    if (r % 2 == 1) {
      seg[r - 1] += x;
      r--;
    }
    r /= 2;
  }
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, q;
  cin >> n >> q;

  siz = 1;
  while (siz < 2 * n) siz <<= 1;
  ofst = siz >> 1;
  seg.resize(siz, 0);

  rep(i, q) {
    ll c;
    cin >> c;
    if (c == 0) {
      ll s, t, x;
      cin >> s >> t >> x;
      sadd(s, t, x);
    } else {
      ll idx;
      cin >> idx;
      ll ans = sget(idx);
      cout << ans << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 4944
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        h: usize,
        w: usize,
        d: usize,
        a: [[usize; w]; h],
        q: usize,
        lr: [(usize, usize); q],
    }
    let mut sum = vec![0; w * h + 1];
    let mut pos = vec![(0, 0); w * h];
    for i in 0..h {
        for j in 0..w {
            pos[a[i][j] - 1] = (i, j);
        }
    }
    for i in d + 1..h * w + 1 {
        let now = pos[i - 1];
        let pre = pos[i - d - 1];
        let cost = (now.0 as i64 - pre.0 as i64).abs() + (now.1 as i64 - pre.1 as i64).abs();
        sum[i] = sum[i - d] + cost as usize;
    }
    for &(l, r) in &lr {
        println!("{}", sum[r] - sum[l]);
    }
}


Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int kawa=0,company[2][10001]={};
    char str[1000];
    while(fgets(str,1000,stdin)){
        if(strcmp(str,"\n")==0)kawa++;
        else company[kawa][atoi(strtok(str,","))]++;
    }
    for(int i=0;i<10001;i++)if(company[0][i]!=0&&company[1][i]!=0)cout<<i<<" "<<company[0][i]+company[1][i]<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

template <class Key, class T>
using gp_hash_table = __gnu_pbds::gp_hash_table<Key, T>;

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 K;
  cin >> K;
  int i = 1;
  int m = 7;
  gp_hash_table<int, bool> seen;
  for (;; ++i) {
    m %= K;
    if (m == 0) {
      cout << i << endl;
      return 0;
    }
    if (seen[m]) {
      cout << -1 << endl;
      return 0;
    }
    seen[m] = true;
    m = m * 10 + 7;
  }
}


Measured memory_bytes: 40260
import sys


if __name__ == '__main__':
    x_limit = 600

    # ??????????????\?????¨???????????????
    for line in sys.stdin:
        d = int(line.strip())  # ????????¢??????????±????

        areas = []  # ????????????????????¢???
        for i in range(0, x_limit, d):  # x=600?????§??????d????????????????????????
            areas.append(d * i**2)  # ???????????¢???????¨????
        print(sum(areas))  # ??¢??????????¨??????¨???

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

#define swap(type, x, y)    { type t = x; x = y; y = t; }

int main(void){
    int n, k;
    vector <int> l;
    int i, j;
    int x;
    int a, b, c;
    int ans = 0;
    
    cin >> n >> k;
    for(i = 0; i < n; i++){
        cin >> x;
        l.push_back(x);
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n - 1; j++){
            if(l[j] < l[j + 1])     swap(int, l[j], l[j + 1]);
        }
    }
    
    for(i = 0; i < k; i++){
        ans += l[i];
    }
    
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

const int mod = 1e9+7;

int n;
int k;
long long ans = 1;
vector < int > adj[N];

void dfs(int u , int p){
    int st;
    if(p == 0){
        st = k - 1;
    } else {
        st = k - 2;
    }
    if(p != 0 && adj[u].size() - 1 > k)
        ans = 0;
    //cout << u << endl;
    //system("PAUSE");
    for(auto v : adj[u]){
        if(v == p)
            continue;
        ans *= st;
        st--;
        ans %= mod;
        dfs(v , u);
    }
}


int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i < n; i++){
        int u , v;
        scanf("%d%d" , &u , &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    ans = k;
    dfs(1 , 0);
    printf("%d\n" , (int)ans);
}





Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<long long> a(n), b(n);

	long long mini = 1e9 + 1;
	rep(i,n){
		cin >> a[i] >> b[i];
		if(a[i] > b[i]) mini = min(mini, b[i]);
	}

	if(a == b) cout << 0 << endl;
	else cout << accumulate(all(a), 0LL) - mini << endl;
}


Measured memory_bytes: 512
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def digit_sum(num:int, base:int) -> int:

    if num < base:
        return num
    else:
        return digit_sum(int(num/base), base) + (num % base)
    

n = ni()

if n % digit_sum(n,10) == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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);
    string S; cin >> S;
    vector<int> A(3);
    rep(i,3) {
        A[S[i]-'a']++;
    }
    cout << ((A[0]*A[1]*A[2]) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
  s.append(''.join(sorted(list(input().strip()))))
ans = 0
tmp = 0
ss = sorted(s)
prev = ''
for iss in ss:
  if prev != iss:
    prev = iss
    ans += int((tmp*(tmp+1))/2)
    tmp = 0
  elif prev == iss:
    # print("prev :{}, iss :{}".format(prev, iss))
    tmp += 1
if tmp != 0:
  ans += int((tmp*(tmp+1))/2)
print(ans)


Measured memory_bytes: 11380
#define _GLIBCXX_DEBUG // 未完
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) { if (b == 0) {return a;} else {return GCD(b, a % b);} }
// a と b の最小公倍数を返す関数
long long LCM(long long a, long long b) { return a/GCD(a,b)*b; }

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; }

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll all = B - A + 1LL;

  ll AC = (A - 1LL) / C;
  ll BC = B / C;
  ll AD = (A - 1LL) / D;
  ll BD = B / D;
  ll least = LCM(C, D);
  ll ACD = (A - 1LL) / least;
  ll BCD = B / least;

  ll res = all - (BC - AC) - (BD - AD) + (BCD - ACD);

  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}












/*

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
}





*/





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<vector<int>,int>a;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		vector<int>t(26,0);
		for(int j=0;j<s.size();j++)
			t[s[j]-'a']++;
		a[t]++;
	}
	long long ans=0;
	for(auto i:a)
		ans+=(long long)(i.second)*(i.second-1)/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 19072
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int N; string S;
    cin >> N >> S;

    int cnt = 0;
    for (int i=0; i<S.size()-1; ++i)
    {
        if(S.substr(i,3)=="ABC") cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

typedef long long ll;

using namespace std;

int main() {
    ll n, w, dw, dv;
    scanf("%lld%lld", &n, &w);
    vector<ll> dp(w + 1, 0);
    for (ll i = 0; i < n; ++i) {
        scanf("%lld%lld", &dw, &dv);
        for (ll j = w; j >= dw; --j) dp.at(j) = max(dp.at(j), dp.at(j - dw) + dv);
    }
    printf("%lld\n", dp.back());
    return 0;
}


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

using vvi = std::vector<std::vector<int>>;

std::vector<std::vector<int>> res(3, std::vector<int>(3, 0));
std::vector<std::vector<int>> card(3, std::vector<int>(3, 0));
int n, p;

void f(vvi& c, vvi& r, int p) {
    for (int i = 0; i < 3; i++) {
        for (int x = 0; x < 3; x++) {
            if (c[i][x] == p) {
                r[i][x] = 1;
            }
        }
    }
}

void judge(vvi& r) {
    for (int i = 0; i < 3; i++) {
        int sum = 0;
        for (int x = 0; x < 3; x++) {
            sum += r[i][x];
        }
        if (sum == 3) {
            std::cout << "Yes" << std::endl;
            return;
        }
    }
    for (int i = 0; i < 3; i++) {
        int sum = 0;
        for (int x = 0; x < 3; x++) {
            sum += r[x][i]; 
        }
        if (sum == 3) {
            std::cout << "Yes" << std::endl;
            return;
        }
    }
    int sum = 0;
    for (int i = 0, x = 0; i <= 2 && x <= 2; i++, x++) {
        sum += r[i][x];
    }
    if (sum == 3) {
        std::cout << "Yes" << std::endl;
        return;
    }
    sum = 0;
    if (r[2][0] && r[1][1] && r[0][2]) {
        std::cout << "Yes" << std::endl;
        return;
    }
    std::cout << "No" << std::endl;
}

int main() {
    for (int i = 0; i < 3; i++) {
        for (int x = 0; x < 3; x++) {
            std::cin >> card[i][x];
        }
    }
    std::cin >> n;
    for (int c = 0; c < n; c++) {
        std::cin >> p;
        f(card, res, p);
    }
    judge(res);
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

struct abcd{
  int a, b, c, d;
};

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

  LL N, M, Q;
  cin >> N >> M >> Q;

  vector<abcd> abcd;
  
  REP(i,Q){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    abcd.push_back({a, b, c, d});
  }

  bool fl = true;

  LL mx = 0;

  vector<int> suuretu(N, 1);
  while(fl){
    LL sum = 0;
    REP(i, Q)
    {
      if(suuretu[abcd[i].b-1]-suuretu[abcd[i].a-1]==abcd[i].c){
        sum += abcd[i].d;
      }
    }
    
    if(sum>mx){
      mx = sum;
    }

    // next
    LL idx = N - 1;
    while(true){
      if(suuretu[idx]<M){
        suuretu[idx]++;
        FOR(i, idx + 1,N){
          suuretu[i] = suuretu[idx];
        }
        break;
      }
      else
      {
        idx--;
        if(idx<0){
          fl = false;
          break;
        }
      }
    }
  }

  cout << mx << endl;
}


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

ll gcd( ll a, ll b )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == a ) || ( 0 == b ) )
		return 0;
	
	// ユークリッドの方法
	while( a != b )
	{
		if ( a > b ) a = a - b;
		else         b = b - a;
	}
	return a;
}//gcd
ll lcm( ll a, ll b )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == a ) || ( 0 == b ) )
		return 0;
	
	return ((a / gcd(a, b)) * b); // lcm = m * n / gcd(m,n)
}//lcm
int main(){
  ll a,b,c,ans;
  cin >> a >> b;
  
  cout << lcm(a,b) << endl;
  return 0;
}


Measured memory_bytes: 256
n, x, y = map(int,input().split())
x -= 1
y -= 1

count = [0]*(n-1)
for i in range(n):
    for j in range(i+1,n):
        kyori = min(j-i, abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(x-j))
        count[kyori-1] += 1

for i in count:
    print(i)

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

using namespace std;

long long dp[100010];

int main() {
	int N,W;
	cin >> N >> W;
	
	int s[N],v[N];
	for (int i = 0; i < N; ++i) {
		cin >> s[i] >> v[i];
	}
	
	for (int i = 0; i < N; ++i) {
		for (int x = W; x >= s[i]; --x) {
			dp[x] = max(dp[x], dp[x-s[i]]+v[i]);
		}
	}
	
	long long ans = 0;
	for (int i = 0; i <= W; ++i) {
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import bisect

A,B,Q = map(int,input().split())
INF = 10**12
S = [-INF]+[int(input()) for i in range(A)]+[INF]
T = [-INF]+[int(input()) for i in range(B)]+[INF]
for i in range(Q) :
    x = int(input())
    
    right_s = S[bisect.bisect_right(S,x)]
    right_t = T[bisect.bisect_right(T,x)]
    left_s = S[bisect.bisect_right(S,x) - 1]
    left_t = T[bisect.bisect_right(T,x) - 1]
    
    dist = []
    
    for i in [left_s,right_s] :
        for j in [left_t,right_t] :
            d = min(abs(x-i), abs(x-j)) + abs(i-j)
            dist.append(d)
    ans = min(dist)
    
    print(ans)
    

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

int main(){
  string S;
  cin >> S;
  
  map<char, char>m;
  m['A'] = 'T';
  m['T'] = 'A';
  m['C'] = 'G';
  m['G'] = 'C';
  
  char ans = m[S[0]];
  cout << ans << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n;
   cin>>n;
   int tmp=n;
   int f=0;
   for(int i=0;i<1000000;i++){
      f+=tmp%10;
      tmp=tmp/10;
      if(tmp==0) break;
   }
   n%f==0? cout<<"Yes":cout<<"No";

   



   
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e4+10;
char s[N];
int n,x,y,qx[N],qy[N],lx,ly;
bool ok[2][N],*X=ok[0],*Y=ok[1];
int main()
{
	scanf("%s%d%d",s+1,&x,&y);
	n=strlen(s+1);
	s[n+1]='T';
	int i=1;
	for (;s[i]=='F';i++,x--);
	x=abs(x);y=abs(y);
	for (int len=0,sig=0;i<=n+1;i++)
	if (s[i]=='T'){
		sig?qy[++ly]=len:qx[++lx]=len;
		sig^=1;
		len=0;
	}
	else len++;
	X[0]=1;
	for (int i=1;i<=lx;i++,swap(X,Y))
	for (int j=0;j<=n;j++){
		Y[j]=0;
		if (j>=qx[i]) Y[j]|=X[j-qx[i]];
		if (j+qx[i]<=n) Y[j]|=X[j+qx[i]];
	}
	if (!X[x]) puts("No"),exit(0);
	memset(ok,0,sizeof ok);
	X[0]=1;
	for (int i=1;i<=ly;i++,swap(X,Y))
	for (int j=0;j<=n;j++){
		Y[j]=0;
		if (j>=qy[i]) Y[j]|=X[j-qy[i]];
		if (j+qy[i]<=n) Y[j]|=X[j+qy[i]];
	}
	if (!X[y]) puts("No"),exit(0);
	puts("Yes");
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    string s;
    cin >> s;

    int n = s.size();
    int ans = 0;
    rep(i, 0, n / 2) {
        if (s[i] != s[n - 1 - i]) { ++ans; }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)



int main(){
    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    int x[n],y[m];
    int xmax=-200;
    int ymin=200;
    for(int i=0;i<n;i++){
        cin>>x[i];
        xmax=max(xmax,x[i]);
    }
    for(int i=0;i<m;i++){
        cin>>y[i];
        ymin=min(ymin,y[i]);
    }

    bool ans=false;

    for(int i=X+1;i<=Y;i++){
        if(xmax<i && ymin>=i){
            ans=true;
        }
    }

    if(ans) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(s: "List[str]"):
    ret = (s[0][0] + s[1][0] + s[2][0]).upper()
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = [ next(tokens) for _ in range(3) ]  # type: "List[str]"
    solve(s)

if __name__ == '__main__':
    main()


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);
const long long MOD = 1000000007;

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    ll a;
    double b;
    ll p[200010];
    string s;
  
    cin >> a >> b;
    ll bx = b*100.0 + 0.1;
    ll ans = a*bx/100;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    bool lst[1001];
    for(int i=0;i<1001;i++)lst[i]=false;
    lst[1]=true;
    for(int i=2;i<=1000;i++){
        for(int j=2;;j++){
            int w=pow(i,j);
            if(w<=1000)lst[w]=true;
            else break;
        }
    }
    int x;
    cin>>x;
    int ans=0;
    for(int i=1;i<=x;i++){
        if(lst[i])ans=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
A, B, C = map(int, input().split())
# 出力
if A==7 and B==5 and C==5:
	print("YES")
elif A==5 and B==7 and C==5:
	print("YES")
elif A==5 and B==5 and C==7:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n;
  cin >> n;
  ll sum=1;
  bool flag=false;
  rep(i,n) {
    ll a;
    cin >> a;
    if(a==0) {
      cout << 0 << endl;
      return 0;
    }
    if(a>1000000000000000000/sum) {
      flag=true;
    }
    if(!flag) sum*=a;
  }
  if(flag) cout << -1 << endl;
  else cout << sum << endl;




  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;


int main(){
int K,S;
cin >> K >> S;

int x=0,y=0,z=0;

int ans = 0;
for (int i = 0; i <= K; i++)
{
    /* code */
    for (int j = 0; j <= K; j++)
    {
        /* code */
        z = S - i - j;
        if(0 <= z && z <= K){
                ans++;
        }
    }
        
}
cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#define M 1001

int main(void)
{
	int n, i, j, temp, sa, a[M];
	
	while(scanf("%d",&n))
	{
		if(n==0)
			break;
		else
		{
			for(i=0;i<n;i++)
				scanf("%d",&a[i]);
			sa = 1000000;
			for(i=0;i<n-1;i++)
			{
				for(j=i+1;j<n;j++)
				{
					temp = a[i]-a[j];
					if(temp<0)
						temp = temp * (-1);
					if(sa>temp)
						sa = temp;
				}
			}
			printf("%d\n",sa);
		}
	}
	return 0;
}


Measured memory_bytes: 2104
#writer:yutaka1999さんの見ながらPythonで写経 通るかな？一応O(HW)=O(10**6)らしいけど...？
#pypy3でだす
from collections import deque

def main():
  h,w=map(int,input().split())
  #global mp
  mp=[list(input()) for _ in range(h)]
  #global dist
  dist=[[-1]*w for i in range(h)]
  q=deque([])
  
  for i in range(h):
    for j in range(w):
      if mp[i][j]=="#":
        dist[i][j]=0
        q.append([i,j])
      else:
        dist[i][j]=-1
  
  while q:
    x,y=q.popleft()
    for i,j in ((1,0),(0,1),(-1,0),(0,-1)):
      xx,yy=x+i,y+j
      if (0<=xx<h and 0<=yy<w and dist[xx][yy]==-1):
        dist[xx][yy]=dist[x][y]+1
        q.append([xx,yy])
  
  ret=0
  for i in range(h):
    for j in range(w):
      ret=max(ret,dist[i][j])
      
  print(ret)
  return

main()


Measured memory_bytes: 176604
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for i in range(m):
        u,v=map(int,input().split())
        u-=1; v-=1
        E[u].append(v)
        E[v].append(u)

    # bipartite check
    col=[-1]*n
    col[0]=0
    Q=[0]
    while(Q):
        v=Q.pop()
        for nv in E[v]:
            if(col[v]==col[nv]): # 二部グラフではない
                print(n*(n-1)//2-m)
                return
            elif(col[nv]!=-1 and col[nv]^col[v]): continue
            col[nv]=1-col[v]
            Q.append(nv)

    depth=[-1]*n
    depth[0]=0
    Q=[0]
    while(Q):
        v=Q.pop()
        for nv in E[v]:
            if(depth[nv]!=-1): continue
            depth[nv]=depth[v]+1
            Q.append(nv)

    odd=sum(1 for i in range(n) if(depth[i]&1))
    even=n-odd
    ans=odd*even-m
    print(ans)
resolve()

Measured memory_bytes: 62316
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(dead_code)]
fn chmin<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x > y && {
        *x = y;
        true
    }
}

#[allow(dead_code)]
fn chmax<T>(x: &mut T, y: T) -> bool
where
    T: PartialOrd + Copy,
{
    *x < y && {
        *x = y;
        true
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input!(n:usize, dams:[usize;n]);

    // dams[0] = mt[0]/2 + mt[1]/2
    // dams[1] = mt[1]/2 + mt[2]/2 ...
    // dams[n-1] = mt[n-1]/2 + mt[0]/2
    // これらを利用して式変形すれば、mt[0] = dams[0] - dams[1] + dams[2] - dams[3] ... + dams[n-1] が得られる
    // mt[0] が決まれば、あとは芋づる式に解が定まる
    let mut mts = vec![0usize;n];
    let mut even_d = 0;
    let mut odd_d = 0;
    for i in 0..n {
        if i % 2 == 0 {
            even_d += dams[i];
        } else {
            odd_d += dams[i];
        }
    }
    mts[0] = even_d - odd_d;
    mts[n-1] = 2 * dams[n-1] - mts[0];
    for i in (1..n-1).rev() {
        mts[i] = 2 * dams[i] - mts[i+1];
    }

    for i in 0..n {
        if i == n - 1 {
            println!("{}", mts[i]);
        } else {
            print!("{} ", mts[i]);
        }
    }
}


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

int n;

int main(){
	scanf("%d", &n);
	if(n == 1) printf("2\n");
	else if(n == 0 || n == 2) printf("1\n");
	else printf("0\n");
	// if(p(n) > 10) 10 ** (p(n) - 1) % p(n) == 1 (because of Fermat's little theorem)
	// else if(n == 0 || n == 2) 10 ** (p(n) - 1) % p(n) == 0;
	// else (n == 1) 10 ** (p(n) - 1) % p(n) == 2;
	// 
	// if 10 ** p(n) % p(n) == 1 then (10 ** p(n) - 1) % p(n) == 0
	// 1/9 * (10 ** p(n) - 1) % p(n) == 0
	return 0;
}



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

typedef int ll;

#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()

typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;

const int mod=1e9+7;

int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}

void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}


const int maxn=1e5+55;
int cnt[maxn];
ll main() {
	// freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	int n,m;
	cin>>n>>m;

	bool ch=0;
	for (int i=0 ; i<m ; i++) {
		int u,v;
		cin>>u>>v;

		cnt[u]++;
		cnt[v]++;
	}	

	for (int i=1 ; i<=n ; i++) {
		if(cnt[i]%2==1) {
			ch=1;
			break;
		}
	}
	if(ch) 
		cout<<"NO\n";
	else
		cout<<"YES\n";
}

Measured memory_bytes: 1024
n = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)
if n < a.length
  while a.length > n do
    a.pop
  end
end
b = a.reverse
b.each_with_index do |b, idx|
  printf idx != n -1 ? "#{b} " : "#{b}"
end
printf "\n"

Measured memory_bytes: 6100
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}
	counter := make(map[int]int)
	for _, a := range as {
		counter[a-1]++
		counter[a]++
		counter[a+1]++
	}
	max := 0
	for _, v := range counter {
		if v > max {
			max = v
		}
	}
	fmt.Println(max)
}


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

#define INF 1000000005LL

ll n, a, b, c;
vl h;
bool check(ll x) {
	ll cnt = 0;
	for (ll i = 0; i < n; i++) {
		ll hh = max(0LL, h[i] - b * x);
		cnt += (hh + c - 1) / c;
	}
	if (cnt > x) return false;
	return true;
}

int main() {
	cin >> n >> a >> b;
	c = a - b;
	for (ll i = 0; i < n; i++) {
		ll hh; cin >> hh;
		h.push_back(hh);
	}

	ll hi, lo, mid;
	hi = INF;
	lo = -1;
	while(lo + 1 < hi) {
		mid = (hi + lo) / 2;
		if (check(mid)) {
			hi = mid;
		} else {
			lo = mid;
		}
	}
	cout << hi << endl;
	return 0;
}


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

bool judge(double s1, double t1, double s2, double t2, double s3, double t3, double xp, double yp);

int main(){
	double x1, y1, x2, y2, x3, y3, xp, yp;

	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		if(judge(x1,y1,x2,y2,x3,y3,xp,yp) && judge(x2,y2,x1,y1,x3,y3,xp,yp) && judge(x3,y3,x1,y1,x2,y2,xp,yp)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return(0);
}


bool judge(double s1, double t1, double s2, double t2, double s3, double t3, double xp, double yp){
	double a, b1, b2, b3;

	if(s2-s3 == 0.0){
		if(min(s1,s2) < xp && xp < max(s1,s2)){
			return true;
		}else{
			return false;
		}
	}else{
		a = (t2-t3)/(s2-s3);
		b1 = t2 - a*s2;
		b2 = t1 - a*s1;
		b3 = yp - a*xp;
	}

	if(min(b1,b2) < b3 && b3 < max(b1,b2)){
		return true;
	}else{
		return false;
	}
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    cums(T& v){ T r; r.push_back(v[0]); for(int i=1; i<v.size(); i++) r.push_back(r[i-1] + v[i]); return r; }
TEMP_T void maxe(T& v, T m){ v = max(v, m); }
TEMP_T void mine(T& v, T m){ v = min(v, m); }

static inline int in(){ int x; scanf("%d", &x); return x; }

struct Solver {
  Solver(vector<int> bs) : bs(bs) {}
  bool solve(int it=0, int a=0, int b=0){
    if (it == bs.size()) return true;
    if (a < bs[it] && solve(it + 1, bs[it], b)) return true;
    if (b < bs[it] && solve(it + 1, a, bs[it])) return true;
    return false;
  }
  vector<int> bs;
};

int main()
{
  int n = in();
  for (int i = 0; i < n; i++){
    vector<int> bs;
    for (int j = 0; j < 10; j++){
      bs.push_back(in());
    }
    Solver solver(bs);
    if (solver.solve()) puts("YES");
    else puts("NO");
  }
  return (0);
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];

	int max = -INF;
 	int	min = INF;

	REP(i, n){
		if (max < a[i]) max = a[i];
		if (min > a[i]) min = a[i];
	}


	cout << max - min << endl;
}


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

int main()
{
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
    return 0;
}

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

using namespace std;

int main() {
  int n;

  cin >> n;

  map<string, int> count;

  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;

    count[str]++;
  }

  int max = -1;

  for (pair<string, int> p : count) {
    if (p.second > max)
      max = p.second;
  }
  for (pair<string, int> p : count) {
    if (p.second == max)
      cout << p.first << "\n";
  }

  return 0;
}

Measured memory_bytes: 25216
n = int(input())
a = [int(input()) for i in range(n)]

count=0

for i in range(n):
    if(a[i]>0):
        count+=(a[i]-1)//2
        a[i]=((a[i]-1))%2+1


for i in range(n-1):
    count+=a[i]//2
    a[i]=a[i]%2
    if((a[i]>0) & (a[i+1]>0)):
        MinNum=min(a[i],a[i+1])
        a[i]-=MinNum
        a[i+1]-=MinNum
        count = count+MinNum


count+=a[n-1]//2
a[n-1]=a[n-1]%2

print(count)

Measured memory_bytes: 7072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;


int main() {

    long long int n;
    cin >> n;

    long double s = 0;

    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        s += 1.00L / in;
    }

    cout << fixed << setprecision(10) << 1.00L / s << endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).rbegin(),(v).rend()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 200010


int main(){
	IOS;
	tihs;

	ll a,b,c;cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
	


	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;

  vvll eds(n);
  rep(i, n) {
    if (i <= n - 2) eds[i].emplace_back(i + 1);
    if (i >= 1) eds[i].emplace_back(i - 1);
  }
  eds[x].emplace_back(y);
  eds[y].emplace_back(x);

  vll ans(n);  // n=0 no use

  rep(i, n) {
    queue<ll> q;
    vector<ll> d(n, -1);
    q.push(i);
    d[i] = 0;
    while (!q.empty()) {
      ll u = q.front();
      q.pop();
      for(ll v : eds[u]){
        if(d[v] == -1){
          d[v] = d[u] + 1;
          q.push(v);
        }
      } // v
    }
    rep(j, n) if(i < j) ans[d[j]]++;
  }

  for (ll i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0


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

  long int a,b,c=0;
  if(n%2==0){
    a=n;b=n;c=n/2;
  }else if(n%3==0){
    a=n/3;b=n*2;c=n*2;
  }
   else {
    for(a=3*n/4;a>0;a--){
      for(b=2*a*n/(4*a-n);b>0 && 4*a*b>n*(a+b) ;b--){
	if(n*a*b%(4*a*b-n*a-n*b)==0){
	  c=n*a*b/(4*a*b-n*a-n*b);
	  break;
	}
      }
      if(c)break;
    }
  }

  printf("%ld %ld %ld",a,b,c);
  return 0;
}


/// confirm df==0 ///


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

#define HASH 200003

typedef struct List {
	struct List *next;
	char *s;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = ((x << 5) + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h[200001];
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h[i] = hash_string(&(S[i][1]));
		d[i].s = S[i];
		d[i].next = hash[h[i]];
		hash[h[i]] = &(d[i]);
	}
	
	int k, m, dp[2][26];
	long long ans = 0, tmp, pow[32];
	const long long inv = div_mod(1, 32, HASH);
	for (k = 1, pow[0] = 32; k < 32; k++) pow[k] = pow[k-1] * pow[k-1] % HASH;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = 0; j <= l[i]; j++) T[j] = S[i][j];
		for (j = l[i] - 2, k = 0, tmp = 1; j > 0; j >>= 1, k++) if ((j & 1) == 1) tmp = tmp * pow[k] % HASH;
		h[i] = (h[i] - tmp * (T[1] - 'a') % HASH + HASH) % HASH;
		for (j = 0; j < 26; j++) dp[0][j] = 0;
		dp[0][S[i][0] - 'a'] = 1;
		dp[1][0] = S[i][0] - 'a';
		for (j = 1, m = 1; j < l[i]; j++) {
			if (dp[0][S[i][j] - 'a'] == 0) {
				dp[0][S[i][j] - 'a'] = 1;
				dp[1][m++] = S[i][j] - 'a';
			}
			for (k = 0; k < m; k++) {
				T[j] = 'a' + dp[1][k];
				for (p = hash[h[i]]; p != NULL; p = p->next) if (lex_smaller(p->s, &(T[j])) == 0) break;
				if (p != NULL) ans++;
			}
			tmp = tmp * inv % HASH;
			h[i] = (h[i] - tmp * (S[i][j+1] - 'a') % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 15720