akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n,m;
    cin>>n>>m;
    vpii cut(m);
    rep(i,0,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        cut[i].first=y;
        cut[i].second=x;
    }
    sort(cut.begin(),cut.end());
    vpii bridge;
    rep(i,0,m){
        if(bridge.empty())bridge.push_back(cut[i]);
        else{
            bool check=false;
            rep(j,0,bridge.size()){
                int bl=bridge[j].second;
                int br=bridge[j].first;
                int cl=cut[i].second;
                int cr=cut[i].first;
                if(br<=cl)continue;
                else{
                    chmax(br,cr);
                    check=true;
                }
            }
            if(!check)bridge.push_back(cut[i]);
        }
    }
    cout<<bridge.size()<<endl;
    return 0;
}




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

namespace program
{
    class Program
    {
        static void Main()
        {
          string s = Input.ScanStr();
          if(s[0]==s[1] && s[1]==s[2])
	          Console.WriteLine("Yes");
          else if(s[1]==s[2] && s[2]==s[3])
            Console.WriteLine("Yes");
          else
            Console.WriteLine("No");
            
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  ll sum{};
  for (int i = 1; i <= N; ++i) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  auto ans = sum;
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  gErr = 0;

  solve();

  return gErr;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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


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

	for(int i=a; i<=b; i++){
		if(i%k ==0){
			writeln("OK");
			return 0;
		}
	}

	writeln("NG");

}




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

const int maxn=200010;
struct Edge
{
	int v,next;
}	e[maxn<<1];
int g[maxn],tot;
void addedge(int x,int y)
{
	tot++;
	e[tot].v=y;
	e[tot].next=g[x];
	g[x]=tot;
}
int du[maxn][2];
char s[maxn];
int que[maxn],cnt;
bool vis[maxn];
int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);
		addedge(y,x);
		du[x][s[y]-'A']++;
		du[y][s[x]-'A']++;
	}
	for (int i=1;i<=n;i++)
	if (du[i][0]==0 || du[i][1]==0)
	{
		que[++cnt]=i;
		vis[i]=true;
	}
	for (int i=1;i<=cnt;i++)
	{
		int u=que[i];
		for (int j=g[u];j;j=e[j].next)
			if (!vis[e[j].v])
			{
				du[e[j].v][s[u]-'A']--;
				if (du[e[j].v][s[u]-'A']==0)
				{
					que[++cnt]=e[j].v;
					vis[e[j].v]=true;
				}
			}
	}
	for (int i=1;i<=n;i++)
		if (!vis[i])
		{
			printf("Yes\n");
			return 0;
		}
	printf("No\n");
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

struct UnionFind {
  vector<int> data;
  UnionFind(int n) {
    data.assign(n, -1);
  }
  int root(int k) {
    if (data[k] < 0) return k;
    return data[k] = root(data[k]);
  }
  bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int size(int k) {
    return -data[root(k)];
  }
};

void solve() {
  int n, m;
  cin >> n >> m;
  vi32 p(n);
  cin >> p;
  rep(i, n) p[i]--;
  auto uf = UnionFind(n);
  int ans = 0;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    uf.unite(x, y);
  }
  rep(i, n) {
    if (uf.root(i) == uf.root(p[i])) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys

s = list(set(list(input())))
s.sort()
#print(s)
for i in range(len(s)):
    if s[i] != chr(ord("a") + i):
        print(chr(ord("a") + i))
        sys.exit()
if len(s) < 26:
  	print(chr(ord("a") + len(s)))
else:
	print("None")

Measured memory_bytes: 3956
/**
 *    author:  tourist
 *    created: 17.11.2019 02:03:54       
**/
#include <bits/stdc++.h>

using namespace std;

class dsu {
 public:
  vector<int> p;
  int n;

  dsu(int _n) : n(_n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
  }

  inline int get(int x) {
    return (x == p[x] ? x : (p[x] = get(p[x])));
  }

  inline bool unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      return true;
    }
    return false;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<tuple<int, int, int>> e;
  auto Add = [&](int i, int j) { e.emplace_back(min(abs(x[i] - x[j]), abs(y[i] - y[j])), i, j); };
  {
    vector<int> order(n);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&](int i, int j) { return x[i] < x[j]; });
    for (int i = 0; i < n - 1; i++) Add(order[i], order[i + 1]);
  }
  {
    vector<int> order(n);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&](int i, int j) { return y[i] < y[j]; });
    for (int i = 0; i < n - 1; i++) Add(order[i], order[i + 1]);
  }
  sort(e.begin(), e.end());
  dsu d(n);
  long long ans = 0;
  for (auto& ee : e) {
    if (d.unite(get<1>(ee), get<2>(ee))) ans += get<0>(ee);
  }
  cout << ans << '\n';
  return 0;
}


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

