akhauriyash/Code-Regression huggingface dataset:
import javax.net.ssl.SSLContext;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Stack;

public class Main {

    private static long gcd(long a, long b)
    {
        while (b > 0)
        {
            long temp = b;
            b = a % b; // % is remainder
            a = temp;
        }
        return a;
    }

    private static long lcm(long a, long b)
    {
        return a * (b / gcd(a, b));
    }

    private static long lcm(long[] input)
    {
        long result = input[0];
        for(int i = 1; i < input.length; i++) result = lcm(result, input[i]);
        return result;
    }


    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        char[] input = reader.readLine().toCharArray();

        int N= 0, S= 0, W= 0, E= 0;

        for (int i = 0; i < input.length; i++) {
            if ('N' == input[i]) N++;
            if ('S' == input[i]) S++;
            if ('W' == input[i]) W++;
            if ('E' == input[i]) E++;
        }

        boolean nsp  = false;
        if (N + S != 0 && N != 0 && S != 0)
            nsp = true;
        else if (N == 0 && S ==0)
            nsp = true;

        boolean ewp  = false;
        if (E + W != 0 && E != 0 && W != 0)
            ewp = true;
        else if (E == 0 && W ==0)
            ewp = true;

        if (ewp==true&&nsp==true)
            System.out.print("Yes");
        else
            System.out.print("No");


//        PrintWriter writer = new PrintWriter(System.out);
//
//        writer.close();


    }
}


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

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORV(i,a,b) for(int i=a;i*i<=b;i++)
#define Forv(i,a,b) for(int i=a;i*i<b;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define Ford(i,a,b) for(int i=a;i>b;i--)
#define Fill(s,a) memset(s,a,sizeof(s))
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int n;
long long ans=0, sum[4001], a[4001], b[4001][4001], x[4001][4001];

void read()
{
    scanf("%d", &n);
    FOR(i, 1, n)
        scanf("%lld", &a[i]);
    FOR(i, 1, n)
        a[n+i] = a[i];
}

void solve()
{
    FOR(i, 1, 2*n)
        sum[i]=sum[i-1]+a[i];
    FOR(j, 1, 2*n)
        FORD(i, j, 1){
            if(i == j)
            {
                b[i][j] = a[i];
                x[i][j] = a[i];
            }
            else
            {
                b[i][j]=(sum[j]-sum[i-1])-min(x[i+1][j],x[i][j-1]);
                if(a[i] > a[j]) x[i][j] = a[i] + (sum[j]-sum[i]-b[i+1][j]);
                else x[i][j] = a[j] + (sum[j-1]-sum[i-1]-b[i][j-1]);
            }
        }
}

void process()
{
    solve();
    FOR(i, 1, n)
    {
        ans = max(ans, a[i]+sum[i+n-1]-sum[i]-x[i+1][i+n-1]);
    }
    cout<<ans<<'\n';
}

int main()
{
    read();
    process();
}

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

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

