akhauriyash/Code-Regression huggingface dataset:
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  string c;
  cin >> c;
  c[0]++;
  print(c);
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

vector<int> v1;

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int s=0;
	bool flag=false;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	sort(v1.begin(),v1.end());
	s-=v1[0];
	for(i=1;i<n-1;i++){
		s+=abs(v1[i]);
	}
	s+=v1[n-1];
	cout<<s<<endl;
	a=v1[0];
	for(i=n-1;i>0;i--){
		if(!flag && (v1[i-1]<0 || i==1)){
			flag=true;
			cout<<v1[i]<<" "<<a<<endl;
			a=v1[i]-a;
			continue;
		}
		cout<<a<<" "<<v1[i]<<endl;
		a-=v1[i];
	}
}


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

typedef pair<int,int>P;

int n,dis[100005];
vector<P>v[100005];

void dfs1(int idx,int pre){
	for(int i=0;i<v[idx].size();i++){
		int next=v[idx][i].first;
		int cost=v[idx][i].second;
		if(next==pre)continue;
		dfs1(next,idx);
		dis[idx]=max(dis[idx],dis[next]+cost);
	}
}

int dfs2(int idx,int d_pre,int pre){
	vector<P>child;
	child.push_back(P(0,-1));
	for(int i=0;i<v[idx].size();i++){
		int next=v[idx][i].first;
		int cost=v[idx][i].second;
		if(next==pre)child.push_back(P(d_pre+cost,next));
		else child.push_back(P(dis[next]+cost,next));
	}
	sort(child.begin(),child.end(),greater<P>());
	int res=child[0].first+child[1].first;
	for(int i=0;i<v[idx].size();i++){
		int next=v[idx][i].first;
		int cost=v[idx][i].second;
		if(next==pre)continue;
		res=max(res,dfs2(next,child[next==child[0].second].first,idx));
	}
	return res;
}

int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b,w;
		cin>>a>>b>>w;
		v[a].push_back(P(b,w));
		v[b].push_back(P(a,w));
	}
	dfs1(n/2,-1);
	cout<<dfs2(n/2,0,-1)<<endl;
}


Measured memory_bytes: 17528
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

ll nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}


int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    ll ans = 0;
    for (auto& p : mp) {
        int i = p.second;
        ans += (ll)nCr(i,2);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    int ans = 0;
    for(int i=1; i<=N; i++){
        ans += max(0, h[i]-h[i-1]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n,x,a,b,c,count=0;
    while(1) {
        scanf("%d %d",&n,&x);
        
        if (n == 0 && x == 0) {
            break;
        }
        
        for (a = 1; a < n-1; a++) {
            for (b = a+1; b < n; b++) {
                for (c = b+1; c <= n; c++) {
                    //printf("%d + %d + %d = %d\n",a,b,c,a+b+c);
                    if (x == a+b+c) {
                        count++;
                    }
                }
            }
        }
        
        printf("%d\n",count);
        
        count = 0;
        
    }
    return 0;

}

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

class Program
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));

		var kisuCount = a.Count(num => num % 2 == 1);

		Console.WriteLine(kisuCount % 2 == 0 ? "YES" : "NO");

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 20576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1);I >= (A); --I)
const ll INF=1e18+3;
const ll MOD=1e9+7;

int k=1;
vector<int> color;
vector<vector<bool>> e;
vector<vector<int>> g;
bool dfs(int v,int p){
	int kp = k;
	if(p%2)kp*=-1;
	color[v]=kp;
	FOR(i,0,g[v].size()){
		if(color[g[v][i]] != -kp && color[g[v][i]] != 0)return false;
		else if(color[g[v][i]] == -kp)continue;
		bool ok = dfs(g[v][i],p+1);
		if(not ok)return false;
	}
	return true;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	e = vector<vector<bool>>(n, vector<bool>(n, true));
	FOR(i,0,m){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		e[a][b]=false;
		e[b][a]=false;
	}
	g.resize(n);
	FOR(i,0,n)
		FOR(j,0,n)
			if(e[i][j]&&i!=j)
				g[i].push_back(j);
	color = vector<int>(n,0);

	FOR(i,0,n){
		if(color[i]!=0)continue;
		bool ok = dfs(i,0);
		if(not ok){
			cout<<-1<<endl;
			return 0;
		}
		k++;
	}
	vector<pair<int,int>> r;
	sort(color.begin(),color.end());
	k=1;
	while(1){
		int x = (upper_bound(color.begin(),color.end(), k)-lower_bound(color.begin(),color.end(), k));
		int y = (upper_bound(color.begin(),color.end(),-k)-lower_bound(color.begin(),color.end(),-k));
		if(x==0&&y==0)break;
		r.push_back({x,y});
		k++;
	}

	set<int> can;
	can.insert(0);
	FOR(i,0,r.size()){
		set<int> w;
		for(int x : can){
			w.insert(x + r[i].first);
			w.insert(x + r[i].second);
		}
		can = w;
	}
	int ans = MOD;
	for(int x : can){
		ans = min(ans,((n-x)*(n-x-1))/2+(x*(x-1))/2);
		
	}
	cout<<ans<<endl;
}

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