int main(){
    long long int n, k;
    cin >> n >> k;

    vector<long long int> a(n), b(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        b[i] = -a[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    long long int upper = 1e18, lower = -1e18-1, mid;
    while(upper - lower > 1){
        mid = (upper + lower) / 2;
        //cout << mid << " : ";

        long long int num = 0;
        for(int i=0; i<n; i++){
            //long long int mem = num;
            if(a[i] <  0) num += upper_bound(b.begin(), b.end(), mid / (long double)(-a[i])) - b.begin();
            if(a[i] >  0) num += upper_bound(a.begin(), a.end(), mid / (long double)a[i]   ) - a.begin();
            if(a[i] == 0 && 0 <= mid) num += n;

            if(a[i] * a[i] <= mid) num -= 1;
            //cout << num - mem << " ";
        }
        //cout << " : " << num << endl;
        if(num < 2 * k) lower = mid;
        else upper = mid;
    }
    cout << upper << endl;
    return 0;
}

Measured memory_bytes: 3328
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
        k: i64,
        d: i64
    }

    let abs_x = x.abs();
    if abs_x / d >= k {
        println!("{}", abs_x - d * k)
    } else {
        let is_even = (k - abs_x / d) % 2 == 0;
        let remains = abs_x % d;
        if is_even {
            println!("{}", abs_x % d);
        } else {
            println!("{}", d - abs_x % d)
        }
    }
}


Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

int N;
string s; 
int circle[201][201];
int rect[201][201];
void solve(){
    long long T=0, A=0;
    cin >>T >> A;
    for(int i=0; i<N-1; ++i){
        long long t, a;
        cin >> t >> a;
        long long n;
        n = max((T%t==0)?T/t:T/t+1, (A%a==0)?A/a:A/a+1);
        T = n*t; A = n*a;
    }
    cout << T+A << endl;
}
int main() {
    cin >> N;
    //(1) K=10 (2)11
    solve();
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    V a(n); rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    if (a.size() == n)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  int h[N + 10];
  REP(i, N) cin >> h[i];
  int dp[N + 10];
  REP(i, N) dp[i] = 1e9;
  dp[0] = 0;
  REP(i, N) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>


void merge(int * ,int , int ,int);
void mergeSort(int*,int,int);

#define N 500000

int count=0;

int main(){

  int S[N],n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);

   mergeSort(S,0,n);

 for(i=0;i<n-1;i++)printf("%d ",S[i]);

  printf("%d\n",S[i]);
  printf("%d\n",count);

  return 0;
}

void merge(int *A , int left, int mid, int right){

  int L[N],R[N],n1,n2,i,j,k;

  n1=mid-left;
  n2=right-mid;

  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];

  L[n1]=1000000001;
  R[n2]=1000000001;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
    count++;
  }

 
}

