akhauriyash/Code-Regression huggingface dataset:
/*
  file : /1257.comp.cpp
  date : 2015-10-19
  summary :
  {
  2<=n<=10^4 ??????n?????£?¶????????´???°????????§??¨?????????????????¨???????????????????????????
  }
  status :
  {
  
  }
  memo :
  {
  
  }
 */

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cassert>
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)
#define repeat(i,j,k) for(int__ i=(j);i<(int__)(k);i++)
#define all(v) v.begin(),v.end()

#define N_MAX 10000
vector<int> sum_prime;

void init(){
    vector<bool> is_prime(N_MAX+1,true);
    is_prime[0]=is_prime[1]=false;
    repeat(i, 2, is_prime.size()){
        if(is_prime[i]){
            for(int j=i*2;j<(int)is_prime.size();j+=i)is_prime[j]=false;
        }
    }
    int prime_num=0;
    int sum =0;
    sum_prime.reserve(N_MAX);
    sum_prime.push_back(0);
    rep(i,is_prime.size()){
        if(is_prime[i]){
            prime_num++;
            sum += i;
            sum_prime.push_back(sum);
        }
    }
}

bool solve(){
    int n;cin>>n;
    if(n==0)return false;
    int ans =0;
    for(int sum : sum_prime){
        int need = sum + n;
        auto itr =lower_bound(all(sum_prime),need);
        if(itr != sum_prime.end() && *itr == need) ans++;
    }
    cout <<ans <<endl;
    
    return true;
}

int main()
{
    init();
    while(solve());
    return 0;
}

Measured memory_bytes: 1208
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main(){


string s;
cin>>s;
string ans="";
rep(i,s.size()){
    if(s[i]=='B'){
        if(ans.size()>0){
            ans=ans.substr(0,ans.size()-1);
        }

    }
    else{
        ans+=string(1,s[i]);
    }
}
cout<<ans<<endl;

return 0;
}

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

int main() {
  string a;
  cin >> a;
  int ans = 0;
  if(a.at(0) == '1')
    ans++;
  if(a.at(1) == '1')
    ans++;
  if(a.at(2) == '1')
    ans++;
  cout << ans << endl;  
}

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

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