int main()
{
    double w, h, x, y, ans1;
    cin >> w >> h >> x >> y;
    int ans2 = 0;
    if (w == x * 2 && h == y * 2)
        ans2 = 1;
    ans1 = w * h / 2;
    cout << ans1 << ' ' << ans2 << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> s(3);
  REP(i, 3) cin >> s[i];
  for(int i = 0; i < 3; i++) {
    char x = s[i][0];
    char ans = x + 'A' - 'a';
    cout << ans;
  }
  cout << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> vec(N,vector<int>(2));
  for(int i=0; i<N; i++){
    cin >> vec.at(i).at(0);
    vec.at(i).at(1) = i+1;
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<N; i++){
    cout << vec.at(i).at(1);
    if(i == N-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

short l[2000];

int main() {
  in(int, n);
  rep(i, n) cin >> l[i];
  sort(l, l + n);

  int ans = 0;
  for (int a = 0; a < n - 2; ++a) {
    for (int b = a + 1; b < n - 1; ++b) {
      for (int c = b + 1; c < n; ++c) {
        if (l[c] >= l[a] + l[b]) {
          break;
        }
        ++ans;
      }
    }
  }
  out(ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,c,x,a,b,p,q,mn=1e9;
vector<int> l,r;
int main()
{
	l.push_back(0);
	r.push_back(0);
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(x>=0)
		{
			r.push_back(x);
		}else
		{
			l.push_back(-x);
		}
	}
	sort(l.begin(),l.end());
	sort(r.begin(),r.end());
	a=l.size()-1;
	b=r.size()-1;
	for(int i=0;i<=c;i++)
	{
		p=i;
		q=c-i;
		if(p<=a&&q<=b)
		{
			mn=min(mn,min(l[p],r[q])+r[q]+l[p]);
		}
	}
	printf("%d\n",mn);
}


Measured memory_bytes: 3932
n = int(input())
ss = [input() for _ in range(n)]
ans = 0
count_ab = 0 # if ab exists
count_a = 0 # if end in a
count_b = 0 # if start in b
count_ba = 0 # if start in b and end in a
for s in ss:
  slen = len(s)
  if s[0] == 'B' and  s[-1] == 'A':
    count_ba +=1
  else:
      if s[0] == 'B':
        count_b +=1
      if s[-1] == 'A':
        count_a +=1
  count_ab += s.count("AB")
 
if count_ba == 0:
    print(count_ab + min(count_a, count_b))
elif count_a == 0 and count_b == 0:
    print(count_ab + count_ba - 1)
elif count_a > 0 and count_b > 0:
    print(count_ab +  min(count_a, count_b) + count_ba)
else:
    print(count_ab + count_ba)

Measured memory_bytes: 3700
#include <iostream>
using namespace std;
const int maxn = 5000010;
int h,a[maxn];
void maxHeapify(int i){
	int l,r,largest;
	l = 2*i;
	r = l+1;
	largest = i;
	if(l<=h&&a[l]>a[i]) 
		largest = l;
	if(r<=h&&a[r]>a[largest])
		largest = r;
	if(largest!=i){
		swap(a[i],a[largest]);
		maxHeapify(largest);
	} 
}
int main(){
	scanf("%d",&h);
	int i;
	for(i=1;i<=h;i++)
		scanf("%d",&a[i]);
	for(i=h/2;i>0;i--)
		maxHeapify(i);
	for(i=1;i<=h;i++)
		printf(" %d",a[i]);
	printf("\n");
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  int c = 0;
  for(int i = 1; i <= n; i++){
    if(to_string(i).size() & 1){
      c++;
    }
  }
  
  cout << c << endl;
}

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 3e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n, m, k;
int ans, cnt, tmp, idx, mx = -infll, mn = infll;
int x, y, z;
string s, t;
int a[N], b[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
int q = 1;
//cin >> q;
while (q--){
    ld l; cin >> l;
    l /= 3;
    cout << setpre(9) << l * l * l;
}
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
n = gets.to_i
array = gets.split(' ').map {|a| a.to_i }

flag = true
change_times = 0

while flag do
    flag = false
    (n-1).downto(1) do |i|
        if array[i] < array[i-1] then
            array[i-1], array[i] = array[i], array[i-1]
            flag = true
            change_times = change_times + 1
        end
    end
end

puts array.join(' ')
puts change_times

Measured memory_bytes: 8716
from collections import deque

Sa = deque(input())
Sb = deque(input())
Sc = deque(input())

t = Sa.popleft()
while True:
    if t == 'a':
        if Sa:
            t = Sa.popleft()
        else:
            ans = 0
            break
    elif t == 'b':
        if Sb:
            t = Sb.popleft()
        else:
            ans = 1
            break
    else:
        if Sc:
            t = Sc.popleft()
        else:
            ans = 2
            break

answers = ['A','B','C']
print(answers[ans])

Measured memory_bytes: 3316
#include<iostream>

using namespace std;

int main(void)
{
	int a, b;
	char op;
	
	while(1){
		cin >> a >> op >> b;
		if(op == '?')
		break;
		
		if(op == '+'){
			cout << a + b << endl;
		}else if(op == '-'){
			cout << a - b << endl;
		}else if(op == '*'){
			cout << a * b << endl;
		}else if(op == '/'){
			cout << a / b << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s1,s2;
	cin>>s1>>s2;
	ll a[26]={0},b[26]={0},i,flag=0;
	for(i=0;i<s1.size();i++){
		a[s1[i]-'a']++;
	}
	for(i=0;i<s1.size();i++){
		b[s2[i]-'a']++;
	}
	sort(a,a+26);
	sort(b,b+26);
	for(i=0;i<26;i++){
		if(a[i]!=b[i]){
			flag=1;
		}
	}
	if(flag==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringJoiner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		
		long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong(),d=sc.nextLong();
		long ans=Long.MIN_VALUE;
		
		 ans=Math.max(a*c, ans);
		// System.out.println(ans);
		ans=Math.max(b*d, ans);
		ans=Math.max(b*c, ans);
		ans=Math.max(a*d, ans);
		System.out.println(ans);
		
		
	}

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

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

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

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

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

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

}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

  ll N, M;
  cin >> N >> M;
  vector<ll> P(M), Y(M);
  vector<vector<pair<ll, ll>>> city(N);

  REP(i, M){
      cin >> P[i] >> Y[i];
      city[P[i]-1].push_back({Y[i], i});
  }
    vector<pair<ll, ll>> ans(M);
  REP(i,N){
    //   REP(j,M){
    //       if(P[j]==i+1){
    //           city.push_back({Y[j], j});
    //       }
    //   }
      sort(city[i].begin(), city[i].end());
    //   REP(j,M){
    //       cout << city[j].first << " " << city[j].second << endl;
    //   }
      REP(j, city[i].size()){
          ans[city[i][j].second].first = i+1;
          ans[city[i][j].second].second = j+1;
      }
  }

  REP(i, M){
      cout << setw(6) << setfill('0') << ans[i].first << setw(6) << setfill('0') << ans[i].second << endl;
  }
}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



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

int main() {
  char c;

  cin>>c;

  if (c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o') {
    cout << "vowel" << endl;
  }
  else
    cout<<"consonant"<<endl;
}

Measured memory_bytes: 3604
class Human:
    def __init__(self, name, card = "", point = 0):
        self.name = name
        self.card = card
        self.point = point
    
    def add_point(self, opponent):
        if self.card > opponent:
            self.point += 3
        elif self.card == opponent:
            self.point += 1
        else:
            pass

Taro = Human('Taro')
Hanako = Human('Hanako')

N = int(input())
for n in range(N):
    Taro.card, Hanako.card = input().split()
    Taro.add_point(Hanako.card)
    Hanako.add_point(Taro.card)

print(Taro.point, Hanako.point)


Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long long
#define ll long long

int main()
{
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  c*=2;

  ll maxc=max(x,y),cp,ct=LLONG_MAX;
  for (ll i=0;i<=maxc;i++) {
    cp = c * i + max(x - i, 0LL) * a + max(y - i, 0LL) * b;
    ct = min(ct, cp);
  }

  cout<<ct<<endl;

  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <array>
using namespace std;
int main() {
    int N;
    cin >> N;
    array<int, 100001> dp {};
    for (int i = 1; i <= N; i++) {
        dp[i] = N;
        for (int p = 1; p <= N && i - p >= 0; p *= 6) {
            dp[i] = min(dp[i], dp[i - p] + 1);
        }
        for (int p = 1; p <= N && i - p >= 0; p *= 9) {
            dp[i] = min(dp[i], dp[i - p] + 1);
        }
        if (i - 1 >= 0) dp[i] = min(dp[i], dp[i - 1] + 1);
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

int n,a[1000010],num[1000010];
bool ok[1000010];

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

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],num[a[i]]++;
	int g=a[1];
	for(int i=2;i<=n;i++) g=gcd(g,a[i]);
	bool flag=false;
	for(int i=2;i<=1000000;i++){
		if(!ok[i]){
			for(int j=i+i;j<=1000000;j+=i) ok[j]=1;
			int cnt=0;
			for(int j=i;j<=1000000;j+=i) cnt+=num[j];
			if(cnt>1){
				flag=true;break;
			}
		}
	}
	if(!flag) cout<<"pairwise coprime"<<endl;
	else if(g==1) cout<<"setwise coprime"<<endl;
	else cout<<"not coprime"<<endl; 
	return 0;
}

Measured memory_bytes: 12360
N = int(input())
d = len(str(N))
if d == 1:
    print(N)
elif d == 2:
    print(9)
elif d == 3:
    print(N-100+1+9)
elif d == 4:
    print(900+9)
elif d == 5:
    print(N-10000+1+900+9)
elif d == 6:
    print(9+900+90000)
 

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}

#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


void bfs(queue<ll>& q,vector<list<ll>>& g, vector<ll>& flag){
    while(!q.empty()){
        ll x = q.front();
        q.pop();
        for(auto&& y: g[x]){
            print("$",x,">",y)
            if(flag[y] > flag.size()){
                flag[y] = x;
                q.push(y);
            }
        }
    }
    print(flag);
}

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

    ll n,m;

    cin >> n >> m;

    vector<list<ll>> g(n,list<ll>());
    vector<ll> flag(n,n+1);
    flag[0] = 0;
    
    for(int i=0; i<m; i++){
        ll a,b;
        cin >> a >> b;

        a--;b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<ll> q;
    q.push(0);

    bfs(q,g,flag);

    cout << "Yes" << endl;

    for(int i=1; i<n; i++)
        cout << flag[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 19652
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	In(string, a, b, c);
	YES(a.back() == b[0] && b.back() == c[0]);

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i=0; i< n; i++)
typedef long long ll;
using namespace std;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) cout << (b - a) / 2 << endl;
	else {
		ll da = a - 1;
		ll db = n - b;
		if (da > db) {
			a += db + 1;
			if (b == n) {
				cout << db + 1 << endl;
				return 0;
			}
			cout << (n - a) / 2 + db + 1<< endl;
		}
		else {
			b -= da+1;
			if (b == 1) {
				cout << da + 1 << endl;
				return 0;
			}
			cout << (b - 1) / 2 + da + 1<< endl;
		}

	}
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    int now = 1;
    int ans = 0;
    rep(i,n) {
        if (now==a[i]) {
            ++now;
            continue;
        }
        ++ans;
    }
    if (now==1) cout << "-1" << endl;
    else cout << ans << endl;
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<int(n);i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int,int>;
const ll mod = 1e9+7;

int main(){
  ll n,k;
  cin>>n>>k;
  ll r,s,p;
  cin>>r>>s>>p;
  string t;
  cin>>t;

  ll ans=0;
  rep(i,n){
    if(i>=k && t[i]==t[i-k]){
      t[i] = 'x';
      continue;
    }
    if(t[i]=='r') ans+=p;
    if(t[i]=='s') ans+=r;
    if(t[i]=='p') ans+=s;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll t;
  //cin>>t;
  //while(t--){
    ll a,b=1,c=1,d=0,e=0,f=0,g=0,h=0,e1=0,f1=0;
    cin>>a>>b>>c>>d;
    if(a*b<=0 && c*d<=0){
       e=min(a,b);e1=max(a,b);
        f=min(c,d);f1=max(c,d);
        g=max((e*f),(e1*f1));
        cout<<g<<endl;
    }
    else if(a*b>0 && c*d>0){
       if((a>0 && c<0) || (a<0 && c>0)){
        if(a>0){
            e=min(a,b);
            f=max(c,d);
            cout<<e*f<<endl;
        }
        else{
            e=max(a,b);
            f=min(c,d);
            cout<<e*f<<endl;
        }
       }
       else{
         e=min(a,b);e1=max(a,b);
        f=min(c,d);f1=max(c,d);
        g=max((e*f),(e1*f1));
        cout<<g<<endl;
       }
    }
    else{
            if(a*b>0){
        if(a>0){
        e=max(a,b);
        f=max(c,d);
        cout<<e*f<<endl;
        }
        else{
            e=min(a,b);
            f=min(c,d);
            cout<<e*f<<endl;
        }
            }
            if(c*d>0){
              if(c>0){
                  e=max(a,b);
        f=max(c,d);
        cout<<e*f<<endl;
              }
              else{
               e=min(a,b);
            f=min(c,d);
            cout<<e*f<<endl;
              }
            }

    }

  //}
  }

Measured memory_bytes: 3632
// #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

// #define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define zero(a) memset(a,0,sizeof(a))

// #define int ll

const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int MOD = 1000000007; // 998244353

int n;
const int N = 100022;
int arr[N];
ll dp[N][2];

ll solve(int pos,int carry){
	if(pos==n){
		if(carry) return -2;
		return 0LL;
	}
	if(dp[pos][carry]!=-1) return dp[pos][carry];
	ll ans = -INF;
	ll a = solve(pos+1,0);
	ll b = solve(pos+1,1);
	if(carry){
		if(a!=-2) ans = max(ans,a+(-arr[pos]));
		if(b!=-2) ans = max(ans,b+arr[pos]);
	}
	else{
		if(b!=-2) ans = max(ans,b+(-arr[pos]));
		if(a!=-2) ans = max(ans,a+arr[pos]);
	}
	if(ans==-INF) ans = -2;
	return dp[pos][carry] = ans;
}	

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	memset(dp,-1,sizeof(dp));
	cin >> n;
	for(int i=0;i<n;i++) cin >> arr[i];
	cout << solve(0,0) << endl;
	return 0;
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{

    ll n,m,l;
    cin>>n>>m>>l;
    ll arr1[n+1][m+1];
    ll arr2[m+1][l+1];
    ll arr3[n+1][l+1];

    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin>>arr1[i][j];
        }
    }

    for(int i=0; i<m; i++)
    {
        for(int j=0; j<l; j++)
        {
            cin>>arr2[i][j];
        }
    }


    ll sum=0;

   for(int i=0;i<l;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<m;k++){
                sum=sum+arr1[j][k]*arr2[k][i];
            }
            arr3[j][i]=sum;
            sum=0;
        }
   }

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cout<<arr3[i][j];
            if(j!=l-1){
                cout<<" ";
            }
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3344
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <utility>
#include <bitset>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
#define MP make_pair
#define PB push_back
const int N=10010;
const int INF=1<<30;
vector<pi> v[N];
int Prim(int n){
    int ans=0,dis[n];
    priority_queue<pi,vector<pi>,greater<pi> >pq;
    pi temp; 
    bitset<N>b;
    dis[0]=0;
    b.reset();
    
for(int i=1;i<n;i++)dis[i]=INF;
pq.push(MP(0,0));
    while(n>0){
        temp=pq.top();
        pq.pop();
        if(b[temp.S])continue;
        b[temp.S]=true;
        ans+=dis[temp.S];
        for(int i=0;i<v[temp.S].size();i++)if(!b[v[temp.S][i].S]){
            if(dis[v[temp.S][i].S]>v[temp.S][i].F){
                dis[v[temp.S][i].S]=v[temp.S][i].F;
                pq.push(v[temp.S][i]);
            }
        }
        n--;
    }
    return ans;
}
int main(){
    int n,m,l,r,temp;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&l,&r,&temp);
        v[l].PB(MP(temp,r));
        v[r].PB(MP(temp,l));
    }
    printf("%d\n",Prim(n));
}


Measured memory_bytes: 5816
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

struct bit{
	int N;
	int b[100020];
	bit(int p){
		N=p+5;
		memset(b,0,sizeof(b));
	}
	void inc(int p){
		p++;
		while(p<=N){
			b[p]++;
			p+=(p&(-p));
		}
	}
	lli sum(int p){
		p++;
		lli res=0;
		while(p>0){
			res+=b[p];
			p-=(p&(-p));
		}
		return res;
	}
};

int n;
typedef pair<lli,lli> lmp;
lli ps[100005];
lli ls[100005];

lmp dat[100005];


int main(void){
	scanf("%d",&n);
	rep(i,n)scanf("%lld",ps+i);
	rep(i,n)scanf("%lld",ls+i);
	
	{
		lli rui=0;
		rep(i,n){
			rui+=ps[i];
			dat[i]=lmp(rui,i);
		}
		sort(dat,dat+n-1);
	}
	bool ok=true;
	{
		lli b=0;
		rep(i,n){
			ok &= (dat[i].fir-b>=ls[i]);
			b = dat[i].fir;
			//printf("(%lld %lld) ",dat[i].fir,dat[i].sec);
		}
		//printf("\n");
	}
	if(!ok)printf("-1\n");
	else{
		lli ans=0;
		bit b(n+5);
		rep(i,n){
			int np=dat[i].sec;
			ans+=(i-b.sum(np));
			b.inc(np);
		}
		printf("%lld\n",ans);
	}
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int w, a, b;
  cin >> w >> a >> b;

  int res;
  if (b >= a-w && b <= a+w) 
    res = 0;
  else {
    if (b > a + w) res = b-a-w;
    else res = a-b-w;
  }
  cout << res << endl;
  

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;
int main() {
	int p = 37;
	printf("%d %d\n", p*p + p + 1, p + 1);
	for (int i = 0; i<p; i++) {
		for (int j = 0; j<p; j++) {
			printf("%d ", i + 1);
			for (int k = 1; k <= p; k++) {
				printf("%d ", k*p + ((j + (k - 1) * i) % p) + 1);
			}
			printf("\n");
		}
	}

	for (int i = 0; i<p + 1; i++) {
		for (int j = 0; j<p; j++) {
			printf("%d ", i*p + j + 1);
		}
		printf("%d\n", p*p + p + 1);
	}

}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;
int main(void){
    int N;
    int max = 0;
    string s[200002];
    map<string, int> m;
   
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s[i];
        m[s[i]]++;
        if(max < m[s[i]])
            max = m[s[i]];
    }
    
    sort(s, s + N);
    string s1 = s[0];
    if(m[s[0]] == max)
        cout << s1 << endl;
    for(int i = 0; i < N; i++){
        if(s1 == s[i])
            continue;
        s1 = s[i];
        if(m[s[i]] == max)
            cout << s[i] << endl;
    }
}


Measured memory_bytes: 26752
import java.util.Scanner;

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

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		String a = scan.next();
		int a2 = Integer.parseInt(a);

		String b = scan.next();
		int b2 = Integer.parseInt(b);
		
		String c = scan.next();
		int c2 = Integer.parseInt(c);
		
		
		if(b2-a2 == c2-b2){
			System.out.println("YES");
			
		} else {
			System.out.println("NO");
		}

	}
}

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