void mergeSort(int *A,int left, int right){

  int mid;

  if(left+1<right) {
    mid=(left+right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }  
  
  
}

Measured memory_bytes: 5580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.function.LongSupplier;

public class Main{ // 

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	static LongSupplier now = new LongSupplier() {
		private long t = System.currentTimeMillis();

		@Override
		public long getAsLong() {
			long a = t;
			t = System.currentTimeMillis();
			long ans = t - a;
			return ans;
		}
	};

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static int tr(Object... objects) {
		System.out.println("tr:" + Arrays.deepToString(objects));
		return 0;
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();
		int k = cin.nextInt();

		int[] x = new int[n];
		for (int i = 0; i < x.length; i++)
			x[i] = cin.nextInt();

		now.getAsLong();

		long ans = solve(n, k, x);
		cout.println(ans);

		assert 0 == tr("elapsed", now.getAsLong());
	}

	private static long solve(int n, int k, int[] x) {
		long ans = 0;
		for (int i = 0; i < n; i++)
			ans += 2 * Math.min(Math.abs(x[i] - k), x[i]);
		return ans;
	}

}


Measured memory_bytes: 23380
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B, C, D;
	
	cin>>A>>B>>C>>D;
	
	cout<<max(min(B,D) - max(A,C), 0ll)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
string s;
cin >> s;
int s_size = s.length();
int ans = 0;
REP(i,s_size) {
  if(s[i]!=s[s_size-i-1]) ans++;
}
cout << ans/2 << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>

using namespace std;

int main() {
    unordered_map<string, int> words;
    int N, M;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        words[s]++;
    }
    cin >> M;
    for (int i = 0; i < M; ++i) {
        string s;
        cin >> s;
        words[s]--;
    }
    int max = 0;
    for (auto&& p: words) {
        if (max < p.second) {
            max = p.second;
        }
    }
    cout << max << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>

using namespace std;
typedef long long ll;

ll N, H;
ll ans = 0, highest = 0;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> H;
		if (H >= highest)ans++;
		highest = max(highest, H);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tootal    
 *    created: 2020/04/11 15:45:45
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    cout << ((k * k - (k & 1)) >> 2) << endl;
    return 0;
}

Measured memory_bytes: 256
N, W=[int(i) for i in input().split()]
wv=[[int(i) for i in input().split()] for _ in range(N)]

max_v=0
for i in range(N):
    max_v+=wv[i][1]

dp=[[99999999999]*(max_v+1) for _ in range(N+1)]

for i in range(N+1):
    for v in range(max_v+1):
        if i==0:
            dp[i][0]=0
            break
        else:
            if v>=wv[i-1][1]:
                dp[i][v]=min(dp[i-1][v-wv[i-1][1]]+wv[i-1][0],dp[i-1][v])
            else:
                dp[i][v]=min(dp[i-1][v], wv[i-1][0])

for i in range(max_v,-1,-1):
    if dp[N][i]<=W:
        print(i)
        break

Measured memory_bytes: 120428
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

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

  VI seq(N);
  REP(i, 0, N){
    scanf("%d ", &seq[i]);
  }

  int s = 0;

  bool flag = true;
  while(flag){
    flag = false;
    for(int i = N-1; i >= 1; i--){
      if(seq[i] < seq[i-1]){
        int tmp = seq[i];
        seq[i] = seq[i-1];
        seq[i-1] = tmp;
        flag = true;
        s++;
      }
    }
  }

  REP(i, 0, N){
    if(i > 0){
      printf(" ");
    }
    printf("%d", seq[i]);
  }
  printf("\n");
  printf("%d\n", s);

  return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;
#include <deque>

int main(void){
    Cin(int, n);
    Vec2(int, n, 0, a);
    Rep(n-1){
        Cin(int, x, y); x --, y --;
        a[x].push_back(y);
        a[y].push_back(x);
    }

    constexpr int INF = 1e7;

    vector<int> d0(n, INF); d0[0] = 0;
    deque<int> q0 {0};
    while(!q0.empty()){
        int k = q0.front(); q0.pop_front();
        for(const auto &e : a[k]){
            if(d0[e] == INF) d0[e] = d0[k] + 1, q0.push_back(e);
        }
    }
    int fe = distance(d0.begin(), max_element(Range(d0)));

    vector<int> d1(n, INF); d1[fe] = 0;
    deque<int> q1 {fe};
    while(!q1.empty()){
        int k = q1.front(); q1.pop_front();
        for(const auto &e : a[k]){
            if(d1[e] == INF) d1[e] = d1[k] + 1, q1.push_back(e);
        }
    }
    int dm = *max_element(Range(d1));
    Cout((dm % 3 == 1) ? "Second" : "First");
}