class Sol{
	public void Solve(){
		
		
		long cnt = 0;
		while(true){
			Array.Sort(A);
			Array.Reverse(A);
//Console.WriteLine(String.Join(" ",A) + ":" + cnt);
			if(A[0] <= N-1){
				Console.WriteLine(cnt);
				return;
			}
			if(A[0] < 3*N){
				cnt++;
				A[0] -= N;
				for(int i=1;i<N;i++){
					A[i]++;
				}
				continue;
			}
			
			if(A[0] - A[N-1] < N){
				cnt += N * (A[N-1] - N);
				long di = A[N-1] - N;
				for(int i=0;i<N;i++) A[i] -= di;
				continue;
			}
			
			int mem = 1;
			for(int i=1;i<N;i++){
				if(A[0] - A[i] < N){
					mem++;
					continue;
				}
				break;
			}
			if(mem == N){
				cnt++;
				A[0] -= N;
				for(int i=1;i<N;i++){
					A[i]++;
				}
				continue;
			}
			
			int l = mem-1;
			int r = mem;
			long diff = A[l] - A[r];
			long k = diff / (N+1);
//Console.WriteLine("diff: {0} , k:{1},cnt:{2},mem:{3}",diff,k,cnt,mem);
			if(k == 0){
				cnt++;
				A[0] -= N;
				for(int i=1;i<N;i++){
					A[i]++;
				}
				continue;
			}
			cnt += mem * k;
			for(int i=0;i<N;i++){
				if(i < mem){
					A[i] -= k * N;
					A[i] += (mem - 1) * k;
				} else {
					A[i] += k * mem;
				}
			}
			
			
		}
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

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


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int>b;b=a;
    sort(all(b));
    int k = n / 2;
    rep(i, n)
    {
        if (a[i] < b[k])
        {
            cout << b[k] << endl;
        }
        else
        {
            cout << b[k - 1] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3840
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 100;
const long long MNN = 3e2 + 10;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, a[MXN], b[MXN];

int main(){
	ios;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> b[i];
	}
	for(int i = 1; i <= n; i++){
		a[i] = n * (i - 1) + 1;
		cout << a[i] << ' ';
	}NL;
	reverse(a + 1, a + n + 1);
	for(int i = n; i >= 1; i--){
		a[b[i]] += (i - 1);
	}
	for(int i = 1; i <= n; i++){
		cout << a[i] << ' ';
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  ll x,y;cin>>x>>y;
  if(x%y==0){
    out(-1);
  }else{
    out(x);
  }

  return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size
    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)
    def same(self, x, y):
        return (self.find(x) == self.find(y))

N, M, *I = map(int, open(0).read().split())
P, XY = I[:N], I[N:]

uf = UnionFind(N + 1)
for x, y in zip(*[iter(XY)] * 2):
    uf.union(x, y)

ans = 0
for i, p in enumerate(P, 1):
    if uf.same(i, p):
        ans += 1

print(ans)

Measured memory_bytes: 44028
#include <stdio.h>

int main(int argc, char** argv)
{
	int n, m, l, i, j, k, *ar1, *ar2;

	scanf("%d %d %d", &n, &m, &l);
	ar1 = (int *)malloc(n * m * sizeof(int));
	ar2 = (int *)malloc(m * l * sizeof(int));

	for (i = 0; i < n + m; i++) {
		if (i < n) {
			for (j = 0; j < m; j++) {
				scanf("%d", &ar1[i * m + j]);
			}
		}
		else {
			for (j = 0; j < l; j++) {
				scanf("%d", &ar2[(i - n) * l + j]);
			}
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			long sum = 0;
			for (k = 0; k < m; k++) {
				sum += (ar1[i * m + k] * ar2[k * l + j]);
			}

			if (j == l - 1) {
				printf("%ld", sum);
			}
			else {
				printf("%ld ", sum);
			}
		}
		printf("\n");
	}

	free(ar1);
	free(ar2);
	return 0;
}

Measured memory_bytes: 680
<?php
fscanf(STDIN, '%s', $c);
for ($i = 0; $i < 26; $i++) { // アルファベットの数(=26)だけ処理ループ
    if (chr(97 + $i) === $c) break;
}
$ans = chr(97 + $i + 1);
echo $ans . PHP_EOL;

Measured memory_bytes: 4728
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] > @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      # if @data[b].nil?
      #   c = a
      # else
      #   c = @data[a] < @data[b] ? a : b
      # end

      c = a
      c = b if (!@data[b].nil? && (@data[b] <= @data[a]))

      if @data[target_idx] > @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < (@data.size - 1)
  end
end


N, M = gets.chomp.split(' ').map(&:to_i)

AB = []
N.times do |i|
  AB[i] = gets.chomp.split(' ').map(&:to_i)
end

group_by_day = Hash[AB.group_by{|v|v[0]}.sort]

day_fee = Array.new(M){[]}
group_by_day.each do |k,v|
  day_fee[k-1] = v.map{|j| j[1]}
end

# require 'pry'
# binding.pry

ans = 0
pq = PriorityQueue.new
day_fee.each_with_index do |fees, idx|
  break if idx > M - 1
  fees.each do |fee|
    pq.push(fee*(-1))
  end
  ans += pq.pop.to_i
  # p pq
  # p pq.pop*(-1)
end

puts ans*(-1)


Measured memory_bytes: 38284
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  unsigned long long A,B;
  cin>>A>>B;
  for(int i=1;i<N;i++){
    //cout<<A<<","<<B<<endl;

  unsigned  long long t,s;
    cin>>t>>s;
    long long c=max((A+t-1)/t,(B+s-1)/s);
    A=t*max(c,(long long)1);
    B=s*max(c,(long long)1);
  }
  cout<<(unsigned long long)(A+B)<<endl;
  //cout<<(unsigned long long)1000000000000000000<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
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;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; cin >> N; pair<ll, int> a[N];
  rep(i, N){
    ll p; cin >> p; a[i] = {p, i};
  }
  sort(a, a+N); int cnt = 0;
  rep(i, N){
    if((a[i].second - i)%2) cnt++;
  }
  cout << cnt/2 << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, L; cin >> N >> L;
	vector<int>r;
	rep(i, 0, N) {
		r.eb(L + i);
	}
	int sum = accumulate(all(r), 0ll);
	int idx = 0;
	rep(i, 0, N) {
		if (abs(r[idx]) > abs(r[i])) {
			idx = i;
		}
	}
	cout << sum - r[idx] << endl;

	return 0;
}


Measured memory_bytes: 256
function main(lines) {
  const [D, T, S] = na();
  
  const ans = D <= S*T ? 'Yes' : 'No';
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);
const getLines = (n) => lines.slice(lineCount, lineCount += n);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 29676
#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()
#define mod 1000000007
typedef long long ll;

int main(){
  ll n, t;
  cin >> n >> t;
  ll now;
  ll sum = 0;
  cin >> now;
  rep(i, n){
    int num;
    cin >> num;
    sum += min(t, num-now);
    now = num;
  }
  sum += t;
  cout << sum << endl;
  return 0;
}
    

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

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

// ???/????????????
struct Point {
  double x, y;
  Point(double x = 0.0, double y = 0.0):x(x), y(y){}
  
  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(x * a, y * a); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point& p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point& p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;

// ??????/??´???
struct Segment {
  Point p1, p2;
};
typedef Segment Line;

// ?????????????????????
double dot(Vector a, Vector b)
{
  return a.x*b.x + a.y*b.y;
}
// ??????????????????????????§??????
double cross(Vector a, Vector b)
{
  return a.x*b.y - a.y*b.x;
}
// ??´?????????
bool isOrthogonal(Vector a, Vector b)
{
  return equals(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2)
{
  return isOrthogonal(a1 - a2, b1 - b2);
}
bool isOrthogonal(Segment s1, Segment s2)
{
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
// ????????????
bool isParallel(Vector a, Vector b)
{
  return equals(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2)
{
  return isParallel(a1 - a2, b1 - b2);
}
bool isParallel(Segment s1, Segment s2)
{
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
// ?°???±
Point project(Segment s, Point p)
{
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
}
// ????°?
Point reflect(Segment s, Point p)
{
  return p + (project(s, p) - p) * 2.0;
}

int main()
{
  Segment s;
  cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
  int q; cin >> q;
  while(q--) {
    Point p;
    cin >> p.x >> p.y;
    Point x = reflect(s, p);
    printf("%.10f %.10f\n", x.x, x.y);
  }
 
  return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define MAX 2000001
#define VMAX 10000

int main() {
    unsigned short *A, *B;

    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);
    A = (unsigned short *)malloc(sizeof(short) * n + 1);
    B = (unsigned short *)malloc(sizeof(short) * n + 1);
    for (i = 0; i <= VMAX; i++) {
        C[i] = 0;
    }
    for (i = 0; i < n; i++) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
    for (i = 1; i <= VMAX; i++) {
        C[i] = C[i] + C[i - 1];
    }
    for (j = 1; j <= n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    for (i = 1; i <= n; i++) {
        if (i > 1) {
            cout << " ";
        }
        cout << B[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 10996
while True:
  n, x = map(int, input().split())
  if n == x == 0:
    break
  ans = 0
  for i in range(1, n+1):
    for j in range(i+1, n+1):
      if(j < x-i-j < n+1):
        ans += 1
  print(ans)
  


Measured memory_bytes: 5596
n= int(input())
dp =[0]*3
for i in range(n):
    ndp=[0]*3
    c =list(map(int,input().split()))
    for j in range(3):
        for k in range(3):
            #print(j,k)
            if j !=k:
                ndp[k] = max(ndp[k],dp[j]+c[k])
                
    dp = ndp
    
print(max(dp))
        

Measured memory_bytes: 48984
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
typedef long long ll;

int N, a[100100], num;
bool same = true;

//if all the same, special case
//otherwise the max is a thingo

void good () {
	puts("Yes");
	exit(0);
}

void bad () {
	puts("No");
	exit(0);
}

int main () {
	scanf("%d", &N);
	fo(i, 0, N) {
		scanf("%d", &a[i]);
		num = max(num, a[i]);
		if (i > 0) same &= (a[i] == a[i-1]);
	}

	if (same) {
		//suppose num+1 colours
		//then all guys must reduce by one
		//so every colour is unique, num must be N-1
		if (num+1 == N) good();

		//suppose num colours
		//everybody shares a colour with someone else
		//min is 1 colour, max is N/2 colours?
		if (num <= N/2) good();

		//otherwise it is impossible
		bad();

		return 0;
	}

	fo(i, 0, N) if (num - a[i] >= 2) {
		bad();
	}

	int uniq = 0, share = 0;
	fo(i, 0, N) {
		if (a[i] == num-1) uniq++;
		else share++;
	}
	//all values are num or num-1
	//and there are num total colours
	//all the values with num-1 must be unique hats
	//all the other ones must have shares with one another (not with unique)

	if (share == 1) bad();

	if (uniq + 1 <= num && num <= uniq + share/2) good();

	bad();

	return 0;
}


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

int main(){
  int n, y, i, x, ans;
  bool b = false;
  cin >> n >> y;
  y /= 1000;
  for(i = 0; i <= n; i++){
    if(5*(n-i) >= y-10*i && (n-i) <= y-10*i && (y-i-n)%4 == 0){
      b = true;
      x = (y-n-9*i)/4;
      y = n-i-x;
      break;
    }
  }
  if(b) cout << i << " " << x << " " << y << endl;
  else cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);++i);
#define FOR(i,m,n) for(int i=(m);i<(n);i++);
#define VSORT(v) sort(v.begin(),v.end());
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;
const int di[]={-1,0,1,0},dj[]={0,-1,0,1};
const int INF = 99999999;
const ll LINF = 9999999999999;

int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<ll> data(4);
    data[0]=a*c;
    data[1]=a*d;
    data[2]=b*c;
    data[3]=b*d;
    cout<<data[max_element(data.begin(),data.end())-data.begin()];

}


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

int main() {

  int n, q;

  cin >> n;
  vector<int> S(n);
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }

  cin >> q;
  vector<int> T(q);
  for (int i = 0; i < q; i++) {
    cin >> T[i];
  }

  int answer = 0;

  for (int i = 0; i < q; i++) {
    auto l_position = lower_bound(S.begin(), S.end(), T[i]);
    if (T[i] == *l_position) {
      answer++;
    }
  }

  cout << answer << endl;

  return 0;

}


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

/*int judgement(char *taro, char *hanako)
{
    int x = 0;
    while(1){
        if(*(taro + x) > *(hanako + x))
            return 1;
        if(*(taro + x) < *(hanako + x))
            return 2;
        if(*(taro + x) == *(hanako + x))
            x++;
        if(*(taro + x) == '\0' && *(hanako + x) == '\0')
            break;
    }
    return 0;
}*/
int main(void){
    char text[250];
    char tword[110];
    char hword[110];
    int taro = 0, hanako = 0;
    int n, x, y, z;
    int j, q, k, a;
    
    scanf("%d", &n);
    for(j = 0; j < n; j++){
        //fgets(text, 250, stdin);
        //tword = strtok(text, " ");
        //hword = strtok(NULL, " ");
        scanf("%s %s", tword, hword);
        
        //printf("%s %s\n", tword, hword);
        x = 0;
        while(1){
            if(*(tword + x) > *(hword + x)){
                taro += 3;
                break;
            }
            if(*(tword + x) < *(hword + x)){
                hanako += 3;
                break;
            }
            if(*(tword + x) == *(hword + x)){
                x++;
            }
            if(*(tword + x) == '\0' && *(hword + x) == '\0'){
                taro += 1;
                hanako += 1;
                break;
            }
         }
    }
    printf("%d %d\n", taro, hanako);
    return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    vector<pair<ll, ll>> lr1, lr2;

    rep(i, N){
        stack<char> s;
        for(char c : S[i]){
            if(s.empty()) s.push(c);
            else if(c==')' && s.top()=='(') s.pop();
            else s.push(c);
        }
        ll l = 0, r = 0;
        while(!s.empty()){
            char c = s.top();
            s.pop();
            if(c=='(') ++l;
            else ++r;
        }
        if(l>=r) lr1.push_back({l, r});
        else if(l<r) lr2.push_back({l, r});
    }
    sort(all(lr1), [](auto lhs, auto rhs){ return lhs.second<rhs.second; });
    sort(all(lr2), [](auto lhs, auto rhs){ return lhs.first<rhs.first; });

    ll sl = 0, sr = 0;
    for(auto p : lr1){
        if(sl<p.second){
            cout << "No" << endl;
            return 0;
        }
        sl += p.first - p.second;
    }
    for(auto p : lr2){
        if(sr<p.first){
            cout << "No" << endl;
            return 0;
        }
        sr += p.second - p.first;
    }
    if(sl==sr) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 50244
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>

using namespace std;
const int INF=100000000;

typedef pair<int, int> P;

int h,w,n;
int ans=0;
int sx,sy;
int kx[10],ky[10];
long int field[1001][1001],field2[1001][1001];
char str[1001];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1,};

int bfs(int x,int y,int e){
	int a=0,b=0;
	queue<P> que;
	for(a=0;a<h;a++){
		for(b=0;b<w;b++){
			field2[b][a]=INF;
		}
	}
	que.push(P(x,y));
	field2[x][y]=0;
	while(que.size()){
		P p=que.front();que.pop();
		if(p.first==kx[e] && p.second==ky[e])break;
		for(a=0;a<4;a++){
			int nx=p.first+dx[a],ny=p.second+dy[a];
			if(0<=nx && nx<w && 0<=ny && ny<h && field[nx][ny]!=-1 && field2[nx][ny]==INF){
				que.push(P(nx,ny));
				field2[nx][ny]=field2[p.first][p.second]+1;
			}
		}
	}
	return field2[kx[e]][ky[e]];
}

int main(void){
	int a,b;
	scanf("%d %d %d",&h,&w,&n);
	for(a=0;a<h;a++){
		scanf("%s",str);
		for(b=0;b<w;b++){
			if(str[b]=='S')sx=b,sy=a;
			if(str[b]=='X')field[b][a]=-1;
			else field[b][a]=0;
			if('1' <= str[b] && str[b] <= '9'){
				field[b][a]=str[b]-'0';
				kx[field[b][a]]=b;
				ky[field[b][a]]=a;
			}
		}
	}
	for(a=1;a<=n;a++){
		if(a==1)ans+=bfs(sx,sy,a);
		if(a>1)ans+=bfs(kx[a-1],ky[a-1],a);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8720
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007
using namespace std;
 
 
 
int main(){
    int N;
    cin >> N;
    int A[N],B[N],C[N-1];
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];
    int ans = B[A[0]-1];
    for (int i = 1; i < N; i++)
    {
        ans += B[A[i]-1];
        if(A[i-1] == A[i] - 1) ans += C[A[i-1]-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i = 0; i < n; i++)
using namespace std;
int dy[4] = { 1, 0, -1, 0 }, dx[4] = { 0, 1, 0, -1 };
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, l;
  cin >> n >> l;
  ll sum = 0;
  ll min_v = INF;
  vector<ll> val;
  val.resize(n);
  rep(i, n) {
    val[i] = i + l;
  }
  ll pos;
  rep(i, n) {
    sum += val[i];
    if (val[i] < min_v) {
      min_v = abs(val[i]);;
      pos = i;
    }
  }
  cout << sum - val[pos] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n[] = new int[3];
    for(int i = 0;i<3;i++){
      n[i] = sc.nextInt();
    }
    Arrays.sort(n);
    int a = n[2] * 10 + n[1] + n[0];
    System.out.println(a);


  }
}


Measured memory_bytes: 21972
import java.util.Scanner;
class Main{
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){	
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int sum = a+b;
			if(sum<10){
				System.out.println("1");
			}
			if(sum<100 && sum>9){
				System.out.println("2");
			}
			if(sum<1000 && sum>99){
				System.out.println("3");
			}
			if(sum<10000 && sum>999){
				System.out.println("4");
			}
			if(sum<100000 && sum>9999){
				System.out.println("5");
			}
			if(sum<1000000 && sum>99999){
				System.out.println("6");
			}
			if(sum<10000000 && sum>999999){
				System.out.println("7");
			}
		}
	}
}

Measured memory_bytes: 26612
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

struct Mod {
    static constexpr auto kMod = 1000000007L;

    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const { return (n * (m.n % kMod)) % kMod; }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p / 2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kMod - 2);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const { return (n + m.n) % kMod; }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    Mod operator-(Mod m) const { return (kMod + n - m.n) % kMod; }

    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }

    int64_t n;
};

main() {
    int64_t n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    vector<Mod> fact(n + 1, 0);
    vector<Mod> ifact(n + 1, 0);
    fact[0] = 1;
    ifact[0] = 1;
    for (auto i : irange(1L, n + 1)) {
        fact[i] = fact[i - 1] * i;
        ifact[i] = ifact[i - 1] / i;
    }

    // K人を全てのグループがi人以下であるようにグループ分けする数 = dp[i][K]
    vector<vector<Mod>> dp(b + 1, vector<Mod>(n + 1, 0));
    for (auto i : irange(0L, a)) {
        dp[i][0] = 1;
    }
    for (auto i : irange(a, b + 1)) {
        dp[i][0] = 1;
        for (auto k : irange(1L, n + 1)) {
            dp[i][k] = dp[i - 1][k];
            // i人ちょうどのグループがg個あるとする
            auto z = ifact[i].pow(c);
            for (auto g = c; i * g <= k && g <= d; ++g) {
                dp[i][k] += fact[k] * ifact[g] * z * ifact[k - g * i] *
                            dp[i - 1][k - g * i];
                z *= ifact[i];
            }
        }
    }

    for (auto i : irange(0L, b + 1)) {
        for (auto j : irange(0L, n + 1)) {
            // cerr << i << "," << j << ":" << dp[i][j] << "\n";
        }
    }

    cout << dp[b][n].n << endl;
}

Measured memory_bytes: 8064
def main() :
    n, q = [int(i) for i in input().split()]
    names = []
    times = []
    elapsed_time = 0
    for i in range(n) :
        inp = input().split()
        names.append(inp[0])
        times.append(int(inp[1]))


    while len(names) != 0 :
        if times[0] > q :
            tmp1 = names.pop(0)
            names.append(tmp1)
            tmp2 = times.pop(0) - q
            times.append(tmp2)
            elapsed_time += q
        else :
            tmp = names.pop(0)
            elapsed_time += times[0]
            times.pop(0)
            print(tmp, elapsed_time)


if __name__ == '__main__' :
    main()

Measured memory_bytes: 9488
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

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

		int maxA = 0;
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			maxA = maxA < a ? a : maxA;
			b[i] = sc.nextInt();
		}

		Arrays.sort(b);

		int count = 0;
		for (int i = n - 1; i >= 0; i--) {
			if (h <= 0 || b[i] < maxA) break;
			h -= b[i];
			count++;
		}

		if (h > 0) {
			count += Math.max(0, h / maxA + (0 < h % maxA ? 1 : 0));
		}

		out.println(count);
		out.flush();
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

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

int N;
int b[10];
bool res;

bool dfs(int n, int b1, int b2) {
    if (n == 9) { 
        if (b[n] > b1 || b[n] > b2) return true;
        return false;
    }
    if ((b[n] > b1 && dfs(n+1,b[n],b2)) ||
        (b[n] > b2 && dfs(n+1,b1,b[n]))) {
        return true;
    } else {
        return false;
    }
}

void solve() {
    res = dfs(1,b[0],-1);
    if (res) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> b[j];  
        }
        solve();
    }
}


Measured memory_bytes: 2912
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
    cout << " " << i;
    break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;
import java.util.Stack;

public class Main {
	final int MARU = 1;
	final int KAKU = 2;
	final boolean DEBUG = false;
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.nextLine();
			if (str.equals("."))
				break;
			if (DEBUG)
				System.out.println(str);
			boolean ans = true;
			Stack<Integer> stack = new Stack<Integer>();
			for (int i = 0; i < str.length(); i++) {
				char c = str.charAt(i);
				switch (c) {
				case '(':
					stack.push(MARU);
					break;
				case '[':
					stack.push(KAKU);
					break;
				case ')':
					if (stack.isEmpty()) {
						ans = false;
						break;
					}
					int m = stack.pop();
					if (m != MARU)
						ans = false;
					break;
				case ']':
					if (stack.isEmpty()) {
						ans = false;
						break;
					}
					int k = stack.pop();
					if (k != KAKU)
						ans = false;
					break;
				}
			}
			if (!stack.isEmpty())
				ans = false;
			System.out.println(ans ? "yes" : "no");
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 48188
#include <cstdio>
#include <algorithm>
using namespace std;
int p[10][10];
int dx[] = { 0, 0, -1, 1, -1, -1, 1, 1, 0, 0, -2, 2 };
int dy[] = { -1, 1, 0, 0, -1, 1, -1, 1, -2, 2, 0, 0 };
int main() {
  int x, y, s;
  while (~scanf("%d,%d,%d", &x, &y, &s)) {
    p[y][x]++;
    for (int i = 0; i < s * 4; ++i) {
      int px = x + dx[i];
      int py = y + dy[i];
      if (px >= 0 && px < 10 && py >= 0 && py < 10) {
        p[py][px]++;
      }
    }
  }
  int dv = 0, mv = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      if (p[j][i] == 0) dv++;
      mv = max(p[j][i], mv);
    }
  }
  printf("%d\n%d\n", dv, mv);
}


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

int main(){
	ll n,m;
	cin >> n >> m;
	vector<pair<ll,ll>> p(n);
	rep(i,n){
		ll a,b;
		cin >> a >> b;
		p[i] = make_pair(a,b);
	}
	sort(p.begin(),p.end());
	ll ans = 0;
	ll count = 0;
	rep(i,n){
		rep(j,p[i].second){
			ans += p[i].first;
			count++;
			if(count == m){
				break;
			}
		}
		if(count == m) break;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1920
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] road = new int[num];

        for(int i=0; i<num; i++){
            road[i] = sc.nextInt();
        }

        int Max = calcMax(road);
        int Min = calcMin(road);

        System.out.println(Max-Min);
    }