int main(int argc, char **argv)
{
	int s, t, *a, *c;
	a = (int *)calloc(10000, sizeof(int));
	c = (int *)calloc(31, sizeof(int));
	
	while(1){
		scanf("%d,%d", &s, &t);
		if(s == 0 && t == 0){
			break;
		}
		a[s] = t;
		c[t]++;
	}
	
	t = 1;
	for(s = 30; s >= 0; s--){
		if(c[s] != 0){
			c[s] = t++;
		}
	}
	while(scanf("%d", &s)!=EOF){
		printf("%d\n", c[a[s]]);
	}
	free(a);
	free(c);
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] b = new int[n];
    if (n < 6){
      for (int i=0;i<n;i++){
        System.out.println(b[i]);
      }
      return;
    }

    int limit = (int) Math.sqrt(n-2);

    int [] a = new int[]{1,1,1};

    while (a[0] < limit){
      int t = cal(a[0],a[1],a[2]);
      if (t<=n){
        b[t-1] += check(a[0],a[1],a[2]);
      }
      a = per(a);
    }

    for (int i=0;i<n;i++){
      System.out.println(b[i]);
    }



  }

  static int[] per(int[] a){
      int x = a[0];
      int y = a[1];
      int z = a[2];
      if (z<y){
        a[2] += 1;
        return a;
      }
      if (y<x){
        a[1] += 1;
        a[2] = 1;
        return a;
      }
      a[0] += 1;
      a[2] = 1;
      a[1] = 1;
      return a;
  }

  static int cal(int a, int b, int c){
    int n = a*a+b*b+c*c+a*b+a*c+b*c;
    return n;
  }

  static int check(int a, int b, int c){
    if (a == b){
      if (b == c){
        return 1;
      }
      else{
        return 3;
      }
    }
    else{
      if (b == c){
        return 3;
      }
    }
    return 6;
  }
}