Measured memory_bytes: 14324
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    ans = 0
    ba = 0  # Num. of str that the first letter is B and the last one is A.
    xa = 0  # Num. of str that the last letter is A and the first one is not B.
    bx = 0  # Num. of str that the first letter is B and the last one is not A.
    for _ in range(N):
        s = str(input().strip())

        # Count the number of AB contained in the initial strings.
        for i in range(len(s)):
            if s[i:i+2] == 'AB':
                ans += 1

        if s[0] == 'B' and s[-1] == 'A':
            ba += 1
        elif s[-1] == 'A':
            xa += 1
        elif s[0] == 'B':
            bx += 1

    if ba == 0:
        # One xa ans one bx make one new "AB".
        #   xa + bx -> xABx
        ans += min(xa, bx)

    elif max(xa, bx) == 0:
        # N of ba make N-1 new "AB".
        # BxxA + BxxA + ... + BxxA -> BxxABxxAB...ABxxA
        ans += ba - 1

    else:  # There is at least one bx or ax and at least one ba.
        # N of ba make N-1 new "AB" and a ba.
        #   ba + ba + ... + ba -> baba...ba = ba
        # The last remaining ba and bx/ax make a new "AB" and a new bx/ax.
        #   ba + bx -> bABx = bx,  xa + ba -> xABa = xa
        # Then, bx and xa make a new "AB".
        #   xa + bx -> xABx 
        ans += ba + min(xa, bx)

    return ans


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


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

int ds = 6;

void dprint( int a[] ){
	for( int i = 0; i < ds; i++ ) {
		cout << a[i] << ":";
	}
	cout << endl;

	return; 
}

void dsort( int a[], int i0, int i1, int i2, int i3 ) {
	int ta[] = { a[i0], a[i1], a[i2], a[i3] };
	int min = ta[0];
	for( int i = 0; i < 4; i++ ) {
		if( min > ta[i] ) {
			min = ta[i];
		}
	}

	int t = 0;
	while( true ) {
		if( a[i0] == min ) {
			break;
		}
		t = a[i0];a[i0]=a[i1];a[i1]=a[i2];a[i2]=a[i3];a[i3]=t;
	}

	return;
}

bool dcomp( int a[], int b[] )
{
	for( int i = 0; i < ds; i++ ) {
		if( a[i] != b[i] ) {
			return false;
		}
	}

	return true;
}

bool drollcomp( int a[], int b[], int i0, int i1, int i2, int i3 )
{
	bool ret = false;
	int t = 0;
	for( int i = 0; i < 4; i++ ) {
		t = b[i0];b[i0]=b[i1];b[i1]=b[i2];b[i2]=b[i3];b[i3]=t;
		ret = dcomp( a, b );
		if( ret == true ) {
			break;
		}
	}
	return ret;
}

bool dcheck( int a[], int b[] ) {
	bool ret = false;

	ret = dcomp( a, b );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 1, 2, 4, 3 );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 0, 1, 5, 4 );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 0, 3, 5, 2 );
	if( ret == true ) {
		return ret;
	}

	return ret;
}

int main()
{
	int dx[ds], dy[ds];

	for( int i = 0; i < ds; i++ ) {
		cin >> dx[i];
	}
	dsort( dx, 0, 1, 5, 4 );
	dsort( dx, 0, 3, 5, 2 );
	dsort( dx, 1, 2, 4, 3 );

	for( int i = 0; i < ds; i++ ) {
		cin >> dy[i];
	}
	dsort( dy, 0, 1, 5, 4 );
	dsort( dy, 0, 3, 5, 2 );
	dsort( dy, 1, 2, 4, 3 );


	bool ret = false;
	ret = dcheck( dx, dy );
	cout << ( ret?"Yes":"No" ) << endl;

	return 0;
}


Measured memory_bytes: 3128
n=gets.chomp.to_i
a=Array.new
a[0]=gets.chomp.split(" ").map{|s| s.to_i}
a[1]=gets.chomp.split(" ").map{|s| s.to_i}
m=0
for j in 0..n-1
  if (a[0][0..j].inject(:+))+(a[1][j..n-1].inject(:+)) > m
    m=(a[0][0..j].inject(:+))+(a[1][j..n-1].inject(:+))
  end
end
puts m

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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=1e5+5;