    public static int calcMax(int[] max){
        int ans = max[0];

        for(int i=0; i<max.length; i++){
            if(ans<max[i]){
                ans = max[i];
            }
        }
        return ans;
        
    }

    public static int calcMin(int[] min){
        int ans = min[0];

        for(int i=0; i<min.length; i++){
            if(ans > min[i]){
                ans = min[i];
            }
        }

        return ans;
    }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 X;
	cin >> X;
	int64 now = 100, res = 0;
	while (now < X) {
	  now += now/100;
	  res++;
	}
	cout << res << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)

int main(){
    int n; cin >> n;
    map<string, int> mp;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
        mp[s[i]]++;
    }
    int m; cin >> m;
    string t[m];
    for(int i = 0; i < m; i++){
        cin >> t[i];
        mp[t[i]]--;
    }
    int mx = 0;
    for(int i = 0; i < n; i++){
        mx = max(mp[s[i]], mx);
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]#a[h][w]
q = int(input())
info = [list(map(int,input().split())) for i in range(q)]

zahyo=[[0,0]]*(h*w+1)
for i in range(h):
  for j in range(w):
    zahyo[a[i][j]]=[i,j]

cost=[0]*(h*w+1)
for i in range(1,d+1):
  cost[i]=0
for i in range(d+1,h*w+1):
  cost[i]=cost[i-d]+abs(zahyo[i][0]-zahyo[i-d][0])+abs(zahyo[i][1]-zahyo[i-d][1])
  