int main() {
  int n,m,sum=0;
  cin>>n>>m;
  vector<vector<int>> list(m);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    if(a>m)continue;
    list[a-1].push_back(b);
  }
  priority_queue<int> q;
  rep(i,m){
    for(int j:list[i]){
      q.push(j);
    }
    if(!q.empty()){
      sum+=q.top();
      q.pop();
    }
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 5504
S = input()
op_cnt = len(S) - 1  # すき間の個数
ops = []
ans = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt  # あらかじめ ["-", "-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き
    formula = ""
    for p_n, p_o in zip(S, op + [""]):  # 少々モヤッとする
        formula += (p_n + p_o)
    ans += eval(formula)

print(ans)
  

Measured memory_bytes: 3060
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node

using namespace std;
///check n=1;
///check corner case;

int main()
{
    ll n; cin>>n;
	if(n%2) cout<<0<<"\n";
	else{
		n/=2;
		ll ans=0;

		for(ll i=5;(n/i)>0;i*=5)
            ans+=n/i;
		cout<<ans<<"\n";
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

map<ll, ll> prime;
void factrization(ll n) {
  for(ll i=2; i*i<=n; i++) {
    while(n%i==0) {
      prime[i]++;
      n/=i;
    }
  }
  
  if(n>1) prime[n]++;
}

map<ll, ll> mp;
void divisor(ll n) {
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      mp[i]++;
      mp[n/i]++;
    }
  }
}

int main() {
  ll i, j, k;
  
  ll N;
  cin >> N;
  
  factrization(N-1);
  
  ll ans=1;
  for(auto it=prime.begin(); it!=prime.end(); it++) {
    ans*=it->sc+1;
  }
  ans--;
  
  
  divisor(N);
  for(auto it=mp.begin(); it!=mp.end(); it++) {
    if(it->ft==1) continue;
    
    ll t=it->ft;
    ll M=N;
    while(M%t==0) {M/=t;}
    
    if(M%t==1) ans++;
  }
  
  pt(ans);
  
}




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

const bool DEBUG = false;

int N;
long long K;
vector<long long> A;

void input() {
  cin >> N >> K;
  A = vector<long long>(N);
  for (size_t i = 0; i < N; i++) cin >> A[i];
}

vector<long long> get_divisor(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  // sort(begin(ret), end(ret));
  return (ret);
}

int main(int argc, char const* argv[]) {
  input();

  long long S = accumulate(A.begin(), A.end(), 0ll);
  auto divisors = get_divisor(S);

  vector<long long> r;
  long long dmax = 1;
  for (auto&& d : divisors) {
    if (S % d != 0) continue;
    if (DEBUG) cout << "candidate: " << d << endl;
    r.clear();
    for (size_t i = 0; i < N; i++)
      if (A[i] % d != 0) r.push_back(A[i] % d);

    if (r.size() == 0) {
      dmax = max(dmax, d);
      if (DEBUG) cout << "valid! " << d << endl;
      continue;
    }

    sort(r.begin(), r.end());
    long long rtotal = accumulate(r.begin(), r.end(), 0ll);
    long long left = 0, right;
    for (size_t i = 0; i < r.size(); i++) {
      left += r[i];
      right = d * (r.size() - (i + 1)) - (rtotal - left);
      if (DEBUG) cout << "left: " << left << ", right: " << right << endl;
      if (left - right == 0 && left <= K && right <= K) {
        if (DEBUG) cout << "valid! " << d << endl;
        dmax = max(dmax, d);
        break;
      }
    }
  }

  cout << dmax << endl;
  return 0;
}


Measured memory_bytes: 256
/** 
 *@file Main.c++
 *プロコンの回答兼ねてきれいめコードの練習
 *@brief  class coding_ans::Ans 標準入力からテストケースを受け取ってansで回答を返すclass 
 *@name tamtam484
 * main() メイン
 **
*/
#include<iostream>
#include<set>
#include<algorithm>
#include<utility>
#include<numeric>
#include<stdexcept>

namespace coding_ans {
    typedef long long ll; //namespaceのなかなら大丈夫だ。
    class Ans{
        int _N;
        std::multiset<ll> _s;
        
    public:
        static const Ans Constructforcin(){
            /**
             *@brief 標準入力から問題を受け取る。
            **/
            int N;
            std::cin>>N;
            std::multiset<ll> s;
            for(int i = 0 ; i<N;i++){
                int kari;
                std::cin>>kari;
                s.insert(kari);
            }
            return Ans(N,s);
        }
        
        Ans(const Ans &a):_N(a._N) , _s(a._s){}
            /**
             *@brief コピーコンストラクタ
            **/
        
        Ans& operator=(const Ans &a){
            /**
             *@brief コピー代入演算子
            **/
            //FIXME ポインタで管理されてるものはこれでdeep copyにできるからあり難い???
            //FIXME 多分デフォルトコンストラクタもこの例ではdeep copyのはず。
            Ans a2(a);
            std::swap(*this,a2);
            return *this;
        }
        
    private:
        Ans(const int N,const std::multiset<ll> s): _N(N), _s(s){}
        /**
         *@brief デフォルトコンストラクタ
         **/
        
        
    private:
        const ll getans() const{
            /** 
             *@brief 答えを得る
             *@detail 
                合計が10で割り切れなければそれが答え。そうでなければ10で割り切れない一番小さなものをけす。 全部10で割れるなら , 0を返す。
             **/
             
            const ll MAXANS = std::accumulate(this->_s.begin(), this->_s.end(),0LL);
            
            if(MAXANS % 10){
                return MAXANS;
            }else{
                const std::multiset<ll>::iterator i = std::find_if(this->_s.begin(), this->_s.end() ,
                                                                   [](int a){return (a%=10);});
                
                return (i!=this->_s.end()) ? MAXANS - *i : 0;
            }
        }
    public:
        void solve() const{
            /**
             *@brief 出力
             **/
            std::cout<<this->getans()<<std::endl;
        }
    };
}

int main(){
    coding_ans::Ans::Constructforcin().solve();
    return 0;
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)
  val MOD = 1e9.toLong + 7

  val N, M = in.next().toInt
  val A = Array.fill[Long](N+2)(Int.MaxValue)
  val B = Array.fill[Long](M+2)(Int.MaxValue)
  A(N+1) = -1
  B(M+1) = -1

  for(i <- 1 to N)
    A(i) = in.next().toLong
  for(i <- 1 to M)
    B(i) = in.next().toLong


  //
  if(A.toSet.size != A.length || B.toSet.size != B.length)
    println(0)
  else {
    // val dpx = new Array[Int](N+1)
    // val dpy = new Array[Int](M+1)

    val X = A.sorted.reverse
    val Y = B.sorted.reverse


    var y = 0; var x = 0
    var ans = 1L

    // X(x) Y(y)
    breakable {
      for (num <- (1 to N*M).reverse) {
        if(X(x+1) == num && Y(y+1) == num) {
          x += 1
          y += 1
        }
        else if(X(x+1) == num) {
          x += 1
          ans *= y
          ans %= MOD
        }
        else if(Y(y+1) == num) {
          y += 1
          ans *= x
          ans %= MOD
        }
        else {
          val index = (N*M - num) + 1  // 上から何番目かを表す
          if(index > x * y) { // 書き込めない場合
            ans = 0L
            break
          }
          else {
            ans *= (x * y) - (index - 1)
            ans %= MOD
          }
        }
      }
    }

    println(ans)
  }
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 31364
#[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 , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[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 ) * } } ; }
#[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 ) * } } ; }

fn main() {
    input! {
        a: i32,
        b: i32,
        k: i32,
    }
    let mut cnt = 0;
    for i in (1..=a.min(b)).rev() {
        if a % i == 0 && b % i == 0 {
            cnt += 1;
        }
        if cnt == k {
            println!("{}", i);
            break;
        }
    }
}


Measured memory_bytes: 2140
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, k;
    cin >> n >> k;
    if(k % 2 == 0){
        cout << ((ll)n / k) * (n / k) * (n / k) + ((ll)(n + k / 2) / k) * ((n + k / 2) / k) * ((n + k / 2) / k) << endl;
    }else{
        cout << ((ll)n / k) * (n / k) * (n / k) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
s = sys.stdin.readline().rstrip("\n")
t = sys.stdin.readline().rstrip("\n")
l = len(s)-len(t)+1
ans = 10000000000
for i in range(l):
    s_ = s[i:i+len(t)]
    ans_ = 0
    for j in range(len(t)):
        if t[j] != s_[j]:
            ans_ += 1
    ans = min(ans,ans_)
print(ans)

Measured memory_bytes: 67556
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>
#include <numeric>

typedef long long Int; 
#pragma warning(disable : 4996)
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;


int main(){
	vector<double> ms;
	double a;
	while (cin >> a){
		ms.push_back(a);
	}
	sort(ms.begin(), ms.end());
	printf("%.1lf",ms[ms.size()-1]-ms[0]);
	puts("");
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n, m;
  cin >> n >> m;
  int x = 2 * m + 1;
  cout << (n + x - 1) / x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int main() {
    string S;
    cin >> S;
    set<char> s;
    rep(i,0,S.size()) {
        s.insert(S[i]);
    }
    if (s.size()==S.size()) {
        cout << "yes" << endl;
    }
    else {
        cout << "no" << endl;
    }
}

Measured memory_bytes: 256
// C - Monsters Battle Royale
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
void solve()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = INF, count = 0, mark = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> mp;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  vlli d(n);
  rep(i, 0, n)
  {
    cin >> d[i];
  }
  rep(i, 0, n - 1)
  {
    ans = min(ans, gcd(d[i], d[i + 1]));
  }
  out(ans);
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  solve();
}

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

int main()
{
    long long N,x;
    cin >> N >> x;
    vector<long> a(N);

    for(int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }

    sort(a.begin(),a.end());
    int count = 0;


    for(int i = 0; i < N; i++)
    {
        if(x >= a.at(i))
        {
            x -= a.at(i);
            count++;
        }
        else break;
    }
    
    if(count == N && x > 0)count--;

    cout << count << endl;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int aa,bb,cc;
    int count=0;
    if(a==b&&b==c&&a%2==0){
        cout << -1 << endl;
        return 0;
    }
    else if(a==b&&b==c&&a%2==1){
        cout << 0 << endl;
        return 0;
    }
    if(a%2==1||b%2==1||c%2==1){
        cout << 0 << endl;
        return 0;
    }
    while(1){
        count++;
        aa=(b+c)/2;
        bb=(c+a)/2;
        cc=(a+b)/2;
        a=aa;
        b=bb;
        c=cc;
        if(a%2==1||b%2==1||c%2==1){
            break;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

void dfs(int v, int N);

vector<int> done(9,0);
int to[9][9];
int clear =0;
int main() {
    int N, M;
    cin >> N >> M;

    // 初期化
    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++){
            to[i][j] = 0;
        }
    }

    // パスの存在するところを1
    for(int i=0; i<M; i++){
        int ai, bi;
        cin >> ai >> bi;
        to[ai][bi]=1;
        to[bi][ai]=1;
    }

    // 始点は1
    done[1] = 1;
    dfs(1,N);


    cout << clear << endl;
    return 0;
}

void dfs(int v, int N) {
    // 全通りの数カウント
    int clear_judge =0;
    for(int i=1; i<=N; i++){
        clear_judge += done[i];
    }

    if(clear_judge==N){
        clear++;
    }


    for(int i = 1; i<=N; i++) {
        if (done[i] == 1 || to[v][i] == 0) {
            continue;
        }
        done[i] = 1;
        dfs(i, N);
        done[i] = 0;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void);

int main(void){
  char CARDs[201];
  char LOCAL_CARDs1[201];
  char LOCAL_CARDs2[201];
  int  shuffle;
  int  get_cards;
  int  cards_count;

  while(1){
    scanf("%s", CARDs);
    if (CARDs[0] == '-') {
      break;
    }
    scanf("%d", &shuffle);

    cards_count = strlen(CARDs);

    for (int i = 0; i < shuffle; i++) {
      scanf("%d", &get_cards);

      strncpy(LOCAL_CARDs2, CARDs, get_cards);
      LOCAL_CARDs2[get_cards] = '\0';

      strncpy(LOCAL_CARDs1, CARDs + get_cards, cards_count - get_cards);
      LOCAL_CARDs1[cards_count-get_cards] = '\0';

      strcat(LOCAL_CARDs1, LOCAL_CARDs2);

      memmove(CARDs, LOCAL_CARDs1, cards_count);
      CARDs[cards_count] = '\0';
    }

    printf("%s\n", CARDs);
  }

  return 0;
}



Measured memory_bytes: 2104
#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.at(i);
  }
  
  int ans = 0;
  bool bo = true;
  
  while (bo) {
    ans++;
    for (int i = 0; i < n; i++) {
      if (a.at(i) % 2 == 0) {
        a.at(i) /= 2;
      }
      else {
        bo = false;
        break;
      }
    }
  }
  cout << ans - 1 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  #pragma GCC target("avx,avx2,fma")
  #include <bits/stdc++.h>
  using namespace std;
  //---------------------------------//
  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define deb(x...)
  #endif
 //------------------------------//

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

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  all(x)       (x).begin(), (x).end()
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;

 // dp[i][2] -> dp[i][
  void solve(){
    int n;
    cin >> n;
    vi v(n);
    for(int i=0;i<n;i++)cin >> v[i];
    vector<vector<ll>> dp(n+1,vector<ll>(2));
     // dp[i][0] max if here operation is applied;

    for(int i=1;i<=n;i++){
       if(i==1){
         dp[i][0] = -v[i-1];
         dp[i][1] = v[i-1];
       }
       else{
        dp[i][0] = max(dp[i-1][0]+v[i-1],dp[i-1][1]-v[i-1]);
        dp[i][1] = max(dp[i-1][0]-(v[i-1]),dp[i-1][1] + v[i-1]);
       }
    }
    cout << dp[n][1];
  }

  int main(){
    IOS
    	solve();
    //cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow

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

int main() {
	// your code goes here
	string a,b ;
	cin>>a>>b ;
	int i,j,min=INT_MAX ;
	for(i=0 ;i+b.size()<=a.size() ;i++)
	{
		int k = i,temp=0 ;
		for(j=0;j<b.size();j++)
		{
			if(a[k]!=b[j])
			  temp++ ;
			k++ ;  
		}
		if(temp<min)
		 min = temp ;
	}
	cout<<min;
	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<math.h>
int main()
{
	int n,k,i,sum=0,ans,max=-20000,min=20000,leap=0,lleap=0;
	int a[500]={};
	while(~scanf("%d%d",&n,&k)){
		for(i=1;i<=n;i++){
			a[i]=k+i-1;
			sum+=a[i];
			if(a[i]>=0){
				if(min>a[i]){
					min=a[i];
					lleap=1;
				}
			}else{
				if(max<a[i]){
					max=a[i];
					leap=1;
				}
			}
		}if(leap==1&&lleap==1){
			ans=fabs(min)>fabs(max)?max:min;
		}else if(leap==1){
			ans=max;
		}else if(lleap==1){
			ans=min;
		}
		printf("%d\n",sum-ans);
		max=-20000;sum=0;min=20000;lleap=0;leap=0;
	}
}

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

typedef long long LL;

#define pb push_back

const int MAXN=100005;

int a[MAXN],cnt,b[MAXN],blo,c[MAXN];
bool vis[MAXN];
vector <int> G[MAXN];
queue <int> q;
LL ans;

void bfs(int u)
{
	blo++;
	int mn=a[u];
	vis[u]=true;
	q.push(u);
	int p=0;
	while (!q.empty())
	{
		int u=q.front();q.pop();
		c[p++]=a[u];
		for (int v:G[u])
			if (!vis[v])
			{
				vis[v]=true;
				mn=min(mn,a[v]);
				q.push(v);
			}
	}
	ans+=mn;
	for (int i=0;i<p;i++)
		if (c[i]!=mn)
			b[cnt++]=c[i];
		else
			mn=-1;
}

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for (int i=0;i<m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].pb(v);
		G[v].pb(u);
	}
	for (int i=0;i<n;i++)
		if (!vis[i])
			bfs(i);
	if (blo==1)
		printf("0");
	else if (n<2*(blo-1))
		printf("Impossible");
	else
	{
		nth_element(b,b+blo-2,b+cnt);
		for (int i=0;i<blo-2;i++)
			ans+=b[i];
		printf("%lld",ans);
	}
	return 0;
}

Measured memory_bytes: 7040
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // */

    lli N,i;
    cin>>N;
    
    vlli V(N);
    rep(i,0,N)
    {
        cin>>V[i];
    }
    
    sort(V.begin(),V.end());
    
    lli Start=0,cnt=0,Sum=0;
    rep(i,0,N)
    {
        if(2*Sum<V[i])
        {
            Start=i;
        }
        Sum+=V[i];
    }
    
    //cout<<Start<<' ';
    
    cout<<N-Start;






 return 0;
}


                                                                                                                                                                                          

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int ans = 0;
		for(int i=1;i<n+1;i++){
			if(Integer.toString(i).length()%2==1){
				ans++;
			}
			
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28500
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
double round(double r)
{
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

int n;
int ans=0;
int num[1000];

int thr(int f,int s,int& p)
{
    int i;
    i=s+1;
    if(i>=n)
        return 0;
    for(;i<n&&num[i]==num[s];i++)
        p++;
    int tot=0;
    while(i<n)
    {
        if(num[f]+num[s]>num[i])
            tot++;
        else
            break;
        i++;
    }
    return tot*p;

}

int sec(int f)
{
    int x=1;
    int i=f+1;
    if(i>=n)
        return 1;
    for(;i<n&&num[i]==num[f];i++)
        x++;
    int p;
    while(i<n)
    {
        p=1;
        ans+=x*thr(f,i,p);
        i+=p;
    }
    return x;
}

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>num[i];
    sort(num,num+n);
    int i=0;
    int x;
    while(i<n)
    {
        x=sec(i);
        i+=x;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
int f(int x){
  if(x < 0){x *= (-1);}
  return x;
}

int main(){
  int n; cin >> n;
  vector<vector<int>>v(n,vector<int>(3, 0));
  for(int i = 0; i < n; i++){
    cin >> v[i][0] >> v[i][1] >> v[i][2];
  }

  bool fin = false;

  for(int i = 0; i < n; i++){
    int l = (v[i][0] + v[i][1] + v[i][2]) % 2;
    if(l != 0){fin = true; break;}
    else if(i == 0){
      if(f(v[0][1]) + f(v[0][2]) > v[0][0]){fin = true; break;}
    }
    else{
      if(f(v[i][1] - v[i-1][1])+f(v[i][2] - v[i-1][2]) > v[i][0]-v[i-1][0]){
        fin = true; break;
      }
    }
  }
  if(fin){cout << "No" << endl;}
  else{cout << "Yes" << endl;}


    
}

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

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

	vector<tuple<string,int,int>> t;
	
	for (int i = 0; i < n; i++) {

		string tmp_s;
		int tmp_p; 

		cin >> tmp_s >> tmp_p;

		t.emplace_back(tmp_s, -tmp_p, i + 1);

	}

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

	for (int i = 0; i < n; i++) {

		cout << get<2>(t[i]) << endl;

	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
m = [0 for _ in range(5)]
s = "MARCH"

for _ in range(n):
    t = input()
    for i in range(5):
        if t[0] == s[i]:
            m[i] += 1

ans = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += m[i] * m[j] * m[k]

print(ans)      

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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

constexpr ll inf = 1e18;
int flag[101];

void solve();

int main()
{
    solve();
}

void solve()
{
    int n;
    int ans = 0;
    in(n);
    floop(i, n)
    {
        int d;
        in(d);
        flag[d] = 1;
    }
    floop(i, 101)
    {
        ans += flag[i];
    }
    out(ans);
}

Measured memory_bytes: 256
"use strict"

function main(input) {
    let nums = input.split(' ')
    nums = nums.map(x => +x)
    nums.sort()//.reverse()
    let num = 0;
    for (let i=0; i<nums.length;i++) {
        let red = (i >= 1) ? nums[i - 1] : 0
        num += Math.abs(nums[i] - red)
    }
    num -= nums[0]
    console.log(num)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    a, b, x = map(int, input().split())
    print(b // x - (a - 1) // x)


if __name__ == '__main__':
    main()


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

int main(){
	string s;
	cin >> s;
	
	int res = 0;
	if(s.size()%2==0){
		rep(i,s.size()/2){
			if(s[i] != s[s.size()-1-i]) res++;
		}
	}
	else{
		rep(i,s.size()/2){
			if(s[i] != s[s.size()-1-i]) res++;
		}
	}
	cout << res << endl;
	return 0;
}

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

typedef long long ll;

struct INFO {
	int to, a, b;

	INFO(int to, ll a, ll b):to(to),a(a),b(b) {

	}
};



int N,M,S,T;
vector<vector<INFO>>links;
vector<int>status;
vector<ll>costA,costB;
void dijkstraA(int s) {
	status.assign(N, 0);
	costA.assign(N, INT64_MAX);

	status[s] = 1;
	costA[s] = 0;

	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>>Q;
	Q.push(make_pair(0, s));
	while (Q.size()) {
		int p = Q.top().second; Q.pop();

		if (status[p] == -1)continue;
		status[p] = -1;

		for (int i = 0; i < links[p].size(); i++) {
			int to = links[p][i].to;

			if (costA[to] > costA[p] + links[p][i].a) {
				costA[to] = costA[p] + links[p][i].a;
				status[to] = 1;

				Q.push(make_pair(costA[to], to));
			}
		}

	}

}
void dijkstraB(int s) {
	status.assign(N, 0);
	costB.assign(N, INT64_MAX);

	status[s] = 1;
	costB[s] = 0;

	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>>Q;
	Q.push(make_pair(0, s));
	while (Q.size()) {
		int p = Q.top().second; Q.pop();

		if (status[p] == -1)continue;
		status[p] = -1;

		for (int i = 0; i < links[p].size(); i++) {
			int to = links[p][i].to;

			if (costB[to] > costB[p] + links[p][i].b) {
				costB[to] = costB[p] + links[p][i].b;
				status[to] = 1;

				Q.push(make_pair(costB[to], to));
			}
		}

	}
}

class RMQ {
	int n;
	vector<pair<ll, int>>dat;
public:
	RMQ(int n_) {
		n = 1;
		while (n<n_)n *= 2;
		dat.resize(2 * n - 1);
		for (int i = 0; i<2 * n - 1; i++)dat[i] = make_pair(INT64_MAX, -1);
	}
	void update(int k, ll a) {
		k += n - 1;
		dat[k] = make_pair(a, k - n + 1);
		while (k>0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	pair<ll, int> query(int a, int b, int k = 0, int l = 0, int r = 0) {
		if (r <= l)r = n;
		if (r <= a || b <= l)return make_pair(INT64_MAX, -1);
		if (a <= l && r <= b)return dat[k];
		pair<ll, int> vl = query(a, b, k * 2 + 1, l, (r + l) / 2);
		pair<ll, int> vr = query(a, b, k * 2 + 2, (r + l) / 2, r);
		return min(vl, vr);
	}
};

int main() {
	ll money = 1e15;

	cin >> N >> M >> S >> T; S--; T--;
	links.resize(N);

	for (int i = 0; i < M; i++) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		links[u].push_back(INFO(v, a, b));
		links[v].push_back(INFO(u, a, b));
	}

	dijkstraA(S);
	dijkstraB(T);

	RMQ rmq(N);

	vector<ll>dat(N);
	for (int i = 0; i < N; i++) {
		rmq.update(i, costA[i] + costB[i]);
	}

	for (int i = 0; i < N; i++) {
		cout << money - rmq.query(i, N).first << endl;
	}


	return 0;
}

Measured memory_bytes: 15168
#include <iostream>
#include <limits.h>
#include <string>
using namespace std;

int main(void){
    int h, w, bomb = 0;
    char s[55][55];
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') cout << "#";
            else {
                if (s[i - 1][j - 1] == '#') bomb++;
                if (s[i - 1][j] == '#') bomb++;
                if (s[i - 1][j + 1] == '#') bomb++;
                if (s[i][j - 1] == '#') bomb++;
                if (s[i][j + 1] == '#') bomb++;
                if (s[i + 1][j - 1] == '#') bomb++;
                if (s[i + 1][j] == '#') bomb++;
                if (s[i + 1][j + 1] == '#') bomb++;
                cout << bomb;
            }
          	bomb = 0;
        }
      	cout << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

using namespace std;

typedef long long LL;

int n, m, k;

double p[2222], x[2222];



int main() {
    
    cin >> n >> k;
    int a= 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        if (x >= k) a += 1;
    }
    cout << a << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int l=s.size()-1;
	int ll=l;
	for(int i=0;i<=l/2-1;i++)
	{
		if(s[i]!=s[l-i])
		{
			printf("No\n");
			return 0;
		}
	} 
	l/=2;
	for(int i=0;i<=(l-1)/2;i++)
	{
		if(s[i]!=s[l-1-i])
		{
			printf("No\n");
			return 0;
		}
	}
	for(int i=0;i<=(l-1)/2;i++)
	{
		if(s[i+l+1]!=s[l-i+l])
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  vector<string> ans;
  map<string,int> m;
  while(t--)
  {
      int n;
      cin>>n;
      string s;
      int count=0;
      REP(i,n)
      {
          cin>>s;
          m[s]++;
          count=max(count,m[s]);
      }
      for(auto i:m)
      {
          if(i.second==count)
          ans.push_back(i.first);
      }
      sort(ans.begin(),ans.end());
      for(auto i:ans)
      {
          cout<<i<<"\n";
      }
  }

  return 0;
}

Measured memory_bytes: 25584
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	vs a = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string x;
	cin >> x;
	for (int i = 0; i < 7; i++) {
		if (x == a[i]) {
			cout << 7 - i << endl;
		}
	}
}

Measured memory_bytes: 3492
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N);
  int64_t S = 0;
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
    S = S ^ A[i];
  }
  for (int64_t i = 0; i < N; ++i) {
    if (i != 0) {
      cout << " ";
    }
    cout << (S ^ A[i]);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4668
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------

#define MAX 10000

int main(void) {
  ll a;

  cin >> n;
  cin >> a;

  n = n % 500;

  if (a >= n) {
	cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int A[500001];
int R[500001];
int L[500001];
int ans = 0;

int gcd (int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


int main() {
	cin >> N;
	for (int n = 0; n < N; n ++) {
		cin >> A[n];
	}
	L[0] = A[0];
	R[N - 1] = A[N - 1];
	for (int n = 1; n < N; n ++) {
		L[n] = gcd(L[n - 1], A[n]);
		R[N - n - 1] = gcd(R[N - n], A[N - n - 1]);
	}
	ans = R[1];
	ans = max(ans, L[N - 2]);
	for (int n = 1; n < N - 1; n ++) {
		ans = max(ans, gcd(L[n - 1], R[n + 1]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
int D,N;
int main(){
	scanf("%d%d",&D,&N);
	if(N==100){
		printf("101");
		while(D--){
			printf("00");
		}
		return 0;
	}
	if(D==0){
		printf("%d",N);
	}
	else{
		printf("%d",N);
		while(D--){
			printf("00");
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program2
    {
        static void Main(string[] args)
        {
            //long n = long.Parse(Console.ReadLine());
            long[] inputLongArray1 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[] inputLongArray2 = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long inputKosuu = inputLongArray1[0];
            long selelctKosuu = inputLongArray1[1];
            long sum = 0;

            Array.Sort(inputLongArray2);

            for(var i = 0; i< selelctKosuu; i++)
            {
                sum += inputLongArray2[i];
            }

            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            sw.Write(sum.ToString());
            Console.SetOut(sw);
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28584
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,M = map(int,readline().split())

PY = [list(map(int,readline().split())) + [i] for i in range(M)]

PY.sort(key=lambda x: (x[0],x[1]))

ans = [None]*M
nowp = 1
cnt = 1
for i in range(M):
    if PY[i][0] != nowp:
        cnt = 1
        nowp = PY[i][0]
    ans[PY[i][2]] = [nowp,cnt]
    cnt += 1

for i in range(M):
    print(str(ans[i][0]).zfill(6) + str(ans[i][1]).zfill(6))


Measured memory_bytes: 40948