Measured memory_bytes: 39204
#include <iostream>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#define REP(i, n) for(int i = 0; i < n; i++)
//#define REPR(i, n) for(int i = n; i >= 0; i--)
//#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 1e9
// template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
// template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

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

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, r, ans=0;
    //double max=0, tmp, ans;
    cin >> n >> r;

    if (n >= 10) {
        ans = r;
    } else {
        ans = r+(10-n)*100;
    }
    
    cout << ans;
}


Measured memory_bytes: 256
func main() {
    let read = { Int(readLine()!)! }
    let a = read()
    let b = read()
    let c = read()
    let x = read()
    
    var ans = 0
    for i in 0...a {
        for j in 0...b {
            for k in 0...c {
                if 500 * i + 100 * j + 50 * k == x {
                    ans += 1
                }
            }
        }
    }
    
    print(ans)
}

main()


Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
const int N=3005;
long long d[N], len[N], ans;
bool abl[N], inq[N];
vector<pair<int, int> > g[N], h[N];
queue<int> q;
int n, m, p;
	
void bfs(int st) {
	q.push(st);
	abl[st]=true;
	while (!q.empty()) {
		int x=q.front(); q.pop(); 
		for (auto y: h[x]) if (!abl[y.first]){
			abl[y.first]=true;
			q.push(y.first);
		}
	}
} 