for i in range(q):
  print(cost[info[i][1]]-cost[info[i][0]])

Measured memory_bytes: 42232
import numpy as np


def main():
    N, K = map(int, input().split())
    mod = 10 ** 9 + 7
    A = [[int(x) for x in input().split()] for _ in range(N)]
    A = np.asarray(A, dtype=object)
    ans = np.identity(N, dtype=object)
    while K > 0:
        if K & 1:
            ans = np.mod(np.dot(ans, A), mod)
        A = np.mod(np.dot(A, A), mod)
        K >>= 1
    print(ans.sum() % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12500
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = sc.nextInt();
        }

        long sum1 = 0;
        long ans1 = 0;
        for (int i = 0; i < n; ++i) {
            sum1 += a[i];
            if (i % 2 == 0 && sum1 <= 0) {
                ans1 += 1 - sum1;
                sum1 = 1;
            } else if (i % 2 == 1 && sum1 >= 0) {
                ans1 += 1 + sum1;
                sum1 = -1;
            }
        }

        long sum2 = 0;
        long ans2 = 0;
        for (int i = 0; i < n; ++i) {
            sum2 += a[i];
            if (i % 2 == 0 && sum2 >= 0) {
                ans2 += 1 + sum2;
                sum2 = -1;
            } else if (i % 2 == 1 && sum2 <= 0) {
                ans2 += 1 - sum2;
                sum2 = 1;
            }
        }

        _out.println(Math.min(ans1, ans2));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main() {
  int H,W;
  cin>>H>>W;
  string s[100];
  for(int i(0);i<H;i++){
    cin>>s[i];
  }
  int cnt[30] = {0};
  for(int h(0);h<H;h++){
    for(int w(0);w<W;w++){
      cnt[s[h][w]-'a']++;
    }
  }
  for(int i(0);i<30;i++){
    cnt[i] %= 4;
  }
  if(H%2 == 0 && W%2 == 0){
    for(int i(0);i<30;i++){
      if(cnt[i] != 0){
        cout << "No" << endl;
        return 0;
      }
    } 
    cout << "Yes" << endl;
  }else if(H%2 == 1 && W%2 == 1){
    int odd(0),even(0);
    for(int i(0);i<30;i++){
      if(cnt[i] %2 == 1) odd++;
      even += cnt[i]/2;
    }
    if(odd == 1 && even <= (W + H - 2)/2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else{
    int guusuu;
    if(H%2 == 1) guusuu = W;
    else guusuu = H;
    int odd(0),even(0);
    for(int i(0);i<30;i++){
      if(cnt[i] %2 == 1) odd++;
      even += cnt[i]/2;
    }
    if(odd == 0 && even <= guusuu/2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c,d;
    
    scanf("%d",&a);
    
    b=a/3600;
    c=(a%3600)/60;
    d=a%60;
    
    printf("%d:%d:%d\n",b,c,d);
    
    return(0);
    
}


Measured memory_bytes: 2112
/*___________Bismillahir Rahmanir Rahim__________*/
//Think positive, be positive and never use negative words
#include<bits/stdc++.h>
#define ll               long long int
#define uni(a)           a.erase(unique(a.begin(),a.end()),a.end())
#define vsum(a)          accumulate(a.begin(),a.end(),0)
#define vmax(a)          *max_element(a.begin(),a.end())
#define vmin(a)          *min_element(a.begin(),a.end())
#define gcd(a,b)         __gcd(a,b)
#define lcm(a,b)         (a/gcd(a,b))*b
#define yes              cout<<"YES"<<endl
#define no               cout<<"NO"<<endl
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    if(n>29) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
/*_________________Alhamdulillah_________________*/

Measured memory_bytes: 3552