int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    string S; cin >> S;
    int N = S.length();

    li black = 0, white = 0, ans = 0;
    for(int i=0; i<N; i++) {
        if(S[i] == 'W')
            ans += black;
        else
            black++;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<queue>

int w, h;
int data[102][102];
int vecx[2][6] = { { -1, 0, 1, 0, -1, -1 }, { 0, 1, 1, 1, 0, -1 } }, vecy[2][6] = { { -1, -1, 0, 1, 1, 0 }, { -1, -1, 0, 1, 1, 0 } };
int ans;

void bfs()
{
	typedef std::pair<int, int> Point;
	std::queue<Point> q;
	q.push( Point( 0, 0 ) );
	
	while( !q.empty() ){
		Point p = q.front(); q.pop();
		int x = p.first;
		int y = p.second;
		
		if( data[y][x] == -1 ) continue;
		
		data[y][x] = -1;
		
		for( int i = 0; i < 6; i++ ){
			int nx = x + vecx[y%2][i];
			int ny = y + vecy[y%2][i];
			
			if( nx >= 0 && nx <= w + 1 && ny >= 0 && ny <= h + 1 && data[ny][nx] != -1 ){
			 	if( data[ny][nx] == 1 ){
					ans++;
				}
				else{
					q.push( Point( nx, ny ) );
				}
			}
		}
	}

 	return;
}

int main()
{
	std::cin >> w >> h;
	for( int i = 1; i <= h; i++ ){
		for( int j = 1; j <= w; j++ ){
			std::cin >> data[i][j];
		}
	}
	
	
	bfs();

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

 	return 0;
}

Measured memory_bytes: 1264
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int N;
long long A;
long long B;
int main(){
  int i;
  long long res = 0;
  rd(N);
  for(i=(0);i<(N);i++){
    res += (long long) (i+1) * (N-i);
  }
  for(i=(0);i<(N-1);i++){
    rd(A);A += (-1);
    rd(B);B += (-1);
    if(A > B){
      swap(A, B);
    }
    ;
    res -= (A+1) * (N-B);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int N; ll A, B;
// {
//   ll res = 0;
//   rd(N);
//   rep(i,N) res += (ll) (i+1) * (N-i);
//   rep(i,N-1){
//     rd(A--,B--);
//     sortE(A,B);
//     res -= (A+1) * (N-B);
//   }
//   wt(res);
// }


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

int main() {
  ll a,b,c,d,e; cin >> a >> b >> c >> d >> e;
  if(a==0) cout << 1 << endl;
  else if(b==0) cout << 2 << endl;
  else if(c==0) cout << 3 << endl;
  else if(d==0) cout << 4 << endl;
  else cout << 5 << endl;
    
  return 0;
}




Measured memory_bytes: 3624
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 2019;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int fast(int a, int b){
    if ( b == 0 ) return 1 ;
    if ( b == 1 ) return a ;
    int y = fast(a, b / 2) ;
    y %= MOD ;
    int ans = 1 ;
    if ( b & 1 ) ans = a ;
    return (( ((y % MOD) * (y % MOD) ) % MOD) * ans) % MOD ;
}
signed main(){
    fastio
    string s ;
    cin >> s ;
    int n = (int) s.size() ;
    vector<int> v(n + 1) ;
    for(int i = 1; i <= n; i++){
        v[i] = v[i - 1] + (fast(10, n - i) * (s[i - 1] - '0')) % MOD ;
        v[i] %= MOD ;
    }
    map<int,int> mp ;
    int ans = 0 ;
    for(int i = 0; i < n + 1; i++){
        if ( mp.count(v[i]) ) {
            ans += mp[v[i]];
        }
        ++mp[v[i]];
    }
    cout << ans << endl;
    return 0; 
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,m;cin>>n>>m;
    int small=0;
    int large=INF;
    REP(i,m){
        int l,r;cin>>l>>r;
        small = max(small,l);
        large = min(large,r);
    }
    cout<<max(0,large-small+1)<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3644
#ダイクストラ法
#O(ElogV)
import heapq
def dijkstra_heap(s,edge):
  #始点sから各頂点への最短距離
  d = [float("inf")] * (n+1)
  used = [False] * (n+1)
  d[s] = 0
  used[s] = True
  edgelist = []
  #edgelist : (sからの暫定(未確定)最短距離,頂点)のリスト
  #edge[s] : sから出る枝の(重み,終点)の配列
  for w,v in edge[s]:
    heapq.heappush(edgelist,w*10**6+v) #sの隣の点は枝の重さがそのまま暫定最短距離となる
  while len(edgelist):
    #まだ使われてない頂点の中から最小の距離のものを探す→確定させる
    minedge = heapq.heappop(edgelist)
    #minedge : (sからの(確定)最短距離,頂点)
    v = minedge%10**6
    if used[v]:
      continue
    d[v] = minedge//10**6
    used[v] = True
    for w,u in edge[v]:
      if not used[u]:
        heapq.heappush(edgelist,(d[v]+w)*10**6+u)
  return d

################################
n,m,s,t = map(int,input().split()) #n:頂点数　w:辺の数

edge_yen = [[] for _ in range(n+1)]
edge_snuke = [[] for _ in range(n+1)]

for i in range(m):
  u,v,a,b = map(int, input().split())
  edge_yen[u].append((a,v))
  edge_yen[v].append((a,u))
  edge_snuke[u].append((b,v))
  edge_snuke[v].append((b,u))

d_yen = dijkstra_heap(s,edge_yen)
d_snuke = dijkstra_heap(t,edge_snuke)
ans = [0]*(n)
m = float("inf")
for i in range(n,0,-1):
  m = min(d_yen[i]+d_snuke[i],m)
  ans[i-1]=10**15-m
print(*ans,sep='\n')

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

int main(){
  int n;
  cin >> n;
  
  int result = 0;
  int max_count = -1;
  for (int i = n; i > 0; i--){
    int count = 0;
    int temp = i;
    while (true){
      if (temp % 2 != 0) break;
      temp = temp / 2;
      ++count;
    }
    if (count > max_count){
      max_count = count;
      result = i;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    ret = 0
    i = 1
    used = set()
    while (i - 1) ** 2 <= N:
        #print(i)
        tmp = N - i
        if tmp % i == 0:
            val = tmp // i
            if val > 0 and N // val == N % val and not val in used:
                ret += val
                used.add(val)
        if N % (i + 1):
            val = N // (i + 1) != i
            if val > 0 and N // val == N % val and not val in used:
                ret += val
                used.add(val)
        i += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import itertools

N = int(input())

march = ["M", "A", "R", "C", "H"]

MARCH = []
initials = []

for _ in range(N):
    s = input()
    initials.append(s[0])

for x in march:
    MARCH.append(initials.count(x))

L = [i for i in range(5)]
C = itertools.combinations(L, 3)

ans = 0

for c in C:
    ans += MARCH[c[0]] * MARCH[c[1]] * MARCH[c[2]]

print(ans)

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

int main() {
 int n;
    cin >> n;
   vector<int> a(n);
    rep(i,n) {
     cin >> a[i];
    }
 
    
    int b = a.at(0);
    int count = 1;
    for(int i = 0; i < 200000; i++) {
     b = a.at(b-1);
        count++;
        if(b == 2) {
         break;
        }
    }
    
    if(count <= 110000 && a.at(0) != 2) {
     cout << count;
    }else if(a.at(0) ==2){
     cout << 1;
    } else {
     cout << -1;}
}

Measured memory_bytes: 3796
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int modpow(int a, int b, int base) {
	vector<int> vb, va;
	while (b != 0) {
		vb.push_back(b % 2);
		b /= 2;
		va.push_back(a);
		a *= a;
		a %= base;
	}
	int ans = 1;
	for (int i = 0;i < vb.size();i++) {
		if (vb[i] == 1) {
			ans *= va[i];
			ans %= base;
		}
	}
	return ans;
}

int main() {
	string s;
	cin >> s;
	int n = s.length();
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		a[i] = atoi(s.substr(i, 1).c_str());
	}
	int kosuu[2019] = { 0 };
	int tmp = 0;
	for (int i = n - 1;i >= 0;i--) {
		tmp += modpow(10, n - 1 - i, 2019) * a[i];
		tmp %= 2019;
		kosuu[tmp]++;
	}
	int cnt = 0;
	for (int i = 0;i < 2019;i++) {
		cnt += (kosuu[i]*(kosuu[i]-1))/2;
	}
	cnt += kosuu[0];
	cout << cnt << endl;

}

Measured memory_bytes: 4112
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int X = sc.nextInt();
		int T = sc.nextInt();

		int sum = 0;
		int totalMinute = 0;

		while(N > sum)
		{
			sum += X;
			totalMinute += T;
		}

		System.out.println(totalMinute);
	}

}


Measured memory_bytes: 27036
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define irep(i,a)for(int i=1;i<=a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long 
int n;
string s;
int main(){
    cin>>n>>s;
    int a=0,b=0;
    rep(i,n){
        if(s[i]=='R')a++;
        else b++;
    }
    if(a>b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        int ans=1;
        for(int i=1;i<n+1;i++){
            ans+=i;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3008
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		long[][] dp = new long[N+1][W+1];
		int[] w = new int[N+1];
		long[] v = new long[N+1];
		for(int i=1; i<N+1; i++) {
			v[i] = sc.nextLong();
			w[i] = sc.nextInt();
		}
		for(int i=1; i<N+1; i++) {
			for(int j=1; j<W+1; j++) {
				if(j-w[i] >= 0) {
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
				} else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		System.out.println(dp[N][W]);
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// ?????????init????????¶
	// root: ??´??\????????°????????§
	// unite: ?????¨??????
	// same: ??°???????????????
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 34940
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
const int maxw=200050;
const int INF=1e9;
struct node{
	int pos,val;
	node(int pos=0,int val=0):pos(pos),val(val){}
};
bool operator < (node a,node b){
	return a.pos<b.pos||(a.pos==b.pos&&a.val<b.val);
}
set<node> s1;
multiset<int> s2;
node nd[maxw];
int h,w;

void solve(){
	scanf("%d %d",&h,&w);
	for(int i=1;i<=w;i++){
		s1.insert(node(i,0));
		s2.insert(0);
	}
	for(int i=1;i<=h;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		auto it=s1.lower_bound(node(a,0));
		int min_v=INF,tot=0;
		while(it!=s1.end()&&(it->pos)<=b+1){
			nd[++tot]=*it;
			min_v=min(min_v,nd[tot].val+(b+1)-nd[tot].pos);
			it++;
		}
		for(int i=1;i<=tot;i++){
			s1.erase(nd[i]);
			auto it=s2.find(nd[i].val);
			s2.erase(it);
		}
		if(tot>0&&b+1<=w){
			s1.insert(node(b+1,min_v));
			s2.insert(min_v);
		}
		if(s2.empty())	printf("-1\n");
		else	printf("%d\n",i+*s2.begin());
	}
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 23600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  int count=0;
  for(int i=1;i<=n;i++){
    if(i%2==0){continue;}
    int d=0;
    for(int j=1;j<=i;j++){
      if(i%j==0){d++;}
    }
    if(d==8){count++;}
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void){
    long long int w,h,x,y;
    scanf("%lld %lld %lld %lld",&w,&h,&x,&y);
    printf("%lld",(w*h)/2);
    if((w%2==1)&&(h%2==1))printf(".5");

    if((2*x==w)&&(2*y==h))printf(" 1\n");
    else printf(" 0\n");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int r, c, i, j;
    int g[101][101] = {0};
    
    scanf("%d %d", &r, &c);
    
    for(i=0; i<r; i++){
        for(j=0; j<c; j++){
            scanf("%d",&g[i][j]);
        }
    }
    for (i=0; i<r+1; i++){
        for (j=0; j<c; j++){
            g[i][c] += g[i][j];
        }
    }
    for (j=0; j<c+1; j++){
        for (i=0; i<r; i++){
            g[r][j] += g[i][j];
        }
    }
    for (i=0; i<r+1; i++){
        for (j=0; j<c; j++){
            printf("%d ",g[i][j]);
        }
        printf("%d\n",g[i][c]);
    }
    return 0;
}

Measured memory_bytes: 648