void spfa(int st) {
	if (!abl[st]) return;
	for (int i=1; i<=n; i++) d[i]=-10000000000LL;
	d[st]=0;
	q.push(st);
	inq[st]=true;
	len[st]=1;
	while (!q.empty()) {
		int x=q.front(); q.pop(); inq[x]=false;
		if (len[x]>n+5) {
			ans=-1;
			return;
		}
		for (int i=0; i<g[x].size(); i++) {
			int y=g[x][i].first, z=g[x][i].second;
			if (!abl[y]) continue;
			if (d[y]<d[x]+z) {
				d[y]=d[x]+z;
				len[y]=len[x]+1;
				if (!inq[y]) {
					inq[y]=true;
					q.push(y);
				}
			} 
		}
	}
//	for (int i=1; i<=n; i++) cout<<d[i]<<" ";
	ans=max(d[n], 0LL);
}
int main() {
	cin>>n>>m>>p;
	for (int i=0, x, y, c; i<m; i++) {
		cin>>x>>y>>c;
		g[x].push_back({y, c-p});
		h[y].push_back({x, c-p});
	}
	
	bfs(n);
	spfa(1);
	
	//find 1到n的最长路 
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define max 2000
#define mod 1000000007
using namespace std;

int arr[max];
vector<int>prime;

void sieve()
{
    memset(arr,0,sizeof(arr));
    int sqrtn=(int)sqrt(max);
    for(int i=3; i<=sqrtn; i+=2)
    {
        if(arr[i]==0){
            for(int j=i*i; j<max; j+=i+i){
                arr[j]=1;
            }
        }
    }
    prime.push_back(2);
    for(int i=3; i<max; i+=2){
        if(arr[i]==0)
            prime.push_back(i);
    }
}

ll factorialDivisors(ll n)
{
    ll result = 1;
    for (int i=0; i<prime.size(); i++)
    {
        ll p=prime[i];
        ll exp=0;
        while(p<=n)
        {
            exp=exp+(n/p);
            p=p*prime[i];
        }
        result = ((result%mod)*((exp+1)%mod))%mod;
    }
    return result;
}

int main()
{
    sieve();
    ll n;
    while(cin>>n){
        cout <<factorialDivisors(n)<<endl;
    }
    return 0;
}


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

int main(void) {
  int s; cin >> s;
  int c = 2;
  vector<int> a;
  a.push_back(s);
  
  while (true) {
    int t = a[c-2];
    if (t % 2 == 0) {
      t /= 2;
    } else {
      t = 3 * t + 1;
    }
    if (find(a.begin(), a.end(), t) != a.end()) {
      cout << c << endl;
      break;
    }
    a.push_back(t);
    c++;
  }
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,a[200010],ans=0;
    cin>>n;
    map<int,int>mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    rep(i,n){
        vector<int>d;
        for(int j=1;j*j<=a[i];j++){
            if(a[i]%j==0){
                d.pb(j);
                if(j*j!=a[i])d.pb(a[i]/j);
            }
        }
        for(int p:d){
            if(p==a[i]){
                if(mp[p]>1){
                    goto ng;
                }
            }
            else{
                if(mp[p]>0){
                    goto ng;
                }
            }
        }
        ans++;
        ng:;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
  bool f[100001];
  int c[100001];

  for (int i = 0; i <= 100000; i++)
  {
    f[i] = false;
    c[i] = 0;
  }

  for (int i = 2; i <= 100000; i++)
    if (!f[i])
      for (int j = i + i; j <= 100000; j += i)
        f[j] = true;

  for (int i = 3; i <= 100000; i += 2)
    if (!f[i] && !f[(i + 1) / 2])
      c[i]++;

  for (int i = 3; i <= 100000; i++)
    c[i] += c[i - 1];

  int q, l, r;
  scanf("%d", &q);

  for (int i = 0; i < q; i++)
  {
    scanf("%d%d", &l, &r);
    printf("%d\n", c[r] - c[l - 1]);
  }

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string.h>
#include<cstdio>
using namespace std;
long long a[2010],b[2010][2010],n,m,ans=2000000000010,cnt;
int main()
{
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++) 
	{
		scanf("%lld",&a[i]);
		b[0][i]=a[i];
	}
	for(int i=1;i<n;i++)
		for(int j=1;j<=n;j++)
			b[i][j]=2000000000010;
	for(int i=1;i<n;i++)
		for(int j=1;j<=n;j++)
		{
			int k=(j-i)%(n+1);
			if(k<=0) k+=n;
			b[i][j]=min(b[i-1][j],a[k]);
		}
	for(int i=0;i<n;i++)
	{
		cnt=i*m;
		for(int j=1;j<=n;j++)
			cnt+=b[i][j];
	    ans=min(ans,cnt);
	}
	printf("%lld",ans);
	return 0;
}

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

int main(){
  double N;
  cin>>N;
  vector<double>kaza(N);
  
  for(int i=0;i<N;i++){
    cin>>kaza.at(i);
  }
  double sum1=0;
  for(int j=0;j<N;j++){
    sum1+=kaza.at(j);
  }
      
  double ave=sum1/N;
  
  int ave2=round(ave);
  
  int sum2=0;
  for(int k=0;k<N;k++){
    sum2+=(kaza.at(k)-ave2)*(kaza.at(k)-ave2);
  }
  cout<<sum2<<endl; 
}

Measured memory_bytes: 512
#include<stdio.h>
typedef long long int lli;

#define min(a,b) (a<b?a:b)

int main(void){
  lli n;
  scanf("%ld",&n);

  //  printf("%ld\n",n);
  lli ans=0,sq,i;
  i=1;sq=2;
  while(sq<n){
    if(n%i==0){
      ans+=n/i-1;
      //      printf("i=%4ld, %ld\n",i,ans);
    }
    i++;
    sq=i*(i+1);
  }
  printf("%ld",ans);

  return 0;
}


Measured memory_bytes: 128